| 1763 | } |
| 1764 | |
| 1765 | int sch_wait(Scheduler *sch, uint64_t timeout_us, int64_t *transcode_ts) |
| 1766 | { |
| 1767 | int ret; |
| 1768 | |
| 1769 | // convert delay to absolute timestamp |
| 1770 | timeout_us += av_gettime(); |
| 1771 | |
| 1772 | pthread_mutex_lock(&sch->finish_lock); |
| 1773 | |
| 1774 | if (sch->nb_mux_done < sch->nb_mux) { |
| 1775 | struct timespec tv = { .tv_sec = timeout_us / 1000000, |
| 1776 | .tv_nsec = (timeout_us % 1000000) * 1000 }; |
| 1777 | pthread_cond_timedwait(&sch->finish_cond, &sch->finish_lock, &tv); |
| 1778 | } |
| 1779 | |
| 1780 | // abort transcoding if any task failed |
| 1781 | ret = sch->nb_mux_done == sch->nb_mux || sch->task_failed; |
| 1782 | |
| 1783 | pthread_mutex_unlock(&sch->finish_lock); |
| 1784 | |
| 1785 | *transcode_ts = atomic_load(&sch->last_dts); |
| 1786 | |
| 1787 | return ret; |
| 1788 | } |
| 1789 | |
| 1790 | static int enc_open(Scheduler *sch, SchEnc *enc, const AVFrame *frame) |
| 1791 | { |
no test coverage detected