MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / tq_alloc

Function tq_alloc

fftools/thread_queue.c:72–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72ThreadQueue *tq_alloc(unsigned int nb_streams, size_t queue_size,
73 enum ThreadQueueType type)
74{
75 ThreadQueue *tq;
76 int ret;
77
78 tq = av_mallocz(sizeof(*tq));
79 if (!tq)
80 return NULL;
81
82 ret = pthread_cond_init(&tq->cond, NULL);
83 if (ret) {
84 av_freep(&tq);
85 return NULL;
86 }
87
88 ret = pthread_mutex_init(&tq->lock, NULL);
89 if (ret) {
90 pthread_cond_destroy(&tq->cond);
91 av_freep(&tq);
92 return NULL;
93 }
94
95 tq->finished = av_calloc(nb_streams, sizeof(*tq->finished));
96 if (!tq->finished)
97 goto fail;
98 tq->nb_streams = nb_streams;
99
100 tq->type = type;
101
102 tq->fifo = (type == THREAD_QUEUE_FRAMES) ?
103 av_container_fifo_alloc_avframe(0) : av_container_fifo_alloc_avpacket(0);
104 if (!tq->fifo)
105 goto fail;
106
107 tq->fifo_stream_index = av_fifo_alloc2(queue_size, sizeof(unsigned), 0);
108 if (!tq->fifo_stream_index)
109 goto fail;
110
111 return tq;
112fail:
113 tq_free(&tq);
114 return NULL;
115}
116
117int tq_send(ThreadQueue *tq, unsigned int stream_idx, void *data)
118{

Callers 1

queue_allocFunction · 0.85

Calls 10

av_freepFunction · 0.85
av_callocFunction · 0.85
av_fifo_alloc2Function · 0.85
tq_freeFunction · 0.85
av_malloczFunction · 0.50
pthread_cond_initFunction · 0.50
pthread_mutex_initFunction · 0.50
pthread_cond_destroyFunction · 0.50

Tested by

no test coverage detected