Commit 499a3845 authored by Clément Stenac's avatar Clément Stenac

Options as infos were bad in several ways: it broke PLAYLIST_GO, used

much memory, and was inconsistent, especially with input_CreateThread
taking an array of options

* Revert to using array of options

* To add an item with options:
    - either use playlist_ItemNew, ItemAddOption, and then AddItem
      (useful if you don't have all your options in an array)
    - either use playlist_AddExt (use this if all your options are
      already in an array)

* To add an item without options: use playlist_Add

You can still add options after an item has been added by using either
playlist_AddOption or playlist_ItemAddOption

* Attempt to improve API and solve thread safety issues.
  - playlist_Item* functions allow to touch items only.
    p_item->lock must be used when needed
    (playlist_ItemNew, playlist_ItemDelete, playlist_Item*Info,
     playlist_ItemSet* )

  - playlist_ItemGetById and ItemGetByPos give you playlist_items
    for GetByPos, you should have the playlist lock

At the moment, the playlist_Set* and playlist_*Info functions are kept (they work with position) but should be avoided.
parent 6dc60921
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vlc_playlist.h : Playlist functions * vlc_playlist.h : Playlist functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2004 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -75,10 +75,11 @@ struct playlist_item_t ...@@ -75,10 +75,11 @@ struct playlist_item_t
char * psz_uri; /**< mrl of this item */ char * psz_uri; /**< mrl of this item */
mtime_t i_duration; /**< A hint about the duration of this mtime_t i_duration; /**< A hint about the duration of this
* item, in milliseconds*/ * item, in milliseconds*/
int i_categories; /**< Number of info categories */ int i_categories; /**< Number of info categories */
item_info_category_t **pp_categories; item_info_category_t **
/**< Pointer to the first info category */ pp_categories; /**< Pointer to the first info category */
int i_status; /**< unused yet */ int i_options; /**< Number of options */
char ** ppsz_options; /**< Array of options */
int i_nb_played; /**< How many times was this item played ? */ int i_nb_played; /**< How many times was this item played ? */
vlc_bool_t b_autodeletion; /**< Indicates whther this item is to vlc_bool_t b_autodeletion; /**< Indicates whther this item is to
* be deleted after playback. True mean * be deleted after playback. True mean
...@@ -86,8 +87,9 @@ struct playlist_item_t ...@@ -86,8 +87,9 @@ struct playlist_item_t
* after playback, false otherwise */ * after playback, false otherwise */
vlc_bool_t b_enabled; /**< Indicates whether this item is to be vlc_bool_t b_enabled; /**< Indicates whether this item is to be
* played or skipped */ * 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 */ int i_id; /**< Unique id to track this item */
vlc_mutex_t lock; /**< Item cannot be changed without this lock */
}; };
/** /**
...@@ -165,11 +167,18 @@ void playlist_Destroy ( playlist_t * ); ...@@ -165,11 +167,18 @@ void playlist_Destroy ( playlist_t * );
VLC_EXPORT( void, playlist_Command, ( playlist_t *, playlist_command_t, int ) ); 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_Add, ( playlist_t *, const char *, const char *, int, int ) );
VLC_EXPORT( int, playlist_AddWDuration, ( playlist_t *, const char *, const char *, int, int, mtime_t ) ); VLC_EXPORT( int, playlist_AddExt, ( playlist_t *, const char *, const char *, int, int, mtime_t, const char **,int ) );
/* 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_Clear, ( playlist_t * ) ); VLC_EXPORT( int, playlist_Clear, ( playlist_t * ) );
VLC_EXPORT( int, playlist_Delete, ( playlist_t *, int ) ); VLC_EXPORT( int, playlist_Delete, ( playlist_t *, int ) );
VLC_EXPORT( int, playlist_Disable, ( playlist_t *, int ) ); VLC_EXPORT( int, playlist_Disable, ( playlist_t *, int ) );
...@@ -178,13 +187,18 @@ VLC_EXPORT( int, playlist_DisableGroup, ( playlist_t *, int ) ); ...@@ -178,13 +187,18 @@ VLC_EXPORT( int, playlist_DisableGroup, ( playlist_t *, int ) );
VLC_EXPORT( int, playlist_EnableGroup, ( playlist_t *, int ) ); VLC_EXPORT( int, playlist_EnableGroup, ( playlist_t *, int ) );
/* Basic item informations accessors */ /* Basic item informations accessors */
VLC_EXPORT( int, playlist_SetGroup, (playlist_t *, int, int ) ); VLC_EXPORT( int, playlist_ItemSetGroup, (playlist_item_t *, int ) );
VLC_EXPORT( int, playlist_SetName, (playlist_t *, int, char * ) ); VLC_EXPORT( int, playlist_ItemSetName, (playlist_item_t *, char * ) );
VLC_EXPORT( int, playlist_SetDuration, (playlist_t *, int, mtime_t ) ); 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 */ /* Item search functions */
VLC_EXPORT( int, playlist_GetPositionById, (playlist_t *, int) ); 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 */ /* Group management functions */
...@@ -195,20 +209,20 @@ VLC_EXPORT( int, playlist_GroupToId, (playlist_t *, char * ) ); ...@@ -195,20 +209,20 @@ VLC_EXPORT( int, playlist_GroupToId, (playlist_t *, char * ) );
/* Info functions */ /* Info functions */
VLC_EXPORT( char * , playlist_GetInfo, ( playlist_t * , int, const char *, const char *) ); 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_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_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_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 */ /* Option functions */
VLC_EXPORT( int, playlist_AddOption, (playlist_t *, int, const char *, ...) ); VLC_EXPORT( int, playlist_AddOption, (playlist_t *, int, const char *) );
VLC_EXPORT( int, playlist_AddItemOption, (playlist_item_t *, const char *, ...) ); VLC_EXPORT( int, playlist_ItemAddOption, (playlist_item_t *, const char *) );
/* Playlist sorting */ /* Playlist sorting */
#define playlist_SortID(p, i) playlist_Sort( p, SORT_ID, i) #define playlist_SortID(p, i) playlist_Sort( p, SORT_ID, i)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* cddax.c : CD digital audio input module for vlc using libcdio * cddax.c : CD digital audio input module for vlc using libcdio
***************************************************************************** *****************************************************************************
* Copyright (C) 2000,2003 VideoLAN * 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> * Authors: Rocky Bernstein <rocky@panix.com>
* Laurent Aimar <fenrir@via.ecp.fr> * Laurent Aimar <fenrir@via.ecp.fr>
...@@ -314,8 +314,13 @@ static void CDDASeek( input_thread_t * p_input, off_t i_off ) ...@@ -314,8 +314,13 @@ static void CDDASeek( input_thread_t * p_input, off_t i_off )
if ( str ) { \ if ( str ) { \
dbg_print( INPUT_DBG_META, "field %s: %s\n", title, str); \ dbg_print( INPUT_DBG_META, "field %s: %s\n", title, str); \
input_AddInfo( p_cat, _(title), "%s", 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 ); \ _(title), "%s" , str ); \
vlc_mutex_unlock( &p_item->lock ); \
} }
...@@ -325,9 +330,10 @@ static void InformationCreate( input_thread_t *p_input ) ...@@ -325,9 +330,10 @@ static void InformationCreate( input_thread_t *p_input )
playlist_t *p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, playlist_t *p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST,
FIND_PARENT ); FIND_PARENT );
input_info_category_t *p_cat; input_info_category_t *p_cat;
playlist_item_t *p_item;
p_cat = input_InfoCategory( p_input, "General" ); p_cat = input_InfoCategory( p_input, "General" );
#ifdef HAVE_LIBCDDB #ifdef HAVE_LIBCDDB
if (p_cdda->i_cddb_enabled) { if (p_cdda->i_cddb_enabled) {
...@@ -669,6 +675,7 @@ CDDACreatePlayListItem(const input_thread_t *p_input, cdda_data_t *p_cdda, ...@@ -669,6 +675,7 @@ CDDACreatePlayListItem(const input_thread_t *p_input, cdda_data_t *p_cdda,
char *p_author; char *p_author;
char *p_title; char *p_title;
char *config_varname = MODULE_STRING "-title-format"; char *config_varname = MODULE_STRING "-title-format";
playlist_item_t *p_item;
#ifdef HAVE_LIBCDDB #ifdef HAVE_LIBCDDB
if (p_cdda->i_cddb_enabled) { if (p_cdda->i_cddb_enabled) {
...@@ -685,54 +692,63 @@ CDDACreatePlayListItem(const input_thread_t *p_input, cdda_data_t *p_cdda, ...@@ -685,54 +692,63 @@ CDDACreatePlayListItem(const input_thread_t *p_input, cdda_data_t *p_cdda,
dbg_print( INPUT_DBG_META, "mrl: %s, title: %s, duration, %ld, pos %d", dbg_print( INPUT_DBG_META, "mrl: %s, title: %s, duration, %ld, pos %d",
psz_mrl, p_title, (long int) i_duration / 1000000 , i_pos ); psz_mrl, p_title, (long int) i_duration / 1000000 , i_pos );
playlist_AddWDuration( p_playlist, psz_mrl, p_title, playlist_operation, playlist_AddExt( p_playlist, psz_mrl, p_title, playlist_operation,
i_pos, i_duration ); i_pos, i_duration , NULL, 0);
if( i_pos == PLAYLIST_END ) i_pos = p_playlist->i_size - 1; 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 = p_author =
CDDAFormatStr( p_input, p_cdda, CDDAFormatStr( p_input, p_cdda,
config_GetPsz( p_input, MODULE_STRING "-author-format" ), config_GetPsz( p_input, MODULE_STRING "-author-format" ),
psz_mrl, i_track ); 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 #ifdef HAVE_LIBCDDB
if (p_cdda->i_cddb_enabled) { if (p_cdda->i_cddb_enabled) {
const char *psz_general_cat = _("General"); const char *psz_general_cat = _("General");
playlist_AddInfo( p_playlist, i_pos, psz_general_cat, _("Album"), playlist_ItemAddInfo( p_item, psz_general_cat, _("Album"),
"%s", p_cdda->cddb.disc->title); "%s", p_cdda->cddb.disc->title);
playlist_AddInfo( p_playlist, i_pos, psz_general_cat, _("Disc Artist(s)"), playlist_ItemAddInfo( p_item, psz_general_cat, _("Disc Artist(s)"),
"%s", p_cdda->cddb.disc->artist); "%s", p_cdda->cddb.disc->artist);
playlist_AddInfo( p_playlist, i_pos, psz_general_cat, playlist_ItemAddInfo( p_item, psz_general_cat,
_("CDDB Disc Category"), _("CDDB Disc Category"),
"%s", CDDB_CATEGORY[p_cdda->cddb.disc->category]); "%s", CDDB_CATEGORY[p_cdda->cddb.disc->category]);
playlist_AddInfo( p_playlist, i_pos, psz_general_cat, _("Genre"), playlist_ItemAddInfo( p_item, psz_general_cat, _("Genre"),
"%s", p_cdda->cddb.disc->genre); "%s", p_cdda->cddb.disc->genre);
if ( p_cdda->cddb.disc->discid ) { if ( p_cdda->cddb.disc->discid ) {
playlist_AddInfo( p_playlist, i_pos, psz_general_cat, _("CDDB Disc ID"), playlist_ItemAddInfo( p_item, psz_general_cat, _("CDDB Disc ID"),
"%x", p_cdda->cddb.disc->discid ); "%x", p_cdda->cddb.disc->discid );
} }
if (p_cdda->cddb.disc->year != 0) { if (p_cdda->cddb.disc->year != 0) {
playlist_AddInfo( p_playlist, i_pos, psz_general_cat, playlist_ItemAddInfo( p_item, psz_general_cat,
_("Year"), "%5d", p_cdda->cddb.disc->year ); _("Year"), "%5d", p_cdda->cddb.disc->year );
} }
if (p_cdda->i_cddb_enabled) { if (p_cdda->i_cddb_enabled) {
cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc, cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
i_track-1); i_track-1);
if (t != NULL && t->artist != NULL) { if (t != NULL && t->artist != NULL) {
playlist_AddInfo( p_playlist, i_pos, psz_general_cat, playlist_ItemAddInfo( p_item, psz_general_cat,
_("Track Artist"), "%s", t->artist ); _("Track Artist"), "%s", t->artist );
playlist_AddInfo( p_playlist, i_pos, psz_general_cat, playlist_ItemAddInfo( p_item , psz_general_cat,
_("Track Title"), "%s", t->title ); _("Track Title"), "%s", t->title );
} }
} }
} }
#endif /*HAVE_LIBCDDB*/ #endif /*HAVE_LIBCDDB*/
vlc_mutex_unlock( &p_item->lock );
} }
static int static int
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* to go here. * to go here.
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2003, 2004 VideoLAN * 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> * Authors: Rocky Bernstein <rocky@panix.com>
* Johan Bilien <jobi@via.ecp.fr> * Johan Bilien <jobi@via.ecp.fr>
...@@ -1003,37 +1003,53 @@ VCDUpdateVar( input_thread_t *p_input, int i_num, int i_action, ...@@ -1003,37 +1003,53 @@ VCDUpdateVar( input_thread_t *p_input, int i_num, int i_action,
static inline void static inline void
MetaInfoAddStr(input_thread_t *p_input, input_info_category_t *p_cat, MetaInfoAddStr(input_thread_t *p_input, input_info_category_t *p_cat,
playlist_t *p_playlist, char *title, playlist_t *p_playlist, char *title,
const char *str) const char *str)
{ {
thread_vcd_data_t *p_vcd = (thread_vcd_data_t *) p_input->p_access_data; 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); dbg_print( INPUT_DBG_META, "field: %s: %s\n", title, str);
input_AddInfo( p_cat, title, "%s", str ); input_AddInfo( p_cat, title, "%s", str );
playlist_AddInfo( p_playlist, -1, p_cat->psz_name, 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 static inline void
MetaInfoAddNum(input_thread_t *p_input, input_info_category_t *p_cat, MetaInfoAddNum(input_thread_t *p_input, input_info_category_t *p_cat,
playlist_t *p_playlist, char *title, int num) playlist_t *p_playlist, char *title, int num)
{ {
thread_vcd_data_t *p_vcd = (thread_vcd_data_t *) p_input->p_access_data; 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); dbg_print( INPUT_DBG_META, "field %s: %d\n", title, num);
input_AddInfo( p_cat, title, "%d", 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) \ #define addstr(title, str) \
MetaInfoAddStr( p_input, p_cat, p_playlist, title, str ); MetaInfoAddStr( p_input, p_cat, p_playlist, title, str );
#define addnum(title, num) \ #define addnum(title, num) \
MetaInfoAddNum( p_input, p_cat, p_playlist, title, num ); MetaInfoAddNum( p_input, p_cat, p_playlist, title, num );
static void InformationCreate( input_thread_t *p_input ) static void InformationCreate( input_thread_t *p_input )
{ {
thread_vcd_data_t *p_vcd = (thread_vcd_data_t *) p_input->p_access_data; thread_vcd_data_t *p_vcd = (thread_vcd_data_t *) p_input->p_access_data;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* speex.c: speex decoder/packetizer/encoder module making use of libspeex. * speex.c: speex decoder/packetizer/encoder module making use of libspeex.
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * 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> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -471,8 +471,19 @@ static void ParseSpeexComments( decoder_t *p_dec, ogg_packet *p_oggpacket ) ...@@ -471,8 +471,19 @@ static void ParseSpeexComments( decoder_t *p_dec, ogg_packet *p_oggpacket )
p_mode = speex_mode_list[p_sys->p_header->mode]; p_mode = speex_mode_list[p_sys->p_header->mode];
input_AddInfo( p_cat, _("Mode"), "%s%s", input_AddInfo( p_cat, _("Mode"), "%s%s",
p_mode->modeName, p_sys->p_header->vbr ? " VBR" : "" ); p_mode->modeName, p_sys->p_header->vbr ? " VBR" : "" );
playlist_AddInfo( p_playlist, -1, _("Speex comment") , _("Mode"), "%s%s",
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" : "" ); p_mode->modeName, p_sys->p_header->vbr ? " VBR" : "" );
if( p_oggpacket->bytes < 8 ) if( p_oggpacket->bytes < 8 )
...@@ -489,7 +500,9 @@ static void ParseSpeexComments( decoder_t *p_dec, ogg_packet *p_oggpacket ) ...@@ -489,7 +500,9 @@ static void ParseSpeexComments( decoder_t *p_dec, ogg_packet *p_oggpacket )
} }
input_AddInfo( p_cat, p_buf, "" ); 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 ); if( p_playlist ) vlc_object_release( p_playlist );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* theora.c: theora decoder module making use of libtheora. * theora.c: theora decoder module making use of libtheora.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * 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> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -340,6 +340,7 @@ static void ParseTheoraComments( decoder_t *p_dec ) ...@@ -340,6 +340,7 @@ static void ParseTheoraComments( decoder_t *p_dec )
input_InfoCategory( p_input, _("Theora comment") ); input_InfoCategory( p_input, _("Theora comment") );
playlist_t *p_playlist = vlc_object_find( p_dec, VLC_OBJECT_PLAYLIST, playlist_t *p_playlist = vlc_object_find( p_dec, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE ); FIND_ANYWHERE );
playlist_item_t *p_item;
int i = 0; int i = 0;
char *psz_name, *psz_value, *psz_comment; char *psz_name, *psz_value, *psz_comment;
while ( i < p_dec->p_sys->tc.comments ) while ( i < p_dec->p_sys->tc.comments )
...@@ -357,8 +358,18 @@ static void ParseTheoraComments( decoder_t *p_dec ) ...@@ -357,8 +358,18 @@ static void ParseTheoraComments( decoder_t *p_dec )
*psz_value = '\0'; *psz_value = '\0';
psz_value++; psz_value++;
input_AddInfo( p_cat, psz_name, psz_value ); input_AddInfo( p_cat, psz_name, psz_value );
playlist_AddInfo( p_playlist, -1, _("Theora comment") , vlc_mutex_lock( &p_playlist->object_lock );
psz_name, psz_value ); 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 ); free( psz_comment );
i++; i++;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vorbis.c: vorbis decoder/encoder/packetizer module making use of libvorbis. * vorbis.c: vorbis decoder/encoder/packetizer module making use of libvorbis.
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2003 VideoLAN * 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> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -456,6 +456,7 @@ static void ParseVorbisComments( decoder_t *p_dec ) ...@@ -456,6 +456,7 @@ static void ParseVorbisComments( decoder_t *p_dec )
input_InfoCategory( p_input, _("Vorbis comment") ); input_InfoCategory( p_input, _("Vorbis comment") );
playlist_t *p_playlist = vlc_object_find( p_dec, VLC_OBJECT_PLAYLIST, playlist_t *p_playlist = vlc_object_find( p_dec, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE ); FIND_ANYWHERE );
playlist_item_t *p_item;
int i = 0; int i = 0;
char *psz_name, *psz_value, *psz_comment; char *psz_name, *psz_value, *psz_comment;
while ( i < p_dec->p_sys->vc.comments ) while ( i < p_dec->p_sys->vc.comments )
...@@ -473,8 +474,18 @@ static void ParseVorbisComments( decoder_t *p_dec ) ...@@ -473,8 +474,18 @@ static void ParseVorbisComments( decoder_t *p_dec )
*psz_value = '\0'; *psz_value = '\0';
psz_value++; psz_value++;
input_AddInfo( p_cat, psz_name, psz_value ); input_AddInfo( p_cat, psz_name, psz_value );
playlist_AddInfo( p_playlist, -1, _("Vorbis comment") , vlc_mutex_lock( &p_playlist->object_lock );
psz_name, psz_value ); 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 ); free( psz_comment );
i++; i++;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* http.c : http mini-server ;) * http.c : http mini-server ;)
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2004 VideoLAN * 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> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* Laurent Aimar <fenrir@via.ecp.fr> * Laurent Aimar <fenrir@via.ecp.fr>
...@@ -125,7 +125,7 @@ static void uri_decode_url_encoded( char *psz ); ...@@ -125,7 +125,7 @@ static void uri_decode_url_encoded( char *psz );
static char *Find_end_MRL( char *psz ); 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 );
/***************************************************************************** /*****************************************************************************
* *
...@@ -1764,7 +1764,7 @@ static void MacroDo( httpd_file_callback_args_t *p_args, ...@@ -1764,7 +1764,7 @@ static void MacroDo( httpd_file_callback_args_t *p_args,
uri_extract_value( p_request, "mrl", mrl, 512 ); uri_extract_value( p_request, "mrl", mrl, 512 );
uri_decode_url_encoded( mrl ); 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 ) if( !p_item || !p_item->psz_uri || !*p_item->psz_uri )
{ {
...@@ -2870,7 +2870,7 @@ static char *Find_end_MRL( char *psz ) ...@@ -2870,7 +2870,7 @@ static char *Find_end_MRL( char *psz )
* create an item with all informations in it, and return the item. * create an item with all informations in it, and return the item.
* return NULL if there is an error. * 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 **ppsz_options = NULL;
char *mrl; char *mrl;
...@@ -2967,17 +2967,10 @@ playlist_item_t * parse_MRL( char *psz ) ...@@ -2967,17 +2967,10 @@ playlist_item_t * parse_MRL( char *psz )
else else
{ {
/* now create an item */ /* now create an item */
p_item = malloc( sizeof( playlist_item_t ) ); p_item = playlist_ItemNew( p_intf, mrl, mrl);
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;
for( i = 0 ; i< i_options ; i++ ) for( i = 0 ; i< i_options ; i++ )
{ {
playlist_AddItemOption( p_item, ppsz_options[i] ); playlist_ItemAddOption( p_item, ppsz_options[i] );
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* id3tag.c: id3 tag parser/skipper based on libid3tag * id3tag.c: id3 tag parser/skipper based on libid3tag
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2004 VideoLAN * 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> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -85,7 +85,14 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size ) ...@@ -85,7 +85,14 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size )
while ( ( p_frame = id3_tag_findframe( p_id3_tag , "T", i ) ) ) 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] ); int i_strings = id3_field_getnstrings( &p_frame->fields[1] );
...@@ -101,7 +108,7 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size ) ...@@ -101,7 +108,7 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size )
{ {
input_AddInfo( p_category, (char *)p_frame->description, input_AddInfo( p_category, (char *)p_frame->description,
ppsz_genres[atoi(psz_temp)]); ppsz_genres[atoi(psz_temp)]);
playlist_AddItemInfo( p_item, "ID3", playlist_ItemAddInfo( p_item, "ID3",
(char *)p_frame->description, (char *)p_frame->description,
ppsz_genres[atoi(psz_temp)]); ppsz_genres[atoi(psz_temp)]);
} }
...@@ -109,7 +116,7 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size ) ...@@ -109,7 +116,7 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size )
{ {
input_AddInfo( p_category, (char *)p_frame->description, input_AddInfo( p_category, (char *)p_frame->description,
psz_temp ); psz_temp );
playlist_AddItemInfo( p_item, "ID3", playlist_ItemAddInfo( p_item, "ID3",
(char *)p_frame->description, (char *)p_frame->description,
psz_temp); psz_temp);
} }
...@@ -128,7 +135,7 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size ) ...@@ -128,7 +135,7 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size )
} }
input_AddInfo( p_category, (char *)p_frame->description, input_AddInfo( p_category, (char *)p_frame->description,
psz_temp ); psz_temp );
playlist_AddItemInfo( p_item, "ID3", playlist_ItemAddInfo( p_item, "ID3",
(char *)p_frame->description, (char *)p_frame->description,
psz_temp); psz_temp);
} }
...@@ -136,13 +143,13 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size ) ...@@ -136,13 +143,13 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size )
{ {
if( p_item ) if( p_item )
{ {
playlist_AddItemInfo( p_item, playlist_ItemAddInfo( p_item,
_("General"), _("Author"), psz_temp); _("General"), _("Author"), psz_temp);
val.b_bool = VLC_TRUE; val.b_bool = VLC_TRUE;
} }
input_AddInfo( p_category, (char *)p_frame->description, input_AddInfo( p_category, (char *)p_frame->description,
psz_temp ); psz_temp );
playlist_AddItemInfo( p_item, "ID3", playlist_ItemAddInfo( p_item, "ID3",
(char *)p_frame->description, (char *)p_frame->description,
psz_temp); psz_temp);
} }
...@@ -150,13 +157,14 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size ) ...@@ -150,13 +157,14 @@ static void ParseID3Tag( input_thread_t *p_input, uint8_t *p_data, int i_size )
{ {
input_AddInfo( p_category, (char *)p_frame->description, input_AddInfo( p_category, (char *)p_frame->description,
psz_temp ); psz_temp );
playlist_AddItemInfo( p_item, "ID3", playlist_ItemAddInfo( p_item, "ID3",
(char *)p_frame->description, (char *)p_frame->description,
psz_temp); psz_temp);
} }
free( psz_temp ); free( psz_temp );
} }
i++; i++;
vlc_mutex_unlock( &p_item->lock );
} }
id3_tag_delete( p_id3_tag ); id3_tag_delete( p_id3_tag );
if(val.b_bool == VLC_TRUE ) if(val.b_bool == VLC_TRUE )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* pda_callbacks.c : Callbacks for the pda Linux Gtk+ plugin. * pda_callbacks.c : Callbacks for the pda Linux Gtk+ plugin.
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * 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> * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
* *
...@@ -133,16 +133,10 @@ void PlaylistAddItem(GtkWidget *widget, gchar *name, char **ppsz_options, int i_ ...@@ -133,16 +133,10 @@ void PlaylistAddItem(GtkWidget *widget, gchar *name, char **ppsz_options, int i_
else else
#endif #endif
{ {
i_id = playlist_Add( p_playlist, (const char*)name, i_id = playlist_AddExt( p_playlist, (const char*)name,
(const char*)name, (const char*)name,
PLAYLIST_APPEND, PLAYLIST_END ); PLAYLIST_APPEND, PLAYLIST_END,
ppsz_options, i_pos );
i_pos = playlist_GetPositionById( p_playlist, i_id );
for( i = 0 ; i< i_size ; i++ )
{
playlist_AddOption( p_playlist, i_pos , ppsz_options[i] );
}
} }
/* Cleanup memory */ /* Cleanup memory */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* iteminfo.cpp : wxWindows plugin for vlc * iteminfo.cpp : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2004 VideoLAN * 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: Clment Stenac <zorglub@videolan.org> * Authors: Clment Stenac <zorglub@videolan.org>
* *
...@@ -178,7 +178,7 @@ wxPanel *ItemInfoDialog::InfoPanel( wxWindow* parent ) ...@@ -178,7 +178,7 @@ wxPanel *ItemInfoDialog::InfoPanel( wxWindow* parent )
author_text = author_text =
new wxTextCtrl( info_panel, Uri_Event, new wxTextCtrl( info_panel, Uri_Event,
wxU( playlist_GetItemInfo( p_item, wxU( playlist_ItemGetInfo( p_item,
_("General"), _("Author") ) ), _("General"), _("Author") ) ),
wxDefaultPosition, wxSize( 300, -1 ), wxDefaultPosition, wxSize( 300, -1 ),
wxTE_PROCESS_ENTER); wxTE_PROCESS_ENTER);
...@@ -305,9 +305,10 @@ void ItemInfoDialog::UpdateInfo() ...@@ -305,9 +305,10 @@ void ItemInfoDialog::UpdateInfo()
*****************************************************************************/ *****************************************************************************/
void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) 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_name = strdup( name_text->GetLineText(0).mb_str() );
p_item->psz_uri = strdup( uri_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() ); author_text->GetLineText(0).mb_str() );
vlc_bool_t b_old_enabled = p_item->b_enabled; vlc_bool_t b_old_enabled = p_item->b_enabled;
...@@ -335,6 +336,7 @@ void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) ...@@ -335,6 +336,7 @@ void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
} }
p_item->b_enabled = enabled_checkbox->IsChecked() ? VLC_TRUE : VLC_FALSE ; p_item->b_enabled = enabled_checkbox->IsChecked() ? VLC_TRUE : VLC_FALSE ;
vlc_mutex_unlock( &p_item->lock );
EndModal( wxID_OK ); EndModal( wxID_OK );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* open.cpp : wxWindows plugin for vlc * open.cpp : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2004 VideoLAN * 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> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -890,11 +890,10 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) ...@@ -890,11 +890,10 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
for( int i = 0; i < (int)mrl.GetCount(); i++ ) for( int i = 0; i < (int)mrl.GetCount(); i++ )
{ {
int i_options = 0; int i_options = 0;
playlist_item_t *p_item =
int i_id = playlist_Add( p_playlist, (const char *)mrl[i].mb_str(), playlist_ItemNew( p_intf,
(const char *)mrl[i].mb_str(), (const char*)mrl[i].mb_str(),
PLAYLIST_APPEND, PLAYLIST_END ); (const char *)mrl[i].mb_str() );
playlist_item_t *p_item = playlist_GetItemById( p_playlist , i_id );
/* Count the input options */ /* Count the input options */
while( i + i_options + 1 < (int)mrl.GetCount() && while( i + i_options + 1 < (int)mrl.GetCount() &&
...@@ -906,7 +905,7 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) ...@@ -906,7 +905,7 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
/* Insert options */ /* Insert options */
for( int j = 0; j < i_options; j++ ) 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 */ /* Get the options from the subtitles dialog */
...@@ -914,7 +913,7 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) ...@@ -914,7 +913,7 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
{ {
for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ ) 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() );
} }
} }
...@@ -923,10 +922,13 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) ...@@ -923,10 +922,13 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
{ {
for( int j = 0; j < (int)sout_mrl.GetCount(); j++ ) 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 ) if( !i && i_open_arg )
{ {
int i_pos = playlist_GetPositionById( p_playlist , i_id ); int i_pos = playlist_GetPositionById( p_playlist , i_id );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* playlist.cpp : wxWindows plugin for vlc * playlist.cpp : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2004 VideoLAN * 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 Teulire <ipkiss@via.ecp.fr> * Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* *
...@@ -405,24 +405,29 @@ void Playlist::UpdateItem( int i ) ...@@ -405,24 +405,29 @@ void Playlist::UpdateItem( int i )
playlist_t *p_playlist = playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE ); FIND_ANYWHERE );
if( p_playlist == NULL ) if( p_playlist == NULL )
{ {
return; 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); vlc_object_release(p_playlist);
return; 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") ) ) ); _("General") , _("Author") ) ) );
char *psz_group = playlist_FindGroup(p_playlist, char *psz_group = playlist_FindGroup(p_playlist,
p_playlist->pp_items[i]->i_group); p_item->i_group);
listview->SetItem( i, 2, listview->SetItem( i, 2,
wxL2U( psz_group ? psz_group : _("Normal") ) ); 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; wxListItem listitem;
listitem.m_itemId = i; listitem.m_itemId = i;
...@@ -431,7 +436,7 @@ void Playlist::UpdateItem( int i ) ...@@ -431,7 +436,7 @@ void Playlist::UpdateItem( int i )
} }
char psz_duration[MSTRTIME_MAX_SIZE]; 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 ); if( dur != -1 ) secstotimestr( psz_duration, dur/1000000 );
else memcpy( psz_duration , "-:--:--", sizeof("-:--:--") ); else memcpy( psz_duration , "-:--:--", sizeof("-:--:--") );
listview->SetItem( i, 3, wxU(psz_duration) ); listview->SetItem( i, 3, wxU(psz_duration) );
...@@ -611,9 +616,9 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) ) ...@@ -611,9 +616,9 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
formats[dialog.GetFilterIndex()].psz_module ); formats[dialog.GetFilterIndex()].psz_module );
} }
} }
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
} }
...@@ -900,6 +905,7 @@ void Playlist::OnEnableSelection( wxCommandEvent& WXUNUSED(event) ) ...@@ -900,6 +905,7 @@ void Playlist::OnEnableSelection( wxCommandEvent& WXUNUSED(event) )
{ {
if( listview->IsSelected( item ) ) if( listview->IsSelected( item ) )
{ {
/*XXX*/
playlist_Enable( p_playlist, item ); playlist_Enable( p_playlist, item );
UpdateItem( item ); UpdateItem( item );
} }
...@@ -921,6 +927,7 @@ void Playlist::OnDisableSelection( wxCommandEvent& WXUNUSED(event) ) ...@@ -921,6 +927,7 @@ void Playlist::OnDisableSelection( wxCommandEvent& WXUNUSED(event) )
{ {
if( listview->IsSelected( item ) ) if( listview->IsSelected( item ) )
{ {
/*XXX*/
playlist_Disable( p_playlist, item ); playlist_Disable( p_playlist, item );
UpdateItem( item ); UpdateItem( item );
} }
...@@ -1021,10 +1028,14 @@ void Playlist::ShowInfos( int i_item ) ...@@ -1021,10 +1028,14 @@ void Playlist::ShowInfos( int i_item )
} }
if( iteminfo_dialog == NULL ) 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( iteminfo_dialog = new ItemInfoDialog(
p_intf, p_playlist->pp_items[i_item], this ); p_intf, p_item , this );
if( iteminfo_dialog->ShowModal() == wxID_OK ) if( iteminfo_dialog->ShowModal() == wxID_OK )
UpdateItem( i_item ); UpdateItem( i_item );
delete iteminfo_dialog; delete iteminfo_dialog;
...@@ -1060,6 +1071,7 @@ void Playlist::OnEnDis( wxCommandEvent& event ) ...@@ -1060,6 +1071,7 @@ void Playlist::OnEnDis( wxCommandEvent& event )
switch( event.GetId() ) switch( event.GetId() )
{ {
case EnableGroup_Event: case EnableGroup_Event:
/*XXX*/
playlist_EnableGroup( p_playlist , playlist_EnableGroup( p_playlist ,
p_playlist->pp_items[i_item]->i_group ); p_playlist->pp_items[i_item]->i_group );
break; break;
...@@ -1168,6 +1180,7 @@ int ItemChanged( vlc_object_t *p_this, const char *psz_variable, ...@@ -1168,6 +1180,7 @@ int ItemChanged( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void *param ) vlc_value_t old_val, vlc_value_t new_val, void *param )
{ {
Playlist *p_playlist_dialog = (Playlist *)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 ); p_playlist_dialog->UpdateItem( new_val.i_int );
return 0; return 0;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* stream.cpp : wxWindows plugin for vlc * stream.cpp : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2004 VideoLAN * 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: Clment Stenac <zorglub@videolan.org> * Authors: Clment Stenac <zorglub@videolan.org>
* *
...@@ -204,11 +204,9 @@ void StreamDialog::OnStart( wxCommandEvent& event ) ...@@ -204,11 +204,9 @@ void StreamDialog::OnStart( wxCommandEvent& event )
for( int i = 0; i < (int)p_open_dialog->mrl.GetCount(); i++ ) 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(),
(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 );
int i_options = 0; int i_options = 0;
/* Count the input options */ /* Count the input options */
...@@ -222,7 +220,7 @@ void StreamDialog::OnStart( wxCommandEvent& event ) ...@@ -222,7 +220,7 @@ void StreamDialog::OnStart( wxCommandEvent& event )
/* Insert options */ /* Insert options */
for( int j = 0; j < i_options; j++ ) 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() ); p_open_dialog->mrl[i + j + 1].mb_str() );
} }
...@@ -231,18 +229,21 @@ void StreamDialog::OnStart( wxCommandEvent& event ) ...@@ -231,18 +229,21 @@ void StreamDialog::OnStart( wxCommandEvent& event )
{ {
for( int j = 0; j < (int)sout_mrl.GetCount(); j++ ) for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
{ {
playlist_AddOption( p_playlist, i_pos , playlist_ItemAddOption( p_item , sout_mrl[j].mb_str() );
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", msg_Dbg(p_intf,"playings %s",
(const char *)p_open_dialog->mrl[i].mb_str()); (const char *)p_open_dialog->mrl[i].mb_str());
i += i_options; i += i_options;
} }
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
Hide(); Hide();
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sap.c : SAP interface module * sap.c : SAP interface module
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Arnaud Schauly <gitan@via.ecp.fr>
* Clment Stenac <zorglub@via.ecp.fr> * Clment Stenac <zorglub@via.ecp.fr>
...@@ -647,6 +647,7 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) ...@@ -647,6 +647,7 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
vlc_bool_t b_http = VLC_FALSE; vlc_bool_t b_http = VLC_FALSE;
char *psz_http_path = NULL; char *psz_http_path = NULL;
playlist_t *p_playlist = NULL; playlist_t *p_playlist = NULL;
playlist_item_t *p_item;
psz_uri_default = NULL; psz_uri_default = NULL;
if( p_sd->i_media > 1 ) if( p_sd->i_media > 1 )
...@@ -670,8 +671,8 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) ...@@ -670,8 +671,8 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
PLAYLIST_CHECK_INSERT, PLAYLIST_END ); PLAYLIST_CHECK_INSERT, PLAYLIST_END );
if( i_id != -1 ) if( i_id != -1 )
{ {
i_pos = playlist_GetPositionById( p_playlist, i_id ); playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
playlist_SetGroup( p_playlist, i_pos, p_intf->p_sys->i_group ); playlist_ItemSetGroup( p_item, p_intf->p_sys->i_group );
} }
/* Remember it */ /* Remember it */
...@@ -838,7 +839,7 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) ...@@ -838,7 +839,7 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
p_sd->psz_sessionname, p_sd->psz_sessionname,
psz_item_uri ); psz_item_uri );
p_item = playlist_GetItemById( p_playlist, p_item = playlist_ItemGetById( p_playlist,
p_intf->p_sys->pp_announces[i]->i_id ); p_intf->p_sys->pp_announces[i]->i_id );
/* Change the name in the item */ /* Change the name in the item */
...@@ -864,8 +865,13 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) ...@@ -864,8 +865,13 @@ static void sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
i_id = playlist_Add ( p_playlist, psz_item_uri , i_id = playlist_Add ( p_playlist, psz_item_uri ,
p_sd->psz_sessionname, p_sd->psz_sessionname,
PLAYLIST_CHECK_INSERT, PLAYLIST_END ); PLAYLIST_CHECK_INSERT, PLAYLIST_END );
i_pos = playlist_GetPositionById( p_playlist, i_id ); p_item = playlist_ItemGetById( p_playlist, i_id );
playlist_SetGroup( p_playlist, i_pos, i_group ); if( p_item )
{
vlc_mutex_lock( &p_item->lock );
playlist_ItemSetGroup( p_item, i_group );
vlc_mutex_unlock( &p_item->lock );
}
/* Then remember it */ /* Then remember it */
p_announce = (struct sap_announce_t *)malloc( p_announce = (struct sap_announce_t *)malloc(
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* decoders. * decoders.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2004 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -787,7 +787,7 @@ static int InitThread( input_thread_t * p_input ) ...@@ -787,7 +787,7 @@ static int InitThread( input_thread_t * p_input )
if( p_playlist ) if( p_playlist )
{ {
playlist_SetDuration( p_playlist, -1 , i_length ); 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 ); var_Set( p_playlist, "item-change", val );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
...@@ -808,7 +808,7 @@ static int InitThread( input_thread_t * p_input ) ...@@ -808,7 +808,7 @@ static int InitThread( input_thread_t * p_input )
var_Get( p_input, "sub-file", &val ); var_Get( p_input, "sub-file", &val );
if( val.psz_string && *val.psz_string ) 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; subtitle_demux_t *p_sub;
if( ( p_sub = subtitle_New( p_input, strdup(val.psz_string), if( ( p_sub = subtitle_New( p_input, strdup(val.psz_string),
i_microsecondperframe ) ) ) i_microsecondperframe ) ) )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libvlc.c: main libvlc source * libvlc.c: main libvlc source
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2004 VideoLAN * 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> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -801,7 +801,6 @@ int VLC_AddTarget( int i_object, char const *psz_target, ...@@ -801,7 +801,6 @@ int VLC_AddTarget( int i_object, char const *psz_target,
char const **ppsz_options, int i_options, char const **ppsz_options, int i_options,
int i_mode, int i_pos ) int i_mode, int i_pos )
{ {
int i;
int i_err; int i_err;
playlist_t *p_playlist; playlist_t *p_playlist;
vlc_t *p_vlc = vlc_current_object( i_object ); vlc_t *p_vlc = vlc_current_object( i_object );
...@@ -827,13 +826,8 @@ int VLC_AddTarget( int i_object, char const *psz_target, ...@@ -827,13 +826,8 @@ int VLC_AddTarget( int i_object, char const *psz_target,
vlc_object_yield( p_playlist ); vlc_object_yield( p_playlist );
} }
i_err = playlist_Add( p_playlist, psz_target, psz_target, i_err = playlist_AddExt( p_playlist, psz_target, psz_target,
i_mode, i_pos ); i_mode, i_pos, -1, ppsz_options, i_options);
for( i = 0 ; i< i_options ; i++ )
{
playlist_AddOption( p_playlist, i_err , ppsz_options[i] );
}
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* win32_specific.c: Win32 specific features * win32_specific.c: Win32 specific features
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2004 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* Gildas Bazin <gbazin@netcourrier.com> * Gildas Bazin <gbazin@netcourrier.com>
...@@ -324,13 +324,8 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam, ...@@ -324,13 +324,8 @@ LRESULT CALLBACK WMCOPYWNDPROC( HWND hwnd, UINT uMsg, WPARAM wParam,
i_id = playlist_Add( p_playlist, ppsz_argv[ i_opt ], i_id = playlist_Add( p_playlist, ppsz_argv[ i_opt ],
ppsz_argv[ i_opt ], ppsz_argv[ i_opt ],
PLAYLIST_APPEND | (i_opt? 0 : PLAYLIST_GO), PLAYLIST_APPEND | (i_opt? 0 : PLAYLIST_GO),
PLAYLIST_END ); PLAYLIST_END, -1,
i_pos = playlist_GetPositionById( p_playlist, i_id ); ppsz_argv[i_opt+1], i_options );
for( j = 0 ; j < i_options ; j++ )
{
playlist_AddOption( p_playlist, i_pos ,
ppsz_argv[i_opt+1+j] );
}
i_opt += i_options; i_opt += i_options;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* info.c : Playlist info management * info.c : Playlist info management
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2004 VideoLAN * 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: Clment Stenac <zorglub@videolan.org> * Authors: Clment Stenac <zorglub@videolan.org>
* *
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
/** /**
* Get one special info * Get one special info
* Must be entered with playlist lock
* *
* \param p_playlist the playlist to get the info from * \param p_playlist the playlist to get the info from
* \param i_item position of the item on * \param i_item position of the item on
...@@ -40,28 +41,27 @@ ...@@ -40,28 +41,27 @@
* \param psz_name the name of the info * \param psz_name the name of the info
* \return the info value if any, an empty string else * \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 ) const char * psz_cat, const char *psz_name )
{ {
playlist_item_t *p_item;
char *psz_buffer;
/* Check the existence of the playlist */ /* Check the existence of the playlist */
if( p_playlist == NULL) if( p_playlist == NULL)
{ {
return strdup(""); return strdup("");
} }
/* Get a correct item */ p_item = playlist_ItemGetByPos( p_playlist, i_pos );
if( i_item >= 0 && i_item < p_playlist->i_size ) if( !p_item )
{
}
else if( p_playlist->i_size > 0 )
{
i_item = p_playlist->i_index;
}
else
{ {
return strdup(""); return strdup("");
} }
return playlist_GetItemInfo( p_playlist->pp_items[i_item] , psz_cat, vlc_mutex_lock( &p_item->lock );
psz_name ); psz_buffer = playlist_ItemGetInfo( p_item ,
psz_cat, psz_name );
vlc_mutex_unlock( &p_item->lock );
return psz_buffer;
} }
/** /**
...@@ -72,7 +72,7 @@ char * playlist_GetInfo( playlist_t *p_playlist, int i_item, ...@@ -72,7 +72,7 @@ char * playlist_GetInfo( playlist_t *p_playlist, int i_item,
* \param psz_name the name of the info * \param psz_name the name of the info
* \return the info value if any, an empty string else * \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 ) const char * psz_cat, const char *psz_name )
{ {
int i,j ; int i,j ;
...@@ -104,29 +104,21 @@ char * playlist_GetItemInfo( playlist_item_t *p_item, ...@@ -104,29 +104,21 @@ char * playlist_GetItemInfo( playlist_item_t *p_item,
* \return the info category. * \return the info category.
*/ */
item_info_category_t * 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 ) const char * psz_cat )
{ {
playlist_item_t *p_item;
/* Check the existence of the playlist */ /* Check the existence of the playlist */
if( p_playlist == NULL) if( p_playlist == NULL)
{ {
return NULL; return NULL;
} }
p_item= playlist_ItemGetByPos( p_playlist , i_pos );
/* Get a correct item */ if( !p_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 NULL; return NULL;
} }
return playlist_ItemGetCategory( p_item , psz_cat );
return playlist_GetItemCategory( p_playlist->pp_items[i_item] , psz_cat );
} }
/** /**
...@@ -136,7 +128,7 @@ playlist_GetCategory( playlist_t *p_playlist, int i_item, ...@@ -136,7 +128,7 @@ playlist_GetCategory( playlist_t *p_playlist, int i_item,
* \param psz_cat the category we want * \param psz_cat the category we want
* \return the info category. * \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 ) const char *psz_cat )
{ {
int i; int i;
...@@ -151,7 +143,7 @@ item_info_category_t *playlist_GetItemCategory( playlist_item_t *p_item, ...@@ -151,7 +143,7 @@ item_info_category_t *playlist_GetItemCategory( playlist_item_t *p_item,
} }
/* We did not find the category, create it */ /* We did not find the category, create it */
return playlist_CreateItemCategory( p_item, psz_cat ); return playlist_ItemCreateCategory( p_item, psz_cat );
} }
...@@ -165,7 +157,7 @@ item_info_category_t *playlist_GetItemCategory( playlist_item_t *p_item, ...@@ -165,7 +157,7 @@ item_info_category_t *playlist_GetItemCategory( playlist_item_t *p_item,
* \return the info category. * \return the info category.
*/ */
item_info_category_t * 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 ) const char * psz_cat )
{ {
playlist_item_t *p_item = NULL; playlist_item_t *p_item = NULL;
...@@ -175,22 +167,13 @@ playlist_CreateCategory( playlist_t *p_playlist, int i_item, ...@@ -175,22 +167,13 @@ playlist_CreateCategory( playlist_t *p_playlist, int i_item,
{ {
return NULL; return NULL;
} }
p_item = playlist_ItemGetByPos( p_playlist , i_pos );
/* Get a correct item */ if( !p_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
{ {
return NULL; return NULL;
} }
return playlist_CreateItemCategory( p_item, psz_cat ); return playlist_ItemCreateCategory( p_item, psz_cat );
} }
/** /**
...@@ -202,7 +185,7 @@ playlist_CreateCategory( playlist_t *p_playlist, int i_item, ...@@ -202,7 +185,7 @@ playlist_CreateCategory( playlist_t *p_playlist, int i_item,
* \return the info category. * \return the info category.
*/ */
item_info_category_t * 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; item_info_category_t *p_cat;
int i; int i;
...@@ -257,25 +240,19 @@ int playlist_AddInfo( playlist_t *p_playlist, int i_item, ...@@ -257,25 +240,19 @@ int playlist_AddInfo( playlist_t *p_playlist, int i_item,
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* Get a correct item */ p_item = playlist_ItemGetByPos( p_playlist, i_item );
if( i_item >= 0 && i_item < p_playlist->i_size ) if( !p_item )
{
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]; return VLC_ENOOBJ;
}
else
{
return VLC_EGENERIC;
} }
va_start( args, psz_format ); va_start( args, psz_format );
vasprintf( &psz_value, psz_format, args ); vasprintf( &psz_value, psz_format, args );
va_end( 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 ); free( psz_value );
return i_ret; return i_ret;
...@@ -291,7 +268,7 @@ int playlist_AddInfo( playlist_t *p_playlist, int i_item, ...@@ -291,7 +268,7 @@ int playlist_AddInfo( playlist_t *p_playlist, int i_item,
* \param psz_format printf-style info * \param psz_format printf-style info
* \return VLC_SUCCESS on success * \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_cat, const char *psz_name,
const char *psz_format, ... ) const char *psz_format, ... )
{ {
...@@ -302,7 +279,7 @@ int playlist_AddItemInfo( playlist_item_t *p_item, ...@@ -302,7 +279,7 @@ int playlist_AddItemInfo( playlist_item_t *p_item,
item_info_category_t *p_cat; item_info_category_t *p_cat;
/* Find or create the category */ /* 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) if( p_cat == NULL)
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -358,12 +335,10 @@ int playlist_AddItemInfo( playlist_item_t *p_item, ...@@ -358,12 +335,10 @@ int playlist_AddItemInfo( playlist_item_t *p_item,
* \param psz_value the option to add * \param psz_value the option to add
* \return the info category. * \return the info category.
*/ */
int playlist_AddOption( playlist_t *p_playlist, int i_item, int playlist_AddOption( playlist_t *p_playlist, int i_pos,
const char * psz_format, ...) const char *psz_option)
{ {
va_list args; playlist_item_t *p_item;
item_info_t *p_info = NULL;
item_info_category_t *p_cat;
/* Check the existence of the playlist */ /* Check the existence of the playlist */
if( p_playlist == NULL) if( p_playlist == NULL)
...@@ -371,39 +346,18 @@ int playlist_AddOption( playlist_t *p_playlist, int i_item, ...@@ -371,39 +346,18 @@ int playlist_AddOption( playlist_t *p_playlist, int i_item,
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* Get a correct item */ p_item = playlist_ItemGetByPos( p_playlist , i_pos );
if( i_item >= 0 && i_item < p_playlist->i_size ) if( !p_item )
{
}
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 )
{ {
msg_Err( p_playlist, "out of memory" ); return VLC_ENOOBJ;
return VLC_EGENERIC;
} }
p_info->psz_name = strdup( "option" ); vlc_mutex_lock( &p_item->lock );
INSERT_ELEM( p_item->ppsz_options,
va_start( args, psz_format ); p_item->i_options,
vasprintf( &p_info->psz_value, psz_format, args ); p_item->i_options,
va_end( args ); (char *)psz_option );
vlc_mutex_unlock( &p_item->lock );
INSERT_ELEM( p_cat->pp_infos, p_cat->i_infos, p_cat->i_infos, p_info );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -415,31 +369,13 @@ int playlist_AddOption( playlist_t *p_playlist, int i_item, ...@@ -415,31 +369,13 @@ int playlist_AddOption( playlist_t *p_playlist, int i_item,
* \param psz_format the option * \param psz_format the option
* \return 0 on success * \return 0 on success
*/ */
int playlist_AddItemOption( playlist_item_t *p_item, int playlist_ItemAddOption( playlist_item_t *p_item,
const char *psz_format, ... ) const char *psz_option )
{ {
va_list args; INSERT_ELEM( p_item->ppsz_options,
item_info_t *p_info = NULL; p_item->i_options,
item_info_category_t *p_cat; p_item->i_options,
(char *)psz_option);
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 );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* item.c : Playlist item functions * item.c : Playlist item functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2004 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
#include "vlc_playlist.h" #include "vlc_playlist.h"
/** /**
* Add a playlist item into a playlist * Add a playlist item into a playlist
* *
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* loadsave.c : Playlist loading / saving functions * loadsave.c : Playlist loading / saving functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2004 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -64,7 +64,7 @@ int playlist_Import( playlist_t * p_playlist, const char *psz_filename ) ...@@ -64,7 +64,7 @@ int playlist_Import( playlist_t * p_playlist, const char *psz_filename )
i_id = playlist_Add( p_playlist, psz_uri, psz_uri, i_id = playlist_Add( p_playlist, psz_uri, psz_uri,
PLAYLIST_INSERT | PLAYLIST_GO , PLAYLIST_END); 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; p_item->b_autodeletion = VLC_TRUE;
vlc_mutex_unlock( &p_playlist->object_lock ); vlc_mutex_unlock( &p_playlist->object_lock );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* playlist.c : Playlist management functions * playlist.c : Playlist management functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2004 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -567,8 +567,6 @@ static void SkipItem( playlist_t *p_playlist, int i_arg ) ...@@ -567,8 +567,6 @@ static void SkipItem( playlist_t *p_playlist, int i_arg )
static void PlayItem( playlist_t *p_playlist ) static void PlayItem( playlist_t *p_playlist )
{ {
playlist_item_t *p_item; playlist_item_t *p_item;
char **ppsz_options;
int i_options;
int i, j; int i, j;
vlc_value_t val; vlc_value_t val;
if( p_playlist->i_index == -1 ) if( p_playlist->i_index == -1 )
...@@ -587,37 +585,12 @@ static void PlayItem( playlist_t *p_playlist ) ...@@ -587,37 +585,12 @@ static void PlayItem( playlist_t *p_playlist )
msg_Dbg( p_playlist, "creating new input thread" ); msg_Dbg( p_playlist, "creating new input thread" );
p_item = p_playlist->pp_items[p_playlist->i_index]; p_item = p_playlist->pp_items[p_playlist->i_index];
i_options = 0; p_item->i_nb_played++;
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_playlist->p_input = input_CreateThread( p_playlist, p_item->psz_uri, p_playlist->p_input = input_CreateThread( p_playlist, p_item->psz_uri,
ppsz_options, i_options ); p_item->ppsz_options,
p_item->i_options );
if( ppsz_options )
{
free( ppsz_options );
}
val.i_int = p_playlist->i_index; val.i_int = p_playlist->i_index;
var_Set( p_playlist, "playlist-current", val); var_Set( p_playlist, "playlist-current", val);
} }
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