mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-04 06:08:26 +02:00
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>
This commit is contained in:
parent
1cbea3f9ca
commit
9837f5a643
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user