* playlist.c : Playlist management functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: playlist.c,v 1.72 2004/01/06 08:50:20 zorglub Exp $
+ * $Id: playlist.c,v 1.82 2004/02/23 21:57:56 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
#include "vlc_playlist.h"
#define PLAYLIST_FILE_HEADER_0_5 "# vlc playlist file version 0.5"
-#define PLAYLIST_FILE_HEADER_0_6 "# vlc playlist file version 0.6"
/*****************************************************************************
* Local prototypes
p_playlist->pp_groups = NULL;
p_playlist->i_last_group = 0;
p_playlist->i_last_id = 0;
+ p_playlist->i_sort = SORT_ID;
+ p_playlist->i_order = ORDER_NORMAL;
- playlist_CreateGroup( p_playlist, "Normal" );
+ playlist_CreateGroup( p_playlist, _("Normal") );
if( vlc_thread_create( p_playlist, "playlist", RunThread,
VLC_THREAD_PRIORITY_LOW, VLC_TRUE ) )
* \param i_command the command to do
* \param i_arg the argument to the command. See playlist_command_t for details
*/
- void playlist_Command( playlist_t * p_playlist, playlist_command_t i_command,
+void playlist_Command( playlist_t * p_playlist, playlist_command_t i_command,
int i_arg )
{
vlc_value_t val;
}
-static void ObjectGarbageCollector( playlist_t *p_playlist,
- int i_type,
- mtime_t *pi_obj_destroyed_date )
+static mtime_t ObjectGarbageCollector( playlist_t *p_playlist, int i_type,
+ mtime_t destroy_date )
{
vlc_object_t *p_obj;
- if( *pi_obj_destroyed_date > mdate() )
- {
- return;
- }
- if( *pi_obj_destroyed_date == 0 )
+ if( destroy_date > mdate() ) return destroy_date;
+
+ if( destroy_date == 0 )
{
/* give a little time */
- *pi_obj_destroyed_date = mdate() + I64C(300000);
+ return mdate() + I64C(1000000);
}
else
{
- while( ( p_obj = vlc_object_find( p_playlist,
- i_type,
- FIND_CHILD ) ) )
+ while( ( p_obj = vlc_object_find( p_playlist, i_type, FIND_CHILD ) ) )
{
if( p_obj->p_parent != (vlc_object_t*)p_playlist )
{
- /* only first chiled (ie unused) */
+ /* only first child (ie unused) */
vlc_object_release( p_obj );
break;
}
if( i_type == VLC_OBJECT_VOUT )
{
- msg_Dbg( p_playlist, "vout garbage collector destroying 1 vout" );
+ msg_Dbg( p_playlist, "garbage collector destroying 1 vout" );
vlc_object_detach( p_obj );
vlc_object_release( p_obj );
vout_Destroy( (vout_thread_t *)p_obj );
sout_DeleteInstance( (sout_instance_t*)p_obj );
}
}
- *pi_obj_destroyed_date = 0;
+ return 0;
}
}
input_StopThread( p_playlist->p_input );
vlc_mutex_unlock( &p_playlist->object_lock );
}
-
- val.i_int = p_playlist->i_index;
- var_Set( p_playlist, "playlist-current", val);
-#if 0
- val.b_bool = VLC_TRUE;
- var_Set( p_playlist, "intf-change", val );
-#endif
continue;
}
else if( p_playlist->p_input->stream.control.i_status != INIT_S )
{
vlc_mutex_unlock( &p_playlist->object_lock );
- ObjectGarbageCollector( p_playlist, VLC_OBJECT_VOUT,
- &i_vout_destroyed_date );
- ObjectGarbageCollector( p_playlist, VLC_OBJECT_SOUT,
- &i_sout_destroyed_date );
+ i_vout_destroyed_date =
+ ObjectGarbageCollector( p_playlist, VLC_OBJECT_VOUT,
+ i_vout_destroyed_date );
+ i_sout_destroyed_date =
+ ObjectGarbageCollector( p_playlist, VLC_OBJECT_SOUT,
+ i_sout_destroyed_date );
vlc_mutex_lock( &p_playlist->object_lock );
}
}
else if( p_playlist->i_status == PLAYLIST_STOPPED )
{
vlc_mutex_unlock( &p_playlist->object_lock );
- ObjectGarbageCollector( p_playlist, VLC_OBJECT_SOUT,
- &i_sout_destroyed_date );
- ObjectGarbageCollector( p_playlist, VLC_OBJECT_VOUT,
- &i_vout_destroyed_date );
+ i_sout_destroyed_date =
+ ObjectGarbageCollector( p_playlist, VLC_OBJECT_SOUT, mdate() );
+ i_vout_destroyed_date =
+ ObjectGarbageCollector( p_playlist, VLC_OBJECT_VOUT, mdate() );
vlc_mutex_lock( &p_playlist->object_lock );
}
vlc_mutex_unlock( &p_playlist->object_lock );
/* Boundary check */
if( p_playlist->i_index >= p_playlist->i_size )
{
- if( p_playlist->i_status == PLAYLIST_STOPPED
- || b_random
- || b_loop )
+ if( p_playlist->i_status == PLAYLIST_STOPPED || b_random || b_loop )
{
p_playlist->i_index -= p_playlist->i_size
* ( p_playlist->i_index / p_playlist->i_size );
}
/* Check that the item is enabled */
- if( p_playlist->pp_items[p_playlist->i_index]->b_enabled == VLC_FALSE &&
- p_playlist->i_enabled != 0)
+ if( p_playlist->pp_items[p_playlist->i_index]->b_enabled == VLC_FALSE &&
+ p_playlist->i_enabled != 0)
{
SkipItem( p_playlist , 1 );
}
*****************************************************************************/
static void PlayItem( playlist_t *p_playlist )
{
+ playlist_item_t *p_item;
+ int i, j;
vlc_value_t val;
if( p_playlist->i_index == -1 )
{
{
return;
}
-
SkipItem( p_playlist, 1 );
}
-
if( p_playlist->i_enabled == 0)
{
return;
}
msg_Dbg( p_playlist, "creating new input thread" );
- p_playlist->p_input = input_CreateThread( p_playlist,
- p_playlist->pp_items[p_playlist->i_index] );
+ p_item = p_playlist->pp_items[p_playlist->i_index];
+
+ p_item->i_nb_played++;
+
+ p_playlist->p_input = input_CreateThread( p_playlist, p_item->psz_uri,
+ p_item->ppsz_options,
+ p_item->i_options );
val.i_int = p_playlist->i_index;
- var_Set( p_playlist, "item-change", val );
+ var_Set( p_playlist, "playlist-current", val);
}