Commit 85ff1461 authored by zorglub's avatar zorglub
Browse files

* Start cleaning up libvlc playlist API (Refs:#457)

  - Return correct item ids
  - Structures for navigating the playlist
  - Consistent locking
* Add a b_locked parameter to the remaining playlist API calls
parent 4630e1ed
......@@ -48,13 +48,12 @@ extern "C" {
* @{
*/
struct libvlc_exception_t
typedef struct
{
int b_raised;
int i_code;
char *psz_message;
};
typedef struct libvlc_exception_t libvlc_exception_t;
} libvlc_exception_t;
/**
* Initialize an exception structure. This can be called several times to reuse
......@@ -140,6 +139,13 @@ VLC_PUBLIC_API void libvlc_destroy( libvlc_instance_t *, libvlc_exception_t * );
* @{
*/
typedef struct {
int i_id;
char * psz_uri;
char * psz_name
} libvlc_playlist_item_t;
/**
* Set loop variable
*/
......
......@@ -368,11 +368,11 @@ VLC_EXPORT( int, playlist_DeleteFromInput, ( playlist_t *, int, vlc_bool_t ) );
VLC_EXPORT( int, playlist_ItemSetName, (playlist_item_t *, const char * ) );
/******************** Item addition ********************/
VLC_EXPORT( int, playlist_Add, ( playlist_t *, const char *, const char *, int, int, vlc_bool_t ) );
VLC_EXPORT( int, playlist_AddExt, ( playlist_t *, const char *, const char *, int, int, mtime_t, const char *const *,int, vlc_bool_t ) );
VLC_EXPORT( int, playlist_AddInput, ( playlist_t *, input_item_t *,int , int, vlc_bool_t ) );
VLC_EXPORT( playlist_item_t *, playlist_NodeAddInput, ( playlist_t *, input_item_t *,playlist_item_t *,int , int ) );
VLC_EXPORT( int, playlist_BothAddInput, ( playlist_t *, input_item_t *,playlist_item_t *,int , int, int*, int* ) );
VLC_EXPORT( int, playlist_Add, ( playlist_t *, const char *, const char *, int, int, vlc_bool_t, vlc_bool_t ) );
VLC_EXPORT( int, playlist_AddExt, ( playlist_t *, const char *, const char *, int, int, mtime_t, const char *const *,int, vlc_bool_t, vlc_bool_t ) );
VLC_EXPORT( int, playlist_AddInput, ( playlist_t *, input_item_t *, int, int, vlc_bool_t, vlc_bool_t ) );
VLC_EXPORT( playlist_item_t *, playlist_NodeAddInput, ( playlist_t *, input_item_t *,playlist_item_t *,int , int, vlc_bool_t ) );
VLC_EXPORT( int, playlist_BothAddInput, ( playlist_t *, input_item_t *,playlist_item_t *,int , int, int*, int*, vlc_bool_t ) );
/********************** Misc item operations **********************/
VLC_EXPORT( playlist_item_t*, playlist_ItemToNode, (playlist_t *,playlist_item_t *, vlc_bool_t) );
......@@ -415,7 +415,7 @@ static inline int playlist_Import( playlist_t *p_playlist, const char *psz_file)
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 );
VLC_TRUE, VLC_FALSE );
input_Read( p_playlist, p_input, VLC_TRUE );
return VLC_SUCCESS;
}
......
......@@ -503,7 +503,8 @@ static int GetTracks( access_t *p_access,
}
#endif
playlist_BothAddInput( p_playlist, p_input_item, p_item_in_category,
PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL );
PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL,
VLC_FALSE );
free( psz_uri ); free( psz_opt ); free( psz_name );
free( psz_first ); free( psz_last );
}
......
......@@ -516,7 +516,8 @@ static int ReadDir( playlist_t *p_playlist, const char *psz_name,
p_parent_category,
PLAYLIST_APPEND|PLAYLIST_PREPARSE|
PLAYLIST_NO_REBUILD,
PLAYLIST_END, NULL, NULL );
PLAYLIST_END, NULL, NULL,
VLC_FALSE );
}
}
}
......
......@@ -112,7 +112,8 @@ int E_(MMSHOpen)( access_t *p_access )
/** \bug we do not autodelete here */
playlist_Add( p_playlist, psz_location, psz_location,
PLAYLIST_INSERT | PLAYLIST_GO, PLAYLIST_END, VLC_TRUE );
PLAYLIST_INSERT | PLAYLIST_GO, PLAYLIST_END, VLC_TRUE,
VLC_FALSE );
vlc_object_release( p_playlist );
free( psz_location );
......
......@@ -796,7 +796,8 @@ static void ReplacePlaylistItem( playlist_t *p_playlist, char *psz_uri )
{
playlist_Stop( p_playlist );
(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 */ );
PLAYLIST_INSERT /* FIXME: used to be PLAYLIST_REPLACE */, PLAYLIST_END|PLAYLIST_GO, VLC_TRUE /* FIXME: p_playlist->status.i_index */,
VLC_FALSE);
}
/****************************************************************************
......
......@@ -343,7 +343,8 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
else
{
playlist_AddInput( p_sys->p_playlist, p_input,
PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE );
PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
VLC_FALSE);
msg_Dbg( p_intf, "requested mrl add: %s", mrl );
}
......
......@@ -851,7 +851,8 @@ void E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t *vars,
else
{
i_id = playlist_AddInput( p_sys->p_playlist, p_input,
PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE );
PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
VLC_FALSE);
msg_Dbg( p_intf, "requested mrl add: %s", mrl );
}
E_(SSPushN)( st, i_id );
......
......@@ -1367,7 +1367,8 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
{
msg_rc( "Trying to add %s to playlist.", newval.psz_string );
playlist_AddInput( p_playlist, p_item,
PLAYLIST_GO|PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE );
PLAYLIST_GO|PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
VLC_FALSE );
}
}
else if( !strcmp( psz_cmd, "enqueue" ) &&
......@@ -1379,7 +1380,8 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
{
msg_rc( "trying to enqueue %s to playlist", newval.psz_string );
playlist_AddInput( p_playlist, p_item,
PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE );
PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
VLC_FALSE);
}
}
else if( !strcmp( psz_cmd, "playlist" ) )
......
......@@ -419,7 +419,7 @@ static int Open( vlc_object_t * p_this )
playlist_BothAddInput( p_playlist, p_input,
p_item_in_category,
PLAYLIST_APPEND, PLAYLIST_END,
NULL, NULL);
NULL, NULL, VLC_FALSE );
}
}
else
......
......@@ -371,7 +371,8 @@ static int Demux( demux_t *p_demux )
playlist_BothAddInput( p_playlist, p_input,
p_item_in_category,
PLAYLIST_APPEND|PLAYLIST_SPREPARSE,
PLAYLIST_END, NULL, NULL );
PLAYLIST_END, NULL, NULL,
VLC_FALSE);
free( psz_string );
}
else continue;
......@@ -451,7 +452,8 @@ static int Demux( demux_t *p_demux )
playlist_BothAddInput( p_playlist, p_entry,
p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE
, PLAYLIST_END, NULL, NULL);
, PLAYLIST_END, NULL, NULL,
VLC_FALSE );
free( psz_string );
}
else continue;
......
......@@ -270,7 +270,7 @@ static int Demux( demux_t *p_demux )
playlist_BothAddInput( p_playlist, p_input,
p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
PLAYLIST_END, NULL, NULL );
PLAYLIST_END, NULL, NULL, VLC_FALSE );
FREENULL( psz_name );
FREENULL( psz_mrl );
FREENULL( psz_genre );
......
......@@ -120,7 +120,7 @@ static int Demux( demux_t *p_demux )
}
playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
PLAYLIST_END, NULL, NULL );
PLAYLIST_END, NULL, NULL, VLC_FALSE );
while( i_options-- ) free( ppsz_options[i_options] );
if( ppsz_options ) free( ppsz_options );
......
......@@ -215,7 +215,7 @@ static int Demux( demux_t *p_demux )
playlist_BothAddInput( p_sys->p_playlist, p_input,
p_sys->p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
PLAYLIST_END, NULL, NULL );
PLAYLIST_END, NULL, NULL, VLC_FALSE );
}
HANDLE_PLAY_AND_RELEASE;
......
......@@ -187,7 +187,7 @@ static int Demux( demux_t *p_demux )
_(VLC_META_ARTIST), "%s", psz_artist );
playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
PLAYLIST_END, NULL, NULL );
PLAYLIST_END, NULL, NULL, VLC_FALSE );
free( psz_mrl );
// XXX Not to be a scare monger, but I suspect options are leaked
}
......
......@@ -163,7 +163,7 @@ static int Demux( demux_t *p_demux )
input_ItemCopyOptions( p_current->p_input, p_input );
playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
PLAYLIST_END, NULL, NULL );
PLAYLIST_END, NULL, NULL, VLC_FALSE );
}
else
{
......@@ -220,7 +220,7 @@ static int Demux( demux_t *p_demux )
input_ItemCopyOptions( p_current->p_input, p_input );
playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
PLAYLIST_END, NULL, NULL );
PLAYLIST_END, NULL, NULL, VLC_FALSE );
free( psz_mrl_orig );
psz_mrl = NULL;
}
......
......@@ -293,7 +293,7 @@ static int Demux( demux_t *p_demux )
playlist_BothAddInput( p_playlist, p_input,
p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE
, PLAYLIST_END, NULL, NULL );
, PLAYLIST_END, NULL, NULL, VLC_FALSE );
FREENULL( psz_item_name );
FREENULL( psz_item_mrl );
FREENULL( psz_item_size );
......
......@@ -362,7 +362,7 @@ static int Demux( demux_t *p_demux )
playlist_BothAddInput( p_sys->p_playlist, p_input,
p_sys->p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
PLAYLIST_END, NULL, NULL );
PLAYLIST_END, NULL, NULL, VLC_FALSE );
if( psz_qtnext )
{
p_input = input_ItemNewExt( p_sys->p_playlist,
......@@ -370,7 +370,7 @@ static int Demux( demux_t *p_demux )
playlist_BothAddInput( p_sys->p_playlist, p_input,
p_sys->p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
PLAYLIST_END, NULL, NULL );
PLAYLIST_END, NULL, NULL, VLC_FALSE );
}
}
......
......@@ -408,7 +408,7 @@ static int Demux ( demux_t *p_demux )
playlist_BothAddInput( p_playlist, p_child, p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE, PLAYLIST_END,
NULL, NULL);
NULL, NULL, VLC_FALSE );
HANDLE_PLAY_AND_RELEASE
return -1; /* Needed for correct operation of go back */
}
......
......@@ -242,7 +242,7 @@ static int DemuxGenre( demux_t *p_demux )
playlist_BothAddInput( p_sys->p_playlist, p_input,
p_sys->p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
PLAYLIST_END, NULL, NULL );
PLAYLIST_END, NULL, NULL, VLC_FALSE );
FREENULL( psz_name );
}
FREENULL( psz_eltname );
......@@ -434,7 +434,7 @@ static int DemuxStation( demux_t *p_demux )
playlist_BothAddInput( p_sys->p_playlist, p_input,
p_sys->p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
PLAYLIST_END, NULL, NULL );
PLAYLIST_END, NULL, NULL, VLC_FALSE );
FREENULL( psz_name );
FREENULL( psz_mt )
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment