[vlc-commits] decoder: simplify and avoid immediate unlock/lock pair

Rémi Denis-Courmont git at videolan.org
Mon Apr 23 18:00:48 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Apr 23 18:59:23 2012 +0300| [1d500945380f586d155cad0c343f8ee503f78ecc] | committer: Rémi Denis-Courmont

decoder: simplify and avoid immediate unlock/lock pair

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1d500945380f586d155cad0c343f8ee503f78ecc
---

 src/input/decoder.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 24c0b20..e630703 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1138,21 +1138,18 @@ static void DecoderWaitDate( decoder_t *p_dec,
     if( *pb_reject || i_deadline < 0 )
         return;
 
-    for( ;; )
+    vlc_mutex_lock( &p_owner->lock );
+    do
     {
-        vlc_mutex_lock( &p_owner->lock );
         if( p_owner->b_flushing || p_owner->b_exit )
         {
             *pb_reject = true;
-            vlc_mutex_unlock( &p_owner->lock );
             break;
         }
-        int i_ret = vlc_cond_timedwait( &p_owner->wait_request, &p_owner->lock,
-                                        i_deadline );
-        vlc_mutex_unlock( &p_owner->lock );
-        if( i_ret )
-            break;
     }
+    while( vlc_cond_timedwait( &p_owner->wait_request, &p_owner->lock,
+                               i_deadline ) == 0 );
+    vlc_mutex_unlock( &p_owner->lock );
 }
 
 static void DecoderPlayAudio( decoder_t *p_dec, aout_buffer_t *p_audio,



More information about the vlc-commits mailing list