- } 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) ) );
-
-#ifdef PLAYLIST_DEBUG
- if( p_next == NULL )
- msg_Dbg( p_playlist, "At end of node" );
-#endif
+ 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 = false;
+ if( b_unplayed && p_next->p_input->i_nb_played != 0 )
+ b_unplayed_ok = false;
+ if( b_ena_ok && b_unplayed_ok ) break;
+ }
+ }
+ if( p_next == NULL ) PL_DEBUG2( "at end of node" );