Commit fe8f7fc7 authored by Clément Stenac's avatar Clément Stenac

Fix a few quirks with playlist filters

parent 0c0286c5
......@@ -418,13 +418,10 @@ VLC_EXPORT( playlist_item_t *, playlist_GetPreferredNode, ( playlist_t *p_playli
/* 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 *, 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 *, vlc_bool_t, vlc_bool_t );
playlist_item_t *playlist_GetLastLeaf( playlist_t *p_playlist,
playlist_item_t *p_root );
......
......@@ -280,16 +280,16 @@ playlist_item_t * playlist_NextItem( playlist_t *p_playlist )
/* 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 )
......@@ -321,8 +321,8 @@ playlist_item_t * playlist_NextItem( playlist_t *p_playlist )
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 )
......@@ -344,15 +344,15 @@ playlist_item_t * playlist_NextItem( playlist_t *p_playlist )
{
for( i = i_skip; i > 0 ; i-- )
{
p_new = playlist_GetNextEnabledLeaf( p_playlist,
p_new = playlist_GetNextLeaf( p_playlist,
p_playlist->request.p_node,
p_new );
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;
}
}
......@@ -363,7 +363,7 @@ playlist_item_t * playlist_NextItem( playlist_t *p_playlist )
{
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" );
......@@ -389,13 +389,14 @@ playlist_item_t * playlist_NextItem( playlist_t *p_playlist )
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 )
......
......@@ -369,7 +369,8 @@ playlist_item_t *playlist_GetLastLeaf(playlist_t *p_playlist,
*/
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;
......@@ -384,47 +385,23 @@ playlist_item_t *playlist_GetNextLeaf( playlist_t *p_playlist,
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
if( !p_next || p_next == p_root )
break;
if( p_next->i_children == -1 )
{
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( 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" );
......@@ -442,7 +419,8 @@ playlist_item_t *playlist_GetNextEnabledLeaf( playlist_t *p_playlist,
*/
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;
......@@ -458,11 +436,21 @@ playlist_item_t *playlist_GetPrevLeaf( playlist_t *p_playlist,
/* 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" );
......
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