Win32: get rid of vlc_thread_ready()
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Wed, 14 Jan 2009 19:19:54 +0000 (21:19 +0200)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Wed, 14 Jan 2009 19:20:19 +0000 (21:20 +0200)
By the way, the Win32 video outputs could probably go through some code
factorization. Don't ask me.

modules/gui/wince/wince.cpp
modules/gui/wince/wince.h
modules/video_output/msw/direct3d.c
modules/video_output/msw/directx.c
modules/video_output/msw/events.c
modules/video_output/msw/glwin32.c
modules/video_output/msw/vout.h
modules/video_output/msw/wingdi.c

index 939fa3e..33389cf 100644 (file)
@@ -191,12 +191,16 @@ static void Run( intf_thread_t *p_intf )
         /* The module is used in dialog provider mode */
 
         /* Create a new thread for the dialogs provider */
+        p_intf->p_sys->thread_ready = CreateEvent (NULL, TRUE, FALSE, NULL);
         if( vlc_thread_create( p_intf, "WinCE Dialogs Thread",
-                               MainLoop, 0, true ) )
+                               MainLoop, 0, false ) )
         {
             msg_Err( p_intf, "cannot create WinCE Dialogs Thread" );
             p_intf->pf_show_dialog = NULL;
         }
+        else
+            WaitForSingleObject (p_priv->thread_ready, INFINITE);
+        CloseHandle (p_priv->thread_ready);
     }
     else
     {
@@ -252,7 +256,7 @@ static void* MainLoop( vlc_object_t * p_this )
     p_intf->p_sys->pf_show_dialog = ShowDialog;
 
     /* OK, initialization is over */
-    vlc_thread_ready( p_intf );
+    SetEvent( p_intf->p_sys->thread_ready );
 
     // Main message loop
     while( GetMessage( &msg, NULL, 0, 0 ) > 0 )
index 73580b5..e7ccf3b 100644 (file)
@@ -86,6 +86,8 @@ struct intf_sys_t
     vector<MenuItemExt*> *p_settings_menu;
 
     VideoWindow          *p_video_window;
+
+    HANDLE   thread_ready;
 };
 
 /*****************************************************************************
index d27e2b2..021323b 100644 (file)
@@ -203,14 +203,18 @@ static int OpenVideo( vlc_object_t *p_this )
     p_vout->p_sys->p_event =
         vlc_object_create( p_vout, sizeof(event_thread_t) );
     p_vout->p_sys->p_event->p_vout = p_vout;
+    p_vout->p_sys->p_event->ready = CreateEvent( NULL, TRUE, FALSE, NULL );
     if( vlc_thread_create( p_vout->p_sys->p_event, "Vout Events Thread",
-                           EventThread, 0, 1 ) )
+                           EventThread, 0, false ) )
     {
         msg_Err( p_vout, "cannot create Vout EventThread" );
+        CloseHandle( p_vout->p_sys->p_event->ready );
         vlc_object_release( p_vout->p_sys->p_event );
         p_vout->p_sys->p_event = NULL;
         goto error;
     }
+    WaitForSingleObject( p_vout->p_sys->p_event->ready, INFINITE )
+    CloseHandle( p_vout->p_sys->p_event->ready );
 
     if( p_vout->p_sys->p_event->b_error )
     {
index 654d842..217ffeb 100644 (file)
@@ -277,14 +277,18 @@ static int OpenVideo( vlc_object_t *p_this )
     p_vout->p_sys->p_event =
         vlc_object_create( p_vout, sizeof(event_thread_t) );
     p_vout->p_sys->p_event->p_vout = p_vout;
+    p_vout->p_sys->p_event->ready = CreateEvent( NULL, TRUE, FALSE, NULL );
     if( vlc_thread_create( p_vout->p_sys->p_event, "Vout Events Thread",
-                           EventThread, 0, 1 ) )
+                           EventThread, 0, false ) )
     {
         msg_Err( p_vout, "cannot create Vout EventThread" );
+        CloseHandle( p_vout->p_sys->p_event->ready );
         vlc_object_release( p_vout->p_sys->p_event );
         p_vout->p_sys->p_event = NULL;
         goto error;
     }
+    WaitForSingleObject( p_vout->p_sys->p_event->ready, INFINITE )
+    CloseHandle( p_vout->p_sys->p_event->ready );
 
     if( p_vout->p_sys->p_event->b_error )
     {
index b0ec026..35c74f3 100644 (file)
@@ -121,7 +121,7 @@ void* EventThread( vlc_object_t *p_this )
     }
 
     /* Signal the creation of the window */
-    vlc_thread_ready( p_event );
+    SetEvent( p_event->window_ready );
 
 #ifndef UNDER_CE
     /* Set power management stuff */
index a7d5a09..5729a27 100644 (file)
@@ -134,14 +134,18 @@ static int OpenVideo( vlc_object_t *p_this )
     p_vout->p_sys->p_event =
         vlc_object_create( p_vout, sizeof(event_thread_t) );
     p_vout->p_sys->p_event->p_vout = p_vout;
+    p_vout->p_sys->p_event->ready = CreateEvent( NULL, TRUE, FALSE, NULL );
     if( vlc_thread_create( p_vout->p_sys->p_event, "Vout Events Thread",
-                           EventThread, 0, 1 ) )
+                           EventThread, 0, false ) )
     {
         msg_Err( p_vout, "cannot create Vout EventThread" );
+        CloseHandle( p_vout->p_sys->p_event->ready );
         vlc_object_release( p_vout->p_sys->p_event );
         p_vout->p_sys->p_event = NULL;
         goto error;
     }
+    WaitForSingleObject( p_vout->p_sys->p_event->ready, INFINITE )
+    CloseHandle( p_vout->p_sys->p_event->ready );
 
     if( p_vout->p_sys->p_event->b_error )
     {
index 043e77f..d1753f1 100644 (file)
@@ -30,6 +30,7 @@ typedef struct event_thread_t
     VLC_COMMON_MEMBERS
 
     vout_thread_t * p_vout;
+    HANDLE window_ready;
 
 } event_thread_t;
 
index 42416b6..190fd90 100644 (file)
@@ -242,14 +242,18 @@ static int OpenVideo ( vlc_object_t *p_this )
     p_vout->p_sys->p_event =
         vlc_object_create( p_vout, sizeof(event_thread_t) );
     p_vout->p_sys->p_event->p_vout = p_vout;
-    if( vlc_thread_create( p_vout->p_sys->p_event, "VLC Vout Events Thread",
-                           EventThread, 0, 1 ) )
+    p_vout->p_sys->p_event->ready = CreateEvent( NULL, TRUE, FALSE, NULL );
+    if( vlc_thread_create( p_vout->p_sys->p_event, "Vout Events Thread",
+                           EventThread, 0, false ) )
     {
         msg_Err( p_vout, "cannot create Vout EventThread" );
+        CloseHandle( p_vout->p_sys->p_event->ready );
         vlc_object_release( p_vout->p_sys->p_event );
         p_vout->p_sys->p_event = NULL;
         goto error;
     }
+    WaitForSingleObject( p_vout->p_sys->p_event->ready, INFINITE )
+    CloseHandle( p_vout->p_sys->p_event->ready );
 
     if( p_vout->p_sys->p_event->b_error )
     {