[x264-devel] commit: Fix extremely rare deadlock with sync-lookahead (Steven Walters )

git version control git at videolan.org
Mon Nov 23 15:17:19 CET 2009


x264 | branch: master | Steven Walters <kemuri9 at gmail.com> | Fri Nov 20 12:04:13 2009 -0800| [0b0f4a3470c58061d09ee26037314c2f8a4d049b] | committer: Jason Garrett-Glaser 

Fix extremely rare deadlock with sync-lookahead
Patch partially by Anton Mitrofanov.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=0b0f4a3470c58061d09ee26037314c2f8a4d049b
---

 encoder/encoder.c   |    2 ++
 encoder/lookahead.c |    2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/encoder/encoder.c b/encoder/encoder.c
index 8523d15..8905fa0 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -1958,8 +1958,10 @@ int     x264_encoder_encode( x264_t *h,
     else
     {
         /* signal kills for lookahead thread */
+        x264_pthread_mutex_lock( &h->lookahead->ifbuf.mutex );
         h->lookahead->b_exit_thread = 1;
         x264_pthread_cond_broadcast( &h->lookahead->ifbuf.cv_fill );
+        x264_pthread_mutex_unlock( &h->lookahead->ifbuf.mutex );
     }
 
     h->i_frame++;
diff --git a/encoder/lookahead.c b/encoder/lookahead.c
index 298ec66..f2bed16 100644
--- a/encoder/lookahead.c
+++ b/encoder/lookahead.c
@@ -166,8 +166,10 @@ void x264_lookahead_delete( x264_t *h )
 {
     if( h->param.i_sync_lookahead )
     {
+        x264_pthread_mutex_lock( &h->lookahead->ifbuf.mutex );
         h->lookahead->b_exit_thread = 1;
         x264_pthread_cond_broadcast( &h->lookahead->ifbuf.cv_fill );
+        x264_pthread_mutex_unlock( &h->lookahead->ifbuf.mutex );
         x264_pthread_join( h->thread[h->param.i_threads]->thread_handle, NULL );
         x264_macroblock_cache_end( h->thread[h->param.i_threads] );
         x264_free( h->thread[h->param.i_threads] );



More information about the x264-devel mailing list