Commit fecb04cb authored by Simon Latapie's avatar Simon Latapie

* http.c: little keep and del functions fix ( don't remove currently

 	   playing playlist item ).
parent de409e6f
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* http.c : http mini-server ;) * http.c : http mini-server ;)
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: http.c,v 1.36 2003/11/18 12:32:04 gbazin Exp $ * $Id: http.c,v 1.37 2003/11/20 08:44:30 garf Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* Laurent Aimar <fenrir@via.ecp.fr> * Laurent Aimar <fenrir@via.ecp.fr>
...@@ -1768,8 +1768,9 @@ static void MacroDo( httpd_file_callback_args_t *p_args, ...@@ -1768,8 +1768,9 @@ static void MacroDo( httpd_file_callback_args_t *p_args,
} }
case MVLC_DEL: case MVLC_DEL:
{ {
int i_item, *p_items = NULL, i_nb_items = 0; int i_item, *p_items = NULL, i_nb_items = 0, i_current = -1;
char item[512], *p_parser = p_request; char item[512], *p_parser = p_request;
vlc_value_t val;
/* Get the list of items to delete */ /* Get the list of items to delete */
while( (p_parser = while( (p_parser =
...@@ -1784,6 +1785,16 @@ static void MacroDo( httpd_file_callback_args_t *p_args, ...@@ -1784,6 +1785,16 @@ static void MacroDo( httpd_file_callback_args_t *p_args,
i_nb_items++; i_nb_items++;
} }
/* we should not remove an item while it is played by VLC */
var_Get( p_sys->p_input, "state", &val );
if( val.i_int == PLAYING_S )
{
i_current = p_sys->p_playlist->i_index;
} else
{
i_current = -1;
}
/* The items need to be deleted from in reversed order */ /* The items need to be deleted from in reversed order */
if( i_nb_items ) if( i_nb_items )
{ {
...@@ -1797,10 +1808,13 @@ static void MacroDo( httpd_file_callback_args_t *p_args, ...@@ -1797,10 +1808,13 @@ static void MacroDo( httpd_file_callback_args_t *p_args,
i_index = j; i_index = j;
} }
if( p_items[i_index] != i_current )
{
playlist_Delete( p_sys->p_playlist, playlist_Delete( p_sys->p_playlist,
p_items[i_index] ); p_items[i_index] );
msg_Dbg( p_intf, "requested playlist delete: %d", msg_Dbg( p_intf, "requested playlist delete: %d",
p_items[i_index] ); p_items[i_index] );
}
p_items[i_index] = -1; p_items[i_index] = -1;
} }
} }
...@@ -1810,9 +1824,10 @@ static void MacroDo( httpd_file_callback_args_t *p_args, ...@@ -1810,9 +1824,10 @@ static void MacroDo( httpd_file_callback_args_t *p_args,
} }
case MVLC_KEEP: case MVLC_KEEP:
{ {
int i_item, *p_items = NULL, i_nb_items = 0; int i_item, *p_items = NULL, i_nb_items = 0, i_current = -1;
char item[512], *p_parser = p_request; char item[512], *p_parser = p_request;
int i,j; int i,j;
vlc_value_t val;
/* Get the list of items to keep */ /* Get the list of items to keep */
while( (p_parser = while( (p_parser =
...@@ -1827,6 +1842,16 @@ static void MacroDo( httpd_file_callback_args_t *p_args, ...@@ -1827,6 +1842,16 @@ static void MacroDo( httpd_file_callback_args_t *p_args,
i_nb_items++; i_nb_items++;
} }
/* we should not remove an item while it is played by VLC */
var_Get( p_sys->p_input, "state", &val );
if( val.i_int == PLAYING_S )
{
i_current = p_sys->p_playlist->i_index;
} else
{
i_current = -1;
}
/* The items need to be deleted from in reversed order */ /* The items need to be deleted from in reversed order */
for( i = p_sys->p_playlist->i_size - 1; i >= 0 ; i-- ) for( i = p_sys->p_playlist->i_size - 1; i >= 0 ; i-- )
{ {
...@@ -1835,7 +1860,7 @@ static void MacroDo( httpd_file_callback_args_t *p_args, ...@@ -1835,7 +1860,7 @@ static void MacroDo( httpd_file_callback_args_t *p_args,
{ {
if( p_items[j] == i ) break; if( p_items[j] == i ) break;
} }
if( j == i_nb_items ) if( (j == i_nb_items) && (i != i_current ) )
{ {
playlist_Delete( p_sys->p_playlist, i ); playlist_Delete( p_sys->p_playlist, i );
msg_Dbg( p_intf, "requested playlist delete: %d", msg_Dbg( p_intf, "requested playlist delete: %d",
......
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