* Local prototypes
*****************************************************************************/
static void VariablesInit( playlist_t *p_playlist );
+static void playlist_Destructor( vlc_object_t * p_this );
static int RandomCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *a )
{
(void)psz_cmd; (void)oldval; (void)newval; (void)a;
- ((playlist_t*)p_this)->b_reset_currently_playing = VLC_TRUE;
+ ((playlist_t*)p_this)->b_reset_currently_playing = true;
playlist_Signal( ((playlist_t*)p_this) );
return VLC_SUCCESS;
}
*/
playlist_t * playlist_Create( vlc_object_t *p_parent )
{
+ static const char playlist_name[] = "playlist";
playlist_t *p_playlist;
- vlc_bool_t b_save;
- int i_tree;
+ bool b_save;
/* Allocate structure */
- p_playlist = vlc_object_create( p_parent, VLC_OBJECT_PLAYLIST );
+ p_playlist = vlc_custom_create( p_parent, sizeof( *p_playlist ),
+ VLC_OBJECT_PLAYLIST, playlist_name );
if( !p_playlist )
{
msg_Err( p_parent, "out of memory" );
/* Initialise data structures */
vlc_mutex_init( p_playlist, &p_playlist->gc_lock );
p_playlist->i_last_playlist_id = 0;
- p_playlist->i_last_input_id = 0;
p_playlist->p_input = NULL;
p_playlist->gc_date = 0;
- p_playlist->b_cant_sleep = VLC_FALSE;
+ p_playlist->b_cant_sleep = false;
ARRAY_INIT( p_playlist->items );
ARRAY_INIT( p_playlist->all_items );
- ARRAY_INIT( p_playlist->input_items );
ARRAY_INIT( p_playlist->current );
p_playlist->i_current_index = 0;
- p_playlist->b_reset_currently_playing = VLC_TRUE;
+ p_playlist->b_reset_currently_playing = true;
p_playlist->last_rebuild_date = 0;
- i_tree = var_CreateGetBool( p_playlist, "playlist-tree" );
- p_playlist->b_always_tree = (i_tree == 1);
- p_playlist->b_never_tree = (i_tree == 2);
+ p_playlist->b_tree = var_CreateGetBool( p_playlist, "playlist-tree" );
- p_playlist->b_doing_ml = VLC_FALSE;
+ p_playlist->b_doing_ml = false;
p_playlist->b_auto_preparse =
var_CreateGetBool( p_playlist, "auto-preparse" ) ;
/* Create playlist and media library */
playlist_NodesPairCreate( p_playlist, _( "Playlist" ),
&p_playlist->p_local_category,
- &p_playlist->p_local_onelevel, VLC_FALSE );
+ &p_playlist->p_local_onelevel, false );
p_playlist->p_local_category->i_flags |= PLAYLIST_RO_FLAG;
p_playlist->p_local_onelevel->i_flags |= PLAYLIST_RO_FLAG;
{
playlist_NodesPairCreate( p_playlist, _( "Media Library" ),
&p_playlist->p_ml_category,
- &p_playlist->p_ml_onelevel, VLC_FALSE );
+ &p_playlist->p_ml_onelevel, false );
if(!p_playlist->p_ml_category || !p_playlist->p_ml_onelevel)
return NULL;
/* Initial status */
p_playlist->status.p_item = NULL;
p_playlist->status.p_node = p_playlist->p_local_onelevel;
- p_playlist->request.b_request = VLC_FALSE;
+ p_playlist->request.b_request = false;
p_playlist->status.i_status = PLAYLIST_STOPPED;
p_playlist->i_sort = SORT_ID;
p_playlist->i_order = ORDER_NORMAL;
- /* Interaction
- * Init the interaction here, as playlist_MLLoad could trigger
- * interaction init */
- p_playlist->p_interaction = NULL;
-
b_save = p_playlist->b_auto_preparse;
- p_playlist->b_auto_preparse = VLC_FALSE;
+ p_playlist->b_auto_preparse = false;
playlist_MLLoad( p_playlist );
- p_playlist->b_auto_preparse = VLC_TRUE;
+ p_playlist->b_auto_preparse = true;
+
+ vlc_object_set_destructor( p_playlist, playlist_Destructor );
+
return p_playlist;
}
*/
void playlist_Destroy( playlist_t *p_playlist )
{
+ /* XXX: should go in the playlist destructor */
var_Destroy( p_playlist, "intf-change" );
var_Destroy( p_playlist, "item-change" );
var_Destroy( p_playlist, "playlist-current" );
var_Destroy( p_playlist, "loop" );
var_Destroy( p_playlist, "activity" );
- vlc_mutex_destroy( &p_playlist->gc_lock );
- vlc_object_detach( p_playlist );
vlc_object_release( p_playlist );
}
+static void playlist_Destructor( vlc_object_t * p_this )
+{
+ playlist_t * p_playlist = (playlist_t *)p_this;
+
+ // Kill preparser
+ if( p_playlist->p_preparse )
+ {
+ vlc_object_release( p_playlist->p_preparse );
+ }
+
+ // Kill meta fetcher
+ if( p_playlist->p_fetcher )
+ {
+ vlc_object_release( p_playlist->p_fetcher );
+ }
+}
+
/* Destroy remaining objects */
-static void ObjectGarbageCollector( playlist_t *p_playlist, vlc_bool_t b_force )
+static void ObjectGarbageCollector( playlist_t *p_playlist, bool b_force )
{
vlc_object_t *p_obj;
{
if( mdate() - p_playlist->gc_date < 1000000 )
{
- p_playlist->b_cant_sleep = VLC_TRUE;
+ p_playlist->b_cant_sleep = true;
return;
}
else if( p_playlist->gc_date == 0 )
}
vlc_mutex_lock( &p_playlist->gc_lock );
- while( ( p_obj = vlc_object_find( p_playlist, VLC_OBJECT_VOUT,
+ while( ( p_obj = vlc_object_find( p_playlist->p_libvlc, VLC_OBJECT_VOUT,
FIND_CHILD ) ) )
{
- if( p_obj->p_parent != VLC_OBJECT(p_playlist) )
+ if( p_obj->p_parent != VLC_OBJECT(p_playlist->p_libvlc) )
{
vlc_object_release( p_obj );
break;
vlc_object_release( p_obj );
sout_DeleteInstance( (sout_instance_t*)p_obj );
}
- p_playlist->b_cant_sleep = VLC_FALSE;
+ p_playlist->b_cant_sleep = false;
vlc_mutex_unlock( &p_playlist->gc_lock );
}
void playlist_MainLoop( playlist_t *p_playlist )
{
playlist_item_t *p_item = NULL;
- vlc_bool_t b_playexit = var_GetBool( p_playlist, "play-and-exit" );
+ bool b_playexit = var_GetBool( p_playlist, "play-and-exit" );
PL_LOCK;
if( p_playlist->b_reset_currently_playing &&
p_playlist->p_input = NULL;
/* Release the playlist lock, because we may get stuck
- * in input_DestroyThread() for some time. */
+ * in vlc_object_release() for some time. */
PL_UNLOCK;
/* Destroy input */
- input_DestroyThread( p_input );
+ vlc_object_release( p_input );
PL_LOCK;
p_playlist->gc_date = mdate();
- p_playlist->b_cant_sleep = VLC_TRUE;
+ p_playlist->b_cant_sleep = true;
if( p_playlist->status.p_item->i_flags
& PLAYLIST_REMOVE_FLAG )
else if( p_playlist->p_input->i_state != INIT_S )
{
PL_UNLOCK;
- ObjectGarbageCollector( p_playlist, VLC_FALSE );
+ ObjectGarbageCollector( p_playlist, false );
PL_LOCK;
}
}
p_playlist->status.i_status = PLAYLIST_STOPPED;
PL_UNLOCK;
- if( b_playexit == VLC_TRUE )
+ if( b_playexit == true )
{
msg_Info( p_playlist, "end of playlist, exiting" );
vlc_object_kill( p_playlist->p_libvlc );
}
- ObjectGarbageCollector( p_playlist, VLC_TRUE );
+ ObjectGarbageCollector( p_playlist, true );
return;
}
playlist_PlayItem( p_playlist, p_item );
}
else
{
- const vlc_bool_t b_gc_forced = p_playlist->status.i_status != PLAYLIST_STOPPED;
+ const bool b_gc_forced = p_playlist->status.i_status != PLAYLIST_STOPPED;
p_playlist->status.i_status = PLAYLIST_STOPPED;
if( p_playlist->status.p_item &&
PL_UNLOCK;
}
-
/**
* Last loop
*
PL_UNLOCK;
/* Destroy input */
- input_DestroyThread( p_input );
+ vlc_object_release( p_input );
continue;
}
else if( p_playlist->p_input->b_die )
playlist_MLDump( p_playlist );
PL_LOCK;
- /* Go through all items, and simply free everything without caring
- * about the tree structure. Do not decref, it will be done by doing
- * the same thing on the input items array */
FOREACH_ARRAY( playlist_item_t *p_del, p_playlist->all_items )
free( p_del->pp_children );
+ vlc_gc_decref( p_del->p_input );
free( p_del );
FOREACH_END();
ARRAY_RESET( p_playlist->all_items );
- FOREACH_ARRAY( input_item_t *p_del, p_playlist->input_items )
- input_ItemClean( p_del );
- free( p_del );
- FOREACH_END();
- ARRAY_RESET( p_playlist->input_items );
-
ARRAY_RESET( p_playlist->items );
ARRAY_RESET( p_playlist->current );
}
stats_TimerStop( p_playlist, STATS_TIMER_PREPARSE );
PL_UNLOCK;
- input_item_SetPreparsed( p_current, VLC_TRUE );
+ input_item_SetPreparsed( p_current, true );
var_SetInteger( p_playlist, "item-change", p_current->i_id );
PL_LOCK;
}
preparse_item_t p;
PL_DEBUG( "need to fetch meta for %s", p_current->psz_name );
p.p_item = p_current;
- p.b_fetch_art = VLC_FALSE;
+ p.b_fetch_art = false;
vlc_object_lock( p_playlist->p_fetcher );
INSERT_ELEM( p_playlist->p_fetcher->p_waiting,
p_playlist->p_fetcher->i_waiting,
preparse_item_t p;
PL_DEBUG("meta ok for %s, need to fetch art", psz_name );
p.p_item = p_current;
- p.b_fetch_art = VLC_TRUE;
+ p.b_fetch_art = true;
vlc_object_lock( p_playlist->p_fetcher );
INSERT_ELEM( p_playlist->p_fetcher->p_waiting,
p_playlist->p_fetcher->i_waiting,
void playlist_FetcherLoop( playlist_fetcher_t *p_obj )
{
playlist_t *p_playlist = (playlist_t *)p_obj->p_parent;
- vlc_bool_t b_fetch_art;
+ bool b_fetch_art;
input_item_t *p_item;
int i_activity;
vlc_mutex_lock( &p_obj->object_lock );
preparse_item_t p;
p.p_item = p_item;
- p.b_fetch_art = VLC_TRUE;
+ p.b_fetch_art = true;
INSERT_ELEM( p_playlist->p_fetcher->p_waiting,
p_playlist->p_fetcher->i_waiting,
0, p );
* FIXME this doesn't work if we need to fetch meta before art ... */
for( i_ret = 0; i_ret < 10 && !input_item_IsPreparsed( p_item ); i_ret++ )
{
- vlc_bool_t b_break;
+ bool b_break;
PL_LOCK;
b_break = ( !p_playlist->p_input || input_GetItem(p_playlist->p_input) != p_item ||
p_playlist->p_input->b_die || p_playlist->p_input->b_eof || p_playlist->p_input->b_error );
{
PL_DEBUG( "downloading art for %s", p_item->psz_name );
if( input_DownloadAndCacheArt( p_playlist, p_item ) )
- input_item_SetArtNotFound( p_item, VLC_TRUE );
+ input_item_SetArtNotFound( p_item, true );
else {
- input_item_SetArtFetched( p_item, VLC_TRUE );
+ input_item_SetArtFetched( p_item, true );
var_SetInteger( p_playlist, "item-change",
p_item->i_id );
}
else if( i_ret == 0 ) /* Was in cache */
{
PL_DEBUG( "found art for %s in cache", p_item->psz_name );
- input_item_SetArtFetched( p_item, VLC_TRUE );
+ input_item_SetArtFetched( p_item, true );
var_SetInteger( p_playlist, "item-change", p_item->i_id );
}
else
{
PL_DEBUG( "art not found for %s", p_item->psz_name );
- input_item_SetArtNotFound( p_item, VLC_TRUE );
+ input_item_SetArtNotFound( p_item, true );
}
vlc_gc_decref( p_item );
}
}
- vlc_mutex_lock( &p_obj->object_lock );
+ vlc_object_lock( p_obj );
i_activity = var_GetInteger( p_playlist, "activity" );
if( i_activity < 0 ) i_activity = 0;
- vlc_mutex_unlock( &p_obj->object_lock );
+ vlc_object_unlock( p_obj );
/* Sleep at least 1ms */
msleep( (i_activity+1) * 1000 );
}
vlc_value_t val;
/* These variables control updates */
var_Create( p_playlist, "intf-change", VLC_VAR_BOOL );
- val.b_bool = VLC_TRUE;
+ val.b_bool = true;
var_Set( p_playlist, "intf-change", val );
var_Create( p_playlist, "item-change", VLC_VAR_INTEGER );
var_Create( p_playlist, "intf-popupmenu", VLC_VAR_BOOL );
var_Create( p_playlist, "intf-show", VLC_VAR_BOOL );
- val.b_bool = VLC_TRUE;
+ val.b_bool = true;
var_Set( p_playlist, "intf-show", val );
var_Create( p_playlist, "activity", VLC_VAR_INTEGER );