Commit 11405d4d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

interface: create the playlist first and use it as parent

parent a5056a2d
......@@ -90,8 +90,7 @@ struct intf_dialog_args_t
struct interaction_dialog_t *p_dialog;
};
VLC_API int intf_Create( vlc_object_t *, const char * );
#define intf_Create(a,b) intf_Create(VLC_OBJECT(a),b)
VLC_API int intf_Create( playlist_t *, const char * );
VLC_API void libvlc_Quit( libvlc_int_t * );
......
......@@ -322,7 +322,7 @@ static void WINAPI ServiceDispatch( DWORD numArgs, char **args )
if( asprintf( &psz_temp, "%s,none", psz_module ) != -1 )
{
/* Try to create the interface */
if( intf_Create( p_intf, psz_temp ) )
if( intf_Create( pl_Get(p_intf), psz_temp ) )
{
msg_Err( p_intf, "interface \"%s\" initialization failed",
psz_temp );
......
......@@ -1420,9 +1420,10 @@ static int Quit( vlc_object_t *p_this, char const *psz_cmd,
static int Intf( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
intf_thread_t *intf = (intf_thread_t *)p_this;
return intf_Create( p_this->p_libvlc, newval.psz_string );
VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
return intf_Create(pl_Get(intf), newval.psz_string );
}
static int Volume( vlc_object_t *p_this, char const *psz_cmd,
......
......@@ -61,22 +61,19 @@ static int AddIntfCallback( vlc_object_t *, char const *,
*/
static vlc_mutex_t lock = VLC_STATIC_MUTEX;
#undef intf_Create
/**
* Create and start an interface.
*
* @param p_this the calling vlc_object_t
* @param playlist playlist and parent object for the interface
* @param chain configuration chain string
* @return VLC_SUCCESS or an error code
*/
int intf_Create( vlc_object_t *p_this, const char *chain )
int intf_Create( playlist_t *playlist, const char *chain )
{
libvlc_int_t *p_libvlc = p_this->p_libvlc;
intf_thread_t * p_intf;
/* Allocate structure */
p_intf = vlc_custom_create( p_libvlc, sizeof( *p_intf ), "interface" );
if( !p_intf )
intf_thread_t *p_intf = vlc_custom_create( playlist, sizeof( *p_intf ),
"interface" );
if( unlikely(p_intf == NULL) )
return VLC_ENOMEM;
/* Variable used for interface spawning */
......@@ -106,7 +103,7 @@ int intf_Create( vlc_object_t *p_this, const char *chain )
text.psz_string = (char *)_("Mouse Gestures");
var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text );
var_AddCallback( p_intf, "intf-add", AddIntfCallback, NULL );
var_AddCallback( p_intf, "intf-add", AddIntfCallback, playlist );
/* Choose the best module */
char *module;
......@@ -122,8 +119,8 @@ int intf_Create( vlc_object_t *p_this, const char *chain )
}
vlc_mutex_lock( &lock );
p_intf->p_next = libvlc_priv( p_libvlc )->p_intf;
libvlc_priv( p_libvlc )->p_intf = p_intf;
p_intf->p_next = pl_priv( playlist )->interface;
pl_priv( playlist )->interface = p_intf;
vlc_mutex_unlock( &lock );
return VLC_SUCCESS;
......@@ -169,39 +166,44 @@ playlist_t *(pl_Get)(vlc_object_t *obj)
* Stops and destroys all interfaces
* @param p_libvlc the LibVLC instance
*/
void intf_DestroyAll( libvlc_int_t *p_libvlc )
void intf_DestroyAll(libvlc_int_t *libvlc)
{
intf_thread_t *p_intf;
vlc_mutex_lock( &lock );
p_intf = libvlc_priv( p_libvlc )->p_intf;
#ifndef NDEBUG
libvlc_priv( p_libvlc )->p_intf = NULL;
#endif
vlc_mutex_unlock( &lock );
playlist_t *playlist;
/* Cleanup the interfaces */
while( p_intf != NULL )
vlc_mutex_lock(&lock);
playlist = libvlc_priv(libvlc)->playlist;
if (playlist != NULL)
{
intf_thread_t *p_next = p_intf->p_next;
intf_thread_t *intf, **pp = &(pl_priv(playlist)->interface);
module_unneed( p_intf, p_intf->p_module );
config_ChainDestroy( p_intf->p_cfg );
vlc_object_release( p_intf );
p_intf = p_next;
while ((intf = *pp) != NULL)
{
*pp = intf->p_next;
vlc_mutex_unlock(&lock);
module_unneed(intf, intf->p_module);
config_ChainDestroy(intf->p_cfg);
var_DelCallback(intf, "intf-add", AddIntfCallback, playlist);
vlc_object_release(intf);
vlc_mutex_lock(&lock);
}
}
vlc_mutex_unlock(&lock);
}
/* Following functions are local */
static int AddIntfCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
static int AddIntfCallback( vlc_object_t *obj, char const *var,
vlc_value_t old, vlc_value_t cur, void *data )
{
(void)psz_cmd; (void)oldval; (void)p_data;
playlist_t *playlist = data;
int ret = intf_Create( VLC_OBJECT(p_this->p_libvlc), newval.psz_string );
int ret = intf_Create( playlist, cur.psz_string );
if( ret )
msg_Err( p_this, "interface \"%s\" initialization failed",
newval.psz_string );
msg_Err( obj, "interface \"%s\" initialization failed",
cur.psz_string );
(void) var; (void) old;
return ret;
}
......@@ -447,7 +447,7 @@ dbus_out:
}
if( asprintf( &psz_temp, "%s,none", psz_module ) != -1)
{
intf_Create( p_libvlc, psz_temp );
libvlc_InternalAddIntf( p_libvlc, psz_temp );
free( psz_temp );
}
}
......@@ -459,7 +459,7 @@ dbus_out:
{
char *logmode = var_CreateGetNonEmptyString( p_libvlc, "logmode" );
var_SetString( p_libvlc, "logmode", "syslog" );
intf_Create( p_libvlc, "logger,none" );
libvlc_InternalAddIntf( p_libvlc, "logger,none" );
if( logmode )
{
......@@ -471,12 +471,10 @@ dbus_out:
else
#endif
if( var_InheritBool( p_libvlc, "file-logging" ) )
intf_Create( p_libvlc, "logger,none" );
libvlc_InternalAddIntf( p_libvlc, "logger,none" );
if( var_InheritBool( p_libvlc, "network-synchronisation") )
{
intf_Create( p_libvlc, "netsync,none" );
}
libvlc_InternalAddIntf( p_libvlc, "netsync,none" );
#ifdef __APPLE__
var_Create( p_libvlc, "drawable-view-top", VLC_VAR_INTEGER );
......@@ -591,13 +589,14 @@ void libvlc_InternalDestroy( libvlc_int_t *p_libvlc )
*/
int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc, const char *name )
{
int ret;
if( !p_libvlc )
return VLC_EGENERIC;
playlist_t *playlist = pl_Get(p_libvlc);
int ret;
if( name != NULL )
ret = intf_Create( p_libvlc, name );
ret = intf_Create( playlist, name );
else
{ /* Default interface */
char *intf = var_InheritString( p_libvlc, "intf" );
......@@ -611,7 +610,7 @@ int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc, const char *name )
_("Running vlc with the default interface. "
"Use 'cvlc' to use vlc without interface.") );
}
ret = intf_Create( p_libvlc, intf );
ret = intf_Create( playlist, intf );
name = "default";
}
if( ret )
......
......@@ -166,9 +166,6 @@ typedef struct libvlc_priv_t
struct playlist_preparser_t *parser; ///< Input item meta data handler
struct vlc_actions *actions; ///< Hotkeys handler
/* Interfaces */
struct intf_thread_t *p_intf; ///< Interfaces linked-list
/* Objects tree */
vlc_mutex_t structure_lock;
......
......@@ -48,6 +48,7 @@ typedef struct playlist_private_t
{
playlist_t public_data;
playlist_preparser_t *p_preparser; /**< Preparser data */
struct intf_thread_t *interface; /**< Linked-list of interfaces */
playlist_item_array_t items_to_delete; /**< Array of items and nodes to
delete... At the very end. This sucks. */
......
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