[vlc-commits] commit: dvdnav: fix race between still image timeout and other interaction ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Thu Apr 15 18:54:43 CEST 2010


vlc/vlc-1.0 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Apr 15 19:34:17 2010 +0300| [098859ba140988d7cf3cebdc094627a45e201c55] | committer: Rémi Denis-Courmont 

dvdnav: fix race between still image timeout and other interaction

This fixes the same issue as b28c362339ac8ef7f3b9b1715631f304e7563418
in master.

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.0.git/?a=commit;h=098859ba140988d7cf3cebdc094627a45e201c55
---

 modules/access/dvdnav.c |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c
index e704904..89de12d 100644
--- a/modules/access/dvdnav.c
+++ b/modules/access/dvdnav.c
@@ -644,7 +644,7 @@ static int Demux( demux_t *p_demux )
     {
     case DVDNAV_BLOCK_OK:   /* mpeg block */
         vlc_mutex_lock( &p_sys->still.lock );
-        vlc_timer_schedule( p_sys->still.timer, false, 0, 0 );
+        vlc_cond_signal( &p_sys->still.wait );
         p_sys->still.b_enabled = false;
         vlc_mutex_unlock( &p_sys->still.lock );
         if( p_sys->b_reset_pcr )
@@ -1324,19 +1324,21 @@ static void* StillThread( void *p_data )
     mutex_cleanup_push( &p_sys->still.lock );
     for( ;; )
     {
-        if( p_sys->still.b_enabled && p_sys->still.i_end )
-        {
-            if( vlc_cond_timedwait( &p_sys->still.wait, &p_sys->still.lock,
-                                    p_sys->still.i_end ) )
-            {   /* Still image time out */
-                int canc = vlc_savecancel();
-                p_sys->still.b_enabled = false;
-                dvdnav_still_skip( p_sys->dvdnav );
-                vlc_restorecancel( canc );
-            }
-        }
-        else
+	while( !p_sys->still.b_enabled || !p_sys->still.i_end )
             vlc_cond_wait( &p_sys->still.wait, &p_sys->still.lock );
+
+        assert( p_sys->still.b_enabled );
+        assert( p_sys->still.i_end );
+        /* wait until i_end then check b_enabled again */
+        if( vlc_cond_timedwait( &p_sys->still.wait, &p_sys->still.lock,
+                                p_sys->still.i_end )
+         && p_sys->still.b_enabled )
+        {   /* Still image time out */
+            int canc = vlc_savecancel();
+            p_sys->still.b_enabled = false;
+            dvdnav_still_skip( p_sys->dvdnav );
+            vlc_restorecancel( canc );
+        }
     }
     vlc_cleanup_pop(  );
 



More information about the vlc-commits mailing list