#include <vlc_demux.h>
#include <vlc_playlist.h>
#include <vlc_threads.h>
-#include <vlc_window.h>
+#include <vlc_vout_window.h>
#include "dialogs.hpp"
#include "os_factory.hpp"
//---------------------------------------------------------------------------
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 * );
vlc_value_t oldVal, vlc_value_t newVal,
void *pParam );
-
static struct
{
intf_thread_t *intf;
intf_thread_t *p_intf = (intf_thread_t *)p_this;
// Allocate instance and initialize some members
- p_intf->p_sys = (intf_sys_t *) malloc( sizeof( intf_sys_t ) );
+ p_intf->p_sys = (intf_sys_t *) calloc( 1, sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL )
- return( VLC_ENOMEM );
-
- p_intf->pf_run = Run;
+ return VLC_ENOMEM;
// Suscribe to messages bank
#if 0
p_intf->p_sys->p_input = NULL;
p_intf->p_sys->p_playlist = pl_Hold( p_intf );
+ if( !p_intf->p_sys->p_playlist )
+ {
+ free( p_intf->p_sys );
+ return VLC_EGENERIC;
+ }
// Initialize "singleton" objects
p_intf->p_sys->p_logger = NULL;
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;
// Create a variable to be notified of skins to be loaded
var_Create( p_intf, "skin-to-load", VLC_VAR_STRING );
- // Initialize singletons
- if( OSFactory::instance( p_intf ) == NULL )
- {
- msg_Err( p_intf, "cannot initialize OSFactory" );
- pl_Release( p_intf );
-#if 0
- msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
-#endif
- return VLC_EGENERIC;
- }
- if( AsyncQueue::instance( p_intf ) == NULL )
- {
- msg_Err( p_intf, "cannot initialize AsyncQueue" );
- pl_Release( p_intf );
-#if 0
- msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
-#endif
- return VLC_EGENERIC;
- }
- if( Interpreter::instance( p_intf ) == NULL )
- {
- msg_Err( p_intf, "cannot instanciate Interpreter" );
- pl_Release( p_intf );
-#if 0
- msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
-#endif
- return VLC_EGENERIC;
- }
- if( VarManager::instance( p_intf ) == NULL )
- {
- msg_Err( p_intf, "cannot instanciate VarManager" );
- pl_Release( p_intf );
-#if 0
- msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
-#endif
- return VLC_EGENERIC;
- }
- if( VlcProc::instance( p_intf ) == NULL )
- {
- msg_Err( p_intf, "cannot initialize VLCProc" );
- pl_Release( p_intf );
-#if 0
- msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
-#endif
- return VLC_EGENERIC;
- }
- if( VoutManager::instance( p_intf ) == NULL )
- {
- msg_Err( p_intf, "cannot instanciate VoutManager" );
- pl_Release( p_intf );
- return VLC_EGENERIC;
- }
- vlc_mutex_lock( &skin_load.mutex );
- skin_load.intf = p_intf;
- vlc_mutex_unlock( &skin_load.mutex );
-
- Dialogs::instance( p_intf );
- ThemeRepository::instance( p_intf );
+ vlc_mutex_init( &p_intf->p_sys->vout_lock );
+ vlc_cond_init( &p_intf->p_sys->vout_wait );
- // Load a theme
- char *skin_last = config_GetPsz( p_intf, "skins2-last" );
+ vlc_mutex_init( &p_intf->p_sys->init_lock );
+ vlc_cond_init( &p_intf->p_sys->init_wait );
- ThemeLoader *pLoader = new ThemeLoader( p_intf );
+ vlc_mutex_lock( &p_intf->p_sys->init_lock );
+ p_intf->p_sys->b_ready = false;
- if( !skin_last || !*skin_last || !pLoader->load( skin_last ) )
+ if( vlc_clone( &p_intf->p_sys->thread, Run, p_intf,
+ VLC_THREAD_PRIORITY_LOW ) )
{
- // Get the resource path and try to load the default skin
- OSFactory *pOSFactory = OSFactory::instance( p_intf );
- const list<string> &resPath = pOSFactory->getResourcePath();
- const string &sep = pOSFactory->getDirSeparator();
-
- list<string>::const_iterator it;
- for( it = resPath.begin(); it != resPath.end(); it++ )
- {
- string path = (*it) + sep + "default.vlt";
- if( pLoader->load( path ) )
- {
- // Theme loaded successfully
- break;
- }
- }
- if( it == resPath.end() )
- {
- // Last chance: the user can select a new theme file
- if( Dialogs::instance( p_intf ) )
- {
- CmdDlgChangeSkin *pCmd = new CmdDlgChangeSkin( p_intf );
- AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
- pQueue->push( CmdGenericPtr( pCmd ) );
- }
- else
- {
- // No dialogs provider, just quit...
- CmdQuit *pCmd = new CmdQuit( p_intf );
- AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
- pQueue->push( CmdGenericPtr( pCmd ) );
- msg_Err( p_intf,
- "cannot show the \"open skin\" dialog: exiting...");
- }
- }
+ 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 );
+ vlc_cond_destroy( &p_intf->p_sys->vout_wait );
+ vlc_mutex_destroy( &p_intf->p_sys->vout_lock );
+ pl_Release( p_intf->p_sys->p_playlist );
+ free( p_intf->p_sys );
+ return VLC_EGENERIC;
}
- delete pLoader;
-
- free( skin_last );
-
-#ifdef WIN32
-
- p_intf->b_should_run_on_first_thread = true;
- // enqueue a command to automatically start the first playlist item
- AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
- CmdPlaylistFirst *pCmd = new CmdPlaylistFirst( p_intf );
- pQueue->push( CmdGenericPtr( pCmd ) );
+ 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 );
-#endif
+ vlc_mutex_lock( &skin_load.mutex );
+ skin_load.intf = p_intf;
+ vlc_mutex_unlock( &skin_load.mutex );
- return( VLC_SUCCESS );
+ return VLC_SUCCESS;
}
//---------------------------------------------------------------------------
skin_load.intf = NULL;
vlc_mutex_unlock( &skin_load.mutex);
- if( p_intf->p_sys->p_theme )
- {
- delete p_intf->p_sys->p_theme;
- p_intf->p_sys->p_theme = NULL;
- msg_Dbg( p_intf, "current theme deleted" );
- }
+ vlc_join( p_intf->p_sys->thread, NULL );
- // Destroy "singleton" objects
- OSFactory::instance( p_intf )->destroyOSLoop();
- ThemeRepository::destroy( p_intf );
- VoutManager::destroy( p_intf );
- //Dialogs::destroy( p_intf );
- Interpreter::destroy( p_intf );
- AsyncQueue::destroy( p_intf );
- VarManager::destroy( p_intf );
- VlcProc::destroy( p_intf );
- OSFactory::destroy( p_intf );
+ vlc_mutex_destroy( &p_intf->p_sys->init_lock );
+ vlc_cond_destroy( &p_intf->p_sys->init_wait );
if( p_intf->p_sys->p_playlist )
- {
- vlc_object_release( p_intf->p_sys->p_playlist );
- }
+ pl_Release( p_this );
// Unsubscribe from messages bank
#if 0
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
#endif
+ vlc_cond_destroy( &p_intf->p_sys->vout_wait );
+ vlc_mutex_destroy( &p_intf->p_sys->vout_lock );
+
// Destroy structure
free( p_intf->p_sys );
}
//---------------------------------------------------------------------------
// 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 )
+ {
+ msg_Err( p_intf, "cannot initialize OSFactory" );
+ b_error = true;
+ goto end;
+ }
+ if( AsyncQueue::instance( p_intf ) == NULL )
+ {
+ msg_Err( p_intf, "cannot initialize AsyncQueue" );
+ b_error = true;
+ goto end;
+ }
+ if( Interpreter::instance( p_intf ) == NULL )
+ {
+ msg_Err( p_intf, "cannot instanciate Interpreter" );
+ b_error = true;
+ goto end;
+ }
+ if( VarManager::instance( p_intf ) == NULL )
+ {
+ msg_Err( p_intf, "cannot instanciate VarManager" );
+ b_error = true;
+ goto end;
+ }
+ if( VlcProc::instance( p_intf ) == NULL )
+ {
+ msg_Err( p_intf, "cannot initialize VLCProc" );
+ b_error = true;
+ goto end;
+ }
+ if( VoutManager::instance( p_intf ) == NULL )
+ {
+ msg_Err( p_intf, "cannot instanciate VoutManager" );
+ b_error = true;
+ goto end;
+ }
+ if( ThemeRepository::instance( p_intf ) == NULL )
+ {
+ msg_Err( p_intf, "cannot instanciate ThemeRepository" );
+ b_error = true;
+ goto end;
+ }
+ if( Dialogs::instance( p_intf ) == NULL )
+ {
+ msg_Err( p_intf, "cannot instanciate qt4 dialogs provider" );
+ b_error = true;
+ goto end;
+ }
+
+ // Load a theme
+ skin_last = config_GetPsz( p_intf, "skins2-last" );
+ pLoader = new ThemeLoader( p_intf );
+
+ if( !skin_last || !pLoader->load( skin_last ) )
+ {
+ // No skins (not even the default one). let's quit
+ CmdQuit *pCmd = new CmdQuit( p_intf );
+ AsyncQueue *pQueue = AsyncQueue::instance( p_intf );
+ pQueue->push( CmdGenericPtr( pCmd ) );
+ msg_Err( p_intf, "no skins found : exiting");
+ }
+
+ delete pLoader;
+ free( skin_last );
+
// Get the instance of OSLoop
- OSLoop *loop = OSFactory::instance( p_intf )->getOSLoop();
+ 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();
- // Delete the theme and save the configuration of the windows
+ // Destroy OSLoop
+ OSFactory::instance( p_intf )->destroyOSLoop();
+
+ // save and delete the theme
if( p_intf->p_sys->p_theme )
{
p_intf->p_sys->p_theme->saveConfig();
- }
- // cannot be called in "Close", because it refcounts skins2
- Dialogs::destroy( p_intf );
+ delete p_intf->p_sys->p_theme;
+ p_intf->p_sys->p_theme = NULL;
+
+ msg_Dbg( p_intf, "current theme deleted" );
+ }
// save config file
config_SaveConfigFile( p_intf, NULL );
+end:
+ // Destroy "singleton" objects
+ Dialogs::destroy( p_intf );
+ ThemeRepository::destroy( p_intf );
+ VoutManager::destroy( p_intf );
+ VlcProc::destroy( p_intf );
+ VarManager::destroy( p_intf );
+ Interpreter::destroy( p_intf );
+ AsyncQueue::destroy( p_intf );
+ 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);
+ return NULL;
}
+static vlc_mutex_t serializer = VLC_STATIC_MUTEX;
// Callbacks for vout requests
static int WindowOpen( vlc_object_t *p_this )
{
vout_window_t *pWnd = (vout_window_t *)p_this;
- intf_thread_t *pIntf = (intf_thread_t *)
- vlc_object_find_name( p_this, "skins2", FIND_ANYWHERE );
+
+ vlc_mutex_lock( &skin_load.mutex );
+ intf_thread_t *pIntf = skin_load.intf;
+ if( pIntf )
+ vlc_object_hold( pIntf );
+ vlc_mutex_unlock( &skin_load.mutex );
if( pIntf == NULL )
return VLC_EGENERIC;
- vlc_object_release( pIntf );
+ if( !config_GetInt( pIntf, "skinned-video") )
+ {
+ vlc_object_release( pIntf );
+ return VLC_EGENERIC;
+ }
+
+ vlc_mutex_lock( &serializer );
pWnd->handle.hwnd = VoutManager::getWindow( pIntf, pWnd );
if( pWnd->handle.hwnd )
{
- pWnd->p_private = pIntf;
pWnd->control = &VoutManager::controlWindow;
+ pWnd->sys = (vout_window_sys_t*)pIntf;
+
+ vlc_mutex_unlock( &serializer );
return VLC_SUCCESS;
}
else
{
+ vlc_object_release( pIntf );
+ vlc_mutex_unlock( &serializer );
return VLC_EGENERIC;
}
}
static void WindowClose( vlc_object_t *p_this )
{
vout_window_t *pWnd = (vout_window_t *)p_this;
- intf_thread_t *pIntf = (intf_thread_t *)p_this->p_private;
+ intf_thread_t *pIntf = (intf_thread_t *)pWnd->sys;
VoutManager::releaseWindow( pIntf, pWnd );
+
+ vlc_object_release( pIntf );
}
//---------------------------------------------------------------------------
p_demux->pf_control = DemuxControl;
// Test that we have a valid .vlt or .wsz file, based on the extension
- // TODO: an actual check of the contents would be better...
- if( ( ext = strchr( p_demux->psz_path, '.' ) ) == NULL ||
+ if( ( ext = strrchr( p_demux->psz_path, '.' ) ) == NULL ||
( strcasecmp( ext, ".vlt" ) && strcasecmp( ext, ".wsz" ) ) )
{
return VLC_EGENERIC;
if( p_intf != NULL )
{
playlist_t *p_playlist = pl_Hold( p_this );
+
+ PL_LOCK;
// Make sure the item is deleted afterwards
/// \bug does not always work
playlist_CurrentPlayingItem( p_playlist )->i_flags |= PLAYLIST_REMOVE_FLAG;
+ PL_UNLOCK;
+
pl_Release( p_this );
var_SetString( p_intf, "skin-to-load", p_demux->psz_path );
//---------------------------------------------------------------------------
static int DemuxControl( demux_t *p_demux, int i_query, va_list args )
{
- return demux_vaControlHelper( p_demux->s, 0, 0, 0, 1, i_query, args );
+ switch( i_query )
+ {
+ case DEMUX_GET_PTS_DELAY:
+ {
+ int64_t *pi_pts_delay = va_arg( args, int64_t * );
+ *pi_pts_delay = 10;
+ return VLC_SUCCESS;
+ }
+ default:
+ return VLC_EGENERIC;
+ }
+
}
" correctly.")
#define SKINS2_PLAYLIST N_("Use a skinned playlist")
#define SKINS2_PLAYLIST_LONG N_("Use a skinned playlist")
+#define SKINS2_VIDEO N_("Display video in a skinned window if any")
+#define SKINS2_VIDEO_LONG N_( \
+ "When set to 'no', this parameter is intended to give old skins a chance" \
+ " to play back video even though no video tag is implemented")
vlc_module_begin ()
set_category( CAT_INTERFACE )
SKINS2_SYSTRAY_LONG, false );
add_bool( "skins2-taskbar", true, onTaskBarChange, SKINS2_TASKBAR,
SKINS2_TASKBAR_LONG, false );
+#endif
add_bool( "skins2-transparency", false, NULL, SKINS2_TRANSPARENCY,
SKINS2_TRANSPARENCY_LONG, false );
-#endif
add_bool( "skinned-playlist", true, NULL, SKINS2_PLAYLIST,
SKINS2_PLAYLIST_LONG, false );
+ add_bool( "skinned-video", true, NULL, SKINS2_VIDEO,
+ SKINS2_VIDEO_LONG, false );
set_shortname( N_("Skins"))
set_description( N_("Skinnable Interface") )
set_capability( "interface", 30 )
add_shortcut( "skins" )
add_submodule ()
-#ifndef WIN32
- set_capability( "xwindow", 51 )
+#ifdef WIN32
+ set_capability( "vout window hwnd", 51 )
#else
- set_capability( "hwnd", 51 )
+ set_capability( "vout window xid", 51 )
#endif
set_callbacks( WindowOpen, WindowClose )
add_submodule ()
set_description( N_("Skins loader demux") )
- set_capability( "demux", 5 )
+ set_capability( "access_demux", 5 )
set_callbacks( DemuxOpen, NULL )
add_shortcut( "skins" )