[vlc-devel] commit: skins2(Windows): fix sporadic vlc hangings at termination ( Erwan Tulou )

git version control git at videolan.org
Mon Jun 29 00:35:04 CEST 2009


vlc | branch: 1.0-bugfix | Erwan Tulou <erwan10 at videolan.org> | Mon Jun 29 00:22:36 2009 +0200| [21dc19e6d17c612ddbdbe876016ca317bb8c8487] | committer: Erwan Tulou 

skins2(Windows): fix sporadic vlc hangings at termination

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.
(cherry picked from commit b1680840287cea049b8ad1e1ff8be0de96f101e4)

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

 modules/gui/skins2/commands/cmd_quit.cpp |    6 ----
 modules/gui/skins2/src/skin_common.hpp   |    6 ++++
 modules/gui/skins2/src/skin_main.cpp     |    5 ++++
 modules/gui/skins2/src/vlcproc.cpp       |   38 +++++++++++++++++++++++++++--
 modules/gui/skins2/src/vout_manager.cpp  |   12 +++++++++
 modules/gui/skins2/src/vout_manager.hpp  |    3 ++
 6 files changed, 61 insertions(+), 9 deletions(-)

diff --git a/modules/gui/skins2/commands/cmd_quit.cpp b/modules/gui/skins2/commands/cmd_quit.cpp
index 57355b4..356c00a 100644
--- a/modules/gui/skins2/commands/cmd_quit.cpp
+++ b/modules/gui/skins2/commands/cmd_quit.cpp
@@ -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 );
 }
diff --git a/modules/gui/skins2/src/skin_common.hpp b/modules/gui/skins2/src/skin_common.hpp
index 684deaf..c893207 100644
--- a/modules/gui/skins2/src/skin_common.hpp
+++ b/modules/gui/skins2/src/skin_common.hpp
@@ -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;
 
diff --git a/modules/gui/skins2/src/skin_main.cpp b/modules/gui/skins2/src/skin_main.cpp
index 7469734..44a195d 100644
--- a/modules/gui/skins2/src/skin_main.cpp
+++ b/modules/gui/skins2/src/skin_main.cpp
@@ -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;
 
diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp
index 1631073..3b985cf 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -34,8 +34,10 @@
 
 #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
diff --git a/modules/gui/skins2/src/vout_manager.cpp b/modules/gui/skins2/src/vout_manager.cpp
index 65d8d89..f164d8d 100644
--- a/modules/gui/skins2/src/vout_manager.cpp
+++ b/modules/gui/skins2/src/vout_manager.cpp
@@ -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();
 }
 
diff --git a/modules/gui/skins2/src/vout_manager.hpp b/modules/gui/skins2/src/vout_manager.hpp
index 1d658e8..e54a290 100644
--- a/modules/gui/skins2/src/vout_manager.hpp
+++ b/modules/gui/skins2/src/vout_manager.hpp
@@ -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 ); }




More information about the vlc-devel mailing list