/* Tree walking - These functions are only for playlist, not plugins */
playlist_item_t *playlist_GetNextLeaf( playlist_t *p_playlist,
- playlist_item_t *p_root,
- playlist_item_t *p_item );
-playlist_item_t *playlist_GetNextEnabledLeaf( playlist_t *p_playlist,
- playlist_item_t *p_root,
- playlist_item_t *p_item );
+ playlist_item_t *p_root,
+ playlist_item_t *, vlc_bool_t, vlc_bool_t );
playlist_item_t *playlist_GetPrevLeaf( playlist_t *p_playlist,
- playlist_item_t *p_root,
- playlist_item_t *p_item );
+ playlist_item_t *p_root,
+ playlist_item_t *, vlc_bool_t, vlc_bool_t );
playlist_item_t *playlist_GetLastLeaf( playlist_t *p_playlist,
- playlist_item_t *p_root );
+ playlist_item_t *p_root );
/***********************************************************************
* Inline functions
/* Random case. This is an exception: if request, but request is skip +- 1
* we don't go to next item but select a new random one. */
- if( b_random )
- msg_Err( p_playlist, "random unsupported" );
-#if 0
- &&
+ if( b_random &&
( !p_playlist->request.b_request ||
- ( p_playlist->request.b_request && ( p_playlist->request.p_item == NULL ||
- p_playlist->request.i_skip == 1 || p_playlist->request.i_skip == -1 ) ) ) )
+ ( p_playlist->request.b_request &&
+ ( p_playlist->request.p_item == NULL ||
+ p_playlist->request.i_skip == 1 ||
+ p_playlist->request.i_skip == -1 ) ) ) )
{
+#if 0
/* how many items to choose from ? */
- i_count = 0;
+ int i_count = 0, i_new;
for ( i = 0; i < p_playlist->i_size; i++ )
{
if ( p_playlist->pp_items[i]->p_input->i_nb_played == 0 )
p_playlist->request.i_skip = 0;
p_playlist->request.b_request = VLC_FALSE;
return p_playlist->pp_items[i_new];
- }
#endif
+ }
/* Start the real work */
if( p_playlist->request.b_request )
{
for( i = i_skip; i > 0 ; i-- )
{
- p_new = playlist_GetNextEnabledLeaf( p_playlist,
- p_playlist->request.p_node,
- p_new );
+ p_new = playlist_GetNextLeaf( p_playlist,
+ p_playlist->request.p_node,
+ p_new, VLC_TRUE, VLC_FALSE );
if( p_new == NULL )
{
PL_DEBUG( "looping - restarting at beginning of node" );
p_new = playlist_GetNextLeaf( p_playlist,
p_playlist->request.p_node,
- NULL );
+ NULL, VLC_TRUE, VLC_FALSE);
if( p_new == NULL ) break;
}
}
{
p_new = playlist_GetPrevLeaf( p_playlist,
p_playlist->request.p_node,
- p_new );
+ p_new, VLC_FALSE, VLC_FALSE );
if( p_new == NULL )
{
PL_DEBUG( "looping - restarting at end of node" );
p_new = playlist_GetNextLeaf( p_playlist,
p_playlist->status.p_node,
- p_playlist->status.p_item );
+ p_playlist->status.p_item,
+ VLC_TRUE, VLC_FALSE );
if( p_new == NULL && b_loop )
{
PL_DEBUG( "looping" );
p_new = playlist_GetNextLeaf( p_playlist,
p_playlist->status.p_node,
- NULL );
+ NULL, VLC_TRUE, VLC_FALSE );
}
/* The new item can't be autoselected */
if( p_new != NULL && p_new->i_flags & PLAYLIST_SKIP_FLAG )
else
{
var_SetInteger( p_playlist, "item-deleted", p_root->p_input->i_id );
- for( i = 0 ; i< p_playlist->i_all_size; i ++ )
+ for( i = 0 ; i< p_playlist->i_all_size; i ++ )
{
- if( p_playlist->pp_all_items[i]->p_input->i_id ==
+ if( p_playlist->pp_all_items[i]->p_input->i_id ==
p_root->p_input->i_id )
- {
+ {
REMOVE_ELEM( p_playlist->pp_all_items, p_playlist->i_all_size,
i );
break;
- }
+ }
}
/* Remove the item from its parent */
*/
playlist_item_t *playlist_GetNextLeaf( playlist_t *p_playlist,
playlist_item_t *p_root,
- playlist_item_t *p_item )
+ playlist_item_t *p_item,
+ vlc_bool_t b_ena, vlc_bool_t b_unplayed )
{
playlist_item_t *p_next;
p_root->p_input->psz_name );
#endif
-
/* Now, walk the tree until we find a suitable next item */
p_next = p_item;
- do
+ while( 1 )
{
+ vlc_bool_t b_ena_ok = VLC_TRUE, b_unplayed_ok = VLC_TRUE;
p_next = GetNextItem( p_playlist, p_root, p_next );
- } while ( p_next && p_next != p_root && p_next->i_children != -1 );
-
-#ifdef PLAYLIST_DEBUG
- if( p_next == NULL )
- msg_Dbg( p_playlist, "At end of node" );
-#endif
- return p_next;
-}
-
-playlist_item_t *playlist_GetNextEnabledLeaf( playlist_t *p_playlist,
- playlist_item_t *p_root,
- playlist_item_t *p_item )
-{
- playlist_item_t *p_next;
-
-#ifdef PLAYLIST_DEBUG
- if( p_item != NULL )
- msg_Dbg( p_playlist, "finding next of %s within %s",
- p_item->p_input->psz_name, p_root->p_input->psz_name );
- else
- msg_Dbg( p_playlist, "finding something to play within %s",
- p_root->p_input->psz_name );
-#endif
-
- assert( p_root && p_root->i_children != -1 );
-
- /* Now, walk the tree until we find a suitable next item */
- p_next = p_item;
- do
- {
- p_next = GetNextItem( p_playlist, p_root, p_next );
- } while ( p_next && p_next != p_root &&
- !( p_next->i_children == -1 &&
- !(p_next->i_flags & PLAYLIST_DBL_FLAG) ) );
-
+ if( !p_next || p_next == p_root )
+ break;
+ if( p_next->i_children == -1 )
+ {
+ if( b_ena && p_next->i_flags & PLAYLIST_DBL_FLAG )
+ b_ena_ok = VLC_FALSE;
+ if( b_unplayed && p_next->p_input->i_nb_played != 0 )
+ b_unplayed_ok = VLC_FALSE;
+ if( b_ena_ok && b_unplayed_ok ) break;
+ }
+ }
#ifdef PLAYLIST_DEBUG
if( p_next == NULL )
msg_Dbg( p_playlist, "At end of node" );
*/
playlist_item_t *playlist_GetPrevLeaf( playlist_t *p_playlist,
playlist_item_t *p_root,
- playlist_item_t *p_item )
+ playlist_item_t *p_item,
+ vlc_bool_t b_ena, vlc_bool_t b_unplayed )
{
playlist_item_t *p_prev;
/* Now, walk the tree until we find a suitable previous item */
p_prev = p_item;
- do
+ while( 1 )
{
+ vlc_bool_t b_ena_ok = VLC_TRUE, b_unplayed_ok = VLC_TRUE;
p_prev = GetPrevItem( p_playlist, p_root, p_prev );
- } while ( p_prev && p_prev != p_root && p_prev->i_children != -1 );
-
+ if( !p_prev || p_prev == p_root )
+ break;
+ if( p_prev->i_children == -1 )
+ {
+ if( b_ena && p_prev->i_flags & PLAYLIST_DBL_FLAG )
+ b_ena_ok = VLC_FALSE;
+ if( b_unplayed && p_prev->p_input->i_nb_played != 0 )
+ b_unplayed_ok = VLC_FALSE;
+ if( b_ena_ok && b_unplayed_ok ) break;
+ }
+ }
#ifdef PLAYLIST_DEBUG
if( p_prev == NULL )
msg_Dbg( p_playlist, "At beginning of node" );