Commit 673861da authored by Clément Stenac's avatar Clément Stenac

* Remove some unneeded complexity in playlist and directory

* Remove some unneeded wrappers and locking
parent d1b0d520
......@@ -27,7 +27,6 @@
#define _VLC__INPUT_H 1
#include <vlc_es.h>
#include <vlc_playlist.h>
#include <vlc_meta.h>
struct vlc_meta_t;
......
......@@ -25,6 +25,9 @@
#define _VLC_PLAYLIST_H_
#include <assert.h>
#include <vlc_input.h>
#include <stdio.h>
#include <stdlib.h>
TYPEDEF_ARRAY(playlist_item_t*, playlist_item_array_t);
TYPEDEF_ARRAY(input_item_t*, input_item_array_t);
......@@ -73,9 +76,7 @@ struct playlist_item_t
#define PLAYLIST_REMOVE_FLAG 0x0010 /**< Remove this item at the end */
#define PLAYLIST_EXPANDED_FLAG 0x0020 /**< Expanded node */
/**
* Playlist status
*/
/** Playlist status */
typedef enum
{ PLAYLIST_STOPPED,PLAYLIST_RUNNING,PLAYLIST_PAUSED } playlist_status_t;
......@@ -95,11 +96,6 @@ struct services_discovery_t
struct playlist_t
{
VLC_COMMON_MEMBERS
/**
\name playlist_t
These members are uniq to playlist_t
*/
/*@{*/
int i_enabled; /**< How many items are enabled ? */
playlist_item_array_t items; /**< Arrays of items */
......@@ -172,10 +168,9 @@ struct playlist_t
/** The input thread computing stats */
input_thread_t *p_stats_computer;
global_stats_t *p_stats; /**< Global statistics */
/*@}*/
};
/* Helper to add an item */
/** Helper to add an item */
struct playlist_add_t
{
int i_node;
......@@ -250,7 +245,6 @@ VLC_EXPORT( int, playlist_NodeSort, ( playlist_t *, playlist_item_t *,int, int
VLC_EXPORT( int, playlist_RecursiveNodeSort, ( playlist_t *, playlist_item_t *,int, int ) );
/* Load/Save */
VLC_EXPORT( int, playlist_Import, ( playlist_t *, const char *, playlist_item_t *, vlc_bool_t ) );
VLC_EXPORT( int, playlist_Export, ( playlist_t *, const char *, playlist_item_t *, const char * ) );
/********************************************************
......@@ -296,68 +290,6 @@ VLC_EXPORT( int, playlist_AddInput, ( playlist_t *, input_item_t *,int , int, vl
VLC_EXPORT( playlist_item_t *, playlist_NodeAddInput, ( playlist_t *, input_item_t *,playlist_item_t *,int , int ) );
VLC_EXPORT( void, playlist_NodeAddItem, ( playlist_t *, playlist_item_t *, playlist_item_t *,int , int ) );
VLC_EXPORT( int, playlist_BothAddInput, ( playlist_t *, input_item_t *,playlist_item_t *,int , int ) );
VLC_EXPORT( void, playlist_AddWhereverNeeded, (playlist_t* , input_item_t*, playlist_item_t*,playlist_item_t*,vlc_bool_t, int ) );
/** Add a MRL into the playlist.
* \see playlist_Add
*/
static inline int playlist_PlaylistAdd( playlist_t *p_playlist,
const char *psz_uri, const char *psz_name,
int i_mode, int i_pos )
{
return playlist_Add( p_playlist, psz_uri, psz_name, i_mode, i_pos,
VLC_TRUE);
}
/** Add a MRL to the media library
* \see playlist_Add
*/
static inline int playlist_MLAdd( playlist_t *p_playlist, const char *psz_uri,
const char *psz_name, int i_mode, int i_pos )
{
return playlist_Add( p_playlist, psz_uri, psz_name, i_mode, i_pos,
VLC_FALSE );
}
/** Add a MRL to the playlist, with duration and options given
* \see playlist_AddExt
*/
static inline int playlist_PlaylistAddExt( playlist_t *p_playlist,
const char * psz_uri, const char *psz_name, int i_mode, int i_pos,
mtime_t i_duration, const char **ppsz_options, int i_options )
{
return playlist_AddExt( p_playlist, psz_uri, psz_name, i_mode, i_pos,
i_duration, ppsz_options, i_options, VLC_TRUE );
}
/** Add a MRL to the media library, with duration and options given
* \see playlist_AddExt
*/
static inline int playlist_MLAddExt( playlist_t *p_playlist,
const char * psz_uri, const char *psz_name, int i_mode, int i_pos,
mtime_t i_duration, const char **ppsz_options, int i_options )
{
return playlist_AddExt( p_playlist, psz_uri, psz_name, i_mode, i_pos,
i_duration, ppsz_options, i_options, VLC_FALSE );
}
/** Add an input item to the playlist node
* \see playlist_AddInput
*/
static inline int playlist_PlaylistAddInput( playlist_t* p_playlist,
input_item_t *p_input, int i_mode, int i_pos )
{
return playlist_AddInput( p_playlist, p_input, i_mode, i_pos, VLC_TRUE );
}
/** Add an input item to the media library
* \see playlist_AddInput
*/
static inline int playlist_MLAddInput( playlist_t* p_playlist,
input_item_t *p_input, int i_mode, int i_pos )
{
return playlist_AddInput( p_playlist, p_input, i_mode, i_pos, VLC_FALSE );
}
/********************** Misc item operations **********************/
VLC_EXPORT( playlist_item_t*, playlist_ItemToNode, (playlist_t *,playlist_item_t *) );
......@@ -413,32 +345,27 @@ VLC_EXPORT( playlist_item_t *, playlist_GetPreferredNode, ( playlist_t *p_playli
/***********************************************************************
* Inline functions
***********************************************************************/
/** Open a playlist file, add its content to the current playlist */
static inline int playlist_Import( playlist_t *p_playlist, const char *psz_file){
char psz_uri[256+10];
input_item_t *p_input;
snprintf( psz_uri, 256+9, "file/://%s", psz_file );
p_input = input_ItemNewExt( p_playlist, psz_uri, psz_file, 0, NULL, -1 );
playlist_AddInput( p_playlist, p_input, PLAYLIST_APPEND, PLAYLIST_END,
VLC_TRUE );
input_Read( p_playlist, p_input, VLC_TRUE );
return VLC_SUCCESS;
}
/** Tell if the playlist is currently running */
static inline vlc_bool_t playlist_IsPlaying( playlist_t * p_playlist )
{
vlc_bool_t b_playing;
vlc_mutex_lock( &p_playlist->object_lock );
b_playing = p_playlist->status.i_status == PLAYLIST_RUNNING;
vlc_mutex_unlock( &p_playlist->object_lock );
return( b_playing );
}
#define playlist_IsPlaying( pl ) ( pl->status.i_status == PLAYLIST_RUNNING )
/** Tell if the playlist is empty */
static inline vlc_bool_t playlist_IsEmpty( playlist_t * p_playlist )
{
vlc_bool_t b_empty;
vlc_mutex_lock( &p_playlist->object_lock );
b_empty = p_playlist->items.i_size == 0;
vlc_mutex_unlock( &p_playlist->object_lock );
return( b_empty );
}
#define playlist_IsEmpty( pl ) ( pl->items.i_size == 0 )
/** Tell the number of items in the current playing context */
static inline int playlist_CurrentSize( vlc_object_t *p_this )
{
return p_this->p_libvlc->p_playlist->current.i_size;
}
#define playlist_CurrentSize( obj ) obj->p_libvlc->p_playlist->current.i_size
/** Ask the playlist to do some work */
static inline void playlist_Signal( playlist_t *p_playlist )
......
......@@ -312,7 +312,7 @@ struct module_symbols_t
void *playlist_NodeGroup_deprecated;
int (*playlist_NodeSort_inner) (playlist_t *, playlist_item_t *,int, int);
int (*playlist_RecursiveNodeSort_inner) (playlist_t *, playlist_item_t *,int, int);
int (*playlist_Import_inner) (playlist_t *, const char *, playlist_item_t *, vlc_bool_t);
void *playlist_Import_deprecated;
int (*playlist_Export_inner) (playlist_t *, const char *, playlist_item_t *, const char *);
spu_t * (*__spu_Create_inner) (vlc_object_t *);
int (*spu_Init_inner) (spu_t *);
......@@ -506,7 +506,7 @@ struct module_symbols_t
int (*playlist_DeleteFromInput_inner) (playlist_t *, int, playlist_item_t *, vlc_bool_t);
int (*playlist_DeleteAllFromInput_inner) (playlist_t *, int);
int (*playlist_LockDeleteAllFromInput_inner) (playlist_t *, int);
void (*playlist_AddWhereverNeeded_inner) (playlist_t* , input_item_t*, playlist_item_t*,playlist_item_t*,vlc_bool_t, int);
void *playlist_AddWhereverNeeded_deprecated;
int (*playlist_DeleteFromItemId_inner) (playlist_t *, int);
void (*playlist_NodeDump_inner) (playlist_t *p_playlist, playlist_item_t *p_item, int i_level);
void *__intf_UserOkayCancel_deprecated;
......@@ -557,6 +557,7 @@ struct module_symbols_t
int (*net_ListenSingle_inner) (vlc_object_t *p_this, const char *psz_host, int i_port, int family, int socktype, int protocol);
char * (*str_format_time_inner) (char *);
char * (*__str_format_meta_inner) (vlc_object_t *, char *);
int (*vout_Snapshot_inner) (vout_thread_t *p_vout, picture_t *p_pic);
};
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
......@@ -821,7 +822,6 @@ struct module_symbols_t
# define playlist_ItemGetByInput (p_symbols)->playlist_ItemGetByInput_inner
# define playlist_NodeSort (p_symbols)->playlist_NodeSort_inner
# define playlist_RecursiveNodeSort (p_symbols)->playlist_RecursiveNodeSort_inner
# define playlist_Import (p_symbols)->playlist_Import_inner
# define playlist_Export (p_symbols)->playlist_Export_inner
# define __spu_Create (p_symbols)->__spu_Create_inner
# define spu_Init (p_symbols)->spu_Init_inner
......@@ -996,7 +996,6 @@ struct module_symbols_t
# define playlist_DeleteFromInput (p_symbols)->playlist_DeleteFromInput_inner
# define playlist_DeleteAllFromInput (p_symbols)->playlist_DeleteAllFromInput_inner
# define playlist_LockDeleteAllFromInput (p_symbols)->playlist_LockDeleteAllFromInput_inner
# define playlist_AddWhereverNeeded (p_symbols)->playlist_AddWhereverNeeded_inner
# define playlist_DeleteFromItemId (p_symbols)->playlist_DeleteFromItemId_inner
# define playlist_NodeDump (p_symbols)->playlist_NodeDump_inner
# define __intf_UserStringInput (p_symbols)->__intf_UserStringInput_inner
......@@ -1034,6 +1033,7 @@ struct module_symbols_t
# define net_ListenSingle (p_symbols)->net_ListenSingle_inner
# define str_format_time (p_symbols)->str_format_time_inner
# define __str_format_meta (p_symbols)->__str_format_meta_inner
# define vout_Snapshot (p_symbols)->vout_Snapshot_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
......@@ -1301,7 +1301,6 @@ struct module_symbols_t
((p_symbols)->playlist_ItemGetByInput_inner) = playlist_ItemGetByInput; \
((p_symbols)->playlist_NodeSort_inner) = playlist_NodeSort; \
((p_symbols)->playlist_RecursiveNodeSort_inner) = playlist_RecursiveNodeSort; \
((p_symbols)->playlist_Import_inner) = playlist_Import; \
((p_symbols)->playlist_Export_inner) = playlist_Export; \
((p_symbols)->__spu_Create_inner) = __spu_Create; \
((p_symbols)->spu_Init_inner) = spu_Init; \
......@@ -1476,7 +1475,6 @@ struct module_symbols_t
((p_symbols)->playlist_DeleteFromInput_inner) = playlist_DeleteFromInput; \
((p_symbols)->playlist_DeleteAllFromInput_inner) = playlist_DeleteAllFromInput; \
((p_symbols)->playlist_LockDeleteAllFromInput_inner) = playlist_LockDeleteAllFromInput; \
((p_symbols)->playlist_AddWhereverNeeded_inner) = playlist_AddWhereverNeeded; \
((p_symbols)->playlist_DeleteFromItemId_inner) = playlist_DeleteFromItemId; \
((p_symbols)->playlist_NodeDump_inner) = playlist_NodeDump; \
((p_symbols)->__intf_UserStringInput_inner) = __intf_UserStringInput; \
......@@ -1514,6 +1512,7 @@ struct module_symbols_t
((p_symbols)->net_ListenSingle_inner) = net_ListenSingle; \
((p_symbols)->str_format_time_inner) = str_format_time; \
((p_symbols)->__str_format_meta_inner) = __str_format_meta; \
((p_symbols)->vout_Snapshot_inner) = vout_Snapshot; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->__sout_CfgParse_deprecated = NULL; \
(p_symbols)->sout_CfgCreate_deprecated = NULL; \
......@@ -1545,6 +1544,7 @@ struct module_symbols_t
(p_symbols)->playlist_Sort_deprecated = NULL; \
(p_symbols)->playlist_Move_deprecated = NULL; \
(p_symbols)->playlist_NodeGroup_deprecated = NULL; \
(p_symbols)->playlist_Import_deprecated = NULL; \
(p_symbols)->playlist_NodeRemoveParent_deprecated = NULL; \
(p_symbols)->__vlc_fix_readdir_charset_deprecated = NULL; \
(p_symbols)->FromUTF32_deprecated = NULL; \
......@@ -1564,6 +1564,7 @@ struct module_symbols_t
(p_symbols)->playlist_PlaylistAddExt_deprecated = NULL; \
(p_symbols)->playlist_PlaylistAddInput_deprecated = NULL; \
(p_symbols)->vlc_input_item_AddOption_deprecated = NULL; \
(p_symbols)->playlist_AddWhereverNeeded_deprecated = NULL; \
(p_symbols)->__intf_UserOkayCancel_deprecated = NULL; \
(p_symbols)->playlist_NodesCreateForSD_deprecated = NULL; \
(p_symbols)->stats_TimerClean_deprecated = NULL; \
......
......@@ -501,8 +501,8 @@ static int GetTracks( access_t *p_access,
}
}
#endif
playlist_AddWhereverNeeded( p_playlist, p_input_item, p_parent,
p_item_in_category, VLC_FALSE, PLAYLIST_APPEND );
playlist_BothAddInput( p_playlist, p_input_item, p_item_in_category,
PLAYLIST_APPEND, PLAYLIST_END );
free( psz_uri ); free( psz_opt ); free( psz_name );
free( psz_first ); free( psz_last );
}
......
......@@ -178,13 +178,24 @@ static int ReadNull( access_t *p_access, uint8_t *p_buffer, int i_len)
*****************************************************************************/
static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
{
char *psz;
int i_mode, i_activity;
char *psz_name = strdup (p_access->psz_path);
if (psz_name == NULL)
char *psz;
int i_mode, i_activity;
playlist_t *p_playlist = pl_Yield( p_access );
playlist_item_t *p_item_in_category;
input_item_t *p_current_input = ( (input_thread_t*)p_access->p_parent)
->input.p_item;
playlist_item_t *p_current =
playlist_LockItemGetByInput( p_playlist, p_current_input );
char *psz_name = strdup (p_access->psz_path);
if( psz_name == NULL )
return VLC_ENOMEM;
if( p_current == NULL ) {
msg_Err( p_access, "unable to find item in playlist" );
return VLC_ENOOBJ;
}
/* Remove the ending '/' char */
if (psz_name[0])
{
......@@ -197,9 +208,6 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
}
}
playlist_item_t *p_item, *p_root_category;
playlist_t *p_playlist = pl_Yield( p_access );
/* Handle mode */
psz = var_CreateGetString( p_access, "recursive" );
if( *psz == '\0' || !strncmp( psz, "none" , 4 ) )
......@@ -212,33 +220,19 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
msg_Dbg( p_access, "opening directory `%s'", p_access->psz_path );
if( p_playlist->status.p_item && p_playlist->status.p_item->p_input ==
((input_thread_t *)p_access->p_parent)->input.p_item )
p_item = p_playlist->status.p_item;
else
{
input_item_t *p_current = ( (input_thread_t*)p_access->p_parent)->
input.p_item;
p_item = playlist_LockItemGetByInput( p_playlist, p_current );
if( !p_item )
{
msg_Dbg( p_playlist, "unable to find item in playlist");
return VLC_ENOOBJ;
}
}
p_item->p_input->i_type = ITEM_TYPE_DIRECTORY;
p_root_category = playlist_LockItemToNode( p_playlist, p_item );
p_current->p_input->i_type = ITEM_TYPE_DIRECTORY;
p_item_in_category = playlist_LockItemToNode( p_playlist, p_current );
i_activity = var_GetInteger( p_playlist, "activity" );
var_SetInteger( p_playlist, "activity", i_activity +
DIRECTORY_ACTIVITY );
ReadDir( p_playlist, psz_name, i_mode, p_item, p_root_category );
ReadDir( p_playlist, psz_name, i_mode, p_current, p_item_in_category );
i_activity = var_GetInteger( p_playlist, "activity" );
var_SetInteger( p_playlist, "activity", i_activity -
DIRECTORY_ACTIVITY );
if( psz_name ) free( psz_name );
vlc_object_release( p_playlist );
......@@ -475,9 +469,10 @@ static int ReadDir( playlist_t *p_playlist, const char *psz_name,
psz_uri, entry, 0, NULL,
-1, ITEM_TYPE_VFILE );
if (p_input != NULL)
playlist_AddWhereverNeeded (p_playlist, p_input, p_parent,
p_parent_category, VLC_FALSE,
PLAYLIST_APPEND|PLAYLIST_PREPARSE);
playlist_BothAddInput( p_playlist, p_input,
p_parent_category,
PLAYLIST_APPEND|PLAYLIST_PREPARSE,
PLAYLIST_END );
}
}
}
......
......@@ -112,8 +112,8 @@ int E_(MMSHOpen)( access_t *p_access )
msg_Dbg( p_access, "redirection to %s", psz_location );
/** \bug we do not autodelete here */
playlist_PlaylistAdd( p_playlist, psz_location, psz_location,
PLAYLIST_INSERT | PLAYLIST_GO, PLAYLIST_END );
playlist_Add( p_playlist, psz_location, psz_location,
PLAYLIST_INSERT | PLAYLIST_GO, PLAYLIST_END, VLC_TRUE );
vlc_object_release( p_playlist );
free( psz_location );
......
......@@ -795,8 +795,8 @@ void GoForward( intf_thread_t *p_intf )
static void ReplacePlaylistItem( playlist_t *p_playlist, char *psz_uri )
{
playlist_Stop( p_playlist );
(void) playlist_PlaylistAdd( p_playlist, psz_uri, psz_uri,
PLAYLIST_INSERT /* FIXME: used to be PLAYLIST_REPLACE */, PLAYLIST_END|PLAYLIST_GO /* FIXME: p_playlist->status.i_index */ );
(void) playlist_Add( p_playlist, psz_uri, psz_uri,
PLAYLIST_INSERT /* FIXME: used to be PLAYLIST_REPLACE */, PLAYLIST_END|PLAYLIST_GO, VLC_TRUE /* FIXME: p_playlist->status.i_index */ );
}
/****************************************************************************
......
......@@ -338,8 +338,8 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
}
else
{
playlist_PlaylistAddInput( p_sys->p_playlist, p_input,
PLAYLIST_APPEND, PLAYLIST_END );
playlist_AddInput( p_sys->p_playlist, p_input,
PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE );
msg_Dbg( p_intf, "requested mrl add: %s", mrl );
}
......
......@@ -850,8 +850,8 @@ void E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t *vars,
}
else
{
i_id = playlist_PlaylistAddInput( p_sys->p_playlist, p_input,
PLAYLIST_APPEND, PLAYLIST_END );
i_id = playlist_AddInput( p_sys->p_playlist, p_input,
PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE );
msg_Dbg( p_intf, "requested mrl add: %s", mrl );
}
E_(SSPushN)( st, i_id );
......
......@@ -1416,8 +1416,8 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
if( p_item )
{
msg_rc( "Trying to add %s to playlist.", newval.psz_string );
playlist_PlaylistAddInput( p_playlist, p_item,
PLAYLIST_GO|PLAYLIST_APPEND, PLAYLIST_END );
playlist_AddInput( p_playlist, p_item,
PLAYLIST_GO|PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE );
}
}
else if( !strcmp( psz_cmd, "enqueue" ) &&
......@@ -1428,8 +1428,8 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
if( p_item )
{
msg_rc( "trying to enqueue %s to playlist", newval.psz_string );
playlist_PlaylistAddInput( p_playlist, p_item,
PLAYLIST_APPEND, PLAYLIST_END );
playlist_AddInput( p_playlist, p_item,
PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE );
}
}
else if( !strcmp( psz_cmd, "playlist" ) )
......
......@@ -415,8 +415,9 @@ static int Open( vlc_object_t * p_this )
p_input = input_ItemNewExt( p_playlist, psz_ref, NULL,
0, NULL, -1 );
input_ItemCopyOptions( p_current->p_input, p_input );
playlist_AddWhereverNeeded( p_playlist, p_input, p_current,
p_item_in_category, VLC_FALSE, PLAYLIST_APPEND );
playlist_BothAddInput( p_playlist, p_input,
p_item_in_category,
PLAYLIST_APPEND, PLAYLIST_END );
}
}
else
......
......@@ -131,7 +131,7 @@ static int Demux( demux_t *p_demux )
char *psz_parse = NULL;
char *psz_backup = NULL;
vlc_bool_t b_entry = VLC_FALSE;
input_item_t *p_input;
INIT_PLAYLIST_STUFF;
/* init txt */
......@@ -355,9 +355,10 @@ static int Demux( demux_t *p_demux )
psz_string[i_strlen] = '\0';
p_input = input_ItemNew( p_playlist, psz_string, psz_title_asx );
input_ItemCopyOptions( p_current->p_input, p_input );
playlist_AddWhereverNeeded( p_playlist, p_input, p_current,
p_item_in_category, (i_parent_id > 0 )? VLC_TRUE : VLC_FALSE,
PLAYLIST_APPEND );
playlist_BothAddInput( p_playlist, p_input,
p_item_in_category,
PLAYLIST_APPEND,
PLAYLIST_END );
free( psz_string );
}
else continue;
......@@ -434,10 +435,9 @@ static int Demux( demux_t *p_demux )
if( psz_copyright_entry ) vlc_meta_SetCopyright( p_entry->p_meta, psz_copyright_entry );
if( psz_moreinfo_entry ) vlc_meta_SetURL( p_entry->p_meta, psz_moreinfo_entry );
if( psz_abstract_entry ) vlc_meta_SetDescription( p_entry->p_meta, psz_abstract_entry );
playlist_AddWhereverNeeded( p_playlist, p_entry, p_current,
p_item_in_category, (i_parent_id > 0 )? VLC_TRUE : VLC_FALSE,
PLAYLIST_APPEND );
playlist_BothAddInput( p_playlist, p_entry,
p_item_in_category,
PLAYLIST_APPEND, PLAYLIST_END);
free( psz_string );
}
else continue;
......
......@@ -84,6 +84,7 @@ static int Demux( demux_t *p_demux )
xml_reader_t *p_xml_reader;
char *psz_elname = NULL;
int i_type;
input_item_t *p_input;
char *psz_mrl = NULL, *psz_name = NULL, *psz_genre = NULL;
char *psz_now = NULL, *psz_listeners = NULL, *psz_bitrate = NULL;
......@@ -265,10 +266,9 @@ static int Demux( demux_t *p_demux )
if( psz_bitrate )
msg_Err( p_playlist, "Unsupported meta bitrate" );
playlist_AddWhereverNeeded( p_playlist, p_input, p_current,
p_item_in_category, (i_parent_id > 0 ) ? VLC_TRUE:
VLC_FALSE, PLAYLIST_APPEND );
playlist_BothAddInput( p_playlist, p_input,
p_item_in_category,
PLAYLIST_APPEND, PLAYLIST_END );
FREENULL( psz_name );
FREENULL( psz_mrl );
FREENULL( psz_genre );
......
......@@ -95,6 +95,7 @@ void E_(Close_DVB)( vlc_object_t *p_this )
static int Demux( demux_t *p_demux )
{
char *psz_line;
input_item_t *p_input;
INIT_PLAYLIST_STUFF;
while( (psz_line = stream_ReadLine( p_demux->s )) )
......@@ -117,10 +118,8 @@ static int Demux( demux_t *p_demux )
EnsureUTF8( ppsz_options[i] );
input_ItemAddOption( p_input, ppsz_options[i] );
}
playlist_AddWhereverNeeded( p_playlist, p_input, p_current,
p_item_in_category,
(i_parent_id > 0 ) ? VLC_TRUE: VLC_FALSE,
PLAYLIST_APPEND );
playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
PLAYLIST_APPEND, PLAYLIST_END );
while( i_options-- ) free( ppsz_options[i_options] );
if( ppsz_options ) free( ppsz_options );
......
......@@ -62,7 +62,6 @@ struct demux_sys_t
playlist_t *p_playlist;
playlist_item_t *p_current;
playlist_item_t *p_item_in_category;
int i_parent_id;
};
/*****************************************************************************
......@@ -129,12 +128,12 @@ static int Demux( demux_t *p_demux )
int i_duration = -1;
char *psz_title = NULL;
char *psz_description = NULL;
input_item_t *p_input;
INIT_PLAYLIST_STUFF;
p_sys->p_playlist = p_playlist;
p_sys->p_current = p_current;
p_sys->i_parent_id = i_parent_id;
p_sys->p_item_in_category = p_item_in_category;
while( ( psz_line = stream_ReadLine( p_demux->s ) ) )
......@@ -214,10 +213,9 @@ static int Demux( demux_t *p_demux )
SADD_INFO( "gvp_version", psz_version );
SADD_INFO( "docid", psz_docid );
SADD_INFO( "description", psz_description );
playlist_AddWhereverNeeded( p_sys->p_playlist, p_input,
p_sys->p_current, p_sys->p_item_in_category,
(p_sys->i_parent_id > 0 ) ? VLC_TRUE: VLC_FALSE,
PLAYLIST_APPEND );
playlist_BothAddInput( p_sys->p_playlist, p_input,
p_sys->p_item_in_category,
PLAYLIST_APPEND, PLAYLIST_END );
}
HANDLE_PLAY_AND_RELEASE;
......
......@@ -56,15 +56,11 @@ int E_(Import_M3U)( vlc_object_t *p_this )
uint8_t *p_peek;
CHECK_PEEK( p_peek, 8 );
if( POKE( p_peek, "#EXTM3U", 7 ) || POKE( p_peek, "RTSPtext", 8 ) ||
isExtension( p_demux, ".m3u" ) || isExtension( p_demux, ".vlc" ) ||
/* A .ram file can contain a single rtsp link */
isExtension( p_demux, ".ram" ) || isExtension( p_demux, ".rm" ) ||
isDemux( p_demux, "m3u" ) )
{
;
}
else
if(! ( POKE( p_peek, "#EXTM3U", 7 ) || POKE( p_peek, "RTSPtext", 8 ) ||
isExtension( p_demux, ".m3u" ) || isExtension( p_demux, ".vlc" ) ||
/* A .ram file can contain a single rtsp link */
isExtension( p_demux, ".ram" ) || isExtension( p_demux, ".rm" ) ||
isDemux( p_demux, "m3u" ) ) )
return VLC_EGENERIC;
STANDARD_DEMUX_INIT_MSG( "found valid M3U playlist" );
......@@ -79,8 +75,7 @@ int E_(Import_M3U)( vlc_object_t *p_this )
void E_(Close_M3U)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
if( p_demux->p_sys->psz_prefix ) free( p_demux->p_sys->psz_prefix );
free( p_demux->p_sys->psz_prefix );
free( p_demux->p_sys );
}
......@@ -94,6 +89,7 @@ static int Demux( demux_t *p_demux )
const char**ppsz_options = NULL;
int i_options = 0, i;
vlc_bool_t b_cleanup = VLC_FALSE;
input_item_t *p_input;
INIT_PLAYLIST_STUFF;
......@@ -172,9 +168,8 @@ static int Demux( demux_t *p_demux )
if ( psz_artist && *psz_artist )
input_ItemAddInfo( p_input, _(VLC_META_INFO_CAT),
_(VLC_META_ARTIST), "%s", psz_artist );
playlist_AddWhereverNeeded( p_playlist, p_input, p_current,
p_item_in_category, (i_parent_id > 0 )? VLC_TRUE : VLC_FALSE,
PLAYLIST_APPEND );
playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
PLAYLIST_APPEND, PLAYLIST_END );
free( psz_mrl );
}
......
......@@ -164,56 +164,3 @@ char *E_(ProcessMRL)( char *psz_mrl, char *psz_prefix )
asprintf( &psz_mrl, "%s%s", psz_prefix, psz_mrl );
return psz_mrl;
}
void E_(AddToPlaylist)( demux_t *p_demux, playlist_t *p_playlist,
input_item_t *p_input,
playlist_item_t *p_item, int i_parent_id )
{
// Only add to parent if specific parent requested or not current
// playlist item
if( i_parent_id > 0 || ! (
p_playlist->status.p_item &&
p_playlist->status.p_item->p_input ==
((input_thread_t *)p_demux->p_parent)->input.p_item ) )
{
playlist_NodeAddInput( p_playlist, p_input, p_item,
PLAYLIST_APPEND, PLAYLIST_END );
}
// Else, add to both
else
{
playlist_BothAddInput( p_playlist, p_input, p_item,
PLAYLIST_APPEND, PLAYLIST_END );
}
input_ItemCopyOptions( p_item->p_input, p_input );
}
vlc_bool_t E_(FindItem)( demux_t *p_demux, playlist_t *p_playlist,
playlist_item_t **pp_item )
{
vlc_bool_t b_play = var_CreateGetBool( p_demux, "playlist-autostart" );
if( b_play && p_playlist->status.p_item &&
p_playlist->status.p_item->p_input ==
((input_thread_t *)p_demux->p_parent)->input.p_item )
{
msg_Dbg( p_playlist, "starting playlist playback" );
*pp_item = p_playlist->status.p_item;
b_play = VLC_TRUE;
}
else
{
input_item_t *p_current = ( (input_thread_t*)p_demux->p_parent)->
input.p_item;
*pp_item = playlist_LockItemGetByInput( p_playlist, p_current );
if( !*pp_item )
{
msg_Dbg( p_playlist, "unable to find item in playlist");
}
msg_Dbg( p_playlist, "not starting playlist playback");
p_playlist->status.i_status = PLAYLIST_STOPPED;
b_play = VLC_FALSE;
}
return b_play;
}
......@@ -21,6 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <vlc_playlist.h>
char *E_(ProcessMRL)( char *, char * );
char *E_(FindPrefix)( demux_t * );
......@@ -67,31 +68,21 @@ int E_(Import_GVP) ( vlc_object_t * );
void E_(Close_GVP) ( vlc_object_t * );
#define INIT_PLAYLIST_STUFF \
int i_parent_id; \
vlc_bool_t b_play; \
playlist_item_t *p_current, *p_item_in_category = NULL; \
input_item_t *p_input; \
playlist_t *p_playlist = pl_Yield( p_demux ); \
i_parent_id = var_CreateGetInteger( p_demux, "parent-item" ); \
if( i_parent_id > 0 ) \
{ \
b_play = VLC_FALSE; \
p_current = playlist_ItemGetById( p_playlist, i_parent_id ); \
} \
else \
{ \
b_play = E_(FindItem)( p_demux, p_playlist, &p_current ); \
p_item_in_category = playlist_ItemToNode( p_playlist, p_current ); \
p_item_in_category->p_input->i_type = ITEM_TYPE_PLAYLIST; \
}
vlc_bool_t b_play = var_CreateGetBool( p_demux, "playlist-autostart" ); \
input_item_t *p_current_input = ( (input_thread_t*)p_demux->p_parent)-> \
input.p_item; \
playlist_item_t *p_current = \