* vlc_playlist.h : Playlist functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: vlc_playlist.h,v 1.26 2004/01/25 18:17:08 zorglub Exp $
+ * $Id: vlc_playlist.h,v 1.27 2004/01/29 17:51:07 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
char * psz_uri; /**< mrl of this item */
mtime_t i_duration; /**< A hint about the duration of this
* item, in milliseconds*/
- int i_categories; /**< Number of info categories */
- item_info_category_t **pp_categories;
- /**< Pointer to the first info category */
- int i_status; /**< unused yet */
+ int i_categories; /**< Number of info categories */
+ item_info_category_t **
+ pp_categories; /**< Pointer to the first info category */
+ int i_options; /**< Number of options */
+ char ** ppsz_options; /**< Array of options */
int i_nb_played; /**< How many times was this item played ? */
vlc_bool_t b_autodeletion; /**< Indicates whther this item is to
* be deleted after playback. True mean
* after playback, false otherwise */
vlc_bool_t b_enabled; /**< Indicates whether this item is to be
* played or skipped */
- int i_group; /**< Which group does this item belongs to ? */
+ int i_group; /**< Which group does this item belongs to ? */
int i_id; /**< Unique id to track this item */
+ vlc_mutex_t lock; /**< Item cannot be changed without this lock */
};
/**
VLC_EXPORT( void, playlist_Command, ( playlist_t *, playlist_command_t, int ) );
-/* Item functions */
+/* Item management functions */
+#define playlist_AddItem(p,pi,i1,i2) playlist_ItemAdd(p,pi,i1,i2)
+#define playlist_ItemNew( a , b, c ) __playlist_ItemNew(VLC_OBJECT(a) , b , c )
+VLC_EXPORT( playlist_item_t* , __playlist_ItemNew, ( vlc_object_t *,const char *,const char * ) );
+VLC_EXPORT( void, playlist_ItemDelete, ( playlist_item_t * ) );
+VLC_EXPORT( int, playlist_ItemAdd, ( playlist_t *, playlist_item_t *, int, int ) );
+
+/* Simple add/remove funcctions */
VLC_EXPORT( int, playlist_Add, ( playlist_t *, const char *, const char *, int, int ) );
-VLC_EXPORT( int, playlist_AddWDuration, ( playlist_t *, const char *, const char *, int, int, mtime_t ) );
-/* For internal use. Do not use this one anymore */
-VLC_EXPORT( int, playlist_AddItem, ( playlist_t *, playlist_item_t *, int, int ) );
+VLC_EXPORT( int, playlist_AddExt, ( playlist_t *, const char *, const char *, int, int, mtime_t, const char **,int ) );
+
+
VLC_EXPORT( int, playlist_Clear, ( playlist_t * ) );
VLC_EXPORT( int, playlist_Delete, ( playlist_t *, int ) );
VLC_EXPORT( int, playlist_Disable, ( playlist_t *, int ) );
VLC_EXPORT( int, playlist_EnableGroup, ( playlist_t *, int ) );
/* Basic item informations accessors */
-VLC_EXPORT( int, playlist_SetGroup, (playlist_t *, int, int ) );
-VLC_EXPORT( int, playlist_SetName, (playlist_t *, int, char * ) );
-VLC_EXPORT( int, playlist_SetDuration, (playlist_t *, int, mtime_t ) );
+VLC_EXPORT( int, playlist_ItemSetGroup, (playlist_item_t *, int ) );
+VLC_EXPORT( int, playlist_ItemSetName, (playlist_item_t *, char * ) );
+VLC_EXPORT( int, playlist_ItemSetDuration, (playlist_item_t *, mtime_t ) );
+
+VLC_EXPORT( int, playlist_SetGroup, (playlist_t * , int , int ) );
+VLC_EXPORT( int, playlist_SetName, (playlist_t *, int , char * ) );
+VLC_EXPORT( int, playlist_SetDuration, (playlist_t *, int , mtime_t ) );
/* Item search functions */
VLC_EXPORT( int, playlist_GetPositionById, (playlist_t *, int) );
-VLC_EXPORT( playlist_item_t *, playlist_GetItemById, (playlist_t *, int) );
+VLC_EXPORT( playlist_item_t *, playlist_ItemGetById, (playlist_t *, int) );
+VLC_EXPORT( playlist_item_t *, playlist_ItemGetByPos, (playlist_t *, int) );
/* Group management functions */
/* Info functions */
VLC_EXPORT( char * , playlist_GetInfo, ( playlist_t * , int, const char *, const char *) );
-VLC_EXPORT( char * , playlist_GetItemInfo, ( playlist_item_t * , const char *, const char *) );
+VLC_EXPORT( char * , playlist_ItemGetInfo, ( playlist_item_t * , const char *, const char *) );
VLC_EXPORT( item_info_category_t*, playlist_GetCategory, ( playlist_t *, int, const char *) );
-VLC_EXPORT( item_info_category_t*, playlist_GetItemCategory, ( playlist_item_t *, const char *) );
+VLC_EXPORT( item_info_category_t*, playlist_ItemGetCategory, ( playlist_item_t *, const char *) );
VLC_EXPORT( item_info_category_t*, playlist_CreateCategory, ( playlist_t *, int, const char *) );
-VLC_EXPORT( item_info_category_t*, playlist_CreateItemCategory, ( playlist_item_t *, const char *) );
+VLC_EXPORT( item_info_category_t*, playlist_ItemCreateCategory, ( playlist_item_t *, const char *) );
VLC_EXPORT( int, playlist_AddInfo, (playlist_t *, int, const char * , const char *, const char *, ...) );
-VLC_EXPORT( int, playlist_AddItemInfo, (playlist_item_t *, const char * , const char *, const char *, ...) );
+VLC_EXPORT( int, playlist_ItemAddInfo, (playlist_item_t *, const char * , const char *, const char *, ...) );
/* Option functions */
-VLC_EXPORT( int, playlist_AddOption, (playlist_t *, int, const char *, ...) );
-VLC_EXPORT( int, playlist_AddItemOption, (playlist_item_t *, const char *, ...) );
+VLC_EXPORT( int, playlist_AddOption, (playlist_t *, int, const char *) );
+VLC_EXPORT( int, playlist_ItemAddOption, (playlist_item_t *, const char *) );
/* Playlist sorting */
#define playlist_SortID(p, i) playlist_Sort( p, SORT_ID, i)
* cddax.c : CD digital audio input module for vlc using libcdio
*****************************************************************************
* Copyright (C) 2000,2003 VideoLAN
- * $Id: access.c,v 1.22 2004/01/07 07:21:31 rocky Exp $
+ * $Id: access.c,v 1.23 2004/01/29 17:51:07 zorglub Exp $
*
* Authors: Rocky Bernstein <rocky@panix.com>
* Laurent Aimar <fenrir@via.ecp.fr>
if ( str ) { \
dbg_print( INPUT_DBG_META, "field %s: %s\n", title, str); \
input_AddInfo( p_cat, _(title), "%s", str ); \
- playlist_AddInfo( p_playlist, -1, p_cat->psz_name, \
+ vlc_mutex_lock( &p_playlist->object_lock ); \
+ p_item = playlist_ItemGetByPos( p_playlist, -1 ); \
+ vlc_mutex_unlock( &p_playlist->object_lock ); \
+ vlc_mutex_lock( &p_item->lock ); \
+ playlist_ItemAddInfo( p_item, p_cat->psz_name, \
_(title), "%s" , str ); \
+ vlc_mutex_unlock( &p_item->lock ); \
}
playlist_t *p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST,
FIND_PARENT );
input_info_category_t *p_cat;
+ playlist_item_t *p_item;
p_cat = input_InfoCategory( p_input, "General" );
-
+
#ifdef HAVE_LIBCDDB
if (p_cdda->i_cddb_enabled) {
char *p_author;
char *p_title;
char *config_varname = MODULE_STRING "-title-format";
+ playlist_item_t *p_item;
#ifdef HAVE_LIBCDDB
if (p_cdda->i_cddb_enabled) {
dbg_print( INPUT_DBG_META, "mrl: %s, title: %s, duration, %ld, pos %d",
psz_mrl, p_title, (long int) i_duration / 1000000 , i_pos );
- playlist_AddWDuration( p_playlist, psz_mrl, p_title, playlist_operation,
- i_pos, i_duration );
+ playlist_AddExt( p_playlist, psz_mrl, p_title, playlist_operation,
+ i_pos, i_duration , NULL, 0);
if( i_pos == PLAYLIST_END ) i_pos = p_playlist->i_size - 1;
+ vlc_mutex_lock( &p_playlist->object_lock );
+ p_item = playlist_ItemGetByPos( p_playlist, i_pos );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ if( !p_item )
+ return;
+
+ vlc_mutex_lock( &p_item->lock );
+
p_author =
CDDAFormatStr( p_input, p_cdda,
config_GetPsz( p_input, MODULE_STRING "-author-format" ),
psz_mrl, i_track );
- playlist_AddInfo( p_playlist, i_pos, _("General"),_("Author"), p_author);
+ playlist_ItemAddInfo( p_item , _("General"),_("Author"), p_author);
#ifdef HAVE_LIBCDDB
if (p_cdda->i_cddb_enabled) {
const char *psz_general_cat = _("General");
- playlist_AddInfo( p_playlist, i_pos, psz_general_cat, _("Album"),
- "%s", p_cdda->cddb.disc->title);
- playlist_AddInfo( p_playlist, i_pos, psz_general_cat, _("Disc Artist(s)"),
- "%s", p_cdda->cddb.disc->artist);
- playlist_AddInfo( p_playlist, i_pos, psz_general_cat,
- _("CDDB Disc Category"),
- "%s", CDDB_CATEGORY[p_cdda->cddb.disc->category]);
- playlist_AddInfo( p_playlist, i_pos, psz_general_cat, _("Genre"),
- "%s", p_cdda->cddb.disc->genre);
+ playlist_ItemAddInfo( p_item, psz_general_cat, _("Album"),
+ "%s", p_cdda->cddb.disc->title);
+ playlist_ItemAddInfo( p_item, psz_general_cat, _("Disc Artist(s)"),
+ "%s", p_cdda->cddb.disc->artist);
+ playlist_ItemAddInfo( p_item, psz_general_cat,
+ _("CDDB Disc Category"),
+ "%s", CDDB_CATEGORY[p_cdda->cddb.disc->category]);
+ playlist_ItemAddInfo( p_item, psz_general_cat, _("Genre"),
+ "%s", p_cdda->cddb.disc->genre);
if ( p_cdda->cddb.disc->discid ) {
- playlist_AddInfo( p_playlist, i_pos, psz_general_cat, _("CDDB Disc ID"),
- "%x", p_cdda->cddb.disc->discid );
+ playlist_ItemAddInfo( p_item, psz_general_cat, _("CDDB Disc ID"),
+ "%x", p_cdda->cddb.disc->discid );
}
if (p_cdda->cddb.disc->year != 0) {
- playlist_AddInfo( p_playlist, i_pos, psz_general_cat,
- _("Year"), "%5d", p_cdda->cddb.disc->year );
+ playlist_ItemAddInfo( p_item, psz_general_cat,
+ _("Year"), "%5d", p_cdda->cddb.disc->year );
}
if (p_cdda->i_cddb_enabled) {
cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
- i_track-1);
+ i_track-1);
if (t != NULL && t->artist != NULL) {
- playlist_AddInfo( p_playlist, i_pos, psz_general_cat,
- _("Track Artist"), "%s", t->artist );
- playlist_AddInfo( p_playlist, i_pos, psz_general_cat,
- _("Track Title"), "%s", t->title );
+ playlist_ItemAddInfo( p_item, psz_general_cat,
+ _("Track Artist"), "%s", t->artist );
+ playlist_ItemAddInfo( p_item , psz_general_cat,
+ _("Track Title"), "%s", t->title );
}
}
}
#endif /*HAVE_LIBCDDB*/
+ vlc_mutex_unlock( &p_item->lock );
}
static int
* to go here.
*****************************************************************************
* Copyright (C) 2000, 2003, 2004 VideoLAN
- * $Id: access.c,v 1.17 2004/01/25 04:53:16 rocky Exp $
+ * $Id: access.c,v 1.18 2004/01/29 17:51:07 zorglub Exp $
*
* Authors: Rocky Bernstein <rocky@panix.com>
* Johan Bilien <jobi@via.ecp.fr>
static inline void
-MetaInfoAddStr(input_thread_t *p_input, input_info_category_t *p_cat,
- playlist_t *p_playlist, char *title,
- const char *str)
+MetaInfoAddStr(input_thread_t *p_input, input_info_category_t *p_cat,
+ playlist_t *p_playlist, char *title,
+ const char *str)
{
thread_vcd_data_t *p_vcd = (thread_vcd_data_t *) p_input->p_access_data;
- if ( str ) {
+ playlist_item_t *p_item;
+ if ( str ) {
dbg_print( INPUT_DBG_META, "field: %s: %s\n", title, str);
- input_AddInfo( p_cat, title, "%s", str );
- playlist_AddInfo( p_playlist, -1, p_cat->psz_name, title,
- "%s",str );
+ input_AddInfo( p_cat, title, "%s", str );
+
+ vlc_mutex_lock( &p_playlist->object_lock );
+ p_item = playlist_ItemGetByPos( p_playlist, -1 );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+
+ vlc_mutex_lock( &p_item->lock );
+ playlist_ItemAddInfo( p_item, p_cat->psz_name, title,
+ "%s",str );
+ vlc_mutex_unlock( &p_item->lock );
}
}
static inline void
-MetaInfoAddNum(input_thread_t *p_input, input_info_category_t *p_cat,
- playlist_t *p_playlist, char *title, int num)
+MetaInfoAddNum(input_thread_t *p_input, input_info_category_t *p_cat,
+ playlist_t *p_playlist, char *title, int num)
{
thread_vcd_data_t *p_vcd = (thread_vcd_data_t *) p_input->p_access_data;
+ playlist_item_t *p_item;
+
+ vlc_mutex_lock( &p_playlist->object_lock );
+ p_item = playlist_ItemGetByPos( p_playlist, -1 );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+
dbg_print( INPUT_DBG_META, "field %s: %d\n", title, num);
input_AddInfo( p_cat, title, "%d", num );
- playlist_AddInfo( p_playlist, -1, p_cat->psz_name, title,
- "%d",num );
+
+ vlc_mutex_lock( &p_item->lock );
+ playlist_ItemAddInfo( p_item , p_cat->psz_name, title, "%d",num );
+ vlc_mutex_unlock( &p_item->lock );
}
-
+
#define addstr(title, str) \
MetaInfoAddStr( p_input, p_cat, p_playlist, title, str );
#define addnum(title, num) \
MetaInfoAddNum( p_input, p_cat, p_playlist, title, num );
-
+
static void InformationCreate( input_thread_t *p_input )
{
thread_vcd_data_t *p_vcd = (thread_vcd_data_t *) p_input->p_access_data;
* speex.c: speex decoder/packetizer/encoder module making use of libspeex.
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: speex.c,v 1.10 2004/01/25 18:20:12 bigben Exp $
+ * $Id: speex.c,v 1.11 2004/01/29 17:51:07 zorglub Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
p_mode = speex_mode_list[p_sys->p_header->mode];
input_AddInfo( p_cat, _("Mode"), "%s%s",
- p_mode->modeName, p_sys->p_header->vbr ? " VBR" : "" );
- playlist_AddInfo( p_playlist, -1, _("Speex comment") , _("Mode"), "%s%s",
+ p_mode->modeName, p_sys->p_header->vbr ? " VBR" : "" );
+
+ vlc_mutex_lock( &p_playlist->object_lock );
+ p_item = playlist_ItemGetByPos( p_playlist, -1 );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ if( !p_item)
+ {
+ msg_Err(p_dec, "unable to find item" );
+ return;
+ }
+ vlc_mutex_lock( &p_item->lock );
+
+ playlist_ItemAddInfo( p_item, _("Speex comment") , _("Mode"),"%s%s",
p_mode->modeName, p_sys->p_header->vbr ? " VBR" : "" );
if( p_oggpacket->bytes < 8 )
}
input_AddInfo( p_cat, p_buf, "" );
- playlist_AddInfo( p_playlist, -1, _("Speex comment") , p_buf , "" );
+ playlist_ItemAddInfo( p_item , _("Speex comment") , p_buf , "" );
+
+ vlc_mutex_unlock( &p_item->lock );
if( p_playlist ) vlc_object_release( p_playlist );
* theora.c: theora decoder module making use of libtheora.
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: theora.c,v 1.23 2004/01/25 18:20:12 bigben Exp $
+ * $Id: theora.c,v 1.24 2004/01/29 17:51:07 zorglub Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
input_InfoCategory( p_input, _("Theora comment") );
playlist_t *p_playlist = vlc_object_find( p_dec, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
+ playlist_item_t *p_item;
int i = 0;
char *psz_name, *psz_value, *psz_comment;
while ( i < p_dec->p_sys->tc.comments )
*psz_value = '\0';
psz_value++;
input_AddInfo( p_cat, psz_name, psz_value );
- playlist_AddInfo( p_playlist, -1, _("Theora comment") ,
- psz_name, psz_value );
+ vlc_mutex_lock( &p_playlist->object_lock );
+ p_item = playlist_ItemGetByPos( p_playlist, -1 );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ if( !p_item)
+ {
+ msg_Err(p_dec, "unable to find item" );
+ return;
+ }
+ vlc_mutex_lock( &p_item->lock );
+ playlist_ItemAddInfo( p_item, _("Theora comment") ,
+ psz_name, psz_value );
+ vlc_mutex_unlock( &p_item->lock );
}
free( psz_comment );
i++;
* vorbis.c: vorbis decoder/encoder/packetizer module making use of libvorbis.
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
- * $Id: vorbis.c,v 1.30 2004/01/25 18:20:12 bigben Exp $
+ * $Id: vorbis.c,v 1.31 2004/01/29 17:51:07 zorglub Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
input_InfoCategory( p_input, _("Vorbis comment") );
playlist_t *p_playlist = vlc_object_find( p_dec, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
+ playlist_item_t *p_item;
int i = 0;
char *psz_name, *psz_value, *psz_comment;
while ( i < p_dec->p_sys->vc.comments )
*psz_value = '\0';
psz_value++;
input_AddInfo( p_cat, psz_name, psz_value );
- playlist_AddInfo( p_playlist, -1, _("Vorbis comment") ,
- psz_name, psz_value );
+ vlc_mutex_lock( &p_playlist->object_lock );
+ p_item = playlist_ItemGetByPos( p_playlist, -1 );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ if( !p_item)
+ {
+ msg_Err(p_dec, "unable to find item" );
+ return;
+ }
+ vlc_mutex_lock( &p_item->lock );
+ playlist_ItemAddInfo( p_item, _("Vorbis comment") ,
+ psz_name, psz_value );
+ vlc_mutex_unlock( &p_item->lock );
}
free( psz_comment );
i++;
* http.c : http mini-server ;)
*****************************************************************************
* Copyright (C) 2001-2004 VideoLAN
- * $Id: http.c,v 1.50 2004/01/25 16:17:03 anil Exp $
+ * $Id: http.c,v 1.51 2004/01/29 17:51:07 zorglub Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
* Laurent Aimar <fenrir@via.ecp.fr>
static char *Find_end_MRL( char *psz );
-static playlist_item_t * parse_MRL( char *psz );
+static playlist_item_t * parse_MRL( intf_thread_t * , char *psz );
/*****************************************************************************
*
uri_extract_value( p_request, "mrl", mrl, 512 );
uri_decode_url_encoded( mrl );
- p_item = parse_MRL( mrl );
+ p_item = parse_MRL( p_intf, mrl );
if( !p_item || !p_item->psz_uri || !*p_item->psz_uri )
{
* create an item with all informations in it, and return the item.
* return NULL if there is an error.
**********************************************************************/
-playlist_item_t * parse_MRL( char *psz )
+playlist_item_t * parse_MRL( intf_thread_t *p_intf, char *psz )
{
char **ppsz_options = NULL;
char *mrl;
else
{
/* now create an item */
- p_item = malloc( sizeof( playlist_item_t ) );
- memset( p_item, 0, sizeof( playlist_item_t ) );
- p_item->psz_name = mrl;
- p_item->psz_uri = strdup( mrl );
- p_item->i_duration = -1;
- p_item->b_enabled = VLC_TRUE;
- p_item->i_group = PLAYLIST_TYPE_MANUAL;
-
+ p_item = playlist_ItemNew( p_intf, mrl, mrl);
for( i = 0 ; i< i_options ; i++ )
{
- playlist_AddItemOption( p_item, ppsz_options[i] );
+ playlist_ItemAddOption( p_item, ppsz_options[i] );
}
}
* id3tag.c: id3 tag parser/skipper based on libid3tag
*****************************************************************************
* Copyright (C) 2002-2004 VideoLAN
- * $Id: id3tag.c,v 1.19 2004/01/25 20:05:29 hartman Exp $
+ * $Id: id3tag.c,v 1.20 2004/01/29 17:51:07 zorglub Exp $
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
*
while ( ( p_frame = id3_tag_findframe( p_id3_tag , "T", i ) ) )
{
- playlist_item_t *p_item = p_playlist ? p_playlist->pp_items[p_playlist->i_index] : NULL;
+ playlist_item_t *p_item = playlist_ItemGetByPos( p_playlist, -1 );
+ if( !p_item )
+ {
+ msg_Err( p_input, "Unable to get item" );
+ return;
+ }
+
+ vlc_mutex_lock( &p_item->lock );
int i_strings = id3_field_getnstrings( &p_frame->fields[1] );
{
input_AddInfo( p_category, (char *)p_frame->description,
ppsz_genres[atoi(psz_temp)]);
- playlist_AddItemInfo( p_item, "ID3",
+ playlist_ItemAddInfo( p_item, "ID3",
(char *)p_frame->description,
ppsz_genres[atoi(psz_temp)]);
}
{
input_AddInfo( p_category, (char *)p_frame->description,
psz_temp );
- playlist_AddItemInfo( p_item, "ID3",
+ playlist_ItemAddInfo( p_item, "ID3",
(char *)p_frame->description,
psz_temp);
}
}
input_AddInfo( p_category, (char *)p_frame->description,
psz_temp );
- playlist_AddItemInfo( p_item, "ID3",
+ playlist_ItemAddInfo( p_item, "ID3",
(char *)p_frame->description,
psz_temp);
}
{
if( p_item )
{
- playlist_AddItemInfo( p_item,
+ playlist_ItemAddInfo( p_item,
_("General"), _("Author"), psz_temp);
val.b_bool = VLC_TRUE;
}
input_AddInfo( p_category, (char *)p_frame->description,
psz_temp );
- playlist_AddItemInfo( p_item, "ID3",
+ playlist_ItemAddInfo( p_item, "ID3",
(char *)p_frame->description,
psz_temp);
}
{
input_AddInfo( p_category, (char *)p_frame->description,
psz_temp );
- playlist_AddItemInfo( p_item, "ID3",
+ playlist_ItemAddInfo( p_item, "ID3",
(char *)p_frame->description,
psz_temp);
}
free( psz_temp );
}
i++;
+ vlc_mutex_unlock( &p_item->lock );
}
id3_tag_delete( p_id3_tag );
if(val.b_bool == VLC_TRUE )
* pda_callbacks.c : Callbacks for the pda Linux Gtk+ plugin.
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
- * $Id: pda_callbacks.c,v 1.25 2004/01/25 14:15:21 kuehne Exp $
+ * $Id: pda_callbacks.c,v 1.26 2004/01/29 17:51:07 zorglub Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
else
#endif
{
- i_id = playlist_Add( p_playlist, (const char*)name,
- (const char*)name,
- PLAYLIST_APPEND, PLAYLIST_END );
-
- i_pos = playlist_GetPositionById( p_playlist, i_id );
-
- for( i = 0 ; i< i_size ; i++ )
- {
- playlist_AddOption( p_playlist, i_pos , ppsz_options[i] );
- }
+ i_id = playlist_AddExt( p_playlist, (const char*)name,
+ (const char*)name,
+ PLAYLIST_APPEND, PLAYLIST_END,
+ ppsz_options, i_pos );
}
/* Cleanup memory */
* iteminfo.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2004 VideoLAN
- * $Id: iteminfo.cpp,v 1.7 2004/01/25 03:29:01 hartman Exp $
+ * $Id: iteminfo.cpp,v 1.8 2004/01/29 17:51:08 zorglub Exp $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
author_text =
new wxTextCtrl( info_panel, Uri_Event,
- wxU( playlist_GetItemInfo( p_item,
+ wxU( playlist_ItemGetInfo( p_item,
_("General"), _("Author") ) ),
wxDefaultPosition, wxSize( 300, -1 ),
wxTE_PROCESS_ENTER);
*****************************************************************************/
void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
{
+ vlc_mutex_lock( &p_item->lock );
p_item->psz_name = strdup( name_text->GetLineText(0).mb_str() );
p_item->psz_uri = strdup( uri_text->GetLineText(0).mb_str() );
- playlist_AddItemInfo( p_item,"General","Author",
+ playlist_ItemAddInfo( p_item,"General","Author",
author_text->GetLineText(0).mb_str() );
vlc_bool_t b_old_enabled = p_item->b_enabled;
}
p_item->b_enabled = enabled_checkbox->IsChecked() ? VLC_TRUE : VLC_FALSE ;
+ vlc_mutex_unlock( &p_item->lock );
EndModal( wxID_OK );
}
* open.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2004 VideoLAN
- * $Id: open.cpp,v 1.66 2004/01/26 22:10:20 gbazin Exp $
+ * $Id: open.cpp,v 1.67 2004/01/29 17:51:08 zorglub Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
for( int i = 0; i < (int)mrl.GetCount(); i++ )
{
int i_options = 0;
-
- int i_id = playlist_Add( p_playlist, (const char *)mrl[i].mb_str(),
- (const char *)mrl[i].mb_str(),
- PLAYLIST_APPEND, PLAYLIST_END );
- playlist_item_t *p_item = playlist_GetItemById( p_playlist , i_id );
+ playlist_item_t *p_item =
+ playlist_ItemNew( p_intf,
+ (const char*)mrl[i].mb_str(),
+ (const char *)mrl[i].mb_str() );
/* Count the input options */
while( i + i_options + 1 < (int)mrl.GetCount() &&
/* Insert options */
for( int j = 0; j < i_options; j++ )
{
- playlist_AddItemOption( p_item, mrl[i + j + 1].mb_str() );
+ playlist_ItemAddOption( p_item, mrl[i + j + 1].mb_str() );
}
/* Get the options from the subtitles dialog */
{
for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
{
- playlist_AddItemOption( p_item, subsfile_mrl[j].mb_str() );
+ playlist_ItemAddOption( p_item, subsfile_mrl[j].mb_str() );
}
}
{
for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
{
- playlist_AddItemOption( p_item, sout_mrl[j].mb_str() );
+ playlist_ItemAddOption( p_item, sout_mrl[j].mb_str() );
}
}
+ int i_id = playlist_AddItem( p_playlist, p_item,
+ PLAYLIST_APPEND, PLAYLIST_END );
+
if( !i && i_open_arg )
{
int i_pos = playlist_GetPositionById( p_playlist , i_id );
* playlist.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2004 VideoLAN
- * $Id: playlist.cpp,v 1.39 2004/01/25 03:29:01 hartman Exp $
+ * $Id: playlist.cpp,v 1.40 2004/01/29 17:51:08 zorglub Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
*
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
+
if( p_playlist == NULL )
{
return;
}
- if( i < 0 || i >= p_playlist->i_size || !p_playlist->pp_items[i] )
+
+ playlist_item_t *p_item = playlist_ItemGetByPos( p_playlist, i );
+
+ if( !p_item )
{
vlc_object_release(p_playlist);
return;
}
- listview->SetItem( i, 0, wxL2U(p_playlist->pp_items[i]->psz_name) );
- listview->SetItem( i, 1, wxU( playlist_GetInfo( p_playlist, i,
+
+ listview->SetItem( i, 0, wxL2U(p_item->psz_name) );
+ listview->SetItem( i, 1, wxU( playlist_ItemGetInfo( p_item,
_("General") , _("Author") ) ) );
char *psz_group = playlist_FindGroup(p_playlist,
- p_playlist->pp_items[i]->i_group);
+ p_item->i_group);
listview->SetItem( i, 2,
wxL2U( psz_group ? psz_group : _("Normal") ) );
- if( p_playlist->pp_items[i]->b_enabled == VLC_FALSE )
+ if( p_item->b_enabled == VLC_FALSE )
{
wxListItem listitem;
listitem.m_itemId = i;
}
char psz_duration[MSTRTIME_MAX_SIZE];
- mtime_t dur = p_playlist->pp_items[i]->i_duration;
+ mtime_t dur = p_item->i_duration;
if( dur != -1 ) secstotimestr( psz_duration, dur/1000000 );
else memcpy( psz_duration , "-:--:--", sizeof("-:--:--") );
listview->SetItem( i, 3, wxU(psz_duration) );
formats[dialog.GetFilterIndex()].psz_module );
}
}
-
+
vlc_object_release( p_playlist );
-
+
}
}
{
if( listview->IsSelected( item ) )
{
+ /*XXX*/
playlist_Enable( p_playlist, item );
UpdateItem( item );
}
{
if( listview->IsSelected( item ) )
{
+ /*XXX*/
playlist_Disable( p_playlist, item );
UpdateItem( item );
}
}
if( iteminfo_dialog == NULL )
{
- if( i_item >= 0 && i_item < p_playlist->i_size )
+ vlc_mutex_lock( &p_playlist->object_lock);
+ playlist_item_t *p_item = playlist_ItemGetByPos( p_playlist, i_item );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+
+ if( p_item )
{
iteminfo_dialog = new ItemInfoDialog(
- p_intf, p_playlist->pp_items[i_item], this );
+ p_intf, p_item , this );
if( iteminfo_dialog->ShowModal() == wxID_OK )
UpdateItem( i_item );
delete iteminfo_dialog;
switch( event.GetId() )
{
case EnableGroup_Event:
+ /*XXX*/
playlist_EnableGroup( p_playlist ,
p_playlist->pp_items[i_item]->i_group );
break;
vlc_value_t old_val, vlc_value_t new_val, void *param )
{
Playlist *p_playlist_dialog = (Playlist *)param;
+ fprintf(stderr,"Update item: %i\n",new_val.i_int);
p_playlist_dialog->UpdateItem( new_val.i_int );
return 0;
}
* stream.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2004 VideoLAN
- * $Id: streamwizard.cpp,v 1.5 2004/01/25 03:29:01 hartman Exp $
+ * $Id: streamwizard.cpp,v 1.6 2004/01/29 17:51:08 zorglub Exp $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
for( int i = 0; i < (int)p_open_dialog->mrl.GetCount(); i++ )
{
- int i_id = playlist_Add( p_playlist,
+ playlist_item_t *p_item = playlist_ItemNew( p_intf,
(const char *)p_open_dialog->mrl[i].mb_str(),
- (const char *)p_open_dialog->mrl[i].mb_str(),
- PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
- int i_pos = playlist_GetPositionById( p_playlist, i_id );
+ (const char *)p_open_dialog->mrl[i].mb_str() );
int i_options = 0;
/* Count the input options */
/* Insert options */
for( int j = 0; j < i_options; j++ )
{
- playlist_AddOption( p_playlist, i_pos,
+ playlist_ItemAddOption( p_item ,
p_open_dialog->mrl[i + j + 1].mb_str() );
}
{
for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
{
- playlist_AddOption( p_playlist, i_pos ,
- sout_mrl[j].mb_str() );
+ playlist_ItemAddOption( p_item , sout_mrl[j].mb_str() );
}
}
+
+ playlist_AddItem( p_playlist, p_item,
+ PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
+
msg_Dbg(p_intf,"playings %s",
(const char *)p_open_dialog->mrl[i].mb_str());
i += i_options;
- }
- vlc_object_release( p_playlist );
+ }
+ vlc_object_release( p_playlist );
- Hide();
+ Hide();
}
* sap.c : SAP interface module
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: sap.c,v 1.51 2004/01/25 18:53:07 gbazin Exp $
+ * $Id: sap.c,v 1.52 2004/01/29 17:51:08 zorglub Exp $
*
* Authors: Arnaud Schauly <gitan@via.ecp.fr>
* Clément Stenac <zorglub@via.ecp.fr>
vlc_bool_t b_http = VLC_FALSE;
char *psz_http_path = NULL;
playlist_t *p_playlist = NULL;
+ playlist_item_t *p_item;
psz_uri_default = NULL;
if( p_sd->i_media > 1 )
PLAYLIST_CHECK_INSERT, PLAYLIST_END );
if( i_id != -1 )
{
- i_pos = playlist_GetPositionById( p_playlist, i_id );
- playlist_SetGroup( p_playlist, i_pos, p_intf->p_sys->i_group );
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
+ playlist_ItemSetGroup( p_item, p_intf->p_sys->i_group );
}
/* Remember it */
p_sd->psz_sessionname,
psz_item_uri );
- p_item = playlist_GetItemById( p_playlist,
+ p_item = playlist_ItemGetById( p_playlist,
p_intf->p_sys->pp_announces[i]->i_id );
/* Change the name in the item */
i_id = playlist_Add ( p_playlist, psz_item_uri ,
p_sd->psz_sessionname,
PLAYLIST_CHECK_INSERT, PLAYLIST_END );
- i_pos = playlist_GetPositionById( p_playlist, i_id );
- playlist_SetGroup( p_playlist, i_pos, i_group );
+ p_item = playlist_ItemGetById( p_playlist, i_id );
+ if( p_item )
+ {
+ vlc_mutex_lock( &p_item->lock );
+ playlist_ItemSetGroup( p_item, i_group );
+ vlc_mutex_unlock( &p_item->lock );
+ }
/* Then remember it */
p_announce = (struct sap_announce_t *)malloc(
* decoders.
*****************************************************************************
* Copyright (C) 1998-2004 VideoLAN
- * $Id: input.c,v 1.283 2004/01/26 23:37:05 hartman Exp $
+ * $Id: input.c,v 1.284 2004/01/29 17:51:08 zorglub Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
if( p_playlist )
{
playlist_SetDuration( p_playlist, -1 , i_length );
- val.b_bool = VLC_TRUE;
+ val.b_bool = p_playlist->i_index;
var_Set( p_playlist, "item-change", val );
vlc_object_release( p_playlist );
}
var_Get( p_input, "sub-file", &val );
if( val.psz_string && *val.psz_string )
{
- msg_Dbg( p_input, "force subtitle: %s", val.psz_string );
+ msg_Dbg( p_input, "force subtitle: %s", val.psz_string );
subtitle_demux_t *p_sub;
if( ( p_sub = subtitle_New( p_input, strdup(val.psz_string),
i_microsecondperframe ) ) )
* libvlc.c: main libvlc source
*****************************************************************************
* Copyright (C) 1998-2004 VideoLAN
- * $Id: libvlc.c,v 1.114 2004/01/29 14:39:08 sigmunau Exp $
+ * $Id: libvlc.c,v 1.115 2004/01/29 17:51:08 zorglub Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
char const **ppsz_options, int i_options,
int i_mode, int i_pos )
{
- int i;
int i_err;
playlist_t *p_playlist;
vlc_t *p_vlc = vlc_current_object( i_object );
vlc_object_yield( p_playlist );
}
- i_err = playlist_Add( p_playlist, psz_target, psz_target,
- i_mode, i_pos );
-
- for( i = 0 ; i< i_options ; i++ )
- {
- playlist_AddOption( p_playlist, i_err , ppsz_options[i] );
- }
+ i_err = playlist_AddExt( p_playlist, psz_target, psz_target,
+ i_mode, i_pos, -1, ppsz_options, i_options);
vlc_object_release( p_playlist );
* win32_specific.c: Win32 specific features
*****************************************************************************
* Copyright (C) 2001-2004 VideoLAN
- * $Id: win32_specific.c,v 1.32 2004/01/25 17:16:06 zorglub Exp $
+ * $Id: win32_specific.c,v 1.33 2004/01/29 17:51:08 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Gildas Bazin <gbazin@netcourrier.com>
i_id = playlist_Add( p_playlist, ppsz_argv[ i_opt ],
ppsz_argv[ i_opt ],
PLAYLIST_APPEND | (i_opt? 0 : PLAYLIST_GO),
- PLAYLIST_END );
- i_pos = playlist_GetPositionById( p_playlist, i_id );
- for( j = 0 ; j < i_options ; j++ )
- {
- playlist_AddOption( p_playlist, i_pos ,
- ppsz_argv[i_opt+1+j] );
- }
+ PLAYLIST_END, -1,
+ ppsz_argv[i_opt+1], i_options );
i_opt += i_options;
}
* info.c : Playlist info management
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: info.c,v 1.7 2004/01/25 17:16:06 zorglub Exp $
+ * $Id: info.c,v 1.8 2004/01/29 17:51:08 zorglub Exp $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
/**
* Get one special info
+ * Must be entered with playlist lock
*
* \param p_playlist the playlist to get the info from
* \param i_item position of the item on
* \param psz_name the name of the info
* \return the info value if any, an empty string else
*/
-char * playlist_GetInfo( playlist_t *p_playlist, int i_item,
+char * playlist_GetInfo( playlist_t *p_playlist, int i_pos,
const char * psz_cat, const char *psz_name )
{
+ playlist_item_t *p_item;
+ char *psz_buffer;
/* Check the existence of the playlist */
if( p_playlist == NULL)
{
return strdup("");
}
- /* Get a correct item */
- if( i_item >= 0 && i_item < p_playlist->i_size )
- {
- }
- else if( p_playlist->i_size > 0 )
- {
- i_item = p_playlist->i_index;
- }
- else
+ p_item = playlist_ItemGetByPos( p_playlist, i_pos );
+ if( !p_item )
{
return strdup("");
}
- return playlist_GetItemInfo( p_playlist->pp_items[i_item] , psz_cat,
- psz_name );
+ vlc_mutex_lock( &p_item->lock );
+ psz_buffer = playlist_ItemGetInfo( p_item ,
+ psz_cat, psz_name );
+ vlc_mutex_unlock( &p_item->lock );
+
+ return psz_buffer;
}
/**
* \param psz_name the name of the info
* \return the info value if any, an empty string else
*/
-char * playlist_GetItemInfo( playlist_item_t *p_item,
+char * playlist_ItemGetInfo( playlist_item_t *p_item,
const char * psz_cat, const char *psz_name )
{
int i,j ;
* \return the info category.
*/
item_info_category_t *
-playlist_GetCategory( playlist_t *p_playlist, int i_item,
+playlist_GetCategory( playlist_t *p_playlist, int i_pos,
const char * psz_cat )
{
+ playlist_item_t *p_item;
/* Check the existence of the playlist */
if( p_playlist == NULL)
{
return NULL;
}
-
- /* Get a correct item */
- if( i_item >= 0 && i_item < p_playlist->i_size )
- {
- }
- else if( p_playlist->i_size > 0 )
- {
- i_item = p_playlist->i_index;
- }
- else
+ p_item= playlist_ItemGetByPos( p_playlist , i_pos );
+ if( !p_item )
{
return NULL;
}
-
- return playlist_GetItemCategory( p_playlist->pp_items[i_item] , psz_cat );
+ return playlist_ItemGetCategory( p_item , psz_cat );
}
/**
* \param psz_cat the category we want
* \return the info category.
*/
-item_info_category_t *playlist_GetItemCategory( playlist_item_t *p_item,
+item_info_category_t *playlist_ItemGetCategory( playlist_item_t *p_item,
const char *psz_cat )
{
int i;
}
/* We did not find the category, create it */
- return playlist_CreateItemCategory( p_item, psz_cat );
+ return playlist_ItemCreateCategory( p_item, psz_cat );
}
* \return the info category.
*/
item_info_category_t *
-playlist_CreateCategory( playlist_t *p_playlist, int i_item,
+playlist_CreateCategory( playlist_t *p_playlist, int i_pos,
const char * psz_cat )
{
playlist_item_t *p_item = NULL;
{
return NULL;
}
-
- /* Get a correct item */
- if( i_item >= 0 && i_item < p_playlist->i_size )
- {
- p_item = p_playlist->pp_items[i_item];
- }
- else if( p_playlist->i_size > 0 )
- {
- p_item = p_playlist->pp_items[p_playlist->i_index];
- }
- else
+ p_item = playlist_ItemGetByPos( p_playlist , i_pos );
+ if( !p_item )
{
return NULL;
}
- return playlist_CreateItemCategory( p_item, psz_cat );
+ return playlist_ItemCreateCategory( p_item, psz_cat );
}
/**
* \return the info category.
*/
item_info_category_t *
-playlist_CreateItemCategory( playlist_item_t *p_item, const char *psz_cat )
+playlist_ItemCreateCategory( playlist_item_t *p_item, const char *psz_cat )
{
item_info_category_t *p_cat;
int i;
return VLC_EGENERIC;
}
- /* Get a correct item */
- if( i_item >= 0 && i_item < p_playlist->i_size )
- {
- p_item = p_playlist->pp_items[i_item];
- }
- else if( p_playlist->i_size > 0 )
+ p_item = playlist_ItemGetByPos( p_playlist, i_item );
+ if( !p_item )
{
- p_item = p_playlist->pp_items[p_playlist->i_index];
- }
- else
- {
- return VLC_EGENERIC;
+ return VLC_ENOOBJ;
}
va_start( args, psz_format );
vasprintf( &psz_value, psz_format, args );
va_end( args );
- i_ret = playlist_AddItemInfo( p_item , psz_cat , psz_name , psz_value );
+ vlc_mutex_lock( &p_item->lock );
+ i_ret = playlist_ItemAddInfo( p_item , psz_cat , psz_name , psz_value );
+ vlc_mutex_unlock( &p_item->lock );
free( psz_value );
return i_ret;
* \param psz_format printf-style info
* \return VLC_SUCCESS on success
*/
-int playlist_AddItemInfo( playlist_item_t *p_item,
+int playlist_ItemAddInfo( playlist_item_t *p_item,
const char *psz_cat, const char *psz_name,
const char *psz_format, ... )
{
item_info_category_t *p_cat;
/* Find or create the category */
- p_cat = playlist_GetItemCategory( p_item, psz_cat );
+ p_cat = playlist_ItemGetCategory( p_item, psz_cat );
if( p_cat == NULL)
{
return VLC_EGENERIC;
* \param psz_value the option to add
* \return the info category.
*/
-int playlist_AddOption( playlist_t *p_playlist, int i_item,
- const char * psz_format, ...)
+int playlist_AddOption( playlist_t *p_playlist, int i_pos,
+ const char *psz_option)
{
- va_list args;
- item_info_t *p_info = NULL;
- item_info_category_t *p_cat;
+ playlist_item_t *p_item;
/* Check the existence of the playlist */
if( p_playlist == NULL)
return VLC_EGENERIC;
}
- /* Get a correct item */
- if( i_item >= 0 && i_item < p_playlist->i_size )
- {
- }
- else if( p_playlist->i_size > 0 )
- {
- i_item = p_playlist->i_index;
- }
- else
- {
- return VLC_EGENERIC;
- }
-
- p_cat = playlist_GetCategory( p_playlist, i_item , _("Options") );
-
- if( p_cat == NULL)
- {
- return VLC_EGENERIC;
- }
-
- if( ( p_info = malloc( sizeof( item_info_t) ) ) == NULL )
+ p_item = playlist_ItemGetByPos( p_playlist , i_pos );
+ if( !p_item )
{
- msg_Err( p_playlist, "out of memory" );
- return VLC_EGENERIC;
+ return VLC_ENOOBJ;
}
- p_info->psz_name = strdup( "option" );
-
- va_start( args, psz_format );
- vasprintf( &p_info->psz_value, psz_format, args );
- va_end( args );
-
- INSERT_ELEM( p_cat->pp_infos, p_cat->i_infos, p_cat->i_infos, p_info );
+ vlc_mutex_lock( &p_item->lock );
+ INSERT_ELEM( p_item->ppsz_options,
+ p_item->i_options,
+ p_item->i_options,
+ (char *)psz_option );
+ vlc_mutex_unlock( &p_item->lock );
return VLC_SUCCESS;
}
* \param psz_format the option
* \return 0 on success
*/
-int playlist_AddItemOption( playlist_item_t *p_item,
- const char *psz_format, ... )
+int playlist_ItemAddOption( playlist_item_t *p_item,
+ const char *psz_option )
{
- va_list args;
- item_info_t *p_info = NULL;
- item_info_category_t *p_cat;
-
- p_cat = playlist_GetItemCategory( p_item, _("Options") );
- if( p_cat == NULL)
- {
- return VLC_EGENERIC;
- }
-
- if( ( p_info = malloc( sizeof( item_info_t) ) ) == NULL )
- {
- return VLC_EGENERIC;
- }
-
- p_info->psz_name = strdup( "option" );
-
- va_start( args, psz_format );
- vasprintf( &p_info->psz_value, psz_format, args );
- va_end( args );
-
- INSERT_ELEM( p_cat->pp_infos, p_cat->i_infos, p_cat->i_infos, p_info );
+ INSERT_ELEM( p_item->ppsz_options,
+ p_item->i_options,
+ p_item->i_options,
+ (char *)psz_option);
return VLC_SUCCESS;
}
/*****************************************************************************
- * item-ext.c : Exported playlist item functions
+ * item-ext.c : Playlist item management functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: item-ext.c,v 1.12 2004/01/25 17:16:06 zorglub Exp $
+ * $Id: item-ext.c,v 1.13 2004/01/29 17:51:08 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Clément Stenac <zorglub@videolan.org>
#include "vlc_playlist.h"
+/***************************************************************************
+ * Item creation/addition functions
+ ***************************************************************************/
+
/**
- * Add a MRL into the playlist, duration given.
+ * Add a MRL into the playlist, duration and options given
*
* \param p_playlist the playlist to add into
* \param psz_uri the mrl to add to the playlist
* PLAYLIST_END the item will be added at the end of the playlist
* regardless of it's size
* \param i_duration length of the item in milliseconds.
+ * \param ppsz_options an array of options
+ * \param i_options the number of options
* \return The id of the playlist item
*/
-int playlist_AddWDuration( playlist_t *p_playlist, const char * psz_uri,
- const char *psz_name, int i_mode, int i_pos,
- mtime_t i_duration )
+int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri,
+ const char *psz_name, int i_mode, int i_pos,
+ mtime_t i_duration, const char **ppsz_options,
+ int i_options )
+{
+ playlist_item_t * p_item = playlist_ItemNew( p_playlist , psz_uri, psz_name );
+
+ if( p_item == NULL )
+ {
+ msg_Err( p_playlist, "unable to add item to playlist" );
+ return -1;
+ }
+
+ p_item->i_duration = i_duration;
+ p_item->ppsz_options = (char **)ppsz_options;
+ p_item->i_options = i_options;
+
+ return playlist_AddItem( p_playlist, p_item, i_mode, i_pos );
+}
+
+/**
+ * Add a MRL into the playlist.
+ *
+ * \param p_playlist the playlist to add into
+ * \param psz_uri the mrl to add to the playlist
+ * \param psz_name a text giving a name or description of this item
+ * \param i_mode the mode used when adding
+ * \param i_pos the position in the playlist where to add. If this is
+ * PLAYLIST_END the item will be added at the end of the playlist
+ * regardless of it's size
+ * \return The id of the playlist item
+*/
+int playlist_Add( playlist_t *p_playlist, const char * psz_uri,
+ const char *psz_name, int i_mode, int i_pos )
+{
+ return playlist_AddExt ( p_playlist, psz_uri, psz_name, i_mode, i_pos,
+ -1, NULL, 0 );
+}
+
+/**
+ * Create a new item, without adding it to the playlist
+ *
+ * \param psz_uri the mrl of the item
+ * \param psz_name a text giving a name or description of the item
+ * \return the new item or NULL on failure
+ */
+playlist_item_t * __playlist_ItemNew( vlc_object_t *p_obj,
+ const char *psz_uri,
+ const char *psz_name )
{
playlist_item_t * p_item;
p_item = malloc( sizeof( playlist_item_t ) );
if( p_item == NULL )
{
- msg_Err( p_playlist, "out of memory" );
+ return NULL;
}
if( psz_uri == NULL)
{
- msg_Err( p_playlist, "Not adding NULL item");
- return -1;
+ return NULL;
}
memset( p_item, 0, sizeof( playlist_item_t ) );
p_item->psz_uri = strdup( psz_uri );
}
p_item->b_enabled = VLC_TRUE;
p_item->i_group = PLAYLIST_TYPE_MANUAL;
- p_item->i_duration = i_duration;
- playlist_CreateItemCategory( p_item, _("General") );
- playlist_CreateItemCategory( p_item, _("Options") );
- return playlist_AddItem( p_playlist, p_item, i_mode, i_pos );
+ p_item->i_duration = -1;
+ p_item->ppsz_options = NULL;
+ p_item->i_options = 0;
+
+ vlc_mutex_init( p_obj->p_vlc , &p_item->lock );
+
+ playlist_ItemCreateCategory( p_item, _("General") );
+ return p_item;
}
/**
- * Add a MRL into the playlist.
+ * Deletes a playlist item
*
- * \param p_playlist the playlist to add into
- * \param psz_uri the mrl to add to the playlist
- * \param psz_name a text giving a name or description of this item
- * \param i_mode the mode used when adding
- * \param i_pos the position in the playlist where to add. If this is
- * PLAYLIST_END the item will be added at the end of the playlist
- * regardless of it's size
- * \return The id of the playlist item
-*/
-int playlist_Add( playlist_t *p_playlist, const char * psz_uri,
- const char *psz_name, int i_mode, int i_pos )
+ * \param p_item the item to delete
+ * \return nothing
+ */
+void playlist_ItemDelete( playlist_item_t *p_item)
{
- return playlist_AddWDuration ( p_playlist, psz_uri, psz_name, i_mode, i_pos,
- -1 );
+ int i,j;
+
+ vlc_mutex_lock( &p_item->lock );
+
+ if( p_item->psz_name )
+ {
+ free( p_item->psz_name );
+ }
+ if( p_item->psz_uri )
+ {
+ free( p_item->psz_uri );
+ }
+
+ /* Free the info categories. Welcome to the segfault factory */
+ if( p_item->i_categories > 0 )
+ {
+ for( i = 0; i < p_item->i_categories; i++ )
+ {
+ for( j= 0 ; j < p_item->pp_categories[i]->i_infos; j++)
+ {
+ if( p_item->pp_categories[i]->pp_infos[j]->psz_name)
+ {
+ free( p_item->pp_categories[i]->
+ pp_infos[j]->psz_name);
+ }
+ if( p_item->pp_categories[i]->pp_infos[j]->psz_value)
+ {
+ free( p_item->pp_categories[i]->
+ pp_infos[j]->psz_value);
+ }
+ free( p_item->pp_categories[i]->pp_infos[j] );
+ }
+ if( p_item->pp_categories[i]->i_infos )
+ free( p_item->pp_categories[i]->pp_infos );
+ if( p_item->pp_categories[i]->psz_name)
+ {
+ free( p_item->pp_categories[i]->psz_name );
+ }
+ free( p_item->pp_categories[i] );
+ }
+ free( p_item->pp_categories );
+ }
+
+ vlc_mutex_unlock( &p_item->lock );
+ vlc_mutex_destroy( &p_item->lock );
+
+ free( p_item );
}
+/***************************************************************************
+ * Item search functions
+ ***************************************************************************/
+
/**
* Search the position of an item by its id
+ * This function must be entered with the playlist lock
+ *
* \param p_playlist the playlist
* \param i_id the id to find
* \return the position, or VLC_EGENERIC on failure
/**
* Search an item by its id
+ *
* \param p_playlist the playlist
* \param i_id the id to find
* \return the item, or NULL on failure
*/
-playlist_item_t * playlist_GetItemById( playlist_t * p_playlist , int i_id )
+playlist_item_t * playlist_ItemGetById( playlist_t * p_playlist , int i_id )
{
int i;
for( i = 0 ; i < p_playlist->i_size ; i++ )
return NULL;
}
+/**
+ * Search an item by its position
+ * This function must be entered with the playlist lock
+ *
+ * \param p_playlist the playlist
+ * \param i_id the id to find
+ * \return the item, or NULL on failure
+ */
+playlist_item_t * playlist_ItemGetByPos( playlist_t * p_playlist , int i_pos )
+{
+ if( i_pos >= 0 && i_pos < p_playlist->i_size)
+ {
+ return p_playlist->pp_items[i_pos];
+ }
+ else if( p_playlist->i_size > 0)
+ {
+ return p_playlist->pp_items[p_playlist->i_index];
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
/**********************************************************************
* playlist_item_t structure accessors
* These functions give access to the fields of the playlist_item_t
/**
* Set the group of a playlist item
*
+ * \param p_item the item
+ * \return VLC_SUCCESS on success
+ */
+int playlist_ItemSetGroup( playlist_item_t *p_item, int i_group)
+{
+ p_item->i_group = i_group;
+ return VLC_SUCCESS;
+}
+
+/**
+ * Set the group of a playlist item (by position)
+ * This function must be entered with the playlist lock
+ * Legacy function due to disappear (locks the whole playlist)
+ *
* \param p_playlist the playlist
* \param i_pos the postition of the item of which we change the group
* \param i_group the new group
*/
int playlist_SetGroup( playlist_t *p_playlist, int i_pos, int i_group )
{
- char *psz_group;
vlc_value_t val;
- /* Check the existence of the playlist */
- if( p_playlist == NULL)
+ playlist_item_t *p_item;
+ if( !p_playlist )
{
- return VLC_EGENERIC;
+ return VLC_ENOOBJ;
}
- vlc_mutex_lock( &p_playlist->object_lock );
-
- /* Get a correct item */
- if( i_pos >= 0 && i_pos < p_playlist->i_size )
+ p_item = playlist_ItemGetByPos( p_playlist , i_pos );
+ if( !p_item )
{
- }
- else if( p_playlist->i_size > 0 )
- {
- i_pos = p_playlist->i_index;
- }
- else
- {
- return VLC_EGENERIC;
+ return VLC_ENOOBJ;
}
- psz_group = playlist_FindGroup( p_playlist , i_group );
- if( psz_group != NULL)
- {
- p_playlist->pp_items[i_pos]->i_group = i_group ;
- }
- vlc_mutex_unlock( &p_playlist->object_lock );
- val.b_bool = i_pos;
+ vlc_mutex_lock( &p_item->lock );
+ playlist_ItemSetGroup( p_item , i_group );
+ vlc_mutex_unlock( &p_item->lock );
+
+ val.b_bool = (i_pos >= 0 && i_pos < p_playlist->i_size ) ? i_pos : -1;
var_Set( p_playlist, "item-change", val );
return VLC_SUCCESS;
/**
* Set the name of a playlist item
*
+ * \param p_item the item
+ * \param psz_name the new name
+ * \return VLC_SUCCESS on success, VLC_EGENERIC on failure
+ */
+int playlist_ItemSetName( playlist_item_t *p_item, char *psz_name )
+{
+ if( psz_name && p_item )
+ {
+ p_item->psz_name = strdup( psz_name );
+ return VLC_SUCCESS;
+ }
+ return VLC_EGENERIC;
+}
+
+/**
+ * Set the name of a playlist item (by position)
+ * This function must be entered with the playlist lock
+ * Legacy function due to disappear (locks the whole playlist)
+ *
* \param p_playlist the playlist
* \param i_pos the position of the item of which we change the name
* \param psz_name the new name
int playlist_SetName( playlist_t *p_playlist, int i_pos, char *psz_name )
{
vlc_value_t val;
-
- /* Check the existence of the playlist */
- if( p_playlist == NULL)
+ playlist_item_t *p_item;
+ if( !p_playlist )
{
- return VLC_EGENERIC;
+ return VLC_ENOOBJ;
}
- vlc_mutex_lock( &p_playlist->object_lock );
-
- /* Get a correct item */
- if( i_pos >= 0 && i_pos < p_playlist->i_size )
+ p_item = playlist_ItemGetByPos( p_playlist , i_pos );
+ if( !p_item )
{
+ return VLC_ENOOBJ;
}
- else if( p_playlist->i_size > 0 )
- {
- i_pos = p_playlist->i_index;
- }
- else
- {
- return VLC_EGENERIC;
- }
-
- if( p_playlist->pp_items[i_pos]->psz_name)
- free( p_playlist->pp_items[i_pos]->psz_name );
- if( psz_name )
- p_playlist->pp_items[i_pos]->psz_name = strdup( psz_name );
-
- vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_mutex_lock( &p_item->lock );
+ playlist_ItemSetName( p_item , psz_name );
+ vlc_mutex_unlock( &p_item->lock );
- val.b_bool = i_pos;
+ val.b_bool = (i_pos >= 0 && i_pos < p_playlist->i_size ) ? i_pos : -1;
var_Set( p_playlist, "item-change", val );
+
return VLC_SUCCESS;
}
/**
* Set the duration of a playlist item
+ * This function must be entered with the item lock
+ *
+ * \param p_item the item
+ * \param psz_name the new name
+ * \return VLC_SUCCESS on success, VLC_EGENERIC on failure
+ */
+int playlist_ItemSetDuration( playlist_item_t *p_item, mtime_t i_duration )
+{
+ char psz_buffer[MSTRTIME_MAX_SIZE];
+ if( p_item )
+ {
+ p_item->i_duration = i_duration;
+ if( i_duration != -1 )
+ {
+ secstotimestr( psz_buffer, i_duration/1000000 );
+ }
+ else
+ {
+ memcpy( psz_buffer, "--:--:--", sizeof("--:--:--") );
+ }
+ playlist_ItemAddInfo( p_item, _("General") , _("Duration"),
+ "%s", psz_buffer );
+
+ return VLC_SUCCESS;
+ }
+ return VLC_EGENERIC;
+}
+
+/**
+ * Set the duration of a playlist item
+ * This function must be entered with the playlist lock
+ * Legacy function due to disappear (locks the whole playlist)
*
* \param p_playlist the playlist
* \param i_pos the position of the item of which we change the duration
*/
int playlist_SetDuration( playlist_t *p_playlist, int i_pos, mtime_t i_duration )
{
- char psz_buffer[MSTRTIME_MAX_SIZE];
vlc_value_t val;
-
- /* Check the existence of the playlist */
- if( p_playlist == NULL)
- {
- return VLC_EGENERIC;
- }
-
- vlc_mutex_lock( &p_playlist->object_lock );
-
- /* Get a correct item */
- if( i_pos >= 0 && i_pos < p_playlist->i_size )
- {
- }
- else if( p_playlist->i_size > 0 )
- {
- i_pos = p_playlist->i_index;
- }
- else
+ playlist_item_t *p_item;
+ if( !p_playlist )
{
- return VLC_EGENERIC;
+ return VLC_ENOOBJ;
}
- p_playlist->pp_items[i_pos]->i_duration = i_duration;
- if( i_duration != -1 )
- {
- secstotimestr( psz_buffer, i_duration/1000000 );
- }
- else
+ p_item = playlist_ItemGetByPos( p_playlist , i_pos );
+ if( !p_item )
{
- memcpy( psz_buffer, "--:--:--", sizeof("--:--:--") );
+ return VLC_ENOOBJ;
}
- playlist_AddInfo( p_playlist, i_pos, _("General") , _("Duration"),
- "%s", psz_buffer );
- vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_mutex_lock( &p_item->lock );
+ playlist_ItemSetDuration( p_item , i_duration );
+ vlc_mutex_unlock( &p_item->lock );
- val.b_bool = i_pos;
+ val.b_bool = (i_pos >= 0 && i_pos < p_playlist->i_size ) ? i_pos : -1;
var_Set( p_playlist, "item-change", val );
+
return VLC_SUCCESS;
}
{
vlc_value_t val;
int i,j;
+ int i_delay=0;
/* if i_pos is the current played item, playlist should stop playing it */
- if( ( p_playlist->i_status == PLAYLIST_RUNNING) && (p_playlist->i_index == i_pos) )
+ if( ( p_playlist->i_status == PLAYLIST_RUNNING) &&
+ (p_playlist->i_index == i_pos) )
{
playlist_Command( p_playlist, PLAYLIST_STOP, 0 );
}
msg_Dbg( p_playlist, "deleting playlist item « %s »",
p_item->psz_name );
+#if 0
+ vlc_mutex_lock( &p_item->lock );
if( p_item->psz_name )
{
}
/* XXX: what if the item is still in use? */
+#endif
+ playlist_ItemDelete( p_item );
+#if 0
free( p_item );
-
+#endif
if( i_pos <= p_playlist->i_index )
{
p_playlist->i_index--;
return 0;
}
-
-
/**
* Clear all playlist items
*
* item.c : Playlist item functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: item.c,v 1.12 2004/01/17 14:08:37 sigmunau Exp $
+ * $Id: item.c,v 1.13 2004/01/29 17:51:08 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
#include "vlc_playlist.h"
+
+
+
+
/**
* Add a playlist item into a playlist
*
* loadsave.c : Playlist loading / saving functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: loadsave.c,v 1.9 2004/01/25 17:16:06 zorglub Exp $
+ * $Id: loadsave.c,v 1.10 2004/01/29 17:51:08 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
i_id = playlist_Add( p_playlist, psz_uri, psz_uri,
PLAYLIST_INSERT | PLAYLIST_GO , PLAYLIST_END);
- p_item = playlist_GetItemById( p_playlist, i_id );
+ p_item = playlist_ItemGetById( p_playlist, i_id );
p_item->b_autodeletion = VLC_TRUE;
vlc_mutex_unlock( &p_playlist->object_lock );
* playlist.c : Playlist management functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: playlist.c,v 1.78 2004/01/26 23:30:18 fenrir Exp $
+ * $Id: playlist.c,v 1.79 2004/01/29 17:51:08 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
static void PlayItem( playlist_t *p_playlist )
{
playlist_item_t *p_item;
- char **ppsz_options;
- int i_options;
int i, j;
vlc_value_t val;
if( p_playlist->i_index == -1 )
msg_Dbg( p_playlist, "creating new input thread" );
p_item = p_playlist->pp_items[p_playlist->i_index];
- i_options = 0;
- ppsz_options = NULL;
-
- /* Beurk, who the hell have done that ???????, why moving options
- * to playlist in a such *bad* way ? --fenrir_is_asking ...*/
- /* Parse input options */
- for( i = 0 ; i < p_item->i_categories ; i++ )
- {
- if( !strcmp( p_item->pp_categories[i]->psz_name, _("Options") ) )
- {
- msg_Dbg( p_playlist, "Parsing %i options for item", p_item->pp_categories[i]->i_infos );
- for( j = 0; j< p_item->pp_categories[i]->i_infos ; j++ )
- {
- msg_Dbg( p_playlist, "Option : %s",
- p_item->pp_categories[i]->pp_infos[j]->psz_value );
- TAB_APPEND( i_options, ppsz_options,
- p_item->pp_categories[i]->pp_infos[j]->psz_value );
- }
- break;
- }
- }
+ p_item->i_nb_played++;
p_playlist->p_input = input_CreateThread( p_playlist, p_item->psz_uri,
- ppsz_options, i_options );
-
- if( ppsz_options )
- {
- free( ppsz_options );
- }
+ p_item->ppsz_options,
+ p_item->i_options );
val.i_int = p_playlist->i_index;
var_Set( p_playlist, "playlist-current", val);
}
-