* @{
*/
-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
* @{
*/
+typedef struct {
+ int i_id;
+ char * psz_uri;
+ char * psz_name
+
+} libvlc_playlist_item_t;
+
/**
* Set loop variable
*/
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) );
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;
}
}
#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 );
}
p_parent_category,
PLAYLIST_APPEND|PLAYLIST_PREPARSE|
PLAYLIST_NO_REBUILD,
- PLAYLIST_END, NULL, NULL );
+ PLAYLIST_END, NULL, NULL,
+ VLC_FALSE );
}
}
}
/** \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 );
{
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);
}
/****************************************************************************
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 );
}
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 );
{
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" ) &&
{
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" ) )
playlist_BothAddInput( p_playlist, p_input,
p_item_in_category,
PLAYLIST_APPEND, PLAYLIST_END,
- NULL, NULL);
+ NULL, NULL, VLC_FALSE );
}
}
else
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;
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;
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 );
}
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 );
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;
_(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
}
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
{
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;
}
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 );
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,
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 );
}
}
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 */
}
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 );
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 )
playlist_BothAddInput( p_playlist, p_new_input,
p_demux->p_sys->p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
- PLAYLIST_END, NULL, NULL );
+ PLAYLIST_END, NULL, NULL, VLC_FALSE );
if( p_demux->p_sys->i_identifier <
p_demux->p_sys->i_tracklist_entries )
{
[[[NSFileManager defaultManager]
displayNameAtPath: o_urlString] UTF8String] );
playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT,
- PLAYLIST_END, VLC_TRUE );
+ PLAYLIST_END, VLC_TRUE, VLC_FALSE );
o_url = [NSURL fileURLWithPath: o_urlString];
[o_controls toogleFullscreen: self];
}
-@end
\ No newline at end of file
+@end
/* Add the item */
playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT,
- i_position == -1 ? PLAYLIST_END : i_position + i_item, VLC_TRUE );
+ i_position == -1 ? PLAYLIST_END : i_position + i_item, VLC_TRUE,
+ VLC_FALSE );
if( i_item == 0 && !b_enqueue )
{
UTF8String] );
playlist_AddInput( p_playlist, p_input, PLAYLIST_STOP,
- PLAYLIST_END, VLC_TRUE );
+ PLAYLIST_END, VLC_TRUE, VLC_FALSE );
if( x == 0 )
{
playlist_Add( THEPL, psz_utf8, NULL,
PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) |
( i ? PLAYLIST_PREPARSE : 0 ),
- PLAYLIST_END, VLC_TRUE );
+ PLAYLIST_END, VLC_TRUE, VLC_FALSE );
}
}
QString s = url.toString();
if( s.length() > 0 ) {
playlist_Add( THEPL, qtu(s), NULL,
- PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE );
+ PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE, VLC_FALSE );
}
}
event->acceptProposedAction();
( i ? PLAYLIST_PREPARSE : 0 ) )
: ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
PLAYLIST_END,
- pl ? VLC_TRUE : VLC_FALSE );
+ pl ? VLC_TRUE : VLC_FALSE, VLC_FALSE );
i++;
}
}
0, NULL, -1 );
playlist_AddInput( THEPL, p_input,
go ? ( PLAYLIST_APPEND | PLAYLIST_GO ) : PLAYLIST_APPEND,
- PLAYLIST_END, pl);
+ PLAYLIST_END, pl, VLC_FALSE );
input_Read( THEPL, p_input, VLC_FALSE );
}
playlist_AddExt( THEPL, qtu( o->mrl ), "Streaming",
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END,
- -1, &psz_option, 1, VLC_TRUE );
+ -1, &psz_option, 1, VLC_TRUE, VLC_FALSE );
}
delete s;
}
if( s.length() > 0 ) {
playlist_Add( THEPL, qtu(s), NULL,
PLAYLIST_APPEND | (first ? PLAYLIST_GO:0),
- PLAYLIST_END, VLC_TRUE );
+ PLAYLIST_END, VLC_TRUE, VLC_FALSE );
first = false;
}
}
playlist_Add( p_playlist, psz_utf8, NULL,
PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) |
(i ? PLAYLIST_PREPARSE : 0 ),
- PLAYLIST_END, VLC_TRUE );
+ PLAYLIST_END, VLC_TRUE, VLC_FALSE );
else
playlist_Add( p_playlist, psz_utf8, NULL,
- PLAYLIST_APPEND | PLAYLIST_PREPARSE , PLAYLIST_END , VLC_TRUE);
+ PLAYLIST_APPEND | PLAYLIST_PREPARSE , PLAYLIST_END , VLC_TRUE, VLC_FALSE );
wxLocaleFree( psz_utf8 );
}
}
char *psz_utf8 = wxFromLocale( path );
playlist_Add( p_playlist, psz_utf8, NULL,
PLAYLIST_APPEND | (event.GetInt() ? PLAYLIST_GO : 0),
- PLAYLIST_END, VLC_TRUE );
+ PLAYLIST_END, VLC_TRUE, VLC_FALSE );
wxLocaleFree( psz_utf8 );
}
{
playlist_AddInput( p_playlist, p_input,
PLAYLIST_APPEND | PLAYLIST_GO,
- PLAYLIST_END, VLC_TRUE );
+ PLAYLIST_END, VLC_TRUE, VLC_FALSE );
}
else
{
playlist_AddInput( p_playlist, p_input,
PLAYLIST_APPEND|PLAYLIST_PREPARSE,
- PLAYLIST_END, VLC_TRUE );
+ PLAYLIST_END, VLC_TRUE, VLC_FALSE );
}
}
input_ItemAddOption( p_input, psz_ttl );
playlist_AddInput( p_playlist, p_input,
- PLAYLIST_GO, PLAYLIST_END, VLC_TRUE );
+ PLAYLIST_GO, PLAYLIST_END, VLC_TRUE, VLC_FALSE );
vlc_object_release(p_playlist);
}
else
playlist_Add( p_playlist, psz_utf8, NULL,
PLAYLIST_APPEND | ((i | b_enqueue) ? 0 : PLAYLIST_GO),
- PLAYLIST_END, VLC_TRUE );
+ PLAYLIST_END, VLC_TRUE, VLC_FALSE );
wxDnDLocaleFree( psz_utf8 );
}
playlist_item_t *p_item;
p_item = playlist_NodeAddInput( p_sys->p_playlist, p_input,
p_sys->p_node_cat,
- PLAYLIST_APPEND, PLAYLIST_END );
+ PLAYLIST_APPEND, PLAYLIST_END,
+ VLC_FALSE);
p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
p_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
p_item = playlist_NodeAddInput( p_sys->p_playlist, p_input,
p_sys->p_node_one,
- PLAYLIST_APPEND, PLAYLIST_END );
+ PLAYLIST_APPEND, PLAYLIST_END,
+ VLC_FALSE );
p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
p_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
}
return;
}
p_item_cat = playlist_NodeAddInput( p_playlist,
- p_input,p_sd->p_sys->p_node_cat, PLAYLIST_APPEND, PLAYLIST_END );
+ p_input,p_sd->p_sys->p_node_cat, PLAYLIST_APPEND, PLAYLIST_END,
+ VLC_FALSE );
p_item_cat->i_flags &= ~PLAYLIST_SKIP_FLAG;
p_item_one = playlist_NodeAddInput( p_playlist,
- p_input,p_sd->p_sys->p_node_one, PLAYLIST_APPEND, PLAYLIST_END );
+ p_input,p_sd->p_sys->p_node_one, PLAYLIST_APPEND, PLAYLIST_END,
+ VLC_FALSE );
p_item_one->i_flags &= ~PLAYLIST_SKIP_FLAG;
vlc_object_release( p_playlist );
p_sys->ppsz_urls[i], 0, NULL, -1 );
input_ItemAddOption( p_input, "demux=podcast" );
p_item = playlist_NodeAddInput( p_playlist, p_input, p_sys->p_node_cat,
- PLAYLIST_APPEND, PLAYLIST_END );
+ PLAYLIST_APPEND, PLAYLIST_END,
+ VLC_FALSE );
p_item = playlist_NodeAddInput( p_playlist, p_input, p_sys->p_node_one,
- PLAYLIST_APPEND, PLAYLIST_END );
+ PLAYLIST_APPEND, PLAYLIST_END,
+ VLC_FALSE );
free( psz_buf );
p_sys->pp_input[i] = input_CreateThread( p_playlist, p_input );
}
}
p_item = playlist_NodeAddInput( pl_Get( p_sd ), p_input, p_child,
- PLAYLIST_APPEND, PLAYLIST_END );
+ PLAYLIST_APPEND, PLAYLIST_END, VLC_FALSE );
p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
p_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
p_sap->i_item_id_cat = p_item->i_id;
p_item = playlist_NodeAddInput( pl_Get( p_sd ), p_input,
- p_sys->p_node_one, PLAYLIST_APPEND, PLAYLIST_END );
+ p_sys->p_node_one, PLAYLIST_APPEND, PLAYLIST_END,
+ VLC_FALSE );
p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
p_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
p_sap->i_item_id_one = p_item->i_id;
p_sys->p_input->b_prefers_tree = VLC_TRUE;
p_sys->p_node_cat = playlist_NodeAddInput( p_playlist, p_sys->p_input,
p_playlist->p_root_category,
- PLAYLIST_APPEND, PLAYLIST_END );
+ PLAYLIST_APPEND, PLAYLIST_END, VLC_FALSE );
p_sys->p_node_one = playlist_NodeAddInput( p_playlist, p_sys->p_input,
p_playlist->p_root_onelevel,
- PLAYLIST_APPEND, PLAYLIST_END );
+ PLAYLIST_APPEND, PLAYLIST_END, VLC_FALSE );
p_sys->p_node_cat->i_flags |= PLAYLIST_RO_FLAG;
p_sys->p_node_cat->i_flags |= PLAYLIST_SKIP_FLAG;
p_sys->p_node_one->i_flags |= PLAYLIST_RO_FLAG;
ItemNode *iNode = (ItemNode *)node;
input_item_t *p_input = input_ItemNew( p_sd, iNode->getResource(), title );
playlist_BothAddInput( p_sys->p_playlist, p_input, p_parent,
- PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL );
+ PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL,
+ VLC_FALSE );
} else if ( node->isContainerNode() )
{
ContainerNode *conNode = (ContainerNode *)node;
item->getTitle() );
int i_cat;
playlist_BothAddInput( p_playlist, p_input, parentNode,
- PLAYLIST_APPEND, PLAYLIST_END, &i_cat, NULL );
+ PLAYLIST_APPEND, PLAYLIST_END, &i_cat, NULL,
+ VLC_FALSE );
/* TODO: do this better by storing ids */
playlist_item_t *p_node = playlist_ItemGetById( p_playlist, i_cat, VLC_FALSE );
assert( p_node );
struct libvlc_instance_t
{
libvlc_int_t *p_libvlc_int;
- vlm_t *p_vlm;
+ vlm_t *p_vlm;
+ int b_playlist_locked;
+ vlc_mutex_t instance_lock;
};
struct libvlc_input_t
#define PL p_instance->p_libvlc_int->p_playlist
+static inline int playlist_was_locked( libvlc_instance_t *p_instance )
+{
+ int was_locked;
+ vlc_mutex_lock( &p_instance->instance_lock );
+ was_locked = p_instance->b_playlist_locked;
+ vlc_mutex_unlock( &p_instance->instance_lock );
+ return was_locked;
+}
+
+static inline void playlist_mark_locked( libvlc_instance_t *p_instance,
+ int locked )
+{
+ vlc_mutex_lock( &p_instance->instance_lock );
+ p_instance->b_playlist_locked = locked;
+ vlc_mutex_unlock( &p_instance->instance_lock );
+}
+
void libvlc_playlist_loop( libvlc_instance_t *p_instance, vlc_bool_t loop,
libvlc_exception_t *p_e)
{
int i_options, char **ppsz_options,
libvlc_exception_t *p_e )
{
+ int did_lock = 0;
assert( PL );
///\todo Handle additionnal options
if( PL->items.i_size == 0 ) RAISEVOID( "Empty playlist" );
if( i_id > 0 )
{
- playlist_item_t *p_item = playlist_ItemGetByInputId( PL, i_id,
- PL->status.p_node );
- if( !p_item ) RAISEVOID( "Unable to find item" );
-
- playlist_Control( PL, PLAYLIST_VIEWPLAY, VLC_FALSE,
+ playlist_item_t *p_item;
+ if (! playlist_was_locked( p_instance ) )
+ {
+ playlist_mark_locked( p_instance, 1 );
+ vlc_mutex_lock( &PL->object_lock );
+ did_lock = 1;
+ }
+
+ p_item = playlist_ItemGetByInputId( PL, i_id,
+ PL->status.p_node );
+ if( !p_item )
+ {
+ if( did_lock == 1 )
+ {
+ vlc_mutex_unlock( &PL->object_lock );
+ playlist_mark_locked( p_instance, 0 );
+ }
+ RAISEVOID( "Unable to find item" );
+ }
+
+ playlist_Control( PL, PLAYLIST_VIEWPLAY, VLC_TRUE,
PL->status.p_node, p_item );
+ if( did_lock == 1 )
+ {
+ vlc_mutex_unlock( &PL->object_lock );
+ playlist_mark_locked( p_instance, 0 );
+ }
}
else
{
- playlist_Play( PL );
+ playlist_Control( PL, PLAYLIST_PLAY,
+ playlist_was_locked( p_instance ) );
}
}
void libvlc_playlist_pause( libvlc_instance_t *p_instance,
- libvlc_exception_t *p_e )
+ libvlc_exception_t *p_e )
{
assert( PL );
- if( playlist_Pause( PL ) != VLC_SUCCESS )
+ if( playlist_Control( PL, PLAYLIST_PAUSE,
+ playlist_was_locked( p_instance ) ) != VLC_SUCCESS )
RAISEVOID( "Empty playlist" );
}
libvlc_exception_t *p_e )
{
assert( PL );
- if( playlist_Stop( PL ) != VLC_SUCCESS )
+ if( playlist_Control( PL, PLAYLIST_STOP,
+ playlist_was_locked( p_instance ) ) != VLC_SUCCESS )
RAISEVOID( "Empty playlist" );
}
void libvlc_playlist_clear( libvlc_instance_t *p_instance,
- libvlc_exception_t *p_e )
+ libvlc_exception_t *p_e )
{
assert( PL );
- playlist_Clear( PL, VLC_FALSE );
+ playlist_Clear( PL, playlist_was_locked( p_instance ) );
}
void libvlc_playlist_next( libvlc_instance_t *p_instance,
libvlc_exception_t *p_e )
{
assert( PL );
- if( playlist_Next( PL ) != VLC_SUCCESS )
+ if( playlist_Control( PL, PLAYLIST_SKIP, playlist_was_locked( p_instance ),
+ 1 ) != VLC_SUCCESS )
RAISEVOID( "Empty playlist" );
}
void libvlc_playlist_prev( libvlc_instance_t *p_instance,
libvlc_exception_t *p_e )
{
- if( playlist_Prev( PL ) != VLC_SUCCESS )
+ if( playlist_Control( PL, PLAYLIST_SKIP, playlist_was_locked( p_instance ),
+ -1 ) != VLC_SUCCESS )
RAISEVOID( "Empty playlist" );
}
libvlc_exception_t *p_e )
{
assert( PL );
+ if( playlist_was_locked( p_instance ) )
+ {
+ libvlc_exeption_raise( p_e, "You must unlock playlist before "
+ "calling libvlc_playlist_add" );
+ return VLC_EGENERIC;
+ }
return playlist_AddExt( PL, psz_uri, psz_name,
PLAYLIST_INSERT, PLAYLIST_END, -1, ppsz_options,
- i_options, 1 );
+ i_options, 1, VLC_FALSE );
}
-
int libvlc_playlist_delete_item( libvlc_instance_t *p_instance, int i_id,
libvlc_exception_t *p_e )
{
assert( PL );
- if( playlist_DeleteFromInput( PL, i_id, VLC_FALSE ) )
+ if( playlist_DeleteFromInput( PL, i_id,
+ playlist_was_locked( p_instance ) ) )
{
libvlc_exception_raise( p_e, "deletion failed" );
return VLC_ENOITEM;
libvlc_exception_t *p_e )
{
assert( PL );
- return PL->items.i_size;
+ return playlist_CurrentSize( PL );
}
+void libvlc_playlist_lock( libvlc_instance_t *p_instance )
+{
+ assert( PL );
+ vlc_mutex_lock( &PL->object_lock );
+ p_instance->b_playlist_locked = 1;
+}
+
+void libvlc_playlist_unlock( libvlc_instance_t *p_instance )
+{
+ assert( PL );
+ p_instance->b_playlist_locked = 0;
+ vlc_mutex_unlock( &PL->object_lock );
+}
+
+
+
libvlc_input_t * libvlc_playlist_get_input( libvlc_instance_t *p_instance,
libvlc_exception_t *p_e )
{
LIBVLC_PLAYLIST_FUNC;
i_err = playlist_AddExt( p_libvlc->p_playlist, psz_target,
NULL, i_mode, i_pos, -1,
- ppsz_options, i_options, VLC_TRUE );
+ ppsz_options, i_options, VLC_TRUE, VLC_FALSE );
LIBVLC_PLAYLIST_FUNC_END;
return i_err;
}
NULL, PLAYLIST_APPEND ,
PLAYLIST_END, -1,
(char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL ),
- i_options, VLC_TRUE );
+ i_options, VLC_TRUE, VLC_FALSE );
} else {
playlist_AddExt( p_playlist, ppsz_argv[i_opt],
NULL, PLAYLIST_APPEND | PLAYLIST_GO,
PLAYLIST_END, -1,
(char const **)( i_options ? &ppsz_argv[i_opt+1] : NULL ),
- i_options, VLC_TRUE );
+ i_options, VLC_TRUE, VLC_FALSE );
}
i_opt += i_options;
* This function is to be used only by the playlist */
int playlist_DeleteFromItemId( playlist_t *p_playlist, int i_id )
{
- playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id, VLC_TRUE );
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id,
+ VLC_TRUE );
if( !p_item ) return VLC_EGENERIC;
return DeleteInner( p_playlist, p_item, VLC_TRUE );
}
*/
int playlist_Add( playlist_t *p_playlist, const char *psz_uri,
const char *psz_name, int i_mode, int i_pos,
- vlc_bool_t b_playlist )
+ vlc_bool_t b_playlist, vlc_bool_t b_locked )
{
return playlist_AddExt( p_playlist, psz_uri, psz_name,
- i_mode, i_pos, -1, NULL, 0, b_playlist );
+ i_mode, i_pos, -1, NULL, 0, b_playlist, b_locked );
}
/**
int playlist_AddExt( playlist_t *p_playlist, const char * psz_uri,
const char *psz_name, int i_mode, int i_pos,
mtime_t i_duration, const char *const *ppsz_options,
- int i_options, vlc_bool_t b_playlist )
+ int i_options, vlc_bool_t b_playlist, vlc_bool_t b_locked )
{
int i_ret;
input_item_t *p_input = input_ItemNewExt( p_playlist, psz_uri, psz_name,
i_options, ppsz_options,
i_duration );
- i_ret = playlist_AddInput( p_playlist, p_input, i_mode, i_pos, b_playlist );
+ i_ret = playlist_AddInput( p_playlist, p_input, i_mode, i_pos, b_playlist,
+ b_locked );
if( i_ret == VLC_SUCCESS )
return p_input->i_id;
return -1;
/** Add an input item to the playlist node */
int playlist_AddInput( playlist_t* p_playlist, input_item_t *p_input,
- int i_mode, int i_pos, vlc_bool_t b_playlist )
+ int i_mode, int i_pos, vlc_bool_t b_playlist,
+ vlc_bool_t b_locked )
{
playlist_item_t *p_item_cat, *p_item_one;
PL_DEBUG( "adding item `%s' ( %s )", p_input->psz_name,
p_input->psz_uri );
- PL_LOCK;
+ if( !b_locked ) PL_LOCK;
/* Add to ONELEVEL */
p_item_one = playlist_ItemNewFromInput( p_playlist, p_input );
GoAndPreparse( p_playlist, i_mode, p_item_cat, p_item_one );
- PL_UNLOCK;
+ if( !b_locked ) PL_UNLOCK;
return VLC_SUCCESS;
}
input_item_t *p_input,
playlist_item_t *p_direct_parent,
int i_mode, int i_pos,
- int *i_cat, int *i_one )
+ int *i_cat, int *i_one, vlc_bool_t b_locked )
{
playlist_item_t *p_item_cat, *p_item_one, *p_up;
int i_top;
assert( p_input );
- vlc_mutex_lock( & p_playlist->object_lock );
+ if( !b_locked ) PL_LOCK;
/* Add to category */
p_item_cat = playlist_ItemNewFromInput( p_playlist, p_input );
if( i_cat ) *i_cat = p_item_cat->i_id;
if( i_one ) *i_one = p_item_one->i_id;
- vlc_mutex_unlock( &p_playlist->object_lock );
+ if( !b_locked ) PL_UNLOCK;
return VLC_SUCCESS;
}
playlist_item_t * playlist_NodeAddInput( playlist_t *p_playlist,
input_item_t *p_input,
playlist_item_t *p_parent,
- int i_mode, int i_pos )
+ int i_mode, int i_pos,
+ vlc_bool_t b_locked )
{
playlist_item_t *p_item;
assert( p_input );
assert( p_parent && p_parent->i_children != -1 );
- vlc_mutex_lock( &p_playlist->object_lock );
+ if( !b_locked ) PL_LOCK;
p_item = playlist_ItemNewFromInput( p_playlist, p_input );
if( p_item == NULL ) return NULL;
AddItem( p_playlist, p_item, p_parent, i_mode, i_pos );
- vlc_mutex_unlock( &p_playlist->object_lock );
+ if( !b_locked ) PL_UNLOCK;
return p_item;
}