Commit 21dc19e6 authored by Erwan Tulou's avatar 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)
parent 0c753806
...@@ -39,12 +39,6 @@ void CmdQuit::execute() ...@@ -39,12 +39,6 @@ void CmdQuit::execute()
// Stop the playlist // Stop the playlist
vout_OSDMessage( getIntf(), DEFAULT_CHAN, "%s", _( "Quit" ) ); 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 // Kill libvlc
libvlc_Quit( getIntf()->p_libvlc ); libvlc_Quit( getIntf()->p_libvlc );
} }
...@@ -113,6 +113,12 @@ struct intf_sys_t ...@@ -113,6 +113,12 @@ struct intf_sys_t
/// The playlist thread /// The playlist thread
playlist_t *p_playlist; playlist_t *p_playlist;
#ifdef WIN32
/// flags in order to terminate properly
bool b_exitRequested;
bool b_exitOK;
#endif
/// Message bank subscription /// Message bank subscription
msg_subscription_t *p_sub; msg_subscription_t *p_sub;
......
...@@ -122,6 +122,11 @@ static int Open( vlc_object_t *p_this ) ...@@ -122,6 +122,11 @@ static int Open( vlc_object_t *p_this )
p_intf->p_sys->p_vlcProc = NULL; p_intf->p_sys->p_vlcProc = NULL;
p_intf->p_sys->p_repository = 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 // No theme yet
p_intf->p_sys->p_theme = NULL; p_intf->p_sys->p_theme = NULL;
......
...@@ -34,8 +34,10 @@ ...@@ -34,8 +34,10 @@
#include "vlcproc.hpp" #include "vlcproc.hpp"
#include "os_factory.hpp" #include "os_factory.hpp"
#include "os_loop.hpp"
#include "os_timer.hpp" #include "os_timer.hpp"
#include "var_manager.hpp" #include "var_manager.hpp"
#include "vout_manager.hpp"
#include "theme.hpp" #include "theme.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
#include "../commands/async_queue.hpp" #include "../commands/async_queue.hpp"
...@@ -200,18 +202,48 @@ VlcProc::~VlcProc() ...@@ -200,18 +202,48 @@ VlcProc::~VlcProc()
void VlcProc::manage() 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 ? // Did the user request to quit vlc ?
if( !vlc_object_alive( getIntf() ) ) if( !vlc_object_alive( getIntf() ) )
{ {
CmdQuit *pCmd = new CmdQuit( getIntf() ); // Get the instance of OSFactory
AsyncQueue *pQueue = AsyncQueue::instance( getIntf() ); OSFactory *pOsFactory = OSFactory::instance( getIntf() );
pQueue->push( CmdGenericPtr( pCmd ) );
// Exit the main OS loop
pOsFactory->getOSLoop()->exit();
return;
} }
#endif
refreshPlaylist(); refreshPlaylist();
refreshAudio(); refreshAudio();
refreshInput(); refreshInput();
} }
void VlcProc::CmdManage::execute() void VlcProc::CmdManage::execute()
{ {
// Just forward to VlcProc // Just forward to VlcProc
......
...@@ -212,6 +212,12 @@ void* VoutManager::acceptVout( vout_thread_t* pVout, int width, int height ) ...@@ -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 ) 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 // Theme may have been destroyed
if( !pIntf->p_sys->p_theme ) if( !pIntf->p_sys->p_theme )
return NULL; return NULL;
...@@ -266,6 +272,12 @@ void VoutManager::releaseWindow( intf_thread_t *pIntf, vout_window_t *pWnd ) ...@@ -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(); pThis->unlockVout();
} }
......
...@@ -113,6 +113,9 @@ class VoutManager: public SkinObject ...@@ -113,6 +113,9 @@ class VoutManager: public SkinObject
// get the VoutMainWindow // get the VoutMainWindow
VoutMainWindow* getVoutMainWindow() { return m_pVoutMainWindow; } VoutMainWindow* getVoutMainWindow() { return m_pVoutMainWindow; }
// test if vout are running
bool hasVout() { return ( m_SavedVoutVec.size() != 0 ) ; }
// (un)lock functions to protect vout sets // (un)lock functions to protect vout sets
void lockVout( ) { vlc_mutex_lock( &vout_lock ); } void lockVout( ) { vlc_mutex_lock( &vout_lock ); }
void unlockVout( ) { vlc_mutex_unlock( &vout_lock ); } void unlockVout( ) { vlc_mutex_unlock( &vout_lock ); }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment