* playlist.c : Playlist management functions
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: playlist.c,v 1.18 2002/11/12 21:20:36 gbazin Exp $
+ * $Id: playlist.c,v 1.23 2002/11/21 15:51:57 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
/* XXX: what if the item is still in use? */
free( p_playlist->pp_items[i_pos] );
- if( i_pos < p_playlist->i_index )
+ if( i_pos <= p_playlist->i_index )
{
p_playlist->i_index--;
}
* in input_DestroyThread() for some time. */
vlc_mutex_unlock( &p_playlist->object_lock );
- /* Check for autodeletion */
- if( p_playlist->pp_items[p_playlist->i_index]->b_autodeletion )
- playlist_Delete( p_playlist, p_playlist->i_index );
-
/* Destroy input */
input_DestroyThread( p_input );
vlc_object_destroy( p_input );
else if( p_playlist->p_input->b_error
|| p_playlist->p_input->b_eof )
{
+ /* Check for autodeletion */
+ if( p_playlist->pp_items[p_playlist->i_index]->b_autodeletion )
+ {
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ playlist_Delete( p_playlist, p_playlist->i_index );
+ vlc_mutex_lock( &p_playlist->object_lock );
+ }
+
/* Select the next playlist item */
SkipItem( p_playlist, 1 );
/* Increment */
if( b_random )
{
- srand( mdate() );
+ srand( (unsigned int)mdate() );
/* Simple random stuff - we cheat a bit to minimize the chances to
* get the same index again. */