Commit 94f547c1 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.
parent 698c8900
......@@ -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 );
}
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
......@@ -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();
}
......
......@@ -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 ); }
......
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