Changeset 17557ea64382428560a75ecef753e88f39158834

Show
Ignore:
Timestamp:
05/01/04 13:59:43 (5 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1073307583 +0000
git-parent:

[051ce627e6f3c469ecaf98676203dc8a59cc9e57]

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

* Makefile.am : Added src/playlist/item-ext.c and src/playlist/info.c

* src/playlist/item.c

src/playlist/info.c
src/playlist/item-ext.c
src/playlist/group.c
src/playlist/sort.c
src/playlist/loadsave.c
include/vlc_playlist.h

  • New playlist_info structures and accessors
    It works pretty like the old input_info (with categories)
    It provides modularity to the playlist
  • Removed ppsz_options and i_options from playlist_item
    (we use the special category Options)
  • Added a unique id to each playlist_item to be able to track the
    items accross playlist reorders
  • Simplified adding of items.
    • playlist_AddExt is removed
    • playlist_AddItem is still here and exported but should not be used
    • use playlist_Add( p_playlist, uri, name, duration, mode, pos )
      and use the accessors for all other things
  • Added setters for fields of the playlist_item structure
  • Introduced "item-change" and "playlist-current" playlist variables
    to give more flexibility than only intf-change

At the moment, duration is still in the structure (easier to use, IMHO)

* src/input/input.c

src/libvlc.c :

playlist item options parsing changed

* include/vlc_common.h : added playlist_info structures

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Makefile.am

    r78ffa46 r17557ea  
    318318    src/playlist/group.c \ 
    319319    src/playlist/item.c \ 
     320    src/playlist/item-ext.c \ 
     321        src/playlist/info.c \ 
    320322    src/input/input.c \ 
    321323    src/input/es_out.c \ 
  • include/vlc_common.h

    r3edb6d7 r17557ea  
    44 ***************************************************************************** 
    55 * Copyright (C) 1998, 1999, 2000 VideoLAN 
    6  * $Id: vlc_common.h,v 1.96 2003/12/06 22:45:53 jpsaman Exp $ 
     6 * $Id: vlc_common.h,v 1.97 2004/01/05 12:59:43 zorglub Exp $ 
    77 * 
    88 * Authors: Samuel Hocevar <sam@via.ecp.fr> 
     
    191191typedef struct playlist_item_t playlist_item_t; 
    192192typedef struct playlist_group_t playlist_group_t; 
     193typedef struct item_info_t item_info_t; 
     194typedef struct item_info_category_t item_info_category_t; 
    193195 
    194196/* Modules */ 
  • include/vlc_playlist.h

    rddc2316 r17557ea  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN 
    5  * $Id: vlc_playlist.h,v 1.18 2003/12/03 21:58:42 sigmunau Exp $ 
     5 * $Id: vlc_playlist.h,v 1.19 2004/01/05 12:59:43 zorglub Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    3535 
    3636/** 
     37 * Playlist info item 
     38 * \see playlist_item_t 
     39 */ 
     40 
     41struct item_info_t 
     42{ 
     43    char * psz_name;            /**< Name of this info */ 
     44    char * psz_value;           /**< Value of the info */ 
     45}; 
     46 
     47/** 
     48 * playlist item info category 
     49 * \see playlist_item_t 
     50 * \see item_info_t 
     51 */ 
     52struct item_info_category_t 
     53{ 
     54    char * psz_name;            /**< Name of this category */ 
     55    int i_infos;                /**< Number of infos in the category */ 
     56    item_info_t **pp_infos;     /**< Pointer to an array of infos */ 
     57}; 
     58 
     59/** 
    3760 * playlist item 
    3861 * \see playlist_t 
     
    4265    char *     psz_name;       /**< text describing this item */ 
    4366    char *     psz_uri;        /**< mrl of this item */ 
    44     mtime_t    i_duration;     /**< A hint about the duration of this item */ 
    45     char **    ppsz_options;   /**< options passed with the :foo=bar syntax */ 
    46     int        i_options;      /**< number of items in the 
    47                                 * ppsz_options array */ 
    48     int        i_type;         /**< unused yet */ 
     67    mtime_t    i_duration;     /**< A hint about the duration of this 
     68                                * item, in miliseconds*/ 
     69    int i_categories;          /**< Number of info categories */ 
     70    item_info_category_t **pp_categories; 
     71                               /**< Pointer to the first info category */ 
    4972    int        i_status;       /**< unused yet */ 
     73    int        i_nb_played;    /**< How many times was this item played ? */ 
    5074    vlc_bool_t b_autodeletion; /**< Indicates whther this item is to 
    5175                                * be deleted after playback. True mean 
     
    5478    vlc_bool_t b_enabled;      /**< Indicates whether this item is to be 
    5579                                * played or skipped */ 
    56  
    57     int        i_group;         /**< unused yet */ 
    58     char *     psz_author;     /**< Author */ 
    59 }; 
    60  
     80    int        i_group;         /**< Which group does this item belongs to ? */ 
     81    int        i_id;           /**< Unique id to track this item */ 
     82}; 
     83 
     84/** 
     85 * playlist group 
     86 * \see playlist_t 
     87 */ 
    6188struct playlist_group_t 
    6289{ 
     
    90117    playlist_group_t **   pp_groups;/**< array of pointers to the playlist 
    91118                                     * groups */ 
    92     int                   i_max_id; /**< Maximal group id given */ 
     119    int                   i_last_group; /**< Maximal group id given */ 
    93120    input_thread_t *      p_input;  /**< the input thread ascosiated 
    94121                                     * with the current item */ 
     122    int                   i_last_id; /**< Last id to an item */ 
    95123    /*@}*/ 
    96124}; 
     
    121149#define playlist_Skip(p,i) playlist_Command(p,PLAYLIST_SKIP,i) 
    122150#define playlist_Goto(p,i) playlist_Command(p,PLAYLIST_GOTO,i) 
     151 
    123152VLC_EXPORT( void, playlist_Command, ( playlist_t *, playlist_command_t, int ) ); 
    124153 
    125 VLC_EXPORT( int,  playlist_Add,    ( playlist_t *, const char *, const char **, int, int, int ) ); 
    126 VLC_EXPORT( int,  playlist_AddExt,    ( playlist_t *, const char *, const char *, mtime_t, const char **, int, int, int ) ); 
     154 
     155/* Item functions */ 
     156VLC_EXPORT( int,  playlist_Add,    ( playlist_t *, const char *, const char *, int, int ) ); 
     157/* For internal use. Do not use this one anymore */ 
    127158VLC_EXPORT( int,  playlist_AddItem, ( playlist_t *, playlist_item_t *, int, int ) ); 
    128159VLC_EXPORT( int,  playlist_Delete, ( playlist_t *, int ) ); 
     
    132163VLC_EXPORT( int,  playlist_EnableGroup, ( playlist_t *, int ) ); 
    133164 
     165/* Basic item informations accessors */ 
     166VLC_EXPORT( int, playlist_SetGroup, (playlist_t *, int, int ) ); 
     167VLC_EXPORT( int, playlist_SetName, (playlist_t *, int, char * ) ); 
     168VLC_EXPORT( int, playlist_SetDuration, (playlist_t *, int, int ) ); 
     169 
     170/* Item search functions */ 
     171VLC_EXPORT( int, playlist_GetPositionById, (playlist_t *, int) ); 
     172VLC_EXPORT( playlist_item_t *, playlist_GetItemById, (playlist_t *, int) ); 
     173 
     174 
     175/* Group management functions */ 
    134176VLC_EXPORT( playlist_group_t *, playlist_CreateGroup, (playlist_t *, char* ) ); 
    135177VLC_EXPORT( int, playlist_DeleteGroup, (playlist_t *, int ) ); 
     
    137179VLC_EXPORT( int, playlist_GroupToId, (playlist_t *, char * ) ); 
    138180 
     181/* Info functions */ 
     182VLC_EXPORT( char * , playlist_GetInfo, ( playlist_t * , int, const char *, const char *) ); 
     183VLC_EXPORT( char * , playlist_GetItemInfo, ( playlist_item_t * , const char *, const char *) ); 
     184 
     185VLC_EXPORT( item_info_category_t*, playlist_GetCategory, ( playlist_t *, int, const char *) ); 
     186VLC_EXPORT( item_info_category_t*, playlist_GetItemCategory, ( playlist_item_t *, const char *) ); 
     187 
     188VLC_EXPORT( item_info_category_t*, playlist_CreateCategory, ( playlist_t *, int, const char *) ); 
     189VLC_EXPORT( item_info_category_t*, playlist_CreateItemCategory, ( playlist_item_t *, const char *) ); 
     190 
     191VLC_EXPORT( int, playlist_AddInfo, (playlist_t *, int, const char * , const char *, const char *, ...) ); 
     192VLC_EXPORT( int, playlist_AddItemInfo, (playlist_item_t *, const char * , const char *, const char *, ...) ); 
     193 
     194/* Option functions */ 
     195VLC_EXPORT( int, playlist_AddOption, (playlist_t *, int, const char *, ...) ); 
     196VLC_EXPORT( int, playlist_AddItemOption, (playlist_item_t *, const char *, ...) ); 
     197 
     198/* Playlist sorting */ 
    139199#define playlist_SortTitle(p, i) playlist_Sort( p, SORT_TITLE, i) 
    140200#define playlist_SortAuthor(p, i) playlist_Sort( p, SORT_AUTHOR, i) 
    141201#define playlist_SortGroup(p, i) playlist_Sort( p, SORT_GROUP, i) 
    142  
    143202VLC_EXPORT( int,  playlist_Sort, ( playlist_t *, int, int) ); 
    144  
    145203VLC_EXPORT( int,  playlist_Move, ( playlist_t *, int, int ) ); 
     204 
     205/* Load/Save */ 
    146206VLC_EXPORT( int,  playlist_LoadFile, ( playlist_t *, const char * ) ); 
    147207VLC_EXPORT( int,  playlist_SaveFile, ( playlist_t *, const char * ) ); 
  • src/input/input.c

    r8cedcb3 r17557ea  
    55 ***************************************************************************** 
    66 * Copyright (C) 1998-2002 VideoLAN 
    7  * $Id: input.c,v 1.271 2003/12/03 22:14:38 sigmunau Exp $ 
     7 * $Id: input.c,v 1.272 2004/01/05 12:59:43 zorglub Exp $ 
    88 * 
    99 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    8787    input_thread_t *    p_input;                        /* thread descriptor */ 
    8888    input_info_category_t * p_info; 
     89    item_info_category_t *p_cat; 
    8990    vlc_value_t val; 
    90     int i
     91    int i,j
    9192 
    9293    /* Allocate descriptor */ 
     
    99100 
    100101    /* Parse input options */ 
    101     for( i = 0; i < p_item->i_options; i++ ) 
    102     { 
    103         ParseOption( p_input, p_item->ppsz_options[i] ); 
     102    for( i = 0 ; i < p_item->i_categories ; i++ ) 
     103    { 
     104        if( !strncmp( p_item->pp_categories[i]->psz_name, "Options", 7 ) ) 
     105        { 
     106            msg_Dbg(p_input,"Parsing %i options for item", 
     107                             p_item->pp_categories[i]->i_infos ); 
     108            for( j = 0; j< p_item->pp_categories[i]->i_infos ; j++ ) 
     109            { 
     110                msg_Dbg(p_input,"Option : %s", 
     111                         p_item->pp_categories[i]->pp_infos[j]->psz_name); 
     112                ParseOption( p_input, 
     113                             p_item->pp_categories[i]->pp_infos[j]->psz_value); 
     114            } 
     115            break; 
     116        } 
    104117    } 
    105118 
     
    790803        if( p_playlist ) 
    791804        { 
    792             vlc_mutex_lock( &p_playlist->object_lock ); 
    793             p_playlist->pp_items[ p_playlist->i_index ]->i_duration = i_length; 
     805            playlist_SetDuration( p_playlist, -1 , i_length ); 
    794806            val.b_bool = VLC_TRUE; 
    795             vlc_mutex_unlock( &p_playlist->object_lock ); 
    796             var_Set( p_playlist, "intf-change", val ); 
     807            var_Set( p_playlist, "item-change", val ); 
    797808            vlc_object_release( p_playlist ); 
    798809        } 
    799     }             
    800         
     810    } 
     811 
    801812 
    802813    /* get fps */ 
  • src/libvlc.c

    r8a9ed93 r17557ea  
    33 ***************************************************************************** 
    44 * Copyright (C) 1998-2002 VideoLAN 
    5  * $Id: libvlc.c,v 1.106 2003/12/24 10:06:53 gbazin Exp $ 
     5 * $Id: libvlc.c,v 1.107 2004/01/05 12:59:43 zorglub Exp $ 
    66 * 
    77 * Authors: Vincent Seguin <seguin@via.ecp.fr> 
     
    797797                   int i_mode, int i_pos ) 
    798798{ 
     799    int i; 
    799800    int i_err; 
    800801    playlist_t *p_playlist; 
     
    822823    } 
    823824 
    824     i_err = playlist_Add( p_playlist, psz_target, ppsz_options, i_options
     825    i_err = playlist_Add( p_playlist, psz_target, psz_target
    825826                          i_mode, i_pos ); 
     827 
     828    for( i = 0 ; i< i_options ; i++ ) 
     829    { 
     830        playlist_AddOption( p_playlist, i_err , ppsz_options[i] ); 
     831    } 
    826832 
    827833    vlc_object_release( p_playlist ); 
  • src/playlist/group.c

    rc882cec r17557ea  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2001 VideoLAN 
    5  * $Id: group.c,v 1.4 2003/12/11 11:30:37 zorglub Exp $ 
     5 * $Id: group.c,v 1.5 2004/01/05 12:59:43 zorglub Exp $ 
    66 * 
    77 * Authors: Cl�nt Stenac <zorglub@videolan.org> 
     
    6262 
    6363    p_group->psz_name = strdup( psz_name ); 
    64     p_group->i_id = ++p_playlist->i_max_id
     64    p_group->i_id = ++p_playlist->i_last_group
    6565 
    6666    msg_Dbg(p_playlist,"Creating group %s with id %i at position %i", 
     
    111111 
    112112/** 
    113  * Find the name with the ID 
     113 * Find the name of the group given its ID 
    114114 * 
    115115 * \param p_playlist the playlist where to find the group 
     
    125125        { 
    126126            if( p_playlist->pp_groups[i]->psz_name) 
    127             return strdup( p_playlist->pp_groups[i]->psz_name ); 
     127                return strdup( p_playlist->pp_groups[i]->psz_name ); 
    128128        } 
    129129    } 
     
    132132 
    133133/** 
    134  * Find the Id with the given name 
     134 * Find the Id of a group given its name 
    135135 * 
    136136 * \param p_playlist the playlist where to find the group 
  • src/playlist/item.c

    rd3de646 r17557ea  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2001 VideoLAN 
    5  * $Id: item.c,v 1.9 2003/12/13 17:16:11 gbazin Exp $ 
     5 * $Id: item.c,v 1.10 2004/01/05 12:59:43 zorglub Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    3333 
    3434/** 
    35  * Add an MRL to the playlist. This is a simplified version of 
    36  * playlist_AddExt inculded for convenince. It equals calling playlist_AddExt 
    37  * with psz_name == psz_target and i_duration == -1 
    38  */ 
    39  
    40 int playlist_Add( playlist_t *p_playlist, const char *psz_target, 
    41                   const char **ppsz_options, int i_options, 
    42                   int i_mode, int i_pos ) 
    43 { 
    44     return playlist_AddExt( p_playlist, psz_target, psz_target, -1, 
    45                             ppsz_options, i_options, i_mode, i_pos ); 
    46 } 
    47  
    48 /** 
    49  * Add a MRL into the playlist. 
    50  * 
    51  * \param p_playlist the playlist to add into 
    52  * \param psz_uri the mrl to add to the playlist 
    53  * \param psz_name a text giving a name or description of this item 
    54  * \param i_duration a hint about the duration of this item, in microseconds,  
    55  *        or -1 if unknown. 
    56  * \param ppsz_options array of options 
    57  * \param i_options number of items in ppsz_options 
    58  * \param i_mode the mode used when adding 
    59  * \param i_pos the position in the playlist where to add. If this is 
    60  *        PLAYLIST_END the item will be added at the end of the playlist 
    61  *        regardless of it's size 
    62  * \return always returns 0 
    63 */ 
    64 int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri, 
    65                      const char * psz_name, mtime_t i_duration, 
    66                      const char **ppsz_options, int i_options, int i_mode, 
    67                      int i_pos ) 
    68 { 
    69     playlist_item_t * p_item; 
    70  
    71     p_item = malloc( sizeof( playlist_item_t ) ); 
    72     if( p_item == NULL ) 
    73     { 
    74         msg_Err( p_playlist, "out of memory" ); 
    75     } 
    76  
    77     p_item->psz_name   = strdup( psz_name ); 
    78     p_item->psz_uri    = strdup( psz_uri ); 
    79     p_item->psz_author = strdup( "" ); 
    80     p_item->i_duration = i_duration; 
    81     p_item->i_type = 0; 
    82     p_item->i_status = 0; 
    83     p_item->b_autodeletion = VLC_FALSE; 
    84     p_item->b_enabled = VLC_TRUE; 
    85     p_item->i_group = PLAYLIST_TYPE_MANUAL; 
    86  
    87     p_item->ppsz_options = NULL; 
    88     p_item->i_options = i_options; 
    89  
    90     if( i_options > 0 ) 
    91     { 
    92         int i; 
    93  
    94         p_item->ppsz_options = malloc( i_options * sizeof(char *) ); 
    95         for( i = 0; i < i_options; i++ ) 
    96         { 
    97             p_item->ppsz_options[i] = strdup( ppsz_options[i] ); 
    98         } 
    99  
    100     } 
    101  
    102     return playlist_AddItem( p_playlist, p_item, i_mode, i_pos ); 
    103 } 
    104  
    105 /** 
    10635 * Add a playlist item into a playlist 
    10736 * 
     
    11241 *        PLAYLIST_END the item will be added at the end of the playlist 
    11342 *        regardless of it's size 
    114  * \return always returns 0 
     43 * \return position of the new item 
    11544*/ 
    11645int playlist_AddItem( playlist_t *p_playlist, playlist_item_t * p_item, 
     
    14372                          free( p_item->psz_uri ); 
    14473                      } 
    145                       if( p_item->i_options ) 
    146                       { 
    147                           int i_opt; 
    148                           for( i_opt = 0; i_opt < p_item->i_options; i_opt++ ) 
    149                           { 
    150                               free( p_item->ppsz_options[i_opt] ); 
    151                           } 
    152                           free( p_item->ppsz_options ); 
    153                       } 
    154                       if( p_item->psz_author ) 
    155                       { 
    156                           free( p_item->psz_author ); 
    157                       } 
    15874                      free( p_item ); 
    15975                      vlc_mutex_unlock( &p_playlist->object_lock ); 
    160                       return 0
     76                      return -1
    16177                 } 
    16278             } 
     
    16985    msg_Dbg( p_playlist, "adding playlist item � %s � ( %s )", p_item->psz_name, p_item->psz_uri); 
    17086 
    171     /* Create the new playlist item */ 
    17287 
     88    p_item->i_id = ++p_playlist->i_last_id; 
    17389 
    17490    /* Do a few boundary checks and allocate space for the item */ 
     
    224140            free( p_playlist->pp_items[i_pos]->psz_uri ); 
    225141        } 
    226         if( p_playlist->pp_items[i_pos]->psz_author ) 
    227         { 
    228             free( p_playlist->pp_items[i_pos]->psz_author ); 
    229         } 
    230142        /* XXX: what if the item is still in use? */ 
    231143        free( p_playlist->pp_items[i_pos] ); 
     
    248160    var_Set( p_playlist, "intf-change", val ); 
    249161 
    250     return 0
     162    return p_item->i_id
    251163} 
    252  
    253 /** 
    254  * delete an item from a playlist. 
    255  * 
    256  * \param p_playlist the playlist to remove from. 
    257  * \param i_pos the position of the item to remove 
    258  * \return returns 0 
    259  */ 
    260 int playlist_Delete( playlist_t * p_playlist, int i_pos ) 
    261 { 
    262     vlc_value_t     val; 
    263  
    264     /* if i_pos is the current played item, playlist should stop playing it */ 
    265     if( p_playlist->i_status == PLAYLIST_RUNNING && 
    266         p_playlist->i_index == i_pos ) 
    267     { 
    268         playlist_Command( p_playlist, PLAYLIST_SKIP, 1 ); 
    269     } 
    270  
    271     vlc_mutex_lock( &p_playlist->object_lock ); 
    272     if( i_pos >= 0 && i_pos < p_playlist->i_size ) 
    273     { 
    274         playlist_item_t *p_item = p_playlist->pp_items[i_pos]; 
    275  
    276         msg_Dbg( p_playlist, "deleting playlist item � %s �", 
    277                  p_item->psz_name ); 
    278  
    279         if( p_item->psz_name ) 
    280         { 
    281             free( p_item->psz_name ); 
    282         } 
    283         if( p_item->psz_uri ) 
    284         { 
    285             free( p_item->psz_uri ); 
    286         } 
    287         if( p_item->psz_author ) 
    288         { 
    289             free( p_item->psz_author ); 
    290         } 
    291         if( p_item->i_options > 0 ) 
    292         { 
    293             int i; 
    294  
    295             for( i = 0; i < p_item->i_options; i++ ) 
    296             { 
    297                 free( p_item->ppsz_options[i] ); 
    298             } 
    299  
    300             free( p_item->ppsz_options ); 
    301         } 
    302  
    303         /* XXX: what if the item is still in use? */ 
    304         free( p_item ); 
    305  
    306         if( i_pos <= p_playlist->i_index ) 
    307         { 
    308             p_playlist->i_index--; 
    309         } 
    310  
    311         /* Renumber the playlist */ 
    312         REMOVE_ELEM( p_playlist->pp_items, 
    313                      p_playlist->i_size, 
    314                      i_pos ); 
    315         if( p_playlist->i_enabled > 0 ) 
    316             p_playlist->i_enabled--; 
    317     } 
    318  
    319     vlc_mutex_unlock( &p_playlist->object_lock ); 
    320  
    321     val.b_bool = VLC_TRUE; 
    322     var_Set( p_playlist, "intf-change", val ); 
    323  
    324     return 0; 
    325 } 
    326  
    327 /** 
    328  * Disables a playlist item 
    329  * 
    330  * \param p_playlist the playlist to disable from. 
    331  * \param i_pos the position of the item to disable 
    332  * \return returns 0 
    333  */ 
    334 int playlist_Disable( playlist_t * p_playlist, int i_pos ) 
    335 { 
    336     vlc_value_t     val; 
    337     vlc_mutex_lock( &p_playlist->object_lock ); 
    338  
    339  
    340     if( i_pos >= 0 && i_pos < p_playlist->i_size ) 
    341     { 
    342         msg_Dbg( p_playlist, "disabling playlist item � %s �", 
    343                              p_playlist->pp_items[i_pos]->psz_name ); 
    344  
    345         if( p_playlist->pp_items[i_pos]->b_enabled == VLC_TRUE ) 
    346             p_playlist->i_enabled--; 
    347         p_playlist->pp_items[i_pos]->b_enabled = VLC_FALSE; 
    348     } 
    349  
    350     vlc_mutex_unlock( &p_playlist->object_lock ); 
    351  
    352     val.b_bool = VLC_TRUE; 
    353     var_Set( p_playlist, "intf-change", val ); 
    354  
    355     return 0; 
    356 } 
    357  
    358 /** 
    359  * Enables a playlist item 
    360  * 
    361  * \param p_playlist the playlist to enable from. 
    362  * \param i_pos the position of the item to enable 
    363  * \return returns 0 
    364  */ 
    365 int playlist_Enable( playlist_t * p_playlist, int i_pos ) 
    366 { 
    367     vlc_value_t     val; 
    368     vlc_mutex_lock( &p_playlist->object_lock ); 
    369  
    370     if( i_pos >= 0 && i_pos < p_playlist->i_size ) 
    371     { 
    372         msg_Dbg( p_playlist, "enabling playlist item � %s �", 
    373                              p_playlist->pp_items[i_pos]->psz_name ); 
    374  
    375         if( p_playlist->pp_items[i_pos]->b_enabled == VLC_FALSE ) 
    376             p_playlist->i_enabled++; 
    377  
    378         p_playlist->pp_items[i_pos]->b_enabled = VLC_TRUE; 
    379     } 
    380  
    381     vlc_mutex_unlock( &p_playlist->object_lock ); 
    382  
    383     val.b_bool = VLC_TRUE; 
    384     var_Set( p_playlist, "intf-change", val ); 
    385  
    386     return 0; 
    387 } 
    388  
    389 /** 
    390  * Disables a playlist group 
    391  * 
    392  * \param p_playlist the playlist to disable from. 
    393  * \param i_pos the id of the group to disable 
    394  * \return returns 0 
    395  */ 
    396 int playlist_DisableGroup( playlist_t * p_playlist, int i_group) 
    397 { 
    398     vlc_value_t     val; 
    399     int i; 
    400     vlc_mutex_lock( &p_playlist->object_lock ); 
    401  
    402     msg_Dbg(p_playlist,"Disabling group %i",i_group); 
    403     for( i = 0 ; i< p_playlist->i_size; i++ ) 
    404     { 
    405         if( p_playlist->pp_items[i]->i_group == i_group ) 
    406         { 
    407             msg_Dbg( p_playlist, "disabling playlist item � %s �", 
    408                            p_playlist->pp_items[i]->psz_name ); 
    409  
    410             if( p_playlist->pp_items[i]->b_enabled == VLC_TRUE ) 
    411                 p_playlist->i_enabled--; 
    412  
    413             p_playlist->pp_items[i]->b_enabled = VLC_FALSE; 
    414         } 
    415     } 
    416     vlc_mutex_unlock( &p_playlist->object_lock ); 
    417  
    418     val.b_bool = VLC_TRUE; 
    419     var_Set( p_playlist, "intf-change", val ); 
    420  
    421     return 0; 
    422 } 
    423  
    424 /** 
    425  * Enables a playlist group 
    426  * 
    427  * \param p_playlist the playlist to enable from. 
    428  * \param i_pos the id of the group to enable 
    429  * \return returns 0 
    430  */ 
    431 int playlist_EnableGroup( playlist_t * p_playlist, int i_group) 
    432 { 
    433     vlc_value_t     val; 
    434     int i; 
    435     vlc_mutex_lock( &p_playlist->object_lock ); 
    436  
    437     for( i = 0 ; i< p_playlist->i_size; i++ ) 
    438     { 
    439         if( p_playlist->pp_items[i]->i_group == i_group ) 
    440         { 
    441             msg_Dbg( p_playlist, "enabling playlist item � %s �", 
    442                            p_playlist->pp_items[i]->psz_name ); 
    443  
    444             if( p_playlist->pp_items[i]->b_enabled == VLC_FALSE ) 
    445                 p_playlist->i_enabled++; 
    446  
    447             p_playlist->pp_items[i]->b_enabled = VLC_TRUE; 
    448         } 
    449     } 
    450     vlc_mutex_unlock( &p_playlist->object_lock ); 
    451  
    452     val.b_bool = VLC_TRUE; 
    453     var_Set( p_playlist, "intf-change", val ); 
    454  
    455     return 0; 
    456 } 
    457  
    458 /** 
    459  * Move an item in a playlist 
    460  * 
    461  * Move the item in the playlist with position i_pos before the current item 
    462  * at position i_newpos. 
    463  * \param p_playlist the playlist to move items in 
    464  * \param i_pos the position of the item to move 
    465  * \param i_newpos the position of the item that will be behind the moved item 
    466  *        after the move 
    467  * \return returns 0 
    468  */ 
    469 int playlist_Move( playlist_t * p_playlist, int i_pos, int i_newpos) 
    470 { 
    471     vlc_value_t     val; 
    472     vlc_mutex_lock( &p_playlist->object_lock ); 
    473  
    474     /* take into account that our own row disappears. */ 
    475     if ( i_pos < i_newpos ) i_newpos--; 
    476  
    477     if( i_pos >= 0 && i_newpos >=0 && i_pos <= p_playlist->i_size 
    478                      && i_newpos <= p_playlist->i_size ) 
    479     { 
    480         playlist_item_t * temp; 
    481  
    482         msg_Dbg( p_playlist, "moving playlist item � %s � (%i -> %i)", 
    483                              p_playlist->pp_items[i_pos]->psz_name, i_pos, 
    484                              i_newpos ); 
    485  
    486         if( i_pos == p_playlist->i_index ) 
    487         { 
    488             p_playlist->i_index = i_newpos; 
    489         } 
    490         else if( i_pos > p_playlist->i_index && i_newpos <= p_playlist->i_index ) 
    491         { 
    492             p_playlist->i_index++; 
    493         } 
    494         else if( i_pos < p_playlist->i_index && i_newpos >= p_playlist->i_index ) 
    495         { 
    496             p_playlist->i_index--; 
    497         } 
    498  
    499         if ( i_pos < i_newpos ) 
    500         { 
    501             temp = p_playlist->pp_items[i_pos]; 
    502             while ( i_pos < i_newpos ) 
    503             { 
    504                 p_playlist->pp_items[i_pos] = p_playlist->pp_items[i_pos+1]; 
    505                 i_pos++; 
    506             } 
    507             p_playlist->pp_items[i_newpos] = temp; 
    508         } 
    509         else if ( i_pos > i_newpos ) 
    510         { 
    511             temp = p_playlist->pp_items[i_pos]; 
    512             while ( i_pos > i_newpos ) 
    513             { 
    514                 p_playlist->pp_items[i_pos] = p_playlist->pp_items[i_pos-1]; 
    515                 i_pos--; 
    516             } 
    517             p_playlist->pp_items[i_newpos] = temp; 
    518         } 
    519     } 
    520  
    521     vlc_mutex_unlock( &p_playlist->object_lock ); 
    522  
    523     val.b_bool = VLC_TRUE; 
    524     var_Set( p_playlist, "intf-change", val ); 
    525  
    526     return 0; 
    527 } 
  • src/playlist/loadsave.c

    rfd616f9 r17557ea  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2001 VideoLAN 
    5  * $Id: loadsave.c,v 1.1 2003/10/29 18:00:46 zorglub Exp $ 
     5 * $Id: loadsave.c,v 1.2 2004/01/05 12:59:43 zorglub Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    119119       if( i_format == 5 ) 
    120120       { 
    121            playlist_Add ( p_playlist , (char *)&line , 
    122                       0, 0, PLAYLIST_APPEND , PLAYLIST_END ); 
     121           playlist_Add ( p_playlist , (char *)&line , (char *)&line, 
     122                        PLAYLIST_APPEND , PLAYLIST_END ); 
    123123       } 
    124124       else 
  • src/playlist/playlist.c

    rd3de646 r17557ea  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2001 VideoLAN 
    5  * $Id: playlist.c,v 1.70 2003/12/13 17:16:11 gbazin Exp $ 
     5 * $Id: playlist.c,v 1.71 2004/01/05 12:59:43 zorglub Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    4545static void PlayItem  ( playlist_t * ); 
    4646 
    47 #if 0 
    48 static void Poubellize ( playlist_t *, input_thread_t * ); 
    49 #endif 
    50  
    5147/** 
    5248 * Create playlist 
     
    7369    var_Set( p_playlist, "intf-change", val ); 
    7470 
     71    var_Create( p_playlist, "item-change", VLC_VAR_INTEGER ); 
     72    val.i_int = -1; 
     73    var_Set( p_playlist, "item-change", val ); 
     74 
     75    var_Create( p_playlist, "playlist-current", VLC_VAR_INTEGER ); 
     76    val.i_int = -1; 
     77    var_Set( p_playlist, "playlist-current", val ); 
     78 
    7579    var_Create( p_playlist, "intf-popupmenu", VLC_VAR_BOOL ); 
    7680 
     
    9195    p_playlist->i_groups = 0; 
    9296    p_playlist->pp_groups = NULL; 
    93     p_playlist->i_max_id = 0; 
     97    p_playlist->i_last_group = 0; 
     98    p_playlist->i_last_id = 0; 
    9499 
    95100    playlist_CreateGroup( p_playlist, "Normal" ); 
     
    122127 
    123128    var_Destroy( p_playlist, "intf-change" ); 
     129    var_Destroy( p_playlist, "item-change" ); 
    124130 
    125131    while( p_playlist->i_groups > 0 ) 
     
    158164        { 
    159165            input_StopThread( p_playlist->p_input ); 
     166            val.i_int = p_playlist->i_index; 
     167            var_Set( p_playlist, "item-change",val ); 
    160168        } 
    161169        break; 
     
    232240 
    233241    vlc_mutex_unlock( &p_playlist->object_lock ); 
    234  
     242#if 0 
    235243    val.b_bool = VLC_TRUE; 
    236244    var_Set( p_playlist, "intf-change", val ); 
    237  
     245#endif 
    238246    return; 
    239247} 
    240 /* Following functions are local */ 
     248 
    241249 
    242250static void ObjectGarbageCollector( playlist_t *p_playlist, 
     
    354362                } 
    355363 
     364                val.i_int = p_playlist->i_index; 
     365                var_Set( p_playlist, "playlist-current", val); 
     366#if 0 
    356367                val.b_bool = VLC_TRUE; 
    357368                var_Set( p_playlist, "intf-change", val ); 
     369#endif 
    358370                continue; 
    359371            } 
     
    539551static void PlayItem( playlist_t *p_playlist ) 
    540552{ 
     553    vlc_value_t val; 
    541554    if( p_playlist->i_index == -1 ) 
    542555    { 
     
    557570    p_playlist->p_input = input_CreateThread( p_playlist, 
    558571                                  p_playlist->pp_items[p_playlist->i_index] ); 
    559 
     572 
     573    val.i_int = p_playlist->i_index; 
     574    var_Set( p_playlist, "item-change", val ); 
     575
  • src/playlist/sort.c

    r4fac715 r17557ea  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2001 VideoLAN 
    5  * $Id: sort.c,v 1.3 2003/12/13 17:46:07 asmax Exp $ 
     5 * $Id: sort.c,v 1.4 2004/01/05 12:59:43 zorglub Exp $ 
    66 * 
    77 * Authors: Cl�nt Stenac <zorglub@videolan.org> 
     
    6565        vlc_mutex_unlock( &p_playlist->object_lock ); 
    6666 
    67         /* Notify the interfaces (XXX: use a different variable) */ 
     67        /* Notify the interfaces */ 
    6868        var_Set( p_playlist, "intf-change", val ); 
    6969 
     
    9090            else if( i_mode == SORT_AUTHOR ) 
    9191            { 
    92                  i_test = strcasecmp( p_playlist->pp_items[i]->psz_author, 
    93                                  p_playlist->pp_items[i_small]->psz_author ); 
     92                 i_test = strcasecmp( 
     93                          playlist_GetInfo( p_playlist, i, 
     94                                            _("General") , _("Author") ), 
     95                          playlist_GetInfo( p_playlist, i_small, 
     96                                            _("General") , _("Author") ) ); 
    9497            } 
    9598 
     
    112115    vlc_mutex_unlock( &p_playlist->object_lock ); 
    113116 
    114     /* Notify the interfaces (XXX: use a different variable) */ 
     117    /* Notify the interfaces */ 
    115118    var_Set( p_playlist, "intf-change", val ); 
    116119