This array is now usable as a reliable source of data for size
Use playlist_CurrentSize(p_playlist) to retrieve the size of the current playset.
15 files changed:
STATS_DISPLAYED_PICTURES,
STATS_LOST_PICTURES,
STATS_DISPLAYED_PICTURES,
STATS_LOST_PICTURES,
- STATS_TIMER_PLAYLIST_WALK,
+ STATS_TIMER_PLAYLIST_BUILD,
STATS_TIMER_ML_LOAD,
STATS_TIMER_ML_DUMP,
STATS_TIMER_INTERACTION,
STATS_TIMER_ML_LOAD,
STATS_TIMER_ML_DUMP,
STATS_TIMER_INTERACTION,
int i_current_index; /**< Index in current array */
/** Reset current item ? */
vlc_bool_t b_reset_currently_playing;
int i_current_index; /**< Index in current array */
/** Reset current item ? */
vlc_bool_t b_reset_currently_playing;
+ mtime_t last_rebuild_date;
int i_last_playlist_id; /**< Last id to an item */
int i_last_input_id ; /**< Last id on an input */
int i_last_playlist_id; /**< Last id to an item */
int i_last_input_id ; /**< Last id on an input */
+/** Tell the number of items in the current playing context */
+static inline int playlist_CurrentSize( vlc_object_t *p_this )
+{
+ return p_this->p_libvlc->p_playlist->current.i_size;
+}
+
/** Ask the playlist to do some work */
static inline void playlist_Signal( playlist_t *p_playlist )
{
/** Ask the playlist to do some work */
static inline void playlist_Signal( playlist_t *p_playlist )
{
var_Get( p_intf, psz_bookmark_name, &val );
char *psz_bookmark = strdup( val.psz_string );
var_Get( p_intf, psz_bookmark_name, &val );
char *psz_bookmark = strdup( val.psz_string );
- for( i = 0; i < p_playlist->items.i_size; i++)
- {
- if( !strcmp( psz_bookmark,
- ARRAY_VAL( p_playlist->items,i )->p_input->psz_uri ) )
+ PL_LOCK;
+ FOREACH_ARRAY( playlist_item_t *p_item, p_playlist->items )
+ if( !strcmp( psz_bookmark, p_item->p_input->psz_uri ) )
- playlist_LockControl( p_playlist, PLAYLIST_VIEWPLAY, NULL,
- ARRAY_VAL( p_playlist->items, i ) );
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, NULL, p_item );
vlc_object_release( p_playlist );
}
vlc_object_release( p_playlist );
}
b_playlist_update = false;
}
#endif
b_playlist_update = false;
}
#endif
- p_mediaControl->SetEnabled( p_playlist->i_size );
+ p_mediaControl->SetEnabled( !playlist_IsEmpty( p_playlist ) );
void
PlaylistView::RebuildList()
{
void
PlaylistView::RebuildList()
{
- playlist_t * p_playlist;
- p_playlist = (playlist_t *) vlc_object_find( p_intf,
- VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-
- if( !p_playlist )
- {
- return;
- }
+ playlist_t * p_playlist = pl_Yield( p_intf );
// remove all items
BListItem * item;
int32 count = CountItems();
while( ( item = RemoveItem( --count ) ) )
delete item;
// remove all items
BListItem * item;
int32 count = CountItems();
while( ( item = RemoveItem( --count ) ) )
delete item;
// rebuild listview from VLC's playlist
// rebuild listview from VLC's playlist
- vlc_mutex_lock( &p_playlist->object_lock );
- for( int i = 0; i < p_playlist->i_size; i++ )
- AddItem( new PlaylistItem( p_playlist->pp_items[i]->input.psz_name ) );
- vlc_mutex_unlock( &p_playlist->object_lock );
+ PL_LOCK;
+ FOREACH_ARRAY( playlist_item_t *p_item, p_playlist->items )
+ AddItem( new PlaylistItem( p_item->p_input->psz_name ) );
+ FOREACH_END();
+ PL_UNLOCK;
vlc_object_release( p_playlist );
}
vlc_object_release( p_playlist );
}
playlist_t *p_playlist = pl_Yield( VLCIntf );
playlist_t *p_playlist = pl_Yield( VLCIntf );
- /** \todo fix i_size use */
- if( p_playlist->items.i_size >= 2 )
+ if( playlist_CurrentSize( p_playlist ) >= 2 )
{
[o_status_field setStringValue: [NSString stringWithFormat:
{
[o_status_field setStringValue: [NSString stringWithFormat:
- _NS("%i items in the playlist"), p_playlist->items.i_size]];
+ _NS("%i items in the playlist"),
+ playlist_CurrentSize( p_playlist )]];
id o_value = [super outlineView: outlineView child: index ofItem: item];
playlist_t *p_playlist = pl_Yield( VLCIntf );
id o_value = [super outlineView: outlineView child: index ofItem: item];
playlist_t *p_playlist = pl_Yield( VLCIntf );
- /* FIXME: playlist->i_size doesn't provide the correct number of items anymore
- * check the playlist API for the fixed function, once zorglub implemented it -- fpk, 9/17/06 */
- /** \todo fix i_size use */
- if( p_playlist->items.i_size >= 2 )
+ if( playlist_CurrentSize( p_playlist ) >= 2 )
{
[o_status_field setStringValue: [NSString stringWithFormat:
{
[o_status_field setStringValue: [NSString stringWithFormat:
- _NS("%i items in the playlist"), p_playlist->items.i_size]];
+ _NS("%i items in the playlist"),
+ playlist_CurrentSize( p_playlist )]];
wxString filter = wxT("");
wxString filter = wxT("");
- if( p_playlist->i_size == 0 )
+ if( playlist_IsEmpty( p_playlist ) )
{
wxMessageBox( wxU(_("Playlist is empty") ), wxU(_("Can't save")),
wxICON_WARNING | wxOK, this );
{
wxMessageBox( wxU(_("Playlist is empty") ), wxU(_("Can't save")),
wxICON_WARNING | wxOK, this );
- if( p_playlist->i_size > 0)
+ if( !playlist_IsEmpty( p_playlist ) )
{
listview = new wxListView( this, ListView_Event,
wxDefaultPosition, wxDefaultSize,
{
listview = new wxListView( this, ListView_Event,
wxDefaultPosition, wxDefaultSize,
listview->InsertColumn( 1, wxU(_("URI")) );
listview->SetColumnWidth( 0, 250 );
listview->SetColumnWidth( 1, 100 );
listview->InsertColumn( 1, wxU(_("URI")) );
listview->SetColumnWidth( 0, 250 );
listview->SetColumnWidth( 1, 100 );
-#if 0
- for( int i=0 ; i < p_playlist->i_size ; i++ )
- {
- wxString filename = wxL2U( p_playlist->pp_items[i]->input.
- psz_name );
- listview->InsertItem( i, filename );
- listview->SetItem( i, 1, wxL2U( p_playlist->pp_items[i]->
- input.psz_uri) );
- listview->SetItemData( i,
- (long)p_playlist->pp_items[i]->input.i_id );
- }
- listview->Select( p_playlist->i_index , TRUE);
-#endif
mainSizer->Add( listview, 1, wxALL|wxEXPAND, 5 );
listview->Hide();
mainSizer->Add( listview, 1, wxALL|wxEXPAND, 5 );
listview->Hide();
- if( p_playlist && p_playlist->i_size ) \
+ if( p_playlist && !playlist_IsEmpty( p_playlist->i_size ) ) \
{ \
popupmenu.InsertSeparator( 0 ); \
popupmenu.Insert( 0, Play_Event, wxU(_("Play")) ); \
{ \
popupmenu.InsertSeparator( 0 ); \
popupmenu.Insert( 0, Play_Event, wxU(_("Play")) ); \
PL_DEBUG("%s is at %i", PLI_NAME(p_cur), p_playlist->i_current_index );
}
PL_DEBUG("%s is at %i", PLI_NAME(p_cur), p_playlist->i_current_index );
}
-static void ResetCurrentlyPlaying( playlist_t *p_playlist, vlc_bool_t b_random,
- playlist_item_t *p_cur )
+void ResetCurrentlyPlaying( playlist_t *p_playlist, vlc_bool_t b_random,
+ playlist_item_t *p_cur )
{
playlist_item_t *p_next = NULL;
{
playlist_item_t *p_next = NULL;
+ stats_TimerStart( p_playlist, "Items array build",
+ STATS_TIMER_PLAYLIST_BUILD );
PL_DEBUG("rebuilding array of current - root %s",
PLI_NAME(p_playlist->status.p_node) );
ARRAY_RESET(p_playlist->current);
PL_DEBUG("rebuilding array of current - root %s",
PLI_NAME(p_playlist->status.p_node) );
ARRAY_RESET(p_playlist->current);
}
}
p_playlist->b_reset_currently_playing = VLC_FALSE;
}
}
p_playlist->b_reset_currently_playing = VLC_FALSE;
+ stats_TimerStop( p_playlist, STATS_TIMER_PLAYLIST_BUILD );
}
/** This function calculates the next playlist item, depending
}
/** This function calculates the next playlist item, depending
i_skip++;
if( p_playlist->b_reset_currently_playing )
i_skip++;
if( p_playlist->b_reset_currently_playing )
+ /* A bit too bad to reset twice ... */
ResetCurrentlyPlaying( p_playlist, b_random, p_new );
else if( p_new )
ResyncCurrentIndex( p_playlist, p_new );
ResetCurrentlyPlaying( p_playlist, b_random, p_new );
else if( p_new )
ResyncCurrentIndex( p_playlist, p_new );
vlc_value_t oldval, vlc_value_t newval, void *a )
{
((playlist_t*)p_this)->b_reset_currently_playing = VLC_TRUE;
vlc_value_t oldval, vlc_value_t newval, void *a )
{
((playlist_t*)p_this)->b_reset_currently_playing = VLC_TRUE;
+ playlist_Signal( ((playlist_t*)p_this) );
p_playlist->i_current_index = 0;
p_playlist->b_reset_currently_playing = VLC_TRUE;
p_playlist->i_current_index = 0;
p_playlist->b_reset_currently_playing = VLC_TRUE;
+ p_playlist->last_rebuild_date = 0;
i_tree = var_CreateGetBool( p_playlist, "playlist-tree" );
p_playlist->b_always_tree = (i_tree == 1);
i_tree = var_CreateGetBool( p_playlist, "playlist-tree" );
p_playlist->b_always_tree = (i_tree == 1);
vlc_bool_t b_playexit = var_GetBool( p_playlist, "play-and-exit" );
PL_LOCK;
vlc_bool_t b_playexit = var_GetBool( p_playlist, "play-and-exit" );
PL_LOCK;
- /* First, check if we have something to do */
- if( p_playlist->request.b_request )
+ if( p_playlist->b_reset_currently_playing &&
+ mdate() - p_playlist->last_rebuild_date > 30000 ) // 30 ms
- /* Stop the existing input */
- if( p_playlist->p_input && !p_playlist->p_input->b_die )
- {
- PL_DEBUG( "incoming request - stopping current input" );
- input_StopThread( p_playlist->p_input );
- }
+ ResetCurrentlyPlaying( p_playlist, var_GetBool( p_playlist, "random"),
+ p_playlist->status.p_item );
+ p_playlist->last_rebuild_date = mdate();
check_input:
/* If there is an input, check that it doesn't need to die. */
if( p_playlist->p_input )
{
check_input:
/* If there is an input, check that it doesn't need to die. */
if( p_playlist->p_input )
{
+ if( p_playlist->request.b_request && !p_playlist->p_input->b_die )
+ {
+ PL_DEBUG( "incoming request - stopping current input" );
+ input_StopThread( p_playlist->p_input );
+ }
+
/* This input is dead. Remove it ! */
if( p_playlist->p_input->b_dead )
{
/* This input is dead. Remove it ! */
if( p_playlist->p_input->b_dead )
{
p_playlist->request.i_status != PLAYLIST_STOPPED ) )
{
msg_Dbg( p_playlist, "starting new item" );
p_playlist->request.i_status != PLAYLIST_STOPPED ) )
{
msg_Dbg( p_playlist, "starting new item" );
- stats_TimerStart( p_playlist, "Playlist walk",
- STATS_TIMER_PLAYLIST_WALK );
p_item = playlist_NextItem( p_playlist );
p_item = playlist_NextItem( p_playlist );
- stats_TimerStop( p_playlist, STATS_TIMER_PLAYLIST_WALK );
p_playlist->p_root_onelevel, VLC_FALSE );
}
p_playlist->b_reset_currently_playing = VLC_TRUE;
p_playlist->p_root_onelevel, VLC_FALSE );
}
p_playlist->b_reset_currently_playing = VLC_TRUE;
+ vlc_cond_signal( &p_playlist->object_wait );
var_SetInteger( p_playlist, "item-change", p_item_in_category->
p_input->i_id );
return p_item_in_category;
var_SetInteger( p_playlist, "item-change", p_item_in_category->
p_input->i_id );
return p_item_in_category;
int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
playlist_item_t *p_node, int i_newpos )
{
int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
playlist_item_t *p_node, int i_newpos )
{
/* Drop on a top level node. Move in the two trees */
if( p_node->p_parent == p_playlist->p_root_category ||
p_node->p_parent == p_playlist->p_root_onelevel )
/* Drop on a top level node. Move in the two trees */
if( p_node->p_parent == p_playlist->p_root_category ||
p_node->p_parent == p_playlist->p_root_onelevel )
if( p_node_category && p_item_category )
TreeMove( p_playlist, p_item_category, p_node_category, 0 );
}
if( p_node_category && p_item_category )
TreeMove( p_playlist, p_item_category, p_node_category, 0 );
}
- return TreeMove( p_playlist, p_item, p_node, i_newpos );
+ i_ret = TreeMove( p_playlist, p_item, p_node, i_newpos );
+ p_playlist->b_reset_currently_playing = VLC_TRUE;
+ vlc_cond_signal( &p_playlist->object_wait );
+ return i_ret;
}
/** Send a notification that an item has been added to a node */
}
/** Send a notification that an item has been added to a node */
p_add->i_node = i_node_id;
val.p_address = p_add;
p_playlist->b_reset_currently_playing = VLC_TRUE;
p_add->i_node = i_node_id;
val.p_address = p_add;
p_playlist->b_reset_currently_playing = VLC_TRUE;
+ vlc_cond_signal( &p_playlist->object_wait );
var_Set( p_playlist, "item-append", val );
free( p_add );
}
var_Set( p_playlist, "item-append", val );
free( p_add );
}
void playlist_PreparseLoop( playlist_preparse_t * );
void playlist_SecondaryPreparseLoop( playlist_secondary_preparse_t * );
void playlist_PreparseLoop( playlist_preparse_t * );
void playlist_SecondaryPreparseLoop( playlist_secondary_preparse_t * );
+void ResetCurrentlyPlaying( playlist_t *, vlc_bool_t, playlist_item_t * );
+
/* Control */
playlist_item_t * playlist_NextItem ( playlist_t * );
int playlist_PlayItem ( playlist_t *, playlist_item_t * );
/* Control */
playlist_item_t * playlist_NextItem ( playlist_t * );
int playlist_PlayItem ( playlist_t *, playlist_item_t * );
-#define PLAYLIST_DEBUG 1
+//#define PLAYLIST_DEBUG 1
+#undef PLAYLIST_DEBUG
#ifdef PLAYLIST_DEBUG
#define PL_DEBUG( msg, args... ) msg_Dbg( p_playlist, msg, ## args )
#ifdef PLAYLIST_DEBUG
#define PL_DEBUG( msg, args... ) msg_Dbg( p_playlist, msg, ## args )
else
p_item->i_flags |= PLAYLIST_DBL_FLAG;
}
else
p_item->i_flags |= PLAYLIST_DBL_FLAG;
}
+ vlc_cond_signal( &p_playlist->object_wait );
static void RunSecondaryPreparse( playlist_secondary_preparse_t * );
static playlist_t * CreatePlaylist( vlc_object_t *p_parent );
static void RunSecondaryPreparse( playlist_secondary_preparse_t * );
static playlist_t * CreatePlaylist( vlc_object_t *p_parent );
-static void HandlePlaylist( playlist_t * );
static void EndPlaylist( playlist_t * );
static void DestroyPlaylist( playlist_t * );
static void EndPlaylist( playlist_t * );
static void DestroyPlaylist( playlist_t * );
-static void HandleInteraction( playlist_t * );
static void DestroyInteraction( playlist_t * );
/*****************************************************************************
static void DestroyInteraction( playlist_t * );
/*****************************************************************************
- HandleInteraction( p_playlist );
- HandlePlaylist( p_playlist );
+ if( p_playlist->p_interaction )
+ intf_InteractionManage( p_playlist );
+
+ playlist_MainLoop( p_playlist );
if( p_playlist->b_cant_sleep )
{
/* 100 ms is an acceptable delay for playlist operations */
if( p_playlist->b_cant_sleep )
{
/* 100 ms is an acceptable delay for playlist operations */
playlist_Destroy( p_playlist );
}
playlist_Destroy( p_playlist );
}
-static void HandlePlaylist( playlist_t *p_playlist )
-{
- playlist_MainLoop( p_playlist );
-}
-
static void EndPlaylist( playlist_t *p_playlist )
{
playlist_LastLoop( p_playlist );
static void EndPlaylist( playlist_t *p_playlist )
{
playlist_LastLoop( p_playlist );
p_playlist->p_interaction = NULL;
}
}
p_playlist->p_interaction = NULL;
}
}
-
-static void HandleInteraction( playlist_t *p_playlist )
-{
- if( p_playlist->p_interaction )
- {
- stats_TimerStart( p_playlist, "Interaction thread",
- STATS_TIMER_INTERACTION );
- intf_InteractionManage( p_playlist );
- stats_TimerStop( p_playlist, STATS_TIMER_INTERACTION );
- }
-}