Commit 9f496b5e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

skins2: do not assume skins2 is the first interface, avoid vlc_object_intf

parent b7155d34
...@@ -78,6 +78,12 @@ static int onTaskBarChange( vlc_object_t *pObj, const char *pVariable, ...@@ -78,6 +78,12 @@ static int onTaskBarChange( vlc_object_t *pObj, const char *pVariable,
void *pParam ); void *pParam );
static struct
{
intf_thread_t *intf;
vlc_mutex_t mutex;
} skin_load = { NULL, VLC_STATIC_MUTEX, };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Open: initialize interface // Open: initialize interface
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
...@@ -163,6 +169,10 @@ static int Open( vlc_object_t *p_this ) ...@@ -163,6 +169,10 @@ static int Open( vlc_object_t *p_this )
#endif #endif
return VLC_EGENERIC; return VLC_EGENERIC;
} }
vlc_mutex_lock( &skin_load.mutex );
skin_load.intf = p_intf;
vlc_mutex_unlock( &skin_load.mutex );
Dialogs::instance( p_intf ); Dialogs::instance( p_intf );
ThemeRepository::instance( p_intf ); ThemeRepository::instance( p_intf );
...@@ -226,6 +236,10 @@ static void Close( vlc_object_t *p_this ) ...@@ -226,6 +236,10 @@ static void Close( vlc_object_t *p_this )
{ {
intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_thread_t *p_intf = (intf_thread_t *)p_this;
vlc_mutex_lock( &skin_load.mutex );
skin_load.intf = NULL;
vlc_mutex_unlock( &skin_load.mutex);
// Destroy "singleton" objects // Destroy "singleton" objects
OSFactory::instance( p_intf )->destroyOSLoop(); OSFactory::instance( p_intf )->destroyOSLoop();
ThemeRepository::destroy( p_intf ); ThemeRepository::destroy( p_intf );
...@@ -325,12 +339,13 @@ static int DemuxOpen( vlc_object_t *p_this ) ...@@ -325,12 +339,13 @@ static int DemuxOpen( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_intf = (intf_thread_t *)vlc_object_find( p_this, VLC_OBJECT_INTF, vlc_mutex_lock( &skin_load.mutex );
FIND_ANYWHERE ); p_intf = skin_load.intf;
if( p_intf )
vlc_object_hold( p_intf );
vlc_mutex_unlock( &skin_load.mutex );
if( p_intf != NULL ) if( p_intf != NULL )
{
// Do nothing is skins2 is not the main interface
if( var_Type( p_intf, "skin-to-load" ) == VLC_VAR_STRING )
{ {
playlist_t *p_playlist = pl_Hold( p_this ); playlist_t *p_playlist = pl_Hold( p_this );
// Make sure the item is deleted afterwards // Make sure the item is deleted afterwards
...@@ -338,9 +353,8 @@ static int DemuxOpen( vlc_object_t *p_this ) ...@@ -338,9 +353,8 @@ static int DemuxOpen( vlc_object_t *p_this )
playlist_CurrentPlayingItem( p_playlist )->i_flags |= PLAYLIST_REMOVE_FLAG; playlist_CurrentPlayingItem( p_playlist )->i_flags |= PLAYLIST_REMOVE_FLAG;
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
vlc_value_t val; var_SetString( p_intf, "skin-to-load", p_demux->psz_path );
val.psz_string = p_demux->psz_path; vlc_object_release( p_intf );
var_Set( p_intf, "skin-to-load", val );
} }
else else
{ {
...@@ -348,9 +362,6 @@ static int DemuxOpen( vlc_object_t *p_this ) ...@@ -348,9 +362,6 @@ static int DemuxOpen( vlc_object_t *p_this )
"skin could not be loaded (not using skins2 intf)" ); "skin could not be loaded (not using skins2 intf)" );
} }
vlc_object_release( p_intf );
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -382,17 +393,19 @@ static int onSystrayChange( vlc_object_t *pObj, const char *pVariable, ...@@ -382,17 +393,19 @@ static int onSystrayChange( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal, vlc_value_t oldVal, vlc_value_t newVal,
void *pParam ) void *pParam )
{ {
intf_thread_t *pIntf = intf_thread_t *pIntf;
(intf_thread_t*)vlc_object_find( pObj, VLC_OBJECT_INTF, FIND_ANYWHERE );
vlc_mutex_lock( &skin_load.mutex );
pIntf = skin_load.intf;
if( pIntf )
vlc_object_hold( pIntf );
vlc_mutex_unlock( &skin_load.mutex );
if( pIntf == NULL ) if( pIntf == NULL )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
} }
// Check that we found the correct interface (same check as for the demux)
if( var_Type( pIntf, "skin-to-load" ) == VLC_VAR_STRING )
{
AsyncQueue *pQueue = AsyncQueue::instance( pIntf ); AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
if( newVal.b_bool ) if( newVal.b_bool )
{ {
...@@ -404,7 +417,6 @@ static int onSystrayChange( vlc_object_t *pObj, const char *pVariable, ...@@ -404,7 +417,6 @@ static int onSystrayChange( vlc_object_t *pObj, const char *pVariable,
CmdRemoveFromTray *pCmd = new CmdRemoveFromTray( pIntf ); CmdRemoveFromTray *pCmd = new CmdRemoveFromTray( pIntf );
pQueue->push( CmdGenericPtr( pCmd ) ); pQueue->push( CmdGenericPtr( pCmd ) );
} }
}
vlc_object_release( pIntf ); vlc_object_release( pIntf );
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -416,17 +428,19 @@ static int onTaskBarChange( vlc_object_t *pObj, const char *pVariable, ...@@ -416,17 +428,19 @@ static int onTaskBarChange( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal, vlc_value_t oldVal, vlc_value_t newVal,
void *pParam ) void *pParam )
{ {
intf_thread_t *pIntf = intf_thread_t *pIntf;
(intf_thread_t*)vlc_object_find( pObj, VLC_OBJECT_INTF, FIND_ANYWHERE );
vlc_mutex_lock( &skin_load.mutex );
pIntf = skin_load.intf;
if( pIntf )
vlc_object_hold( pIntf );
vlc_mutex_unlock( &skin_load.mutex );
if( pIntf == NULL ) if( pIntf == NULL )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
} }
// Check that we found the correct interface (same check as for the demux)
if( var_Type( pIntf, "skin-to-load" ) == VLC_VAR_STRING )
{
AsyncQueue *pQueue = AsyncQueue::instance( pIntf ); AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
if( newVal.b_bool ) if( newVal.b_bool )
{ {
...@@ -438,7 +452,6 @@ static int onTaskBarChange( vlc_object_t *pObj, const char *pVariable, ...@@ -438,7 +452,6 @@ static int onTaskBarChange( vlc_object_t *pObj, const char *pVariable,
CmdRemoveFromTaskBar *pCmd = new CmdRemoveFromTaskBar( pIntf ); CmdRemoveFromTaskBar *pCmd = new CmdRemoveFromTaskBar( pIntf );
pQueue->push( CmdGenericPtr( pCmd ) ); pQueue->push( CmdGenericPtr( pCmd ) );
} }
}
vlc_object_release( pIntf ); vlc_object_release( pIntf );
return VLC_SUCCESS; return VLC_SUCCESS;
......
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