36#include "libavutil/avassert.h"
37#include "libavutil/error.h"
38#include "libavutil/fifo.h"
39#include "libavutil/intreadwrite.h"
40#include "libavutil/mem.h"
41#include "libavutil/thread.h"
78 while (av_fifo_read(tq->
fifo, &elem, 1) >= 0)
81 av_fifo_freep2(&tq->
fifo);
87 pthread_cond_destroy(&tq->
cond);
88 pthread_mutex_destroy(&tq->
lock);
94 ObjPool *obj_pool,
void (*obj_move)(
void *dst,
void *src))
99 tq = av_mallocz(
sizeof(*tq));
103 ret = pthread_cond_init(&tq->
cond, NULL);
109 ret = pthread_mutex_init(&tq->
lock, NULL);
111 pthread_cond_destroy(&tq->
cond);
121 tq->
fifo = av_fifo_alloc2(queue_size,
sizeof(
FifoElem), 0);
140 finished = &tq->
finished[stream_idx];
145 ret = AVERROR(EINVAL);
150 pthread_cond_wait(&tq->
cond, &tq->
lock);
164 ret = av_fifo_write(tq->
fifo, &elem, 1);
165 av_assert0(ret >= 0);
166 pthread_cond_broadcast(&tq->
cond);
179 unsigned int nb_finished = 0;
181 if (av_fifo_read(tq->
fifo, &elem, 1) >= 0) {
188 for (
unsigned int i = 0; i < tq->
nb_streams; i++) {
202 return nb_finished == tq->
nb_streams ? AVERROR_EOF : AVERROR(EAGAIN);
215 if (ret == AVERROR(EAGAIN)) {
216 pthread_cond_wait(&tq->
cond, &tq->
lock);
224 pthread_cond_broadcast(&tq->
cond);
241 pthread_cond_broadcast(&tq->
cond);
256 pthread_cond_broadcast(&tq->
cond);
void(* obj_move)(void *dst, void *src)