- /* Start the real work */
- if( p_playlist->request.b_request )
- {
- p_new = p_playlist->request.p_item;
- i_skip = p_playlist->request.i_skip;
- PL_DEBUG( "processing request item %s node %s skip %i",
- PLI_NAME( p_playlist->request.p_item ),
- PLI_NAME( p_playlist->request.p_node ), i_skip );
-
- if( p_playlist->request.p_node &&
- p_playlist->request.p_node != p_playlist->status.p_node )
- {
- p_playlist->status.p_node = p_playlist->request.p_node;
- p_playlist->b_reset_currently_playing = VLC_TRUE;
- }
-
- /* If we are asked for a node, dont take it */
- if( i_skip == 0 && ( p_new == NULL || p_new->i_children != -1 ) )
- 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 );
- else
- p_playlist->i_current_index = -1;
-
- if( p_playlist->current.i_size && i_skip > 0 )
- {
- for( i = i_skip; i > 0 ; i-- )
- {
- p_playlist->i_current_index++;
- if( p_playlist->i_current_index == p_playlist->current.i_size )
- {
- PL_DEBUG( "looping - restarting at beginning of node" );
- p_playlist->i_current_index = 0;
- }
- }
- p_new = ARRAY_VAL( p_playlist->current,
- p_playlist->i_current_index );
- }
- else if( p_playlist->current.i_size && i_skip < 0 )
- {
- for( i = i_skip; i < 0 ; i++ )
- {
- p_playlist->i_current_index--;
- if( p_playlist->i_current_index == -1 )
- {
- PL_DEBUG( "looping - restarting at end of node" );
- p_playlist->i_current_index = p_playlist->current.i_size-1;
- }
- }
- p_new = ARRAY_VAL( p_playlist->current,
- p_playlist->i_current_index );
- }
- /* Clear the request */
- p_playlist->request.b_request = VLC_FALSE;
- }
- /* "Automatic" item change ( next ) */
- else
- {
- PL_DEBUG( "changing item without a request (current %i/%i)",
- p_playlist->i_current_index, p_playlist->current.i_size );
- /* Cant go to next from current item */
- if( p_playlist->status.p_item &&
- p_playlist->status.p_item->i_flags & PLAYLIST_SKIP_FLAG )
- return NULL;
-
- if( p_playlist->b_reset_currently_playing )
- ResetCurrentlyPlaying( p_playlist, b_random,
- p_playlist->status.p_item );
-
- p_playlist->i_current_index++;
- if( p_playlist->i_current_index == p_playlist->current.i_size )
- {
- if( !b_loop || p_playlist->current.i_size == 0 ) return NULL;
- p_playlist->i_current_index = 0;
- }
- PL_DEBUG( "using item %i", p_playlist->i_current_index );
- if ( p_playlist->current.i_size == 0 ) return NULL;
-
- p_new = ARRAY_VAL( p_playlist->current, p_playlist->i_current_index );
- /* The new item can't be autoselected */
- if( p_new != NULL && p_new->i_flags & PLAYLIST_SKIP_FLAG )
- return NULL;
- }
- return p_new;
-}
-
-/** Start the input for an item */
-int playlist_PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
-{
- vlc_value_t val;
- input_item_t *p_input = p_item->p_input;
- int i_activity = var_GetInteger( p_playlist, "activity") ;
-
- msg_Dbg( p_playlist, "creating new input thread" );
-
- p_input->i_nb_played++;
- p_playlist->status.p_item = p_item;
-
- p_playlist->status.i_status = PLAYLIST_RUNNING;
-
- var_SetInteger( p_playlist, "activity", i_activity +
- DEFAULT_INPUT_ACTIVITY );
- p_playlist->p_input = input_CreateThread( p_playlist, p_input );
-
- if( p_playlist->p_fetcher->i_art_policy == ALBUM_ART_WHEN_PLAYED )
- {
- vlc_bool_t b_has_art;
-
- vlc_mutex_lock( &p_input->lock );
- /* p_input->p_meta should not be null after a successfull CreateThread */
- b_has_art = !EMPTY_STR( input_item_GetArtURL( p_input ) );
- vlc_mutex_unlock( &p_input->lock );
-
- if( !b_has_art )
- {
- PL_DEBUG( "requesting art for %s", p_input->psz_name );
- playlist_AskForArtEnqueue( p_playlist, p_input );
- }
- }
-
- val.i_int = p_input->i_id;
- vlc_mutex_unlock( &p_playlist->object_lock);
- var_Set( p_playlist, "playlist-current", val);
- vlc_mutex_lock( &p_playlist->object_lock);