diff options
author | Tian Qi <tianqi@kuaishou.com> | 2020-08-28 09:13:02 +0800 |
---|---|---|
committer | Rick Kern <kernrj@gmail.com> | 2020-09-28 21:46:40 -0400 |
commit | 9837f5a64322e89f825a99f14c1a0d27b17b183c (patch) | |
tree | 23033c89b79a7df49e39a68d92f0a4801a19f868 | |
parent | 1cbea3f9caa8d8641f749219a0c207320908778f (diff) | |
download | ffmpeg-9837f5a64322e89f825a99f14c1a0d27b17b183c.tar.gz |
avcodec/videotoolboxenc: move pthread_cond_signal after add buffer to the queue
In the VT encoding insertion by FFmpeg,
and vtenc_q_push is callback to add the encoded data
to the singly linked list group in VTEncContext,
and consumers are notified to fetch it.
However, because it first informs consumers of pthread_cond_signal,
and then inserts the data into the tail,
there is a multi-thread safety hazard.
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Rick Kern <kernrj@gmail.com>
-rw-r--r-- | libavcodec/videotoolboxenc.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index a99a224bfc..ec445de7c2 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -340,7 +340,6 @@ static void vtenc_q_push(VTEncContext *vtctx, CMSampleBufferRef buffer, ExtraSEI info->next = NULL; pthread_mutex_lock(&vtctx->lock); - pthread_cond_signal(&vtctx->cv_sample_sent); if (!vtctx->q_head) { vtctx->q_head = info; @@ -350,6 +349,7 @@ static void vtenc_q_push(VTEncContext *vtctx, CMSampleBufferRef buffer, ExtraSEI vtctx->q_tail = info; + pthread_cond_signal(&vtctx->cv_sample_sent); pthread_mutex_unlock(&vtctx->lock); } |