int i_nb_played; /**< How many times was this item played ? */
+
+ /* LEGACY FIELDS */
vlc_bool_t b_autodeletion; /**< Indicates whther this item is to
* be deleted after playback. True mean
* that this item is to be deleted
* after playback, false otherwise */
vlc_bool_t b_enabled; /**< Indicates whether this item is to be
* played or skipped */
+ /* END LEGACY FIELDS */
};
#define PLAYLIST_SAVE_FLAG 0x1 /**< Must it be saved */
/* Creation/Deletion */
#define playlist_Create(a) __playlist_Create(VLC_OBJECT(a))
playlist_t * __playlist_Create ( vlc_object_t * );
-void playlist_Destroy ( playlist_t * );
+int playlist_Destroy ( playlist_t * );
/* Playlist control */
#define playlist_Play(p) playlist_Control(p,PLAYLIST_PLAY )
/* Services discovery */
VLC_EXPORT( int, playlist_ServicesDiscoveryAdd, (playlist_t *, const char *));
-VLC_EXPORT( void, playlist_ServicesDiscoveryRemove, (playlist_t *, const char *));
+VLC_EXPORT( int, playlist_ServicesDiscoveryRemove, (playlist_t *, const char *));
VLC_EXPORT( int, playlist_AddSDModules, (playlist_t *, char *));
VLC_EXPORT( vlc_bool_t, playlist_IsServicesDiscoveryLoaded, ( playlist_t *,const char *));
#define playlist_AddItem(p,pi,i1,i2) playlist_ItemAdd(p,pi,i1,i2)
#define playlist_ItemNew( a , b, c ) __playlist_ItemNew(VLC_OBJECT(a) , b , c )
VLC_EXPORT( playlist_item_t* , __playlist_ItemNew, ( vlc_object_t *,const char *,const char * ) );
-VLC_EXPORT( void, playlist_ItemDelete, ( playlist_item_t * ) );
-VLC_EXPORT( void, playlist_ItemAddParent, ( playlist_item_t *, int,playlist_item_t *) );
-VLC_EXPORT( void, playlist_CopyParents, ( playlist_item_t *,playlist_item_t *) );
+VLC_EXPORT( int, playlist_ItemDelete, ( playlist_item_t * ) );
+VLC_EXPORT( int, playlist_ItemAddParent, ( playlist_item_t *, int,playlist_item_t *) );
+VLC_EXPORT( int, playlist_CopyParents, ( playlist_item_t *,playlist_item_t *) );
/* Item informations accessors */
VLC_EXPORT( int, playlist_ItemSetName, (playlist_item_t *, char * ) );
VLC_EXPORT( int, playlist_ItemSetDuration, (playlist_item_t *, mtime_t ) );
/* View management functions */
VLC_EXPORT( int, playlist_ViewInsert, (playlist_t *, int, char * ) );
-VLC_EXPORT( void, playlist_ViewDelete, (playlist_t *,playlist_view_t* ) );
+VLC_EXPORT( int, playlist_ViewDelete, (playlist_t *,playlist_view_t* ) );
VLC_EXPORT( playlist_view_t *, playlist_ViewFind, (playlist_t *, int ) );
VLC_EXPORT( int, playlist_ViewUpdate, (playlist_t *, int ) );
-VLC_EXPORT( void, playlist_ViewDump, (playlist_t *, playlist_view_t * ) );
+VLC_EXPORT( int, playlist_ViewDump, (playlist_t *, playlist_view_t * ) );
VLC_EXPORT( int, playlist_ViewEmpty, (playlist_t *, int, vlc_bool_t ) );
/* Node management */
VLC_EXPORT( int, playlist_Delete, ( playlist_t *, int ) );
VLC_EXPORT( int, playlist_Disable, ( playlist_t *, playlist_item_t * ) );
VLC_EXPORT( int, playlist_Enable, ( playlist_t *, playlist_item_t * ) );
-VLC_EXPORT( void, playlist_ItemToNode, (playlist_t *,playlist_item_t *) );
+VLC_EXPORT( int, playlist_ItemToNode, (playlist_t *,playlist_item_t *) );
+VLC_EXPORT( int, playlist_Replace, (playlist_t *,playlist_item_t *, input_item_t*) );
/* Item search functions */
* \return the item, or NULL on failure
*/
playlist_item_t * playlist_ItemGetByInput( playlist_t * p_playlist ,
- input_item_t *p_item )
+ input_item_t *p_item )
{
int i;
for( i = 0 ; i < p_playlist->i_size ; i++ )
/**
* Transform an item to a node
*
+ * This function must be entered without the playlist lock
+ *
* \param p_playlist the playlist object
* \param p_item the item to transform
* \return nothing
*/
-void playlist_ItemToNode( playlist_t *p_playlist,playlist_item_t *p_item )
+int playlist_ItemToNode( playlist_t *p_playlist,playlist_item_t *p_item )
{
int i = 0;
if( p_item->i_children == -1 )
}
vlc_mutex_unlock( &p_playlist->object_lock );
- /* Handle the parents
- * Nothing to do ! */
+ return VLC_SUCCESS;
}
/**
- * delete an item from a playlist.
+ * Replaces an item with another one
+ * This function must be entered without the playlist lock
+ *
+ * \see playlist_Replace
+ */
+int playlist_LockAndReplace( playlist_t *p_playlist,
+ playlist_item_t *p_olditem,
+ input_item_t *p_new )
+{
+ int i_ret;
+ vlc_mutex_lock( &p_playlist->object_lock );
+ i_ret = playlist_Replace( p_playlist, p_olditem, p_new );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ return i_ret;
+}
+
+/**
+ * Replaces an item with another one
+ * This function must be entered with the playlist lock:
+ *
+ * \param p_playlist the playlist
+ * \param p_olditem the item to replace
+ * \param p_new the new input_item
+ * \return VLC_SUCCESS or an error
+ */
+int playlist_Replace( playlist_t *p_playlist, playlist_item_t *p_olditem,
+ input_item_t *p_new )
+{
+ int i;
+ int j;
+
+ if( p_olditem->i_children != -1 )
+ {
+ msg_Err( p_playlist, "playlist_Replace can only be used on leafs");
+ return VLC_EGENERIC;
+ }
+
+ p_olditem->i_nb_played = 0;
+ memcpy( &p_olditem->input, p_new, sizeof( input_item_t ) );
+
+ p_olditem->i_nb_played = 0;
+
+ for( i = 0 ; i< p_olditem->i_parents ; i++ )
+ {
+ playlist_item_t *p_parent = p_olditem->pp_parents[i]->p_parent;
+
+ for( j = 0 ; j< p_parent->i_children ; i++ )
+ {
+ if( p_parent->pp_children[j] == p_olditem )
+ {
+ p_parent->i_serial++;
+ }
+ }
+ }
+ return VLC_SUCCESS;
+}
+
+/**
+ * Deletes an item from a playlist.
+ *
+ * This function must be entered without the playlist lock
*
* \param p_playlist the playlist to remove from.
* \param i_id the identifier of the item to delete
/**
* Move an item in a playlist
*
+ * This function must be entered without the playlist lock
+ *
* Move the item in the playlist with position i_pos before the current item
* at position i_newpos.
* \param p_playlist the playlist to move items in
return VLC_SUCCESS;
}
+
+/**
+ * Moves an item
+ *
+ * \param p_playlist the playlist
+ * \param p_item the item to move
+ * \param p_node the new parent of the item
+ * \param i_newpos the new position under this new parent
+ * \param i_view the view in which the move must be done or ALL_VIEWS
+ * \return VLC_SUCCESS or an error
+ */
+int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
+ playlist_item_t *p_node, int i_newpos, int i_view )
+{
+ int i;
+ playlist_item_t *p_detach = NULL;
+#if 0
+ if( i_view == ALL_VIEWS )
+ {
+ for( i = 0 ; i < p_playlist->i_views; i++ )
+ {
+ playlist_TreeMove( p_playlist, p_item, p_node, i_newpos,
+ p_playlist->pp_views[i] );
+ }
+ }
+#endif
+
+ /* Find the parent */
+ for( i = 0 ; i< p_item->i_parents; i++ )
+ {
+ if( p_item->pp_parents[i]->i_view == i_view )
+ {
+ p_detach = p_item->pp_parents[i]->p_parent;
+ break;
+ }
+ }
+ if( p_detach == NULL )
+ {
+ msg_Err( p_playlist, "item not found in view %i", i_view );
+ return VLC_EGENERIC;
+ }
+
+ /* Detach from the parent */
+// playlist_NodeDetach( p_detach, p_item );
+
+ /* Attach to new parent */
+
+ return VLC_SUCCESS;
+}
* \param p_item the item to delete
* \return nothing
*/
-void playlist_ItemDelete( playlist_item_t *p_item )
+int playlist_ItemDelete( playlist_item_t *p_item )
{
vlc_mutex_lock( &p_item->input.lock );
vlc_mutex_destroy( &p_item->input.lock );
free( p_item );
+
+ return VLC_SUCCESS;
}
/**
* \param p_parent the parent to add
* \return nothing
*/
-void playlist_ItemAddParent( playlist_item_t *p_item, int i_view,
- playlist_item_t *p_parent )
+int playlist_ItemAddParent( playlist_item_t *p_item, int i_view,
+ playlist_item_t *p_parent )
{
vlc_bool_t b_found = VLC_FALSE;
int i;
p_item->i_parents, p_item->i_parents,
p_ip );
}
+ return VLC_SUCCESS;
}
/**
* Copy all parents from parent to child
*/
-void playlist_CopyParents( playlist_item_t *p_parent,
+int playlist_CopyParents( playlist_item_t *p_parent,
playlist_item_t *p_child )
{
int i=0;
p_parent->pp_parents[i]->i_view,
p_parent );
}
+ return VLC_SUCCESS;
}
return VLC_EGENERIC;
}
+/*
+ * Guess the type of the item using the beginning of the mrl */
static void GuessType( input_item_t *p_item)
{
int i;
*****************************************************************************/
static void RunThread ( playlist_t * );
static playlist_item_t * NextItem ( playlist_t * );
-static void PlayItem ( playlist_t *, playlist_item_t * );
+static int PlayItem ( playlist_t *, playlist_item_t * );
static int ItemChange( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
*/
playlist_t * __playlist_Create ( vlc_object_t *p_parent )
{
- int i_index;
playlist_t *p_playlist;
playlist_view_t *p_view;
vlc_value_t val;
*
* Delete all items in the playlist and free the playlist structure.
* \param p_playlist the playlist structure to destroy
+ * \return VLC_SUCCESS or an error
*/
-void playlist_Destroy( playlist_t * p_playlist )
+int playlist_Destroy( playlist_t * p_playlist )
{
int i;
p_playlist->b_die = 1;
}
vlc_object_destroy( p_playlist );
+
+ return VLC_SUCCESS;
}
/*****************************************************************************
* PlayItem: start the input thread for an item
****************************************************************************/
-static void PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
+static int PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
{
vlc_value_t val;
- int i;
msg_Dbg( p_playlist, "creating new input thread" );
var_Set( p_playlist, "playlist-current", val);
vlc_mutex_lock( &p_playlist->object_lock);
+ return VLC_SUCCESS;
+
}
/* Forward item change from input */
return VLC_SUCCESS;
}
-void playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
+int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
const char *psz_module )
{
int i;
if( p_sd )
{
+ vlc_mutex_unlock( &p_playlist->object_lock );
p_sd->b_die = VLC_TRUE;
vlc_thread_join( p_sd );
module_Unneed( p_sd, p_sd->p_module );
+ vlc_mutex_lock( &p_playlist->object_lock );
vlc_object_destroy( p_sd );
}
else
{
msg_Warn( p_playlist, "module %s is not loaded", psz_module );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ return VLC_EGENERIC;
}
vlc_mutex_unlock( &p_playlist->object_lock );
- return;
+ return VLC_SUCCESS;
}
vlc_bool_t playlist_IsServicesDiscoveryLoaded( playlist_t * p_playlist,
int playlist_NodeSort( playlist_t * p_playlist , playlist_item_t *p_node,
int i_mode, int i_type )
{
- int i_id;
vlc_value_t val;
val.b_bool = VLC_TRUE;
* \param p_view the view to delete
* \return nothing
*/
-void playlist_ViewDelete( playlist_t *p_playlist,playlist_view_t *p_view )
+int playlist_ViewDelete( playlist_t *p_playlist,playlist_view_t *p_view )
{
- //playlist_Delete( p_view->p_root );
REMOVE_ELEM( p_playlist->pp_views, p_playlist->i_views, 0 );
+ return VLC_SUCCESS;
}
* \param p_view the view to dump
* \return nothing
*/
-void playlist_ViewDump( playlist_t *p_playlist, playlist_view_t *p_view )
+int playlist_ViewDump( playlist_t *p_playlist, playlist_view_t *p_view )
{
msg_Dbg( p_playlist, "dumping view %i",p_view->i_id );
playlist_NodeDump( p_playlist,p_view->p_root, 1 );
+ return VLC_SUCCESS;
}
/**