[vlc-devel] commit: skins2: correct skins failing to display a video passed at the command line. ( Erwan Tulou )

git version control git at videolan.org
Sat Jul 18 15:33:54 CEST 2009


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Fri Jul 17 11:29:02 2009 +0200| [327a0522f3441875102fd9e891c38346e1b4dba4] | committer: Erwan Tulou 

skins2: correct skins failing to display a video passed at the command line.

skins2 now does some intializations (GUI) in the Run function, and therefore needs the Open function to wait till the Run thread is ready. This patch fully copies the qt4 initialization process.

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

 modules/gui/skins2/src/skin_common.hpp |    6 ++++
 modules/gui/skins2/src/skin_main.cpp   |   47 +++++++++++++++++++++++++++++---
 2 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/modules/gui/skins2/src/skin_common.hpp b/modules/gui/skins2/src/skin_common.hpp
index 684deaf..1540cf6 100644
--- a/modules/gui/skins2/src/skin_common.hpp
+++ b/modules/gui/skins2/src/skin_common.hpp
@@ -140,6 +140,12 @@ struct intf_sys_t
 
     /// Current theme
     Theme *p_theme;
+
+    /// synchronisation at start of interface
+    vlc_thread_t thread;
+    vlc_mutex_t  init_lock;
+    vlc_cond_t   init_wait;
+    bool         b_ready;
 };
 
 
diff --git a/modules/gui/skins2/src/skin_main.cpp b/modules/gui/skins2/src/skin_main.cpp
index d6cfd43..bbb7f32 100644
--- a/modules/gui/skins2/src/skin_main.cpp
+++ b/modules/gui/skins2/src/skin_main.cpp
@@ -65,7 +65,7 @@ extern "C" __declspec( dllexport )
 //---------------------------------------------------------------------------
 static int  Open  ( vlc_object_t * );
 static void Close ( vlc_object_t * );
-static void Run   ( intf_thread_t * );
+static void *Run  ( void * );
 
 static int DemuxOpen( vlc_object_t * );
 static int Demux( demux_t * );
@@ -99,8 +99,6 @@ static int Open( vlc_object_t *p_this )
     if( p_intf->p_sys == NULL )
         return VLC_ENOMEM;
 
-    p_intf->pf_run = Run;
-
     // Suscribe to messages bank
 #if 0
     p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
@@ -127,6 +125,27 @@ static int Open( vlc_object_t *p_this )
     // Create a variable to be notified of skins to be loaded
     var_Create( p_intf, "skin-to-load", VLC_VAR_STRING );
 
+    vlc_mutex_init( &p_intf->p_sys->init_lock );
+    vlc_cond_init( &p_intf->p_sys->init_wait );
+
+    vlc_mutex_lock( &p_intf->p_sys->init_lock );
+    p_intf->p_sys->b_ready = false;
+
+    if( vlc_clone( &p_intf->p_sys->thread, Run, p_intf,
+                               VLC_THREAD_PRIORITY_LOW ) )
+    {
+        vlc_mutex_unlock( &p_intf->p_sys->init_lock );
+        vlc_cond_destroy( &p_intf->p_sys->init_wait );
+        vlc_mutex_destroy( &p_intf->p_sys->init_lock );
+        pl_Release( p_intf->p_sys->p_playlist );
+        free( p_intf->p_sys );
+        return VLC_EGENERIC;
+    }
+
+    while( !p_intf->p_sys->b_ready )
+        vlc_cond_wait( &p_intf->p_sys->init_wait, &p_intf->p_sys->init_lock );
+    vlc_mutex_unlock( &p_intf->p_sys->init_lock );
+
     vlc_mutex_lock( &skin_load.mutex );
     skin_load.intf = p_intf;
     vlc_mutex_unlock( &skin_load.mutex );
@@ -147,6 +166,11 @@ static void Close( vlc_object_t *p_this )
     skin_load.intf = NULL;
     vlc_mutex_unlock( &skin_load.mutex);
 
+    vlc_mutex_destroy( &p_intf->p_sys->init_lock );
+    vlc_cond_destroy( &p_intf->p_sys->init_wait );
+
+    vlc_join( p_intf->p_sys->thread, NULL );
+
     if( p_intf->p_sys->p_playlist )
         pl_Release( p_this );
 
@@ -163,15 +187,19 @@ static void Close( vlc_object_t *p_this )
 //---------------------------------------------------------------------------
 // Run: main loop
 //---------------------------------------------------------------------------
-static void Run( intf_thread_t *p_intf )
+static void *Run( void * p_obj )
 {
     int canc = vlc_savecancel();
 
+    intf_thread_t *p_intf = (intf_thread_t *)p_obj;
+
     bool b_error = false;
     char *skin_last = NULL;
     ThemeLoader *pLoader = NULL;
     OSLoop *loop = NULL;
 
+    vlc_mutex_lock( &p_intf->p_sys->init_lock );
+
     // Initialize singletons
     if( OSFactory::instance( p_intf ) == NULL )
     {
@@ -270,6 +298,11 @@ static void Run( intf_thread_t *p_intf )
     // Get the instance of OSLoop
     loop = OSFactory::instance( p_intf )->getOSLoop();
 
+    // Signal the main thread this thread is now ready
+    p_intf->p_sys->b_ready = true;
+    vlc_cond_signal( &p_intf->p_sys->init_wait );
+    vlc_mutex_unlock( &p_intf->p_sys->init_lock );
+
     // Enter the main event loop
     loop->run();
 
@@ -302,7 +335,13 @@ end:
     OSFactory::destroy( p_intf );
 
     if( b_error )
+    {
+        p_intf->p_sys->b_ready = true;
+        vlc_cond_signal( &p_intf->p_sys->init_wait );
+        vlc_mutex_unlock( &p_intf->p_sys->init_lock );
+
         libvlc_Quit( p_intf->p_libvlc );
+    }
 
     vlc_restorecancel(canc);
 }




More information about the vlc-devel mailing list