Message ID | 20200828011302.78140-1-lq@chinaffmpeg.org |
---|---|
State | Accepted |
Commit | 9837f5a64322e89f825a99f14c1a0d27b17b183c |
Headers | show |
Series | [FFmpeg-devel] avcodec/videotoolboxenc: move pthread_cond_signal after add buffer to the queue | expand |
Context | Check | Description |
---|---|---|
andriy/default | pending | |
andriy/make | success | Make finished |
andriy/make_fate | success | Make fate finished |
> On Aug 28, 2020, at 9:13 AM, Steven Liu <lq@chinaffmpeg.org> wrote: > > From: Tian Qi <tianqi@kuaishou.com> > > 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. The patch makes the code more logical, although it’s not a real issue. So LGTM. > > Signed-off-by: Steven Liu <lq@chinaffmpeg.org> > --- > libavcodec/videotoolboxenc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c > index e89cfaeed8..62ed86fc04 100644 > --- a/libavcodec/videotoolboxenc.c > +++ b/libavcodec/videotoolboxenc.c > @@ -338,7 +338,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; > @@ -348,6 +347,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); > } > > -- > 2.25.0 > > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index e89cfaeed8..62ed86fc04 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -338,7 +338,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; @@ -348,6 +347,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); }