]> git.sesse.net Git - vlc/commitdiff
Fixed a potential race condition between "event thread" and manage() (msw).
authorLaurent Aimar <fenrir@videolan.org>
Mon, 28 Sep 2009 18:51:35 +0000 (20:51 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Mon, 28 Sep 2009 18:51:35 +0000 (20:51 +0200)
modules/video_output/msw/common.c
modules/video_output/msw/events.c
modules/video_output/msw/vout.h

index ca32c5538906f5b42a5b800272b85d96cdb015d1..de1c93b1e18297e4879e0f8cb98ce593ece7cf77 100644 (file)
@@ -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 )
     {
index 2104dce56bcec4afb10b3506364fd30358414ce2..7698376e6dc3452e6c31ca38a69e8a9031cafc6f 100644 (file)
@@ -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;
 }
 
index 6a974ed8dfbaf6858c166b6da87dfd775549f8a4..e4e29b14903cd4e3dc2f6593d1a41c405480c4ee 100644 (file)
@@ -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