Changeset 673861da5ce8bfeb0a4adbd5be95aa5fd2da9e4b

Show
Ignore:
Timestamp:
12/11/06 00:37:25 (2 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1163288245 +0000
git-parent:

[d1b0d5205fe25610f697435bff3e60e938a7bb41]

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

* Remove some unneeded complexity in playlist and directory
* Remove some unneeded wrappers and locking

Files:

Legend:

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

    rfad2848 r673861d  
    2828 
    2929#include <vlc_es.h> 
    30 #include <vlc_playlist.h> 
    3130#include <vlc_meta.h> 
    3231 
  • include/vlc_playlist.h

    r717e0b6 r673861d  
    2626 
    2727#include <assert.h> 
     28#include <vlc_input.h> 
     29#include <stdio.h> 
     30#include <stdlib.h> 
    2831 
    2932TYPEDEF_ARRAY(playlist_item_t*, playlist_item_array_t); 
     
    7477#define PLAYLIST_EXPANDED_FLAG  0x0020    /**< Expanded node */ 
    7578 
    76 /** 
    77  * Playlist status 
    78  */ 
     79/** Playlist status */ 
    7980typedef enum 
    8081{ PLAYLIST_STOPPED,PLAYLIST_RUNNING,PLAYLIST_PAUSED } playlist_status_t; 
     
    9697{ 
    9798    VLC_COMMON_MEMBERS 
    98 /** 
    99    \name playlist_t 
    100    These members are uniq to playlist_t 
    101 */ 
    102 /*@{*/ 
    10399    int                   i_enabled; /**< How many items are enabled ? */ 
    104100 
     
    173169    input_thread_t      *p_stats_computer; 
    174170    global_stats_t      *p_stats;             /**< Global statistics */ 
    175     /*@}*/ 
    176 }; 
    177  
    178 /* Helper to add an item */ 
     171}; 
     172 
     173/** Helper to add an item */ 
    179174struct playlist_add_t 
    180175{ 
     
    251246 
    252247/* Load/Save */ 
    253 VLC_EXPORT( int,  playlist_Import, ( playlist_t *, const char *, playlist_item_t *, vlc_bool_t ) ); 
    254248VLC_EXPORT( int,  playlist_Export, ( playlist_t *, const char *, playlist_item_t *, const char * ) ); 
    255249 
     
    297291VLC_EXPORT( void, playlist_NodeAddItem, ( playlist_t *, playlist_item_t *, playlist_item_t *,int , int ) ); 
    298292VLC_EXPORT( int, playlist_BothAddInput, ( playlist_t *, input_item_t *,playlist_item_t *,int , int ) ); 
    299 VLC_EXPORT( void, playlist_AddWhereverNeeded, (playlist_t* , input_item_t*, playlist_item_t*,playlist_item_t*,vlc_bool_t, int ) ); 
    300  
    301 /** Add a MRL into the playlist. 
    302  * \see playlist_Add 
    303  */ 
    304 static inline int playlist_PlaylistAdd( playlist_t *p_playlist, 
    305                           const char *psz_uri, const char *psz_name, 
    306                           int i_mode, int i_pos ) 
    307 { 
    308     return playlist_Add( p_playlist, psz_uri, psz_name, i_mode, i_pos, 
    309                          VLC_TRUE); 
    310 } 
    311  
    312 /** Add a MRL to the media library 
    313  * \see playlist_Add 
    314  */ 
    315 static inline int playlist_MLAdd( playlist_t *p_playlist, const char *psz_uri, 
    316                                   const char *psz_name, int i_mode, int i_pos ) 
    317 { 
    318     return playlist_Add( p_playlist, psz_uri, psz_name, i_mode, i_pos, 
    319                          VLC_FALSE ); 
    320 } 
    321  
    322 /** Add a MRL to the playlist, with duration and options given 
    323  * \see playlist_AddExt 
    324  */ 
    325 static inline int playlist_PlaylistAddExt( playlist_t *p_playlist, 
    326             const char * psz_uri, const char *psz_name, int i_mode, int i_pos, 
    327             mtime_t i_duration, const char **ppsz_options, int i_options )  
    328 { 
    329     return playlist_AddExt( p_playlist, psz_uri, psz_name, i_mode, i_pos, 
    330                             i_duration, ppsz_options, i_options, VLC_TRUE ); 
    331 } 
    332  
    333 /** Add a MRL to the media library, with duration and options given 
    334  * \see playlist_AddExt 
    335  */ 
    336 static inline int playlist_MLAddExt( playlist_t *p_playlist, 
    337             const char * psz_uri, const char *psz_name, int i_mode, int i_pos, 
    338             mtime_t i_duration, const char **ppsz_options, int i_options )  
    339 { 
    340     return playlist_AddExt( p_playlist, psz_uri, psz_name, i_mode, i_pos, 
    341                             i_duration, ppsz_options, i_options, VLC_FALSE ); 
    342 } 
    343  
    344 /** Add an input item to the playlist node 
    345  * \see playlist_AddInput 
    346  */ 
    347 static inline int playlist_PlaylistAddInput( playlist_t* p_playlist, 
    348                                 input_item_t *p_input, int i_mode, int i_pos ) 
    349 { 
    350     return playlist_AddInput( p_playlist, p_input, i_mode, i_pos, VLC_TRUE ); 
    351 } 
    352  
    353 /** Add an input item to the media library 
    354  * \see playlist_AddInput 
    355  */ 
    356 static inline int playlist_MLAddInput( playlist_t* p_playlist, 
    357                                 input_item_t *p_input, int i_mode, int i_pos ) 
    358 { 
    359     return playlist_AddInput( p_playlist, p_input, i_mode, i_pos, VLC_FALSE ); 
    360 } 
    361293 
    362294/********************** Misc item operations **********************/ 
     
    414346 * Inline functions 
    415347 ***********************************************************************/ 
     348/** Open a playlist file, add its content to the current playlist */ 
     349static inline int playlist_Import( playlist_t *p_playlist, const char *psz_file){ 
     350    char psz_uri[256+10]; 
     351    input_item_t *p_input; 
     352    snprintf( psz_uri, 256+9, "file/://%s", psz_file ); 
     353    p_input = input_ItemNewExt( p_playlist, psz_uri, psz_file, 0, NULL, -1 ); 
     354    playlist_AddInput( p_playlist, p_input, PLAYLIST_APPEND, PLAYLIST_END, 
     355                       VLC_TRUE ); 
     356    input_Read( p_playlist, p_input, VLC_TRUE ); 
     357    return VLC_SUCCESS; 
     358} 
    416359 
    417360/** Tell if the playlist is currently running */ 
    418 static inline vlc_bool_t playlist_IsPlaying( playlist_t * p_playlist ) 
    419 
    420     vlc_bool_t b_playing; 
    421     vlc_mutex_lock( &p_playlist->object_lock ); 
    422     b_playing = p_playlist->status.i_status == PLAYLIST_RUNNING; 
    423     vlc_mutex_unlock( &p_playlist->object_lock ); 
    424     return( b_playing ); 
    425 
     361#define playlist_IsPlaying( pl ) ( pl->status.i_status == PLAYLIST_RUNNING ) 
    426362 
    427363/** Tell if the playlist is empty */ 
    428 static inline vlc_bool_t playlist_IsEmpty( playlist_t * p_playlist ) 
    429 
    430     vlc_bool_t b_empty; 
    431     vlc_mutex_lock( &p_playlist->object_lock ); 
    432     b_empty = p_playlist->items.i_size == 0; 
    433     vlc_mutex_unlock( &p_playlist->object_lock ); 
    434     return( b_empty ); 
    435 
     364#define playlist_IsEmpty( pl ) ( pl->items.i_size == 0 ) 
    436365 
    437366/** Tell the number of items in the current playing context */ 
    438 static inline int playlist_CurrentSize( vlc_object_t *p_this ) 
    439 
    440     return p_this->p_libvlc->p_playlist->current.i_size; 
    441 
     367#define playlist_CurrentSize( obj ) obj->p_libvlc->p_playlist->current.i_size 
     368 
    442369 
    443370/** Ask the playlist to do some work */ 
  • include/vlc_symbols.h

    r4e3e7fc r673861d  
    313313    int (*playlist_NodeSort_inner) (playlist_t *, playlist_item_t *,int, int); 
    314314    int (*playlist_RecursiveNodeSort_inner) (playlist_t *, playlist_item_t *,int, int); 
    315     int (*playlist_Import_inner) (playlist_t *, const char *, playlist_item_t *, vlc_bool_t)
     315    void *playlist_Import_deprecated
    316316    int (*playlist_Export_inner) (playlist_t *, const char *, playlist_item_t *, const char *); 
    317317    spu_t * (*__spu_Create_inner) (vlc_object_t *); 
     
    507507    int (*playlist_DeleteAllFromInput_inner) (playlist_t *, int); 
    508508    int (*playlist_LockDeleteAllFromInput_inner) (playlist_t *, int); 
    509     void (*playlist_AddWhereverNeeded_inner) (playlist_t* , input_item_t*, playlist_item_t*,playlist_item_t*,vlc_bool_t, int)
     509    void *playlist_AddWhereverNeeded_deprecated
    510510    int (*playlist_DeleteFromItemId_inner) (playlist_t *, int); 
    511511    void (*playlist_NodeDump_inner) (playlist_t *p_playlist, playlist_item_t *p_item, int i_level); 
     
    558558    char * (*str_format_time_inner) (char *); 
    559559    char * (*__str_format_meta_inner) (vlc_object_t *, char *); 
     560    int (*vout_Snapshot_inner) (vout_thread_t *p_vout, picture_t *p_pic); 
    560561}; 
    561562# if defined (__PLUGIN__) 
     
    822823#  define playlist_NodeSort (p_symbols)->playlist_NodeSort_inner 
    823824#  define playlist_RecursiveNodeSort (p_symbols)->playlist_RecursiveNodeSort_inner 
    824 #  define playlist_Import (p_symbols)->playlist_Import_inner 
    825825#  define playlist_Export (p_symbols)->playlist_Export_inner 
    826826#  define __spu_Create (p_symbols)->__spu_Create_inner 
     
    997997#  define playlist_DeleteAllFromInput (p_symbols)->playlist_DeleteAllFromInput_inner 
    998998#  define playlist_LockDeleteAllFromInput (p_symbols)->playlist_LockDeleteAllFromInput_inner 
    999 #  define playlist_AddWhereverNeeded (p_symbols)->playlist_AddWhereverNeeded_inner 
    1000999#  define playlist_DeleteFromItemId (p_symbols)->playlist_DeleteFromItemId_inner 
    10011000#  define playlist_NodeDump (p_symbols)->playlist_NodeDump_inner 
     
    10351034#  define str_format_time (p_symbols)->str_format_time_inner 
    10361035#  define __str_format_meta (p_symbols)->__str_format_meta_inner 
     1036#  define vout_Snapshot (p_symbols)->vout_Snapshot_inner 
    10371037# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) 
    10381038/****************************************************************** 
     
    13021302    ((p_symbols)->playlist_NodeSort_inner) = playlist_NodeSort; \ 
    13031303    ((p_symbols)->playlist_RecursiveNodeSort_inner) = playlist_RecursiveNodeSort; \ 
    1304     ((p_symbols)->playlist_Import_inner) = playlist_Import; \ 
    13051304    ((p_symbols)->playlist_Export_inner) = playlist_Export; \ 
    13061305    ((p_symbols)->__spu_Create_inner) = __spu_Create; \ 
     
    14771476    ((p_symbols)->playlist_DeleteAllFromInput_inner) = playlist_DeleteAllFromInput; \ 
    14781477    ((p_symbols)->playlist_LockDeleteAllFromInput_inner) = playlist_LockDeleteAllFromInput; \ 
    1479     ((p_symbols)->playlist_AddWhereverNeeded_inner) = playlist_AddWhereverNeeded; \ 
    14801478    ((p_symbols)->playlist_DeleteFromItemId_inner) = playlist_DeleteFromItemId; \ 
    14811479    ((p_symbols)->playlist_NodeDump_inner) = playlist_NodeDump; \ 
     
    15151513    ((p_symbols)->str_format_time_inner) = str_format_time; \ 
    15161514    ((p_symbols)->__str_format_meta_inner) = __str_format_meta; \ 
     1515    ((p_symbols)->vout_Snapshot_inner) = vout_Snapshot; \ 
    15171516    (p_symbols)->net_ConvertIPv4_deprecated = NULL; \ 
    15181517    (p_symbols)->__sout_CfgParse_deprecated = NULL; \ 
     
    15461545    (p_symbols)->playlist_Move_deprecated = NULL; \ 
    15471546    (p_symbols)->playlist_NodeGroup_deprecated = NULL; \ 
     1547    (p_symbols)->playlist_Import_deprecated = NULL; \ 
    15481548    (p_symbols)->playlist_NodeRemoveParent_deprecated = NULL; \ 
    15491549    (p_symbols)->__vlc_fix_readdir_charset_deprecated = NULL; \ 
     
    15651565    (p_symbols)->playlist_PlaylistAddInput_deprecated = NULL; \ 
    15661566    (p_symbols)->vlc_input_item_AddOption_deprecated = NULL; \ 
     1567    (p_symbols)->playlist_AddWhereverNeeded_deprecated = NULL; \ 
    15671568    (p_symbols)->__intf_UserOkayCancel_deprecated = NULL; \ 
    15681569    (p_symbols)->playlist_NodesCreateForSD_deprecated = NULL; \ 
  • modules/access/cdda.c

    r19f542a r673861d  
    502502        } 
    503503#endif 
    504         playlist_AddWhereverNeeded( p_playlist, p_input_item, p_parent
    505                                p_item_in_category, VLC_FALSE, PLAYLIST_APPEND ); 
     504        playlist_BothAddInput( p_playlist, p_input_item, p_item_in_category
     505                               PLAYLIST_APPEND, PLAYLIST_END ); 
    506506        free( psz_uri ); free( psz_opt ); free( psz_name ); 
    507507        free( psz_first ); free( psz_last ); 
  • modules/access/directory.c

    r128cbba r673861d  
    179179static int Read( access_t *p_access, uint8_t *p_buffer, int i_len) 
    180180{ 
    181     char *psz; 
    182     int  i_mode, i_activity; 
    183  
    184     char *psz_name = strdup (p_access->psz_path); 
    185     if (psz_name == NULL) 
     181    char               *psz; 
     182    int                 i_mode, i_activity; 
     183    playlist_t         *p_playlist = pl_Yield( p_access ); 
     184    playlist_item_t    *p_item_in_category; 
     185    input_item_t       *p_current_input = ( (input_thread_t*)p_access->p_parent) 
     186                                                       ->input.p_item; 
     187    playlist_item_t    *p_current = 
     188                playlist_LockItemGetByInput( p_playlist, p_current_input ); 
     189    char               *psz_name = strdup (p_access->psz_path); 
     190 
     191    if( psz_name == NULL ) 
    186192        return VLC_ENOMEM; 
     193 
     194    if( p_current == NULL ) { 
     195        msg_Err( p_access, "unable to find item in playlist" ); 
     196        return VLC_ENOOBJ; 
     197    } 
    187198 
    188199    /* Remove the ending '/' char */ 
     
    197208        } 
    198209    } 
    199  
    200     playlist_item_t *p_item, *p_root_category; 
    201     playlist_t *p_playlist = pl_Yield( p_access ); 
    202210 
    203211    /* Handle mode */ 
     
    213221    msg_Dbg( p_access, "opening directory `%s'", p_access->psz_path ); 
    214222 
    215     if( p_playlist->status.p_item && p_playlist->status.p_item->p_input == 
    216         ((input_thread_t *)p_access->p_parent)->input.p_item ) 
    217         p_item = p_playlist->status.p_item; 
    218     else 
    219     { 
    220         input_item_t *p_current = ( (input_thread_t*)p_access->p_parent)-> 
    221                                                         input.p_item; 
    222         p_item = playlist_LockItemGetByInput( p_playlist, p_current ); 
    223         if( !p_item ) 
    224         { 
    225             msg_Dbg( p_playlist, "unable to find item in playlist"); 
    226             return VLC_ENOOBJ; 
    227         } 
    228     } 
    229     p_item->p_input->i_type = ITEM_TYPE_DIRECTORY; 
    230  
    231     p_root_category = playlist_LockItemToNode( p_playlist, p_item ); 
     223    p_current->p_input->i_type = ITEM_TYPE_DIRECTORY; 
     224    p_item_in_category = playlist_LockItemToNode( p_playlist, p_current ); 
    232225 
    233226    i_activity = var_GetInteger( p_playlist, "activity" ); 
     
    235228                    DIRECTORY_ACTIVITY ); 
    236229 
    237     ReadDir( p_playlist, psz_name, i_mode, p_item, p_root_category ); 
     230    ReadDir( p_playlist, psz_name, i_mode, p_current, p_item_in_category ); 
    238231 
    239232    i_activity = var_GetInteger( p_playlist, "activity" ); 
    240233    var_SetInteger( p_playlist, "activity", i_activity - 
    241234                    DIRECTORY_ACTIVITY ); 
     235 
    242236    if( psz_name ) free( psz_name ); 
    243237    vlc_object_release( p_playlist ); 
     
    476470                                                 -1, ITEM_TYPE_VFILE ); 
    477471                if (p_input != NULL) 
    478                     playlist_AddWhereverNeeded (p_playlist, p_input, p_parent, 
    479                                                 p_parent_category, VLC_FALSE, 
    480                                                 PLAYLIST_APPEND|PLAYLIST_PREPARSE); 
     472                    playlist_BothAddInput( p_playlist, p_input, 
     473                                           p_parent_category, 
     474                                           PLAYLIST_APPEND|PLAYLIST_PREPARSE, 
     475                                           PLAYLIST_END ); 
    481476            } 
    482477        } 
  • modules/access/mms/mmsh.c

    r415749b r673861d  
    113113 
    114114        /** \bug we do not autodelete here */ 
    115         playlist_PlaylistAdd( p_playlist, psz_location, psz_location, 
    116                               PLAYLIST_INSERT | PLAYLIST_GO, PLAYLIST_END ); 
     115        playlist_Add( p_playlist, psz_location, psz_location, 
     116                      PLAYLIST_INSERT | PLAYLIST_GO, PLAYLIST_END, VLC_TRUE ); 
    117117        vlc_object_release( p_playlist ); 
    118118 
  • modules/codec/cmml/intf.c

    ra79b5f6 r673861d  
    796796{ 
    797797    playlist_Stop( p_playlist ); 
    798     (void) playlist_PlaylistAdd( p_playlist, psz_uri, psz_uri, 
    799                          PLAYLIST_INSERT /* FIXME: used to be PLAYLIST_REPLACE */, PLAYLIST_END|PLAYLIST_GO /* FIXME: p_playlist->status.i_index */ ); 
     798    (void) playlist_Add( p_playlist, psz_uri, psz_uri, 
     799                         PLAYLIST_INSERT /* FIXME: used to be PLAYLIST_REPLACE */, PLAYLIST_END|PLAYLIST_GO, VLC_TRUE /* FIXME: p_playlist->status.i_index */ ); 
    800800} 
    801801 
  • modules/control/http/macro.c

    r799b282 r673861d  
    339339                    else 
    340340                    { 
    341                         playlist_PlaylistAddInput( p_sys->p_playlist, p_input, 
    342                                           PLAYLIST_APPEND, PLAYLIST_END ); 
     341                        playlist_AddInput( p_sys->p_playlist, p_input, 
     342                                     PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE ); 
    343343                        msg_Dbg( p_intf, "requested mrl add: %s", mrl ); 
    344344                    } 
  • modules/control/http/rpn.c

    raedf2f6 r673861d  
    851851            else 
    852852            { 
    853                 i_id = playlist_PlaylistAddInput( p_sys->p_playlist, p_input, 
    854                                          PLAYLIST_APPEND, PLAYLIST_END ); 
     853                i_id = playlist_AddInput( p_sys->p_playlist, p_input, 
     854                                   PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE ); 
    855855                msg_Dbg( p_intf, "requested mrl add: %s", mrl ); 
    856856            } 
  • modules/control/rc.c

    rd94f906 r673861d  
    14171417        { 
    14181418            msg_rc( "Trying to add %s to playlist.", newval.psz_string ); 
    1419             playlist_PlaylistAddInput( p_playlist, p_item, 
    1420                               PLAYLIST_GO|PLAYLIST_APPEND, PLAYLIST_END ); 
     1419            playlist_AddInput( p_playlist, p_item, 
     1420                     PLAYLIST_GO|PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE ); 
    14211421        } 
    14221422    } 
     
    14291429        { 
    14301430            msg_rc( "trying to enqueue %s to playlist", newval.psz_string ); 
    1431             playlist_PlaylistAddInput( p_playlist, p_item, 
    1432                               PLAYLIST_APPEND, PLAYLIST_END ); 
     1431            playlist_AddInput( p_playlist, p_item, 
     1432                              PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE ); 
    14331433        } 
    14341434    } 
  • modules/demux/mp4/mp4.c

    r7f779f6 r673861d  
    416416                                            0, NULL, -1 ); 
    417417                        input_ItemCopyOptions( p_current->p_input, p_input ); 
    418                         playlist_AddWhereverNeeded( p_playlist, p_input, p_current, 
    419                                 p_item_in_category, VLC_FALSE, PLAYLIST_APPEND ); 
     418                        playlist_BothAddInput( p_playlist, p_input, 
     419                                               p_item_in_category, 
     420                                               PLAYLIST_APPEND, PLAYLIST_END ); 
    420421                    } 
    421422                } 
  • modules/demux/playlist/asx.c

    r11566f0 r673861d  
    132132    char        *psz_backup = NULL; 
    133133    vlc_bool_t  b_entry = VLC_FALSE; 
    134  
     134    input_item_t *p_input; 
    135135    INIT_PLAYLIST_STUFF; 
    136136 
     
    356356                            p_input = input_ItemNew( p_playlist, psz_string, psz_title_asx ); 
    357357                            input_ItemCopyOptions( p_current->p_input, p_input ); 
    358                             playlist_AddWhereverNeeded( p_playlist, p_input, p_current, 
    359                                  p_item_in_category, (i_parent_id > 0 )? VLC_TRUE : VLC_FALSE, 
    360                                  PLAYLIST_APPEND ); 
     358                            playlist_BothAddInput( p_playlist, p_input, 
     359                                                   p_item_in_category, 
     360                                                   PLAYLIST_APPEND, 
     361                                                   PLAYLIST_END ); 
    361362                            free( psz_string ); 
    362363                        } 
     
    435436                            if( psz_moreinfo_entry ) vlc_meta_SetURL( p_entry->p_meta, psz_moreinfo_entry ); 
    436437                            if( psz_abstract_entry ) vlc_meta_SetDescription( p_entry->p_meta, psz_abstract_entry ); 
    437                              
    438                             playlist_AddWhereverNeeded( p_playlist, p_entry, p_current, 
    439                                 p_item_in_category, (i_parent_id > 0 )? VLC_TRUE : VLC_FALSE, 
    440                                 PLAYLIST_APPEND ); 
     438                            playlist_BothAddInput( p_playlist, p_entry, 
     439                                                 p_item_in_category, 
     440                                                 PLAYLIST_APPEND, PLAYLIST_END); 
    441441                            free( psz_string ); 
    442442                        } 
  • modules/demux/playlist/b4s.c

    r3923780 r673861d  
    8585    char *psz_elname = NULL; 
    8686    int i_type; 
     87    input_item_t *p_input; 
    8788    char *psz_mrl = NULL, *psz_name = NULL, *psz_genre = NULL; 
    8889    char *psz_now = NULL, *psz_listeners = NULL, *psz_bitrate = NULL; 
     
    266267                        msg_Err( p_playlist, "Unsupported meta bitrate" ); 
    267268 
    268                     playlist_AddWhereverNeeded( p_playlist, p_input, p_current, 
    269                          p_item_in_category, (i_parent_id > 0 ) ? VLC_TRUE: 
    270                                                  VLC_FALSE, PLAYLIST_APPEND ); 
    271  
     269                    playlist_BothAddInput( p_playlist, p_input, 
     270                                           p_item_in_category, 
     271                                           PLAYLIST_APPEND, PLAYLIST_END ); 
    272272                    FREENULL( psz_name ); 
    273273                    FREENULL( psz_mrl ); 
  • modules/demux/playlist/dvb.c

    r857b51f r673861d  
    9696{ 
    9797    char       *psz_line; 
     98    input_item_t *p_input; 
    9899    INIT_PLAYLIST_STUFF; 
    99100 
     
    118119            input_ItemAddOption( p_input, ppsz_options[i] ); 
    119120        } 
    120         playlist_AddWhereverNeeded( p_playlist, p_input, p_current,  
    121                                     p_item_in_category, 
    122                                     (i_parent_id > 0 ) ? VLC_TRUE: VLC_FALSE, 
    123                                     PLAYLIST_APPEND ); 
     121        playlist_BothAddInput( p_playlist, p_input, p_item_in_category, 
     122                               PLAYLIST_APPEND, PLAYLIST_END ); 
    124123 
    125124        while( i_options-- ) free( ppsz_options[i_options] ); 
  • modules/demux/playlist/gvp.c

    r64220f4 r673861d  
    6363    playlist_item_t *p_current; 
    6464    playlist_item_t *p_item_in_category; 
    65     int i_parent_id; 
    6665}; 
    6766 
     
    130129    char *psz_title = NULL; 
    131130    char *psz_description = NULL; 
     131    input_item_t *p_input; 
    132132 
    133133    INIT_PLAYLIST_STUFF; 
     
    135135    p_sys->p_playlist = p_playlist; 
    136136    p_sys->p_current = p_current; 
    137     p_sys->i_parent_id = i_parent_id; 
    138137    p_sys->p_item_in_category = p_item_in_category; 
    139138 
     
    215214        SADD_INFO( "docid", psz_docid ); 
    216215        SADD_INFO( "description", psz_description ); 
    217         playlist_AddWhereverNeeded( p_sys->p_playlist, p_input, 
    218                             p_sys->p_current, p_sys->p_item_in_category, 
    219                             (p_sys->i_parent_id > 0 ) ? VLC_TRUE: VLC_FALSE, 
    220                             PLAYLIST_APPEND ); 
     216        playlist_BothAddInput( p_sys->p_playlist, p_input, 
     217                               p_sys->p_item_in_category, 
     218                               PLAYLIST_APPEND, PLAYLIST_END ); 
    221219    } 
    222220 
  • modules/demux/playlist/m3u.c

    r857b51f r673861d  
    5757    CHECK_PEEK( p_peek, 8 ); 
    5858 
    59     if( POKE( p_peek, "#EXTM3U", 7 ) || POKE( p_peek, "RTSPtext", 8 ) || 
    60         isExtension( p_demux, ".m3u" ) || isExtension( p_demux, ".vlc" ) || 
    61         /* A .ram file can contain a single rtsp link */ 
    62         isExtension( p_demux, ".ram" ) || isExtension( p_demux, ".rm" ) || 
    63         isDemux( p_demux,  "m3u" ) ) 
    64     { 
    65         ; 
    66     } 
    67     else 
     59    if(! ( POKE( p_peek, "#EXTM3U", 7 ) || POKE( p_peek, "RTSPtext", 8 ) || 
     60           isExtension( p_demux, ".m3u" ) || isExtension( p_demux, ".vlc" ) || 
     61           /* A .ram file can contain a single rtsp link */ 
     62           isExtension( p_demux, ".ram" ) || isExtension( p_demux, ".rm" ) || 
     63           isDemux( p_demux,  "m3u" ) ) ) 
    6864        return VLC_EGENERIC; 
    6965 
     
    8076{ 
    8177    demux_t *p_demux = (demux_t *)p_this; 
    82  
    83     if( p_demux->p_sys->psz_prefix ) free( p_demux->p_sys->psz_prefix ); 
     78    free( p_demux->p_sys->psz_prefix ); 
    8479    free( p_demux->p_sys ); 
    8580} 
     
    9590    int        i_options = 0, i; 
    9691    vlc_bool_t b_cleanup = VLC_FALSE; 
     92    input_item_t *p_input; 
    9793 
    9894    INIT_PLAYLIST_STUFF; 
     
    173169                input_ItemAddInfo( p_input, _(VLC_META_INFO_CAT), 
    174170                                        _(VLC_META_ARTIST), "%s", psz_artist ); 
    175             playlist_AddWhereverNeeded( p_playlist, p_input, p_current, 
    176                  p_item_in_category, (i_parent_id > 0 )? VLC_TRUE : VLC_FALSE, 
    177                  PLAYLIST_APPEND ); 
     171            playlist_BothAddInput( p_playlist, p_input, p_item_in_category, 
     172                                   PLAYLIST_APPEND, PLAYLIST_END ); 
    178173            free( psz_mrl ); 
    179174        } 
  • modules/demux/playlist/playlist.c

    r318e9b8 r673861d  
    165165    return psz_mrl; 
    166166} 
    167  
    168 void E_(AddToPlaylist)( demux_t *p_demux, playlist_t *p_playlist, 
    169                         input_item_t *p_input, 
    170                         playlist_item_t *p_item, int i_parent_id ) 
    171 { 
    172     // Only add to parent if specific parent requested or not current 
    173     // playlist item 
    174    if( i_parent_id > 0 || ! ( 
    175          p_playlist->status.p_item && 
    176          p_playlist->status.p_item->p_input == 
    177               ((input_thread_t *)p_demux->p_parent)->input.p_item ) ) 
    178    { 
    179        playlist_NodeAddInput( p_playlist, p_input, p_item, 
    180                               PLAYLIST_APPEND, PLAYLIST_END ); 
    181    } 
    182    // Else, add to both 
    183    else 
    184    { 
    185        playlist_BothAddInput( p_playlist, p_input, p_item, 
    186                               PLAYLIST_APPEND, PLAYLIST_END ); 
    187    } 
    188    input_ItemCopyOptions( p_item->p_input, p_input ); 
    189 } 
    190  
    191  
    192 vlc_bool_t E_(FindItem)( demux_t *p_demux, playlist_t *p_playlist, 
    193                      playlist_item_t **pp_item ) 
    194 { 
    195      vlc_bool_t b_play = var_CreateGetBool( p_demux, "playlist-autostart" ); 
    196  
    197      if( b_play && p_playlist->status.p_item && 
    198              p_playlist->status.p_item->p_input == 
    199                 ((input_thread_t *)p_demux->p_parent)->input.p_item ) 
    200      { 
    201          msg_Dbg( p_playlist, "starting playlist playback" ); 
    202          *pp_item = p_playlist->status.p_item; 
    203          b_play = VLC_TRUE; 
    204      } 
    205      else 
    206      { 
    207          input_item_t *p_current = ( (input_thread_t*)p_demux->p_parent)-> 
    208                                                         input.p_item; 
    209          *pp_item = playlist_LockItemGetByInput( p_playlist, p_current ); 
    210          if( !*pp_item ) 
    211          { 
    212              msg_Dbg( p_playlist, "unable to find item in playlist"); 
    213          } 
    214          msg_Dbg( p_playlist, "not starting playlist playback"); 
    215          p_playlist->status.i_status = PLAYLIST_STOPPED; 
    216          b_play = VLC_FALSE; 
    217      } 
    218      return b_play; 
    219 } 
  • modules/demux/playlist/playlist.h

    r318e9b8 r673861d  
    2222 *****************************************************************************/ 
    2323 
     24#include <vlc_playlist.h> 
    2425char *E_(ProcessMRL)( char *, char * ); 
    2526char *E_(FindPrefix)( demux_t * ); 
     
    6869 
    6970#define INIT_PLAYLIST_STUFF \ 
    70     int i_parent_id; \ 
    71     vlc_bool_t b_play; \ 
    72     playlist_item_t *p_current, *p_item_in_category = NULL; \ 
    73     input_item_t *p_input; \ 
    7471    playlist_t *p_playlist = pl_Yield( p_demux ); \ 
    75     i_parent_id = var_CreateGetInteger( p_demux, "parent-item" ); \ 
    76     if( i_parent_id > 0 ) \ 
    77     { \ 
    78         b_play = VLC_FALSE;     \ 
    79         p_current = playlist_ItemGetById( p_playlist, i_parent_id );    \ 
    80     } \ 
    81     else \ 
    82     { \ 
    83         b_play = E_(FindItem)( p_demux, p_playlist, &p_current ); \ 
    84         p_item_in_category = playlist_ItemToNode( p_playlist, p_current ); \ 
    85         p_item_in_category->p_input->i_type = ITEM_TYPE_PLAYLIST;        \ 
    86     } 
     72    vlc_bool_t b_play = var_CreateGetBool( p_demux, "playlist-autostart" ); \ 
     73    input_item_t *p_current_input = ( (input_thread_t*)p_demux->p_parent)-> \ 
     74                                                         input.p_item; \ 
     75    playlist_item_t *p_current = \ 
     76                 playlist_LockItemGetByInput( p_playlist, p_current_input ); \ 
     77    playlist_item_t *p_item_in_category = \ 
     78                            playlist_ItemToNode( p_playlist, p_current ); \ 
     79    b_play = b_play && p_current == p_playlist->status.p_item; \ 
     80    if( p_item_in_category ) \ 
     81        p_item_in_category->p_input->i_type = ITEM_TYPE_PLAYLIST; 
    8782 
    8883#define HANDLE_PLAY_AND_RELEASE \ 
    8984    /* Go back and play the playlist */ \ 
    90     if( b_play && p_playlist->status.p_item && \ 
    91                   p_playlist->status.p_item->i_children > 0 ) \ 
    92     { \ 
    93         playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,  \ 
    94                           p_playlist->status.p_item, NULL ); \ 
    95     } \ 
     85    if( b_play && p_item_in_category && p_item_in_category->i_children > 0 ) \ 
     86        playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, p_item_in_category, \ 
     87                          NULL ); \ 
    9688    vlc_object_release( p_playlist ); 
    97  
  • modules/demux/playlist/pls.c

    r857b51f r673861d  
    9090    int            i_new_item = 0; 
    9191    int            i_key_length; 
     92    input_item_t *p_input; 
    9293 
    9394    INIT_PLAYLIST_STUFF; 
     
    156157                                            0, NULL, -1 ); 
    157158                input_ItemCopyOptions( p_current->p_input, p_input ); 
    158                 playlist_AddWhereverNeeded( p_playlist, p_input, p_current, 
    159                                 p_item_in_category, (i_parent_id > 0 ) ? 
    160                                 VLC_TRUE: VLC_FALSE, PLAYLIST_APPEND ); 
     159                playlist_BothAddInput( p_playlist, p_input, p_item_in_category, 
     160                                        PLAYLIST_APPEND, PLAYLIST_END ); 
    161161            } 
    162162            else 
     
    213213        p_input = input_ItemNewExt( p_playlist, psz_mrl, psz_name,0, NULL, -1 ); 
    214214        input_ItemCopyOptions( p_current->p_input, p_input ); 
    215         playlist_AddWhereverNeeded( p_playlist, p_input, p_current, 
    216                                 p_item_in_category, (i_parent_id > 0 ) ? 
    217                                 VLC_TRUE: VLC_FALSE, PLAYLIST_APPEND ); 
     215        playlist_BothAddInput( p_playlist, p_input, p_item_in_category, 
     216                               PLAYLIST_APPEND, PLAYLIST_END ); 
    218217