+ /* Start the real work */
+ if( p_sys->request.b_request )
+ {
+ p_new = p_sys->request.p_item;
+ int i_skip = p_sys->request.i_skip;
+ PL_DEBUG( "processing request item %s node %s skip %i",
+ PLI_NAME( p_sys->request.p_item ),
+ PLI_NAME( p_sys->request.p_node ), i_skip );
+
+ if( p_sys->request.p_node &&
+ p_sys->request.p_node != get_current_status_node( p_playlist ) )
+ {
+
+ set_current_status_node( p_playlist, p_sys->request.p_node );
+ p_sys->request.p_node = NULL;
+ p_sys->b_reset_currently_playing = true;
+ }
+
+ /* If we are asked for a node, go to it's first child */
+ if( i_skip == 0 && ( p_new == NULL || p_new->i_children != -1 ) )
+ {
+ i_skip++;
+ if( p_new != NULL )
+ {
+ p_new = playlist_GetNextLeaf( p_playlist, p_new, NULL, true, false );
+ for( int i = 0; i < p_playlist->current.i_size; i++ )
+ {
+ if( p_new == ARRAY_VAL( p_playlist->current, i ) )
+ {
+ p_playlist->i_current_index = i;
+ i_skip = 0;
+ }
+ }
+ }
+ }
+
+ if( p_sys->b_reset_currently_playing )
+ /* A bit too bad to reset twice ... */
+ ResetCurrentlyPlaying( p_playlist, 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) )
+ {
+ if( p_playlist->i_current_index < -1 )
+ p_playlist->i_current_index = -1;
+ for( int 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( int 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_sys->request.b_request = false;
+ }
+ /* "Automatic" item change ( next ) */
+ else