[vlc-devel] commit: Fixed a potential race condition between "event thread" and manage( ) (msw). (Laurent Aimar )

git version control git at videolan.org
Mon Sep 28 20:56:57 CEST 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Mon Sep 28 20:51:35 2009 +0200| [ed50ccdcf85438111239e2d55c01941d94daf909] | committer: Laurent Aimar 

Fixed a potential race condition between "event thread" and manage() (msw).

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

 modules/video_output/msw/common.c |    3 +++
 modules/video_output/msw/events.c |   24 +++++++++++++++++++-----
 modules/video_output/msw/vout.h   |    4 ++++
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/modules/video_output/msw/common.c b/modules/video_output/msw/common.c
index ca32c55..de1c93b 100644
--- a/modules/video_output/msw/common.c
+++ b/modules/video_output/msw/common.c
@@ -187,6 +187,9 @@ void CommonManage( vout_thread_t *p_vout )
         vlc_mutex_unlock( &p_vout->p_sys->lock );
     }
 
+    /* */
+    p_vout->p_sys->i_changes |= EventThreadRetreiveChanges( p_vout->p_sys->p_event );
+
     /* autoscale toggle */
     if( p_vout->i_changes & VOUT_SCALE_CHANGE )
     {
diff --git a/modules/video_output/msw/events.c b/modules/video_output/msw/events.c
index 2104dce..7698376 100644
--- a/modules/video_output/msw/events.c
+++ b/modules/video_output/msw/events.c
@@ -240,7 +240,9 @@ static void *EventThread( void *p_this )
             break;
 
         case WM_LBUTTONDBLCLK:
-            p_event->p_vout->p_sys->i_changes |= VOUT_FULLSCREEN_CHANGE;
+            vlc_mutex_lock( &p_event->lock );
+            p_event->i_changes |= VOUT_FULLSCREEN_CHANGE;
+            vlc_mutex_unlock( &p_event->lock );
             break;
 
         case WM_MBUTTONDOWN:
@@ -779,7 +781,11 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
 #ifdef UNDER_CE
         if( p_vout->p_sys->hparent &&
             hwnd != p_vout->p_sys->hfswnd && p_vout->b_fullscreen )
-            p_vout->p_sys->i_changes |= VOUT_FULLSCREEN_CHANGE;
+        {
+            vlc_mutex_lock( &p_event->lock );
+            p_event->i_changes |= VOUT_FULLSCREEN_CHANGE;
+            vlc_mutex_unlock( &p_event->lock );
+        }
 
         if( hwnd == p_vout->p_sys->hfswnd )
         {
@@ -908,6 +914,15 @@ void EventThreadUpdateTitle( event_thread_t *p_event, const char *psz_fallback )
 
     PostMessage( p_event->p_vout->p_sys->hwnd, WM_VLC_CHANGE_TEXT, 0, 0 );
 }
+unsigned EventThreadRetreiveChanges( event_thread_t *p_event )
+{
+    vlc_mutex_lock( &p_event->lock );
+    unsigned i_changes = p_event->i_changes;
+    p_event->i_changes = 0;
+    vlc_mutex_unlock( &p_event->lock );
+
+    return i_changes;
+}
 
 event_thread_t *EventThreadCreate( vout_thread_t *p_vout )
 {
@@ -946,6 +961,8 @@ void EventThreadDestroy( event_thread_t *p_event )
 
 int EventThreadStart( event_thread_t *p_event )
 {
+    p_event->i_changes = 0;
+
     p_event->b_ready = false;
     p_event->b_done  = false;
     p_event->b_error = false;
@@ -989,8 +1006,5 @@ void EventThreadStop( event_thread_t *p_event )
 
     vlc_join( p_event->thread, NULL );
     p_event->b_ready = false;
-
-    /* clear the changes formerly signaled */
-    p_event->p_vout->p_sys->i_changes = 0;
 }
 
diff --git a/modules/video_output/msw/vout.h b/modules/video_output/msw/vout.h
index 6a974ed..e4e29b1 100644
--- a/modules/video_output/msw/vout.h
+++ b/modules/video_output/msw/vout.h
@@ -45,6 +45,9 @@ typedef struct
     /* Title */
     char *psz_title;
 
+    /* */
+    unsigned i_changes;
+
 } event_thread_t;
 
 #ifdef MODULE_NAME_IS_wingapi
@@ -267,6 +270,7 @@ void            EventThreadStop( event_thread_t * );
 
 void            EventThreadMouseAutoHide( event_thread_t * );
 void            EventThreadUpdateTitle( event_thread_t *, const char *psz_fallback );
+unsigned        EventThreadRetreiveChanges( event_thread_t * );
 
 /*****************************************************************************
  * Prototypes from common.c




More information about the vlc-devel mailing list