Changeset 499a384591d4238957f08348471fab5f36747fe7

Show
Ignore:
Timestamp:
29/01/04 18:51:08 (5 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1075398668 +0000
git-parent:

[6dc60921e4ccc73903b9b2d07dab30b546c6366f]

git-author:
Clément Stenac <zorglub@videolan.org> 1075398668 +0000
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_playlist.h

    r6de15a6 r499a384  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2004 VideoLAN 
    5  * $Id: vlc_playlist.h,v 1.26 2004/01/25 18:17:08 zorglub Exp $ 
     5 * $Id: vlc_playlist.h,v 1.27 2004/01/29 17:51:07 zorglub Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    7676    mtime_t    i_duration;     /**< A hint about the duration of this 
    7777                                * item, in milliseconds*/ 
    78     int i_categories;          /**< Number of info categories */ 
    79     item_info_category_t **pp_categories; 
    80                                /**< Pointer to the first info category */ 
    81     int        i_status;       /**< unused yet */ 
     78    int        i_categories;   /**< Number of info categories */ 
     79    item_info_category_t ** 
     80               pp_categories;  /**< Pointer to the first info category */ 
     81    int        i_options;      /**< Number of options */ 
     82    char **    ppsz_options;   /**< Array of options */ 
    8283    int        i_nb_played;    /**< How many times was this item played ? */ 
    8384    vlc_bool_t b_autodeletion; /**< Indicates whther this item is to 
     
    8788    vlc_bool_t b_enabled;      /**< Indicates whether this item is to be 
    8889                                * played or skipped */ 
    89     int        i_group;        /**< Which group does this item belongs to ? */ 
     90    int        i_group;        /**< Which group does this item belongs to ? */ 
    9091    int        i_id;           /**< Unique id to track this item */ 
     92    vlc_mutex_t lock;          /**< Item cannot be changed without this lock */ 
    9193}; 
    9294 
     
    166168 
    167169 
    168 /* Item functions */ 
     170/* Item management functions */ 
     171#define playlist_AddItem(p,pi,i1,i2) playlist_ItemAdd(p,pi,i1,i2) 
     172#define playlist_ItemNew( a , b, c ) __playlist_ItemNew(VLC_OBJECT(a) , b , c ) 
     173VLC_EXPORT( playlist_item_t* , __playlist_ItemNew, ( vlc_object_t *,const char *,const char * ) ); 
     174VLC_EXPORT( void, playlist_ItemDelete, ( playlist_item_t * ) ); 
     175VLC_EXPORT( int,  playlist_ItemAdd, ( playlist_t *, playlist_item_t *, int, int ) ); 
     176 
     177/* Simple add/remove funcctions */ 
    169178VLC_EXPORT( int,  playlist_Add,    ( playlist_t *, const char *, const char *, int, int ) ); 
    170 VLC_EXPORT( int,  playlist_AddWDuration, ( playlist_t *, const char *, const char *, int, int, mtime_t ) ); 
    171 /* For internal use. Do not use this one anymore */ 
    172 VLC_EXPORT( int,  playlist_AddItem, ( playlist_t *, playlist_item_t *, int, int ) ); 
     179VLC_EXPORT( int,  playlist_AddExt, ( playlist_t *, const char *, const char *, int, int, mtime_t, const char **,int ) ); 
     180 
     181 
    173182VLC_EXPORT( int,  playlist_Clear, ( playlist_t * ) ); 
    174183VLC_EXPORT( int,  playlist_Delete, ( playlist_t *, int ) ); 
     
    179188 
    180189/* Basic item informations accessors */ 
    181 VLC_EXPORT( int, playlist_SetGroup, (playlist_t *, int, int ) ); 
    182 VLC_EXPORT( int, playlist_SetName, (playlist_t *, int, char * ) ); 
    183 VLC_EXPORT( int, playlist_SetDuration, (playlist_t *, int, mtime_t ) ); 
     190VLC_EXPORT( int, playlist_ItemSetGroup, (playlist_item_t *, int ) ); 
     191VLC_EXPORT( int, playlist_ItemSetName, (playlist_item_t *,  char * ) ); 
     192VLC_EXPORT( int, playlist_ItemSetDuration, (playlist_item_t *, mtime_t ) ); 
     193 
     194VLC_EXPORT( int, playlist_SetGroup, (playlist_t * , int , int ) ); 
     195VLC_EXPORT( int, playlist_SetName, (playlist_t *, int ,  char * ) ); 
     196VLC_EXPORT( int, playlist_SetDuration, (playlist_t *, int , mtime_t ) ); 
    184197 
    185198/* Item search functions */ 
    186199VLC_EXPORT( int, playlist_GetPositionById, (playlist_t *, int) ); 
    187 VLC_EXPORT( playlist_item_t *, playlist_GetItemById, (playlist_t *, int) ); 
     200VLC_EXPORT( playlist_item_t *, playlist_ItemGetById, (playlist_t *, int) ); 
     201VLC_EXPORT( playlist_item_t *, playlist_ItemGetByPos, (playlist_t *, int) ); 
    188202 
    189203 
     
    196210/* Info functions */ 
    197211VLC_EXPORT( char * , playlist_GetInfo, ( playlist_t * , int, const char *, const char *) ); 
    198 VLC_EXPORT( char * , playlist_GetItemInfo, ( playlist_item_t * , const char *, const char *) ); 
     212VLC_EXPORT( char * , playlist_ItemGetInfo, ( playlist_item_t * , const char *, const char *) ); 
    199213 
    200214VLC_EXPORT( item_info_category_t*, playlist_GetCategory, ( playlist_t *, int, const char *) ); 
    201 VLC_EXPORT( item_info_category_t*, playlist_GetItemCategory, ( playlist_item_t *, const char *) ); 
     215VLC_EXPORT( item_info_category_t*, playlist_ItemGetCategory, ( playlist_item_t *, const char *) ); 
    202216 
    203217VLC_EXPORT( item_info_category_t*, playlist_CreateCategory, ( playlist_t *, int, const char *) ); 
    204 VLC_EXPORT( item_info_category_t*, playlist_CreateItemCategory, ( playlist_item_t *, const char *) ); 
     218VLC_EXPORT( item_info_category_t*, playlist_ItemCreateCategory, ( playlist_item_t *, const char *) ); 
    205219 
    206220VLC_EXPORT( int, playlist_AddInfo, (playlist_t *, int, const char * , const char *, const char *, ...) ); 
    207 VLC_EXPORT( int, playlist_AddItemInfo, (playlist_item_t *, const char * , const char *, const char *, ...) ); 
     221VLC_EXPORT( int, playlist_ItemAddInfo, (playlist_item_t *, const char * , const char *, const char *, ...) ); 
    208222 
    209223/* Option functions */ 
    210 VLC_EXPORT( int, playlist_AddOption, (playlist_t *, int, const char *, ...) ); 
    211 VLC_EXPORT( int, playlist_AddItemOption, (playlist_item_t *, const char *, ...) ); 
     224VLC_EXPORT( int, playlist_AddOption, (playlist_t *, int, const char *) ); 
     225VLC_EXPORT( int, playlist_ItemAddOption, (playlist_item_t *, const char *) ); 
    212226 
    213227/* Playlist sorting */ 
  • modules/access/cdda/access.c

    r9841276 r499a384  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000,2003 VideoLAN 
    5  * $Id: access.c,v 1.22 2004/01/07 07:21:31 rocky Exp $ 
     5 * $Id: access.c,v 1.23 2004/01/29 17:51:07 zorglub Exp $ 
    66 * 
    77 * Authors: Rocky Bernstein <rocky@panix.com> 
     
    315315    dbg_print( INPUT_DBG_META, "field %s: %s\n", title, str);  \ 
    316316    input_AddInfo( p_cat, _(title), "%s", str );               \ 
    317     playlist_AddInfo( p_playlist, -1, p_cat->psz_name,         \ 
     317    vlc_mutex_lock( &p_playlist->object_lock );                \ 
     318    p_item = playlist_ItemGetByPos( p_playlist, -1 );          \ 
     319    vlc_mutex_unlock( &p_playlist->object_lock );              \ 
     320    vlc_mutex_lock( &p_item->lock );                           \ 
     321    playlist_ItemAddInfo( p_item, p_cat->psz_name,             \ 
    318322                      _(title), "%s" , str );                  \ 
     323    vlc_mutex_unlock( &p_item->lock );                         \ 
    319324  } 
    320325 
     
    326331                                            FIND_PARENT ); 
    327332  input_info_category_t *p_cat; 
     333  playlist_item_t *p_item; 
    328334 
    329335  p_cat = input_InfoCategory( p_input, "General" ); 
    330    
     336 
    331337 
    332338#ifdef HAVE_LIBCDDB 
     
    670676  char *p_title; 
    671677  char *config_varname = MODULE_STRING "-title-format"; 
     678  playlist_item_t *p_item; 
    672679 
    673680#ifdef HAVE_LIBCDDB 
     
    686693  dbg_print( INPUT_DBG_META, "mrl: %s, title: %s, duration, %ld, pos %d", 
    687694             psz_mrl, p_title, (long int) i_duration / 1000000 , i_pos ); 
    688   playlist_AddWDuration( p_playlist, psz_mrl, p_title, playlist_operation,  
    689             i_pos, i_duration ); 
     695  playlist_AddExt( p_playlist, psz_mrl, p_title, playlist_operation, 
     696                         i_pos, i_duration , NULL, 0); 
    690697 
    691698  if( i_pos == PLAYLIST_END ) i_pos = p_playlist->i_size - 1; 
     699 
     700  vlc_mutex_lock( &p_playlist->object_lock ); 
     701  p_item = playlist_ItemGetByPos( p_playlist, i_pos ); 
     702  vlc_mutex_unlock( &p_playlist->object_lock ); 
     703  if( !p_item ) 
     704      return; 
     705 
     706  vlc_mutex_lock( &p_item->lock ); 
    692707 
    693708  p_author = 
     
    696711                   psz_mrl, i_track ); 
    697712 
    698   playlist_AddInfo( p_playlist, i_pos, _("General"),_("Author"), p_author); 
     713  playlist_ItemAddInfo( p_item , _("General"),_("Author"), p_author); 
    699714 
    700715#ifdef HAVE_LIBCDDB 
     
    702717    const char *psz_general_cat = _("General"); 
    703718 
    704     playlist_AddInfo( p_playlist, i_pos, psz_general_cat, _("Album"), 
    705              "%s", p_cdda->cddb.disc->title); 
    706     playlist_AddInfo( p_playlist, i_pos, psz_general_cat, _("Disc Artist(s)"), 
    707              "%s", p_cdda->cddb.disc->artist); 
    708     playlist_AddInfo( p_playlist, i_pos, psz_general_cat, 
    709              _("CDDB Disc Category"), 
    710              "%s", CDDB_CATEGORY[p_cdda->cddb.disc->category]); 
    711     playlist_AddInfo( p_playlist, i_pos, psz_general_cat, _("Genre"), 
    712              "%s", p_cdda->cddb.disc->genre); 
     719    playlist_ItemAddInfo( p_item, psz_general_cat, _("Album"), 
     720                      "%s", p_cdda->cddb.disc->title); 
     721    playlist_ItemAddInfo( p_item, psz_general_cat, _("Disc Artist(s)"), 
     722                      "%s", p_cdda->cddb.disc->artist); 
     723    playlist_ItemAddInfo( p_item, psz_general_cat, 
     724                        _("CDDB Disc Category"), 
     725                      "%s", CDDB_CATEGORY[p_cdda->cddb.disc->category]); 
     726    playlist_ItemAddInfo( p_item, psz_general_cat, _("Genre"), 
     727                      "%s", p_cdda->cddb.disc->genre); 
    713728    if ( p_cdda->cddb.disc->discid ) { 
    714       playlist_AddInfo( p_playlist, i_pos, psz_general_cat, _("CDDB Disc ID"), 
    715            "%x", p_cdda->cddb.disc->discid ); 
     729      playlist_ItemAddInfo( p_item, psz_general_cat, _("CDDB Disc ID"), 
     730                        "%x", p_cdda->cddb.disc->discid ); 
    716731    } 
    717732    if (p_cdda->cddb.disc->year != 0) { 
    718       playlist_AddInfo( p_playlist, i_pos, psz_general_cat, 
    719            _("Year"), "%5d", p_cdda->cddb.disc->year ); 
     733      playlist_ItemAddInfo( p_item, psz_general_cat, 
     734                        _("Year"), "%5d", p_cdda->cddb.disc->year ); 
    720735    } 
    721736 
    722737    if (p_cdda->i_cddb_enabled) { 
    723738      cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc, 
    724                      i_track-1); 
     739                                          i_track-1); 
    725740      if (t != NULL && t->artist != NULL) { 
    726    playlist_AddInfo( p_playlist, i_pos, psz_general_cat, 
    727              _("Track Artist"), "%s", t->artist ); 
    728    playlist_AddInfo( p_playlist, i_pos, psz_general_cat, 
    729              _("Track Title"), "%s",  t->title ); 
     741        playlist_ItemAddInfo( p_item, psz_general_cat, 
     742                          _("Track Artist"), "%s", t->artist ); 
     743        playlist_ItemAddInfo( p_item , psz_general_cat, 
     744                          _("Track Title"), "%s",  t->title ); 
    730745      } 
    731746    } 
     
    734749#endif /*HAVE_LIBCDDB*/ 
    735750 
     751  vlc_mutex_unlock( &p_item->lock ); 
    736752} 
    737753 
  • modules/access/vcdx/access.c

    rc71e26d r499a384  
    55 ***************************************************************************** 
    66 * Copyright (C) 2000, 2003, 2004 VideoLAN 
    7  * $Id: access.c,v 1.17 2004/01/25 04:53:16 rocky Exp $ 
     7 * $Id: access.c,v 1.18 2004/01/29 17:51:07 zorglub Exp $ 
    88 * 
    99 * Authors: Rocky Bernstein <rocky@panix.com> 
     
    10041004 
    10051005static inline void 
    1006 MetaInfoAddStr(input_thread_t *p_input, input_info_category_t *p_cat,  
    1007           playlist_t *p_playlist, char *title,  
    1008          const char *str) 
     1006MetaInfoAddStr(input_thread_t *p_input, input_info_category_t *p_cat, 
     1007               playlist_t *p_playlist, char *title, 
     1008               const char *str) 
    10091009{ 
    10101010  thread_vcd_data_t *p_vcd = (thread_vcd_data_t *) p_input->p_access_data; 
    1011   if ( str ) {                                                                 
     1011  playlist_item_t *p_item; 
     1012  if ( str ) { 
    10121013    dbg_print( INPUT_DBG_META, "field: %s: %s\n", title, str); 
    1013     input_AddInfo( p_cat, title, "%s", str );               
    1014     playlist_AddInfo( p_playlist, -1, p_cat->psz_name, title, 
    1015                       "%s",str );                                              
     1014    input_AddInfo( p_cat, title, "%s", str ); 
     1015 
     1016    vlc_mutex_lock( &p_playlist->object_lock ); 
     1017    p_item = playlist_ItemGetByPos( p_playlist, -1 ); 
     1018    vlc_mutex_unlock( &p_playlist->object_lock ); 
     1019 
     1020    vlc_mutex_lock( &p_item->lock ); 
     1021    playlist_ItemAddInfo( p_item, p_cat->psz_name, title, 
     1022                          "%s",str ); 
     1023    vlc_mutex_unlock( &p_item->lock ); 
    10161024  } 
    10171025} 
     
    10191027 
    10201028static inline void 
    1021 MetaInfoAddNum(input_thread_t *p_input, input_info_category_t *p_cat,  
    1022           playlist_t *p_playlist, char *title, int num) 
     1029MetaInfoAddNum(input_thread_t *p_input, input_info_category_t *p_cat, 
     1030               playlist_t *p_playlist, char *title, int num) 
    10231031{ 
    10241032  thread_vcd_data_t *p_vcd = (thread_vcd_data_t *) p_input->p_access_data; 
     1033  playlist_item_t *p_item; 
     1034 
     1035  vlc_mutex_lock( &p_playlist->object_lock ); 
     1036  p_item = playlist_ItemGetByPos( p_playlist, -1 ); 
     1037  vlc_mutex_unlock( &p_playlist->object_lock ); 
     1038 
    10251039  dbg_print( INPUT_DBG_META, "field %s: %d\n", title, num); 
    10261040  input_AddInfo( p_cat, title, "%d", num ); 
    1027   playlist_AddInfo( p_playlist, -1, p_cat->psz_name, title, 
    1028                     "%d",num ); 
    1029 
    1030    
     1041 
     1042  vlc_mutex_lock( &p_item->lock ); 
     1043  playlist_ItemAddInfo( p_item ,  p_cat->psz_name, title, "%d",num ); 
     1044  vlc_mutex_unlock( &p_item->lock ); 
     1045
     1046 
    10311047#define addstr(title, str) \ 
    10321048  MetaInfoAddStr( p_input, p_cat, p_playlist, title, str ); 
     
    10341050#define addnum(title, num) \ 
    10351051  MetaInfoAddNum( p_input, p_cat, p_playlist, title, num ); 
    1036    
     1052 
    10371053static void InformationCreate( input_thread_t *p_input  ) 
    10381054{ 
  • modules/codec/speex.c

    rfea7f38 r499a384  
    33 ***************************************************************************** 
    44 * Copyright (C) 2003 VideoLAN 
    5  * $Id: speex.c,v 1.10 2004/01/25 18:20:12 bigben Exp $ 
     5 * $Id: speex.c,v 1.11 2004/01/29 17:51:07 zorglub Exp $ 
    66 * 
    77 * Authors: Gildas Bazin <gbazin@netcourrier.com> 
     
    472472    p_mode = speex_mode_list[p_sys->p_header->mode]; 
    473473    input_AddInfo( p_cat, _("Mode"), "%s%s", 
    474                    p_mode->modeName, p_sys->p_header->vbr ? " VBR" : "" ); 
    475     playlist_AddInfo( p_playlist, -1, _("Speex comment") , _("Mode"), "%s%s", 
     474                  p_mode->modeName, p_sys->p_header->vbr ? " VBR" : "" ); 
     475 
     476    vlc_mutex_lock( &p_playlist->object_lock ); 
     477    p_item = playlist_ItemGetByPos( p_playlist, -1 ); 
     478    vlc_mutex_unlock( &p_playlist->object_lock ); 
     479    if( !p_item) 
     480    { 
     481        msg_Err(p_dec, "unable to find item" ); 
     482        return; 
     483    } 
     484    vlc_mutex_lock( &p_item->lock ); 
     485 
     486    playlist_ItemAddInfo( p_item, _("Speex comment") , _("Mode"),"%s%s", 
    476487                    p_mode->modeName, p_sys->p_header->vbr ? " VBR" : "" ); 
    477488 
     
    490501 
    491502    input_AddInfo( p_cat, p_buf, "" ); 
    492     playlist_AddInfo( p_playlist, -1, _("Speex comment") , p_buf , "" ); 
     503    playlist_ItemAddInfo( p_item , _("Speex comment") , p_buf , "" ); 
     504 
     505    vlc_mutex_unlock( &p_item->lock ); 
    493506 
    494507    if( p_playlist ) vlc_object_release( p_playlist ); 
  • modules/codec/theora.c

    rfea7f38 r499a384  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2001 VideoLAN 
    5  * $Id: theora.c,v 1.23 2004/01/25 18:20:12 bigben Exp $ 
     5 * $Id: theora.c,v 1.24 2004/01/29 17:51:07 zorglub Exp $ 
    66 * 
    77 * Authors: Gildas Bazin <gbazin@netcourrier.com> 
     
    341341    playlist_t *p_playlist = vlc_object_find( p_dec, VLC_OBJECT_PLAYLIST, 
    342342                                              FIND_ANYWHERE ); 
     343    playlist_item_t *p_item; 
    343344    int i = 0; 
    344345    char *psz_name, *psz_value, *psz_comment; 
     
    358359            psz_value++; 
    359360            input_AddInfo( p_cat, psz_name, psz_value ); 
    360             playlist_AddInfo( p_playlist, -1, _("Theora comment") , 
    361                               psz_name, psz_value ); 
     361            vlc_mutex_lock( &p_playlist->object_lock ); 
     362            p_item = playlist_ItemGetByPos( p_playlist, -1 ); 
     363            vlc_mutex_unlock( &p_playlist->object_lock ); 
     364            if( !p_item) 
     365            { 
     366                msg_Err(p_dec, "unable to find item" ); 
     367                return; 
     368            } 
     369            vlc_mutex_lock( &p_item->lock ); 
     370            playlist_ItemAddInfo( p_item, _("Theora comment") , 
     371                                  psz_name, psz_value ); 
     372            vlc_mutex_unlock( &p_item->lock ); 
    362373        } 
    363374        free( psz_comment ); 
  • modules/codec/vorbis.c

    rfea7f38 r499a384  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001-2003 VideoLAN 
    5  * $Id: vorbis.c,v 1.30 2004/01/25 18:20:12 bigben Exp $ 
     5 * $Id: vorbis.c,v 1.31 2004/01/29 17:51:07 zorglub Exp $ 
    66 * 
    77 * Authors: Gildas Bazin <gbazin@netcourrier.com> 
     
    457457    playlist_t *p_playlist = vlc_object_find( p_dec, VLC_OBJECT_PLAYLIST, 
    458458                                              FIND_ANYWHERE ); 
     459    playlist_item_t *p_item; 
    459460    int i = 0; 
    460461    char *psz_name, *psz_value, *psz_comment; 
     
    474475            psz_value++; 
    475476            input_AddInfo( p_cat, psz_name, psz_value ); 
    476             playlist_AddInfo( p_playlist, -1, _("Vorbis comment") , 
    477                               psz_name, psz_value ); 
     477            vlc_mutex_lock( &p_playlist->object_lock ); 
     478            p_item = playlist_ItemGetByPos( p_playlist, -1 ); 
     479            vlc_mutex_unlock( &p_playlist->object_lock ); 
     480            if( !p_item) 
     481            { 
     482                    msg_Err(p_dec, "unable to find item" ); 
     483                    return; 
     484            } 
     485            vlc_mutex_lock( &p_item->lock ); 
     486            playlist_ItemAddInfo( p_item, _("Vorbis comment") , 
     487                            psz_name, psz_value ); 
     488            vlc_mutex_unlock( &p_item->lock ); 
    478489        } 
    479490        free( psz_comment ); 
  • modules/control/http.c

    r59bd8e1 r499a384  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001-2004 VideoLAN 
    5  * $Id: http.c,v 1.50 2004/01/25 16:17:03 anil Exp $ 
     5 * $Id: http.c,v 1.51 2004/01/29 17:51:07 zorglub Exp $ 
    66 * 
    77 * Authors: Gildas Bazin <gbazin@netcourrier.com> 
     
    126126static char *Find_end_MRL( char *psz ); 
    127127 
    128 static playlist_item_t * parse_MRL( char *psz ); 
     128static playlist_item_t * parse_MRL( intf_thread_t * , char *psz ); 
    129129 
    130130/***************************************************************************** 
     
    17651765                    uri_extract_value( p_request, "mrl", mrl, 512 ); 
    17661766                    uri_decode_url_encoded( mrl ); 
    1767                     p_item = parse_MRL( mrl ); 
     1767                    p_item = parse_MRL( p_intf, mrl ); 
    17681768 
    17691769                    if( !p_item || !p_item->psz_uri || !*p_item->psz_uri ) 
     
    28712871 * return NULL if there is an error. 
    28722872 **********************************************************************/ 
    2873 playlist_item_t * parse_MRL( char *psz ) 
     2873playlist_item_t * parse_MRL( intf_thread_t *p_intf, char *psz ) 
    28742874{ 
    28752875    char **ppsz_options = NULL; 
     
    29682968    { 
    29692969        /* now create an item */ 
    2970         p_item = malloc( sizeof( playlist_item_t ) ); 
    2971         memset( p_item, 0, sizeof( playlist_item_t ) ); 
    2972         p_item->psz_name   = mrl; 
    2973         p_item->psz_uri    = strdup( mrl ); 
    2974         p_item->i_duration = -1; 
    2975         p_item->b_enabled = VLC_TRUE; 
    2976         p_item->i_group = PLAYLIST_TYPE_MANUAL; 
    2977  
     2970        p_item = playlist_ItemNew( p_intf, mrl, mrl); 
    29782971        for( i = 0 ; i< i_options ; i++ ) 
    29792972        { 
    2980             playlist_AddItemOption( p_item, ppsz_options[i] ); 
     2973            playlist_ItemAddOption( p_item, ppsz_options[i] ); 
    29812974        } 
    29822975    } 
  • modules/demux/util/id3tag.c

    rffdca9a r499a384  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002-2004 VideoLAN 
    5  * $Id: id3tag.c,v 1.19 2004/01/25 20:05:29 hartman Exp $ 
     5 * $Id: id3tag.c,v 1.20 2004/01/29 17:51:07 zorglub Exp $ 
    66 * 
    77 * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> 
     
    8686    while ( ( p_frame = id3_tag_findframe( p_id3_tag , "T", i ) ) ) 
    8787    { 
    88         playlist_item_t *p_item = p_playlist ? p_playlist->pp_items[p_playlist->i_index] : NULL; 
     88        playlist_item_t *p_item = playlist_ItemGetByPos( p_playlist, -1 ); 
     89        if( !p_item ) 
     90        { 
     91            msg_Err( p_input, "Unable to get item" ); 
     92            return; 
     93        } 
     94 
     95        vlc_mutex_lock( &p_item->lock ); 
    8996 
    9097        int i_strings = id3_field_getnstrings( &p_frame->fields[1] ); 
     
    102109                    input_AddInfo( p_category, (char *)p_frame->description, 
    103110                                   ppsz_genres[atoi(psz_temp)]); 
    104                     playlist_AddItemInfo( p_item, "ID3", 
     111                    playlist_ItemAddInfo( p_item, "ID3", 
    105112                                    (char *)p_frame->description, 
    106113                                    ppsz_genres[atoi(psz_temp)]); 
     
    110117                    input_AddInfo( p_category, (char *)p_frame->description, 
    111118                                                psz_temp ); 
    112                     playlist_AddItemInfo( p_item, "ID3", 
     119                    playlist_ItemAddInfo( p_item, "ID3", 
    113120                                    (char *)p_frame->description, 
    114121                                    psz_temp); 
     
    129136                input_AddInfo( p_category, (char *)p_frame->description, 
    130137                                            psz_temp ); 
    131                 playlist_AddItemInfo( p_item, "ID3", 
     138                playlist_ItemAddInfo( p_item, "ID3", 
    132139                                        (char *)p_frame->description, 
    133140                                    psz_temp); 
     
    137144                if( p_item ) 
    138145                { 
    139                     playlist_AddItemInfo( p_item, 
     146                    playlist_ItemAddInfo( p_item, 
    140147                                          _("General"), _("Author"), psz_temp); 
    141148                    val.b_bool = VLC_TRUE; 
     
    143150                input_AddInfo( p_category, (char *)p_frame->description, 
    144151                                            psz_temp ); 
    145                 playlist_AddItemInfo( p_item, "ID3", 
     152                playlist_ItemAddInfo( p_item, "ID3", 
    146153                                           (char *)p_frame->description, 
    147154                                           psz_temp); 
     
    151158                input_AddInfo( p_category, (char *)p_frame->description, 
    152159                                            psz_temp ); 
    153                 playlist_AddItemInfo( p_item, "ID3", 
     160                playlist_ItemAddInfo( p_item, "ID3", 
    154161                                           (char *)p_frame->description, 
    155162                                           psz_temp); 
     
    158165        } 
    159166        i++; 
     167        vlc_mutex_unlock( &p_item->lock ); 
    160168    } 
    161169    id3_tag_delete( p_id3_tag ); 
  • modules/gui/pda/pda_callbacks.c

    rc14327c r499a384  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000, 2001 VideoLAN 
    5  * $Id: pda_callbacks.c,v 1.25 2004/01/25 14:15:21 kuehne Exp $ 
     5 * $Id: pda_callbacks.c,v 1.26 2004/01/29 17:51:07 zorglub Exp $ 
    66 * 
    77 * Authors: Jean-Paul Saman <jpsaman@wxs.nl> 
     
    134134#endif 
    135135            { 
    136                 i_id = playlist_Add( p_playlist, (const char*)name, 
    137                                 (const char*)name, 
    138                               PLAYLIST_APPEND, PLAYLIST_END ); 
    139  
    140                 i_pos = playlist_GetPositionById( p_playlist, i_id ); 
    141  
    142                 for( i = 0 ; i< i_size ; i++ ) 
    143                 { 
    144                     playlist_AddOption( p_playlist, i_pos , ppsz_options[i] ); 
    145                 } 
     136                i_id = playlist_AddExt( p_playlist, (const char*)name, 
     137                              (const char*)name, 
     138                              PLAYLIST_APPEND, PLAYLIST_END, 
     139                              ppsz_options, i_pos ); 
    146140            } 
    147141 
  • modules/gui/wxwindows/iteminfo.cpp

    rd03df88 r499a384  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000-2004 VideoLAN 
    5  * $Id: iteminfo.cpp,v 1.7 2004/01/25 03:29:01 hartman Exp $ 
     5 * $Id: iteminfo.cpp,v 1.8 2004/01/29 17:51:08 zorglub Exp $ 
    66 * 
    77 * Authors: Cl�nt Stenac <zorglub@videolan.org> 
     
    179179    author_text = 
    180180                   new wxTextCtrl( info_panel, Uri_Event, 
    181                                    wxU( playlist_GetItemInfo( p_item, 
     181                                   wxU( playlist_ItemGetInfo( p_item, 
    182182                                          _("General"), _("Author") ) ), 
    183183                                   wxDefaultPosition, wxSize( 300, -1 ), 
     
    306306void ItemInfoDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) 
    307307{ 
     308    vlc_mutex_lock( &p_item->lock ); 
    308309    p_item->psz_name = strdup( name_text->GetLineText(0).mb_str() ); 
    309310    p_item->psz_uri = strdup( uri_text->GetLineText(0).mb_str() ); 
    310     playlist_AddItemInfo( p_item,"General","Author", 
     311    playlist_ItemAddInfo( p_item,"General","Author", 
    311312                            author_text->GetLineText(0).mb_str() ); 
    312313    vlc_bool_t b_old_enabled = p_item->b_enabled; 
     
    336337 
    337338    p_item->b_enabled = enabled_checkbox->IsChecked() ? VLC_TRUE : VLC_FALSE ; 
     339    vlc_mutex_unlock( &p_item->lock ); 
    338340    EndModal( wxID_OK ); 
    339341} 
  • modules/gui/wxwindows/open.cpp

    r41fd167 r499a384  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000-2004 VideoLAN 
    5  * $Id: open.cpp,v 1.66 2004/01/26 22:10:20 gbazin Exp $ 
     5 * $Id: open.cpp,v 1.67 2004/01/29 17:51:08 zorglub Exp $ 
    66 * 
    77 * Authors: Gildas Bazin <gbazin@netcourrier.com> 
     
    891891    { 
    892892        int i_options = 0; 
    893  
    894         int i_id = playlist_Add( p_playlist, (const char *)mrl[i].mb_str(), 
    895                       (const char *)mrl[i].mb_str(), 
    896                       PLAYLIST_APPEND, PLAYLIST_END ); 
    897         playlist_item_t *p_item = playlist_GetItemById( p_playlist , i_id ); 
     893        playlist_item_t *p_item = 
     894                  playlist_ItemNew( p_intf, 
     895                                    (const char*)mrl[i].mb_str(), 
     896                                    (const char *)mrl[i].mb_str() ); 
    898897 
    899898        /* Count the input options */ 
     
    907906        for( int j = 0; j < i_options; j++ ) 
    908907        { 
    909             playlist_AddItemOption( p_item, mrl[i + j  + 1].mb_str() ); 
     908            playlist_ItemAddOption( p_item, mrl[i + j  + 1].mb_str() ); 
    910909        } 
    911910 
     
    915914            for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ ) 
    916915            { 
    917                 playlist_AddItemOption( p_item, subsfile_mrl[j].mb_str() ); 
     916                playlist_ItemAddOption( p_item, subsfile_mrl[j].mb_str() ); 
    918917            } 
    919918        } 
     
    924923            for( int j = 0; j < (int)sout_mrl.GetCount(); j++ ) 
    925924            { 
    926                 playlist_AddItemOption( p_item, sout_mrl[j].mb_str() ); 
     925                playlist_ItemAddOption( p_item, sout_mrl[j].mb_str() ); 
    927926            } 
    928927        } 
     928 
     929       int i_id = playlist_AddItem( p_playlist, p_item, 
     930                      PLAYLIST_APPEND, PLAYLIST_END ); 
    929931 
    930932        if( !i && i_open_arg ) 
  • modules/gui/wxwindows/playlist.cpp

    rd03df88 r499a384  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000-2004 VideoLAN 
    5  * $Id: playlist.cpp,v 1.39 2004/01/25 03:29:01 hartman Exp $ 
     5 * $Id: playlist.cpp,v 1.40 2004/01/29 17:51:08 zorglub Exp $ 
    66 * 
    77 * Authors: Olivier Teuli� <ipkiss@via.ecp.fr> 
     
    406406        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    407407                                       FIND_ANYWHERE ); 
    408     if( p_playlist == NULL ) 
    409     { 
    410         return; 
    411     } 
    412     if( i < 0 || i >= p_playlist->i_size || !p_playlist->pp_items[i] ) 
     408 
     409    if( p_playlist == NULL ) 
     410    { 
     411        return; 
     412    } 
     413 
     414    playlist_item_t *p_item = playlist_ItemGetByPos( p_playlist, i ); 
     415 
     416    if( !p_item ) 
    413417    { 
    414418        vlc_object_release(p_playlist); 
    415419        return; 
    416420    } 
    417     listview->SetItem( i, 0, wxL2U(p_playlist->pp_items[i]->psz_name) ); 
    418     listview->SetItem( i, 1, wxU( playlist_GetInfo( p_playlist, i, 
     421 
     422    listview->SetItem( i, 0, wxL2U(p_item->psz_name) ); 
     423    listview->SetItem( i, 1, wxU( playlist_ItemGetInfo( p_item, 
    419424                                       _("General") , _("Author") ) ) ); 
    420425    char *psz_group = playlist_FindGroup(p_playlist, 
    421                                          p_playlist->pp_items[i]->i_group); 
     426                                         p_item->i_group); 
    422427    listview->SetItem( i, 2, 
    423428             wxL2U( psz_group ? psz_group : _("Normal") ) ); 
    424429 
    425     if( p_playlist->pp_items[i]->b_enabled == VLC_FALSE ) 
     430    if( p_item->b_enabled == VLC_FALSE ) 
    426431    { 
    427432        wxListItem listitem; 
     
    432437 
    433438    char psz_duration[MSTRTIME_MAX_SIZE]; 
    434     mtime_t dur = p_playlist->pp_items[i]->i_duration; 
     439    mtime_t dur = p_item->i_duration; 
    435440    if( dur != -1 ) secstotimestr( psz_duration, dur/1000000 ); 
    436441    else memcpy( psz_duration , "-:--:--", sizeof("-:--:--") ); 
     
    612617            } 
    613618        } 
    614          
     619 
    615620        vlc_object_release( p_playlist ); 
    616          
     621 
    617622    } 
    618623} 
     
    901906        if( listview->IsSelected( item ) ) 
    902907        { 
     908            /*XXX*/ 
    903909            playlist_Enable( p_playlist, item ); 
    904910            UpdateItem( item ); 
     
    922928        if( listview->IsSelected( item ) ) 
    923929        { 
     930            /*XXX*/ 
    924931            playlist_Disable( p_playlist, item ); 
    925932            UpdateItem( item ); 
     
    10221029    if( iteminfo_dialog == NULL ) 
    10231030    { 
    1024         if( i_item >= 0 && i_item < p_playlist->i_size ) 
     1031        vlc_mutex_lock( &p_playlist->object_lock); 
     1032        playlist_item_t *p_item = playlist_ItemGetByPos( p_playlist, i_item ); 
     1033        vlc_mutex_unlock( &p_playlist->object_lock ); 
     1034 
     1035        if( p_item ) 
    10251036        { 
    10261037            iteminfo_dialog = new ItemInfoDialog( 
    1027                               p_intf, p_playlist->pp_items[i_item], this ); 
     1038                              p_intf, p_item , this ); 
    10281039            if( iteminfo_dialog->ShowModal()  == wxID_OK ) 
    10291040                UpdateItem( i_item ); 
     
    10611072       { 
    10621073           case EnableGroup_Event: 
     1074               /*XXX*/ 
    10631075               playlist_EnableGroup( p_playlist , 
    10641076                                  p_playlist->pp_items[i_item]->i_group ); 
     
    11691181{ 
    11701182    Playlist *p_playlist_dialog = (Playlist *)param; 
     1183    fprintf(stderr,"Update item: %i\n",new_val.i_int); 
    11711184    p_playlist_dialog->UpdateItem( new_val.i_int ); 
    11721185    return 0; 
  • modules/gui/wxwindows/streamwizard.cpp

    rd03df88 r499a384  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000-2004 VideoLAN 
    5  * $Id: streamwizard.cpp,v 1.5 2004/01/25 03:29:01 hartman Exp $ 
     5 * $Id: streamwizard.cpp,v 1.6 2004/01/29 17:51:08 zorglub Exp $ 
    66 * 
    77 * Authors: Cl�nt Stenac <zorglub@videolan.org> 
     
    205205    for( int i = 0; i < (int)p_open_dialog->mrl.GetCount(); i++ ) 
    206206    { 
    207         int i_id = playlist_Add( p_playlist
     207        playlist_item_t *p_item = playlist_ItemNew( p_intf
    208208                      (const char *)p_open_dialog->mrl[i].mb_str(), 
    209                       (const char *)p_open_dialog->mrl[i].mb_str(), 
    210                       PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END ); 
    211         int i_pos = playlist_GetPositionById( p_playlist, i_id ); 
     209                      (const char *)p_open_dialog->mrl[i].mb_str() ); 
    212210        int i_options = 0; 
    213211 
     
    223221        for( int j = 0; j < i_options; j++ ) 
    224222        { 
    225             playlist_AddOption( p_playlist, i_pos
     223            playlist_ItemAddOption( p_item
    226224                  &nbs