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

playlist: create instance only when needed

This avoids checking that the playlist exists over and over again. The
playlist always exists when an interface is running.
parent c39376d3
...@@ -188,8 +188,42 @@ void libvlc_InternalPlay(libvlc_int_t *libvlc) ...@@ -188,8 +188,42 @@ void libvlc_InternalPlay(libvlc_int_t *libvlc)
} }
/** /**
* Stops and destroys all interfaces * Starts an interface plugin.
* @param p_libvlc the LibVLC instance */
int libvlc_InternalAddIntf(libvlc_int_t *libvlc, const char *name)
{
playlist_t *playlist = intf_GetPlaylist(libvlc);
int ret;
if (unlikely(playlist == NULL))
ret = VLC_ENOMEM;
else
if (name != NULL)
ret = intf_Create(playlist, name);
else
{ /* Default interface */
char *intf = var_InheritString(libvlc, "intf");
if (intf == NULL) /* "intf" has not been set */
{
char *pidfile = var_InheritString(libvlc, "pidfile");
if (pidfile != NULL)
free(pidfile);
else
msg_Info(libvlc, _("Running vlc with the default interface. "
"Use 'cvlc' to use vlc without interface."));
}
ret = intf_Create(playlist, intf);
name = "default";
}
if (ret != VLC_SUCCESS)
msg_Err(libvlc, "interface \"%s\" initialization failed", name);
return ret;
}
/**
* Stops and destroys all interfaces, then the playlist.
* @warning FIXME
* @param libvlc the LibVLC instance
*/ */
void intf_DestroyAll(libvlc_int_t *libvlc) void intf_DestroyAll(libvlc_int_t *libvlc)
{ {
...@@ -213,8 +247,13 @@ void intf_DestroyAll(libvlc_int_t *libvlc) ...@@ -213,8 +247,13 @@ void intf_DestroyAll(libvlc_int_t *libvlc)
vlc_mutex_lock(&lock); vlc_mutex_lock(&lock);
} }
libvlc_priv(libvlc)->playlist = NULL;
} }
vlc_mutex_unlock(&lock); vlc_mutex_unlock(&lock);
if (playlist != NULL)
playlist_Destroy(playlist);
} }
/* Following functions are local */ /* Following functions are local */
......
...@@ -532,11 +532,6 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc ) ...@@ -532,11 +532,6 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
} }
#endif #endif
/* Free playlist now, all threads are gone */
playlist_t *p_playlist = libvlc_priv (p_libvlc)->playlist;
if( p_playlist != NULL )
playlist_Destroy( p_playlist );
#if !defined( _WIN32 ) && !defined( __OS2__ ) #if !defined( _WIN32 ) && !defined( __OS2__ )
char *pidfile = var_InheritString( p_libvlc, "pidfile" ); char *pidfile = var_InheritString( p_libvlc, "pidfile" );
if( pidfile != NULL ) if( pidfile != NULL )
...@@ -583,40 +578,6 @@ void libvlc_InternalDestroy( libvlc_int_t *p_libvlc ) ...@@ -583,40 +578,6 @@ void libvlc_InternalDestroy( libvlc_int_t *p_libvlc )
vlc_object_release( p_libvlc ); vlc_object_release( p_libvlc );
} }
/**
* Add an interface plugin and run it
*/
int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc, const char *name )
{
if( !p_libvlc )
return VLC_EGENERIC;
playlist_t *playlist = pl_Get(p_libvlc);
int ret;
if( name != NULL )
ret = intf_Create( playlist, name );
else
{ /* Default interface */
char *intf = var_InheritString( p_libvlc, "intf" );
if( intf == NULL ) /* "intf" has not been set */
{
char *pidfile = var_InheritString( p_libvlc, "pidfile" );
if( pidfile != NULL )
free( pidfile );
else
msg_Info( p_libvlc, "%s",
_("Running vlc with the default interface. "
"Use 'cvlc' to use vlc without interface.") );
}
ret = intf_Create( playlist, intf );
name = "default";
}
if( ret )
msg_Err( p_libvlc, "interface \"%s\" initialization failed", name );
return ret;
}
/***************************************************************************** /*****************************************************************************
* GetFilenames: parse command line options which are not flags * GetFilenames: parse command line options which are not flags
***************************************************************************** *****************************************************************************
......
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