]> git.sesse.net Git - vlc/commitdiff
skins2(Windows): fix sporadic vlc hangings at termination
authorErwan Tulou <erwan10@videolan.org>
Sun, 28 Jun 2009 22:22:36 +0000 (00:22 +0200)
committerErwan Tulou <erwan10@videolan.org>
Sun, 28 Jun 2009 22:34:00 +0000 (00:34 +0200)
As skins2(Windows) runs in the main thread, special care must be given to playlist/input/vout termination. Up to now, vout threads kept on running with the GUI event loop no longer operational, leading to vlc hangings.

modules/gui/skins2/commands/cmd_quit.cpp
modules/gui/skins2/src/skin_common.hpp
modules/gui/skins2/src/skin_main.cpp
modules/gui/skins2/src/vlcproc.cpp
modules/gui/skins2/src/vout_manager.cpp
modules/gui/skins2/src/vout_manager.hpp

index 57355b4a97fa5a0371bcd11240339e910d614924..356c00a092be88613916c09894dc2c159df0a053 100644 (file)
@@ -39,12 +39,6 @@ void CmdQuit::execute()
     // Stop the playlist
     vout_OSDMessage( getIntf(), DEFAULT_CHAN, "%s", _( "Quit" ) );
 
-    // Get the instance of OSFactory
-    OSFactory *pOsFactory = OSFactory::instance( getIntf() );
-
-    // Exit the main OS loop
-    pOsFactory->getOSLoop()->exit();
-
     // Kill libvlc
     libvlc_Quit( getIntf()->p_libvlc );
 }
index 684deaf532f5ce270999e6cdb1ba21e73f9873ec..c893207325ba1856b323f38c68e9486a4d929ef8 100644 (file)
@@ -113,6 +113,12 @@ struct intf_sys_t
     /// The playlist thread
     playlist_t *p_playlist;
 
+#ifdef WIN32
+    /// flags in order to terminate properly
+    bool b_exitRequested;
+    bool b_exitOK;
+#endif
+
     /// Message bank subscription
     msg_subscription_t *p_sub;
 
index e792a42f7327f7f89d0558003d0a172342ccf59e..36263a218ba52d45ab43fa3d17443e1fee6bc407 100644 (file)
@@ -122,6 +122,11 @@ static int Open( vlc_object_t *p_this )
     p_intf->p_sys->p_vlcProc = NULL;
     p_intf->p_sys->p_repository = NULL;
 
+#ifdef WIN32
+    p_intf->p_sys->b_exitRequested = false;
+    p_intf->p_sys->b_exitOK = false;
+#endif
+
     // No theme yet
     p_intf->p_sys->p_theme = NULL;
 
index c76bb97517ed9e98fdbda3d636118fdc99306953..5e89658e6535c6c319eca05ac551a3288743f8b1 100644 (file)
 
 #include "vlcproc.hpp"
 #include "os_factory.hpp"
+#include "os_loop.hpp"
 #include "os_timer.hpp"
 #include "var_manager.hpp"
+#include "vout_manager.hpp"
 #include "theme.hpp"
 #include "window_manager.hpp"
 #include "../commands/async_queue.hpp"
@@ -200,18 +202,48 @@ VlcProc::~VlcProc()
 
 void VlcProc::manage()
 {
+#ifdef WIN32
+    if( !vlc_object_alive( getIntf() ) &&
+        !getIntf()->p_sys->b_exitRequested )
+    {
+        getIntf()->p_sys->b_exitRequested = true;
+
+        // explicitly stop the playlist
+        playlist_Stop( getIntf()->p_sys->p_playlist );
+
+        if( !VoutManager::instance( getIntf() )->hasVout() )
+            getIntf()->p_sys->b_exitOK = true;
+    }
+
+    if( getIntf()->p_sys->b_exitOK )
+    {
+        // Get the instance of OSFactory
+        OSFactory *pOsFactory = OSFactory::instance( getIntf() );
+
+        // Exit the main OS loop
+        pOsFactory->getOSLoop()->exit();
+
+        return;
+    }
+#else
     // Did the user request to quit vlc ?
     if( !vlc_object_alive( getIntf() ) )
     {
-        CmdQuit *pCmd = new CmdQuit( getIntf() );
-        AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
-        pQueue->push( CmdGenericPtr( pCmd ) );
+        // Get the instance of OSFactory
+        OSFactory *pOsFactory = OSFactory::instance( getIntf() );
+
+        // Exit the main OS loop
+        pOsFactory->getOSLoop()->exit();
+
+        return;
     }
+#endif
 
     refreshPlaylist();
     refreshAudio();
     refreshInput();
 }
+
 void VlcProc::CmdManage::execute()
 {
     // Just forward to VlcProc
index 65d8d89e2695276db69c024ca6a273dc424e4c4f..f164d8d7022cdeb5178ead67133fd91585cf6910 100644 (file)
@@ -212,6 +212,12 @@ void* VoutManager::acceptVout( vout_thread_t* pVout, int width, int height )
 
 void *VoutManager::getWindow( intf_thread_t *pIntf, vout_window_t *pWnd )
 {
+
+#ifdef WIN32
+    if( pIntf->p_sys->b_exitRequested )
+        return NULL;
+#endif
+
     // Theme may have been destroyed
     if( !pIntf->p_sys->p_theme )
         return NULL;
@@ -266,6 +272,12 @@ void VoutManager::releaseWindow( intf_thread_t *pIntf, vout_window_t *pWnd )
         }
     }
 
+#ifdef WIN32
+    if( pIntf->p_sys->b_exitRequested )
+        pIntf->p_sys->b_exitOK = ( pThis->m_SavedVoutVec.size() == 0 );
+#endif
+
+
     pThis->unlockVout();
 }
 
index 1d658e8519de1b176ebcd0fa997b41d06a9c7a57..e54a290225d14515553b1637bf98b1ca80893998 100644 (file)
@@ -113,6 +113,9 @@ class VoutManager: public SkinObject
         // get the VoutMainWindow
         VoutMainWindow* getVoutMainWindow() { return m_pVoutMainWindow; }
 
+        // test if vout are running
+        bool hasVout() { return ( m_SavedVoutVec.size() != 0 ) ; }
+
         // (un)lock functions to protect vout sets
         void lockVout( ) { vlc_mutex_lock( &vout_lock ); }
         void unlockVout( ) { vlc_mutex_unlock( &vout_lock ); }