Commit 28d49d98 authored by Clément Stenac's avatar Clément Stenac

Store playlist object in instance-specific object

parent 8923568d
...@@ -5507,7 +5507,7 @@ dnl AC_DEFINE_UNQUOTED(MODULE_SUFFIX, "__${VLC_SYMBOL}", [String suffix for modu ...@@ -5507,7 +5507,7 @@ dnl AC_DEFINE_UNQUOTED(MODULE_SUFFIX, "__${VLC_SYMBOL}", [String suffix for modu
dnl AC_DEFINE_UNQUOTED(MODULE_SYMBOL, ${VLC_SYMBOL}, [Symbol suffix for module functions]) dnl AC_DEFINE_UNQUOTED(MODULE_SYMBOL, ${VLC_SYMBOL}, [Symbol suffix for module functions])
dnl New definitions with value matching 0.8.6 release dnl New definitions with value matching 0.8.6 release
module_symbol="0_8_6b" module_symbol="0_8_6c"
AC_DEFINE_UNQUOTED(MODULE_SUFFIX, "__${module_symbol}", [String suffix for module functions]) AC_DEFINE_UNQUOTED(MODULE_SUFFIX, "__${module_symbol}", [String suffix for module functions])
AC_DEFINE_UNQUOTED(MODULE_SYMBOL, $module_symbol, [Symbol suffix for module functions]) AC_DEFINE_UNQUOTED(MODULE_SYMBOL, $module_symbol, [Symbol suffix for module functions])
VLC_ENTRY="vlc_entry__${module_symbol}" VLC_ENTRY="vlc_entry__${module_symbol}"
......
...@@ -80,28 +80,26 @@ struct libvlc_int_t ...@@ -80,28 +80,26 @@ struct libvlc_int_t
VLC_COMMON_MEMBERS VLC_COMMON_MEMBERS
/* Global properties */ /* Global properties */
int i_argc; /* command line arguments count */ int i_argc; ///< command line arguments count
char ** ppsz_argv; /* command line arguments */ char ** ppsz_argv; ///< command line arguments
char * psz_homedir; /* configuration directory */ char * psz_homedir; ///< configuration directory
char * psz_userdir; /* user's home directory */ char * psz_userdir; ///< user's home directory
char * psz_configfile; /* location of config file */ char * psz_configfile; ///< location of config file
/* Fast memcpy plugin used */ playlist_t *p_playlist; ///< playlist object
module_t * p_memcpy_module;
void* ( *pf_memcpy ) ( void *, const void *, size_t );
void* ( *pf_memset ) ( void *, int, size_t );
/* Statistics */ module_t * p_memcpy_module; ///< Fast memcpy plugin used
vlc_bool_t b_stats; ///< Should we collect stats void* ( *pf_memcpy ) ( void *, const void *, size_t ); ///< fast memcpy
/* Timers handling */ void* ( *pf_memset ) ( void *, int, size_t ); ///< fast memset
vlc_bool_t b_stats; ///< Should we collect stats ?
vlc_mutex_t timer_lock; ///< Lock to protect timers vlc_mutex_t timer_lock; ///< Lock to protect timers
int i_timers; ///< Number of timers int i_timers; ///< Number of timers
counter_t **pp_timers; ///< Array of all timers counter_t **pp_timers; ///< Array of all timers
/* Locks */ vlc_mutex_t config_lock; ///< Lock for the config file
vlc_mutex_t config_lock; /* lock for the config file */
#ifdef __APPLE__ #ifdef __APPLE__
vlc_mutex_t quicktime_lock; /* QT is not thread safe on OSX */ vlc_mutex_t quicktime_lock; ///< QT is not thread safe on OSX
#endif #endif
/* Structure storing the action name / key associations */ /* Structure storing the action name / key associations */
......
...@@ -201,7 +201,7 @@ struct playlist_add_t ...@@ -201,7 +201,7 @@ struct playlist_add_t
/* Global thread */ /* Global thread */
#define playlist_ThreadCreate(a) __playlist_ThreadCreate(VLC_OBJECT(a)) #define playlist_ThreadCreate(a) __playlist_ThreadCreate(VLC_OBJECT(a))
playlist_t *__playlist_ThreadCreate ( vlc_object_t * ); void __playlist_ThreadCreate ( vlc_object_t * );
int playlist_ThreadDestroy ( playlist_t * ); int playlist_ThreadDestroy ( playlist_t * );
/* Helpers */ /* Helpers */
......
...@@ -244,8 +244,8 @@ int VLC_Create( void ) ...@@ -244,8 +244,8 @@ int VLC_Create( void )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_libvlc->thread_id = 0; p_libvlc->thread_id = 0;
p_libvlc->p_playlist = NULL;
p_libvlc->psz_object_name = "root"; p_libvlc->psz_object_name = "libvlc";
/* Initialize mutexes */ /* Initialize mutexes */
vlc_mutex_init( p_libvlc, &p_libvlc->config_lock ); vlc_mutex_init( p_libvlc, &p_libvlc->config_lock );
...@@ -263,6 +263,13 @@ int VLC_Create( void ) ...@@ -263,6 +263,13 @@ int VLC_Create( void )
return p_libvlc->i_object_id; return p_libvlc->i_object_id;
} }
#define LIBVLC_FUNC \
libvlc_int_t * p_libvlc = vlc_current_object( i_object ); \
if( !p_libvlc ) return VLC_ENOOBJ;
#define LIBVLC_FUNC_END \
if( i_object ) vlc_object_release( p_libvlc );
/***************************************************************************** /*****************************************************************************
* VLC_Init: initialize a vlc_t structure. * VLC_Init: initialize a vlc_t structure.
***************************************************************************** *****************************************************************************
...@@ -290,16 +297,9 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) ...@@ -290,16 +297,9 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
char * psz_language; char * psz_language;
#endif #endif
#endif #endif
libvlc_int_t * p_libvlc = vlc_current_object( i_object ); LIBVLC_FUNC;
if( !p_libvlc ) /* System specific initialization code */
{
return VLC_ENOOBJ;
}
/*
* System specific initialization code
*/
system_Init( p_libvlc, &i_argc, ppsz_argv ); system_Init( p_libvlc, &i_argc, ppsz_argv );
/* Get the executable name (similar to the basename command) */ /* Get the executable name (similar to the basename command) */
...@@ -727,11 +727,9 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) ...@@ -727,11 +727,9 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
/* Do a copy (we don't need to modify the strings) */ /* Do a copy (we don't need to modify the strings) */
memcpy( p_libvlc->p_hotkeys, p_hotkeys, sizeof(p_hotkeys) ); memcpy( p_libvlc->p_hotkeys, p_hotkeys, sizeof(p_hotkeys) );
/* /* Initialize playlist and get commandline files */
* Initialize playlist and get commandline files playlist_ThreadCreate( p_libvlc );
*/ if( !p_libvlc->p_playlist )
p_playlist = playlist_ThreadCreate( p_libvlc );
if( !p_playlist )
{ {
msg_Err( p_libvlc, "playlist initialization failed" ); msg_Err( p_libvlc, "playlist initialization failed" );
if( p_libvlc->p_memcpy_module != NULL ) if( p_libvlc->p_memcpy_module != NULL )
...@@ -742,6 +740,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) ...@@ -742,6 +740,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
if( i_object ) vlc_object_release( p_libvlc ); if( i_object ) vlc_object_release( p_libvlc );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_playlist = p_libvlc->p_playlist;
psz_modules = config_GetPsz( p_playlist, "services-discovery" ); psz_modules = config_GetPsz( p_playlist, "services-discovery" );
if( psz_modules && *psz_modules ) if( psz_modules && *psz_modules )
...@@ -864,7 +863,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) ...@@ -864,7 +863,7 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
} }
if ( val.psz_string != NULL ) free( val.psz_string ); if ( val.psz_string != NULL ) free( val.psz_string );
if( i_object ) vlc_object_release( p_libvlc ); LIBVLC_FUNC_END;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -892,16 +891,9 @@ int VLC_AddIntf( int i_object, char const *psz_module, ...@@ -892,16 +891,9 @@ int VLC_AddIntf( int i_object, char const *psz_module,
*****************************************************************************/ *****************************************************************************/
int VLC_Die( int i_object ) int VLC_Die( int i_object )
{ {
libvlc_int_t *p_libvlc = vlc_current_object( i_object ); LIBVLC_FUNC;
if( !p_libvlc )
{
return VLC_ENOOBJ;
}
p_libvlc->b_die = VLC_TRUE; p_libvlc->b_die = VLC_TRUE;
LIBVLC_FUNC_END;
if( i_object ) vlc_object_release( p_libvlc );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -915,17 +907,10 @@ int VLC_CleanUp( int i_object ) ...@@ -915,17 +907,10 @@ int VLC_CleanUp( int i_object )
vout_thread_t * p_vout; vout_thread_t * p_vout;
aout_instance_t * p_aout; aout_instance_t * p_aout;
announce_handler_t * p_announce; announce_handler_t * p_announce;
libvlc_int_t *p_libvlc = vlc_current_object( i_object );
LIBVLC_FUNC;
/* Check that the handle is valid */ /* Ask the interfaces to stop and destroy them */
if( !p_libvlc )
{
return VLC_ENOOBJ;
}
/*
* Ask the interfaces to stop and destroy them
*/
msg_Dbg( p_libvlc, "removing all interfaces" ); msg_Dbg( p_libvlc, "removing all interfaces" );
while( (p_intf = vlc_object_find( p_libvlc, VLC_OBJECT_INTF, FIND_CHILD )) ) while( (p_intf = vlc_object_find( p_libvlc, VLC_OBJECT_INTF, FIND_CHILD )) )
{ {
...@@ -935,21 +920,11 @@ int VLC_CleanUp( int i_object ) ...@@ -935,21 +920,11 @@ int VLC_CleanUp( int i_object )
intf_Destroy( p_intf ); intf_Destroy( p_intf );
} }
/* /* Free playlist */
* Free playlist msg_Dbg( p_libvlc, "removing playlist" );
*/ playlist_ThreadDestroy( p_libvlc->p_playlist );
msg_Dbg( p_libvlc, "removing playlist handler" );
while( (p_playlist = vlc_object_find( p_libvlc, VLC_OBJECT_PLAYLIST,
FIND_CHILD )) )
{
vlc_object_detach( p_playlist );
vlc_object_release( p_playlist );
playlist_ThreadDestroy( p_playlist );
}
/* /* Free video outputs */
* Free video outputs
*/
msg_Dbg( p_libvlc, "removing all video outputs" ); msg_Dbg( p_libvlc, "removing all video outputs" );
while( (p_vout = vlc_object_find( p_libvlc, VLC_OBJECT_VOUT, FIND_CHILD )) ) while( (p_vout = vlc_object_find( p_libvlc, VLC_OBJECT_VOUT, FIND_CHILD )) )
{ {
...@@ -958,9 +933,7 @@ int VLC_CleanUp( int i_object ) ...@@ -958,9 +933,7 @@ int VLC_CleanUp( int i_object )
vout_Destroy( p_vout ); vout_Destroy( p_vout );
} }
/* /* Free audio outputs */
* Free audio outputs
*/
msg_Dbg( p_libvlc, "removing all audio outputs" ); msg_Dbg( p_libvlc, "removing all audio outputs" );
while( (p_aout = vlc_object_find( p_libvlc, VLC_OBJECT_AOUT, FIND_CHILD )) ) while( (p_aout = vlc_object_find( p_libvlc, VLC_OBJECT_AOUT, FIND_CHILD )) )
{ {
...@@ -972,9 +945,7 @@ int VLC_CleanUp( int i_object ) ...@@ -972,9 +945,7 @@ int VLC_CleanUp( int i_object )
stats_TimersDumpAll( p_libvlc ); stats_TimersDumpAll( p_libvlc );
stats_TimersClean( p_libvlc ); stats_TimersClean( p_libvlc );
/* /* Free announce handler(s?) */
* Free announce handler(s?)
*/
while( (p_announce = vlc_object_find( p_libvlc, VLC_OBJECT_ANNOUNCE, while( (p_announce = vlc_object_find( p_libvlc, VLC_OBJECT_ANNOUNCE,
FIND_CHILD ) ) ) FIND_CHILD ) ) )
{ {
...@@ -984,8 +955,7 @@ int VLC_CleanUp( int i_object ) ...@@ -984,8 +955,7 @@ int VLC_CleanUp( int i_object )
announce_HandlerDestroy( p_announce ); announce_HandlerDestroy( p_announce );
} }
if( i_object ) vlc_object_release( p_libvlc ); LIBVLC_FUNC_END;
return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -996,54 +966,24 @@ int VLC_CleanUp( int i_object ) ...@@ -996,54 +966,24 @@ int VLC_CleanUp( int i_object )
*****************************************************************************/ *****************************************************************************/
int VLC_Destroy( int i_object ) int VLC_Destroy( int i_object )
{ {
libvlc_int_t *p_libvlc = vlc_current_object( i_object ); LIBVLC_FUNC;
if( !p_libvlc ) /* Free allocated memory */
{
return VLC_ENOOBJ;
}
/*
* Free allocated memory
*/
if( p_libvlc->p_memcpy_module ) if( p_libvlc->p_memcpy_module )
{ {
module_Unneed( p_libvlc, p_libvlc->p_memcpy_module ); module_Unneed( p_libvlc, p_libvlc->p_memcpy_module );
p_libvlc->p_memcpy_module = NULL; p_libvlc->p_memcpy_module = NULL;
} }
/* /* Free module bank ! */
* Free module bank !
*/
module_EndBank( p_libvlc ); module_EndBank( p_libvlc );
if( p_libvlc->psz_homedir ) FREENULL( p_libvlc->psz_homedir );
{ FREENULL( p_libvlc->psz_userdir );
free( p_libvlc->psz_homedir ); FREENULL( p_libvlc->psz_configfile );
p_libvlc->psz_homedir = NULL; FREENULL( p_libvlc->p_hotkeys );
}
if( p_libvlc->psz_userdir )
{
free( p_libvlc->psz_userdir );
p_libvlc->psz_userdir = NULL;
}
if( p_libvlc->psz_configfile ) /* System specific cleaning code */
{
free( p_libvlc->psz_configfile );
p_libvlc->psz_configfile = NULL;
}
if( p_libvlc->p_hotkeys )
{
free( p_libvlc->p_hotkeys );
p_libvlc->p_hotkeys = NULL;
}
/*
* System specific cleaning code
*/
system_End( p_libvlc ); system_End( p_libvlc );
/* /*
...@@ -1077,13 +1017,8 @@ int VLC_Destroy( int i_object ) ...@@ -1077,13 +1017,8 @@ int VLC_Destroy( int i_object )
*****************************************************************************/ *****************************************************************************/
int VLC_VariableSet( int i_object, char const *psz_var, vlc_value_t value ) int VLC_VariableSet( int i_object, char const *psz_var, vlc_value_t value )
{ {
libvlc_int_t *p_libvlc = vlc_current_object( i_object );
int i_ret; int i_ret;
LIBVLC_FUNC;
if( !p_libvlc )
{
return VLC_ENOOBJ;
}
/* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then /* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then
* we handle it as a configuration variable. Don't tell Gildas :) -- sam */ * we handle it as a configuration variable. Don't tell Gildas :) -- sam */
...@@ -1118,7 +1053,7 @@ int VLC_VariableSet( int i_object, char const *psz_var, vlc_value_t value ) ...@@ -1118,7 +1053,7 @@ int VLC_VariableSet( int i_object, char const *psz_var, vlc_value_t value )
i_ret = var_Set( p_libvlc, psz_var, value ); i_ret = var_Set( p_libvlc, psz_var, value );
if( i_object ) vlc_object_release( p_libvlc ); LIBVLC_FUNC_END;
return i_ret; return i_ret;
} }
...@@ -1127,17 +1062,10 @@ int VLC_VariableSet( int i_object, char const *psz_var, vlc_value_t value ) ...@@ -1127,17 +1062,10 @@ int VLC_VariableSet( int i_object, char const *psz_var, vlc_value_t value )
*****************************************************************************/ *****************************************************************************/
int VLC_VariableGet( int i_object, char const *psz_var, vlc_value_t *p_value ) int VLC_VariableGet( int i_object, char const *psz_var, vlc_value_t *p_value )
{ {
libvlc_int_t *p_libvlc = vlc_current_object( i_object );
int i_ret; int i_ret;
LIBVLC_FUNC;
if( !p_libvlc )
{
return VLC_ENOOBJ;
}
i_ret = var_Get( p_libvlc , psz_var, p_value ); i_ret = var_Get( p_libvlc , psz_var, p_value );
LIBVLC_FUNC_END;
if( i_object ) vlc_object_release( p_libvlc );
return i_ret; return i_ret;
} }
...@@ -1147,13 +1075,7 @@ int VLC_VariableGet( int i_object, char const *psz_var, vlc_value_t *p_value ) ...@@ -1147,13 +1075,7 @@ int VLC_VariableGet( int i_object, char const *psz_var, vlc_value_t *p_value )
int VLC_VariableType( int i_object, char const *psz_var, int *pi_type ) int VLC_VariableType( int i_object, char const *psz_var, int *pi_type )
{ {
int i_type; int i_type;
libvlc_int_t *p_libvlc = vlc_current_object( i_object ); LIBVLC_FUNC;
if( !p_libvlc )
{
return VLC_ENOOBJ;
}
/* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then /* FIXME: Temporary hack for Mozilla, if variable starts with conf:: then
* we handle it as a configuration variable. Don't tell Gildas :) -- sam */ * we handle it as a configuration variable. Don't tell Gildas :) -- sam */
if( !strncmp( psz_var, "conf::", 6 ) ) if( !strncmp( psz_var, "conf::", 6 ) )
...@@ -1187,7 +1109,7 @@ int VLC_VariableType( int i_object, char const *psz_var, int *pi_type ) ...@@ -1187,7 +1109,7 @@ int VLC_VariableType( int i_object, char const *psz_var, int *pi_type )
else else
i_type = VLC_VAR_TYPE & var_Type( p_libvlc , psz_var ); i_type = VLC_VAR_TYPE & var_Type( p_libvlc , psz_var );
if( i_object ) vlc_object_release( p_libvlc ); LIBVLC_FUNC_END;
if( i_type > 0 ) if( i_type > 0 )
{ {
...@@ -1197,47 +1119,31 @@ int VLC_VariableType( int i_object, char const *psz_var, int *pi_type ) ...@@ -1197,47 +1119,31 @@ int VLC_VariableType( int i_object, char const *psz_var, int *pi_type )
return VLC_ENOVAR; return VLC_ENOVAR;
} }
#define LIBVLC_PLAYLIST_FUNC \
libvlc_int_t *p_libvlc = vlc_current_object( i_object );\
if( !p_libvlc || !p_libvlc->p_playlist ) return VLC_ENOOBJ; \
vlc_object_yield( p_libvlc->p_playlist );
#define LIBVLC_PLAYLIST_FUNC_END \
vlc_object_release( p_libvlc->p_playlist ); \
if( i_object ) vlc_object_release( p_libvlc );
/***************************************************************************** /*****************************************************************************
* VLC_AddTarget: adds a target for playing. * VLC_AddTarget: adds a target for playing.
***************************************************************************** *****************************************************************************
* This function adds psz_target to the current playlist. If a playlist does * This function adds psz_target to the playlist
* not exist, it will create one.
*****************************************************************************/ *****************************************************************************/
int VLC_AddTarget( int i_object, char const *psz_target, int VLC_AddTarget( int i_object, char const *psz_target,
char const **ppsz_options, int i_options, char const **ppsz_options, int i_options,
int i_mode, int i_pos ) int i_mode, int i_pos )
{ {
int i_err; int i_err;
playlist_t *p_playlist; LIBVLC_PLAYLIST_FUNC;
libvlc_int_t *p_libvlc = vlc_current_object( i_object ); i_err = playlist_PlaylistAddExt( p_libvlc->p_playlist, psz_target,
psz_target, i_mode, i_pos, -1,
if( !p_libvlc ) ppsz_options, i_options );
{ LIBVLC_PLAYLIST_FUNC_END;
return VLC_ENOOBJ;
}
p_playlist = vlc_object_find( p_libvlc, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist == NULL )
{
msg_Dbg( p_libvlc, "no playlist present, creating one" );
p_playlist = playlist_ThreadCreate( p_libvlc );
if( p_playlist == NULL )
{
if( i_object ) vlc_object_release( p_libvlc );
return VLC_EGENERIC;
}
vlc_object_yield( p_playlist );
}
i_err = playlist_PlaylistAddExt( p_playlist, psz_target, psz_target,
i_mode, i_pos, -1, ppsz_options, i_options);
vlc_object_release( p_playlist );
if( i_object ) vlc_object_release( p_libvlc );
return i_err; return i_err;
} }
...@@ -1246,27 +1152,9 @@ int VLC_AddTarget( int i_object, char const *psz_target, ...@@ -1246,27 +1152,9 @@ int VLC_AddTarget( int i_object, char const *psz_target,
*****************************************************************************/ *****************************************************************************/
int VLC_Play( int i_object ) int VLC_Play( int i_object )
{ {
playlist_t * p_playlist; LIBVLC_PLAYLIST_FUNC;
libvlc_int_t *p_libvlc = vlc_current_object( i_object ); playlist_Play( p_libvlc->p_playlist );
LIBVLC_PLAYLIST_FUNC_END;
/* Check that the handle is valid */
if( !p_libvlc )
{
return VLC_ENOOBJ;
}
p_playlist = vlc_object_find( p_libvlc, VLC_OBJECT_PLAYLIST, FIND_CHILD );
if( !p_playlist )
{
if( i_object ) vlc_object_release( p_libvlc );
return VLC_ENOOBJ;
}
playlist_Play( p_playlist );
vlc_object_release( p_playlist );
if( i_object ) vlc_object_release( p_libvlc );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -1275,27 +1163,9 @@ int VLC_Play( int i_object ) ...@@ -1275,27 +1163,9 @@ int VLC_Play( int i_object )
*****************************************************************************/ *****************************************************************************/
int VLC_Pause( int i_object ) int VLC_Pause( int i_object )
{ {
playlist_t * p_playlist; LIBVLC_PLAYLIST_FUNC;
libvlc_int_t *p_libvlc = vlc_current_object( i_object ); playlist_Pause( p_libvlc->p_playlist );
LIBVLC_PLAYLIST_FUNC_END;
/* Check that the handle is valid */
if( !p_libvlc )
{
return VLC_ENOOBJ;
}
p_playlist = vlc_object_find( p_libvlc, VLC_OBJECT_PLAYLIST, FIND_CHILD );
if( !p_playlist )
{
if( i_object ) vlc_object_release( p_libvlc );
return VLC_ENOOBJ;
}
playlist_Pause( p_playlist );
vlc_object_release( p_playlist );
if( i_object ) vlc_object_release( p_libvlc );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -1304,27 +1174,9 @@ int VLC_Pause( int i_object ) ...@@ -1304,27 +1174,9 @@ int VLC_Pause( int i_object )
*****************************************************************************/ *****************************************************************************/
int VLC_Stop( int i_object ) int VLC_Stop( int i_object )
{ {
playlist_t * p_playlist; LIBVLC_PLAYLIST_FUNC;
libvlc_int_t *p_libvlc = vlc_current_object( i_object ); playlist_Stop( p_libvlc->p_playlist );
LIBVLC_PLAYLIST_FUNC_END;
/* Check that the handle is valid */
if( !p_libvlc )
{
return VLC_ENOOBJ;
}
p_playlist = vlc_object_find( p_libvlc, VLC_OBJECT_PLAYLIST, FIND_CHILD );
if( !p_playlist )
{
if( i_object ) vlc_object_release( p_libvlc );
return VLC_ENOOBJ;
}
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
if( i_object ) vlc_object_release( p_libvlc );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -1333,38 +1185,20 @@ int VLC_Stop( int i_object ) ...@@ -1333,38 +1185,20 @@ int VLC_Stop( int i_object )
*****************************************************************************/ *****************************************************************************/
vlc_bool_t VLC_IsPlaying( int i_object ) vlc_bool_t VLC_IsPlaying( int i_object )
{ {
playlist_t * p_playlist;
vlc_bool_t b_playing; vlc_bool_t b_playing;
libvlc_int_t *p_libvlc = vlc_current_object( i_object ); LIBVLC_PLAYLIST_FUNC;
if( p_libvlc->p_playlist->p_input )
/* Check that the handle is valid */
if( !p_libvlc )
{
return VLC_ENOOBJ;
}
p_playlist = vlc_object_find( p_libvlc, VLC_OBJECT_PLAYLIST, FIND_CHILD );
if( !p_playlist )
{
if( i_object ) vlc_object_release( p_libvlc );
return VLC_ENOOBJ;
}
if( p_playlist->p_input )
{ {
vlc_value_t val; vlc_value_t val;
var_Get( p_playlist->p_input, "state", &val ); var_Get( p_libvlc->p_playlist->p_input, "state", &val );
b_playing = ( val.i_int == PLAYING_S ); b_playing = ( val.i_int == PLAYING_S );
} }
else else
{ {
b_playing = playlist_IsPlaying( p_playlist ); b_playing = playlist_IsPlaying( p_libvlc->p_playlist );
} }
vlc_object_release( p_playlist ); LIBVLC_PLAYLIST_FUNC_END;
if( i_object ) vlc_object_release( p_libvlc );
return b_playing; return b_playing;
} }
......
...@@ -53,6 +53,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent ) ...@@ -53,6 +53,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
msg_Err( p_parent, "out of memory" ); msg_Err( p_parent, "out of memory" );
return NULL; return NULL;
} }
p_parent->p_libvlc->p_playlist = p_playlist;
VariablesInit( p_playlist ); VariablesInit( p_playlist );
...@@ -170,6 +171,7 @@ void playlist_Destroy( playlist_t *p_playlist ) ...@@ -170,6 +171,7 @@ void playlist_Destroy( playlist_t *p_playlist )
vlc_mutex_destroy( &p_playlist->gc_lock ); vlc_mutex_destroy( &p_playlist->gc_lock );
vlc_object_destroy( p_playlist->p_preparse ); vlc_object_destroy( p_playlist->p_preparse );
vlc_object_detach( p_playlist );
vlc_object_destroy( p_playlist ); vlc_object_destroy( p_playlist );
} }
......
...@@ -56,9 +56,9 @@ playlist_item_t * playlist_ItemNewWithType( vlc_object_t *p_obj, ...@@ -56,9 +56,9 @@ playlist_item_t * playlist_ItemNewWithType( vlc_object_t *p_obj,
playlist_item_t *__playlist_ItemNewFromInput( vlc_object_t *p_obj, playlist_item_t *__playlist_ItemNewFromInput( vlc_object_t *p_obj,
input_item_t *p_input ) input_item_t *p_input )
{ {
/** FIXME !!!!! don't find playlist each time */
playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_obj, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
DECMALLOC_NULL( p_item, playlist_item_t ); DECMALLOC_NULL( p_item, playlist_item_t );
playlist_t *p_playlist = p_obj->p_libvlc->p_playlist;
vlc_object_yield( p_playlist );
p_item->p_input = p_input; p_item->p_input = p_input;
vlc_gc_incref( p_item->p_input ); vlc_gc_incref( p_item->p_input );
......
...@@ -57,12 +57,12 @@ static void DestroyInteraction( playlist_t * ); ...@@ -57,12 +57,12 @@ static void DestroyInteraction( playlist_t * );
* \param p_parent * \param p_parent
* \return an object with a started thread * \return an object with a started thread
*/ */
playlist_t * __playlist_ThreadCreate( vlc_object_t *p_parent ) void __playlist_ThreadCreate( vlc_object_t *p_parent )
{ {
playlist_t *p_playlist; playlist_t *p_playlist;
p_playlist = CreatePlaylist( p_parent ); p_playlist = CreatePlaylist( p_parent );
if( !p_playlist ) return NULL; if( !p_playlist ) return;
// Stats // Stats
p_playlist->p_stats = (global_stats_t *)malloc( sizeof( global_stats_t ) ); p_playlist->p_stats = (global_stats_t *)malloc( sizeof( global_stats_t ) );
...@@ -78,7 +78,7 @@ playlist_t * __playlist_ThreadCreate( vlc_object_t *p_parent ) ...@@ -78,7 +78,7 @@ playlist_t * __playlist_ThreadCreate( vlc_object_t *p_parent )
{ {
msg_Err( p_playlist, "unable to create preparser" ); msg_Err( p_playlist, "unable to create preparser" );
vlc_object_destroy( p_playlist ); vlc_object_destroy( p_playlist );
return NULL; return;
} }
p_playlist->p_preparse->i_waiting = 0; p_playlist->p_preparse->i_waiting = 0;
p_playlist->p_preparse->pp_waiting = NULL; p_playlist->p_preparse->pp_waiting = NULL;
...@@ -90,7 +90,7 @@ playlist_t * __playlist_ThreadCreate( vlc_object_t *p_parent ) ...@@ -90,7 +90,7 @@ playlist_t * __playlist_ThreadCreate( vlc_object_t *p_parent )
msg_Err( p_playlist, "cannot spawn preparse thread" ); msg_Err( p_playlist, "cannot spawn preparse thread" );
vlc_object_detach( p_playlist->p_preparse ); vlc_object_detach( p_playlist->p_preparse );
vlc_object_destroy( p_playlist->p_preparse ); vlc_object_destroy( p_playlist->p_preparse );
return NULL; return;
} }
// Start the thread // Start the thread
...@@ -99,13 +99,13 @@ playlist_t * __playlist_ThreadCreate( vlc_object_t *p_parent ) ...@@ -99,13 +99,13 @@ playlist_t * __playlist_ThreadCreate( vlc_object_t *p_parent )
{ {
msg_Err( p_playlist, "cannot spawn playlist thread" ); msg_Err( p_playlist, "cannot spawn playlist thread" );
vlc_object_destroy( p_playlist ); vlc_object_destroy( p_playlist );
return NULL; return;
} }
/* The object has been initialized, now attach it */ /* The object has been initialized, now attach it */
vlc_object_attach( p_playlist, p_parent ); vlc_object_attach( p_playlist, p_parent );
return p_playlist; return;
} }
/** /**
......
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