- Remove a bunch of transition now-useless API.
- Remove all playlist_Lock* functions. Matching functions now accept a
b_locked parameter that should be set to VLC_TRUE if the playlist is
locked when calling the function. The advantages are that it reduces
the API bloat and that the b_locked flag can be propagated in the
call stack
- Remove useless playlist testsuite
- Remove broken daap plugin (unmaintained wrt VLC API changes, relies on
an unmaintained library, probably unable to read content from new itunes,
...). Implementations exist in rhythmbox, xmms2 and
daap-sharp, we should see if a proper lib exists or if we could
make one
- Reduce verbosity a bit
- Documentation
fi
fi
-dnl
-dnl DAAP access plugin and services discovery
-dnl
-AC_ARG_ENABLE(daap,
- [ --enable-daap DAAP shares services discovery support (default enabled)])
-if test "$enable_daap" != "no"
-then
- PKG_CHECK_MODULES(DAAP, opendaap >= 0.3.0,
- [ VLC_ADD_PLUGINS([daap])
- VLC_ADD_LDFLAGS([daap],[$DAAP_LIBS])
- VLC_ADD_CFLAGS([daap],[$DAAP_CFLAGS])]:,
- [AC_MSG_WARN(DAAP library not found)])
-fi
-
dnl
dnl Bonjour services discovery
dnl
* to the playlist in vlc
*
* \defgroup vlc_playlist Playlist
+ *
+ * The VLC playlist system has a tree structure. This allows advanced
+ * categorization, like for SAP streams (which are grouped by "sap groups").
+ *
+ * The base structure for all playlist operations is the input_item_t. This
+ * contains all information needed to play a stream and get info, ie, mostly,
+ * mrl and metadata. This structure contains a unique i_id field. ids are
+ * not recycled when an item is destroyed.
+ *
+ * Input items are not used directly, but through playlist items.
+ * The playlist items are themselves in a tree structure. They only contain
+ * a link to the input item, a unique id and a few flags. the playlist
+ * item id is NOT the same as the input item id.
+ * Several playlist items can be attached to a single input item. The input
+ * item is refcounted and is automatically destroyed when it is not used
+ * anymore.
+ *
+ * In the playlist itself, there are two trees, that should always be kept
+ * in sync. The "category" tree contains the whole tree structure with
+ * several levels, while the onelevel tree contains only one level :), ie
+ * it only contains "real" items, not nodes
+ * For example, if you open a directory, you will have
+ *
+ * Category tree: Onevelel tree:
+ * Playlist Playlist
+ * - Dir - item1
+ * - Subdir - item2
+ * - item1
+ * - item2
+ *
+ * The top-level items of both tree are the same, and they are reproduced
+ * in the left-part of the playlist GUIs, they are the "sources" from the
+ * source selectors. Top-level items include: playlist, media library, SAP,
+ * Shoutcast, devices, ...
+ *
+ * It is envisioned that a third tree will appear: VLM, but it's not done yet
+ *
+ * The playlist also stores, for utility purposes, an array of all input
+ * items, an array of all playlist items and an array of all playlist items
+ * and nodes (both are represented by the same structure).
+ *
+ * So, here is an example:
+ *
+ * Inputs array
+ * - input 1 -> name = foo 1 uri = ...
+ * - input 2 -> name = foo 2 uri = ...
+ *
+ * Category tree Onlevel tree
+ * - playlist (id 1) - playlist (id 3)
+ * - category 1 (id 2) - foo 2 (id 8 - input 2)
+ * - foo 2 (id 6 - input 2) - media library (id 4)
+ * - media library (id 2) - foo 1 (id6 - input 1)
+ * - foo 1 (id 5 - input 1)
+ *
+ * Sometimes, an item must be transformed to a node. This happens for the
+ * directory access for example. In that case, the item is removed from
+ * the onelevel tree, as it is not a real item anymore.
+ *
+ * For "standard" item addition, you can use playlist_Add, playlist_AddExt
+ * (more options) or playlist_AddInput if you already created your input
+ * item. This will add the item at the root of "Playlist" or of "Media library"
+ * in each of the two trees.
+ *
+ * If you want more control (like, adding the item as the child of a given
+ * node in the category tree, use playlist_BothAddInput. You'll have to provide
+ * the node in the category tree. The item will be added as a child of
+ * this node in the category tree, and as a child of the matching top-level
+ * node in the onelevel tree. (Nodes are created with playlist_NodeCreate)
+ *
+ * Generally speaking, playlist_NodeAddInput should not be used in newer code, it
+ * will maybe become useful again when we merge VLM;
+ *
+ * To delete an item, use playlist_DeleteFromInput( input_id ) which will
+ * remove all occurences of the input in both trees
+ *
* @{
*/
-/**
- * playlist export helper structure
- */
+/** Helper structure to export to file part of the playlist */
struct playlist_export_t
{
char *psz_filename;
playlist_item_t *p_root;
};
-/**
- * playlist item / node
- * \see playlist_t
- */
+/** playlist item / node */
struct playlist_item_t
{
input_item_t *p_input; /**< input item descriptor */
playlist_item_array_t current; /**< Items currently being played */
int i_current_index; /**< Index in current array */
- /** Reset current item ? */
+ /** Reset current item array */
vlc_bool_t b_reset_currently_playing;
mtime_t last_rebuild_date;
int i_last_playlist_id; /**< Last id to an item */
int i_last_input_id ; /**< Last id on an input */
- services_discovery_t **pp_sds;
- int i_sds;
+ services_discovery_t **pp_sds; /**< Loaded service discovery modules */
+ int i_sds; /**< Number of service discovery modules */
/* Predefined items */
- playlist_item_t * p_root_category;
- playlist_item_t * p_root_onelevel;
+ playlist_item_t * p_root_category; /**< Root of category tree */
+ playlist_item_t * p_root_onelevel; /**< Root of onelevel tree */
playlist_item_t * p_local_category; /** < "Playlist" in CATEGORY view */
playlist_item_t * p_ml_category; /** < "Library" in CATEGORY view */
playlist_item_t * p_local_onelevel; /** < "Playlist" in ONELEVEL view */
} request;
// Playlist-unrelated fields
- interaction_t *p_interaction; /**< Interaction manager */
- /** The input thread computing stats */
- input_thread_t *p_stats_computer;
- global_stats_t *p_stats; /**< Global statistics */
+ interaction_t *p_interaction; /**< Interaction manager */
+ input_thread_t *p_stats_computer; /**< Input thread computing stats */
+ global_stats_t *p_stats; /**< Global statistics */
};
/** Helper to add an item */
#define pl_Release(a) vlc_object_release( a->p_libvlc->p_playlist );
/* Playlist control */
-#define playlist_Play(p) playlist_LockControl(p,PLAYLIST_PLAY )
-#define playlist_Pause(p) playlist_LockControl(p,PLAYLIST_PAUSE )
-#define playlist_Stop(p) playlist_LockControl(p,PLAYLIST_STOP )
-#define playlist_Next(p) playlist_LockControl(p,PLAYLIST_SKIP, 1)
-#define playlist_Prev(p) playlist_LockControl(p,PLAYLIST_SKIP, -1)
-#define playlist_Skip(p,i) playlist_LockControl(p,PLAYLIST_SKIP, i)
+#define playlist_Play(p) playlist_Control(p,PLAYLIST_PLAY, VLC_FALSE )
+#define playlist_Pause(p) playlist_Control(p,PLAYLIST_PAUSE, VLC_FALSE )
+#define playlist_Stop(p) playlist_Control(p,PLAYLIST_STOP, VLC_FALSE )
+#define playlist_Next(p) playlist_Control(p,PLAYLIST_SKIP, VLC_FALSE, 1)
+#define playlist_Prev(p) playlist_Control(p,PLAYLIST_SKIP, VLC_FALSE, -1)
+#define playlist_Skip(p,i) playlist_Control(p,PLAYLIST_SKIP, VLC_FALSE, i)
-VLC_EXPORT( int, playlist_Control, ( playlist_t *, int, ... ) );
-VLC_EXPORT( int, playlist_LockControl, ( playlist_t *, int, ... ) );
+VLC_EXPORT( int, playlist_Control, ( playlist_t *, int, vlc_bool_t, ... ) );
-VLC_EXPORT( void, playlist_Clear, ( playlist_t * ) );
-VLC_EXPORT( void, playlist_LockClear, ( playlist_t * ) );
+VLC_EXPORT( void, playlist_Clear, ( playlist_t *, vlc_bool_t ) );
VLC_EXPORT( int, playlist_PreparseEnqueue, (playlist_t *, input_item_t *) );
VLC_EXPORT( int, playlist_PreparseEnqueueItem, (playlist_t *, playlist_item_t *) );
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 */
+/* Save a playlist file */
VLC_EXPORT( int, playlist_Export, ( playlist_t *, const char *, playlist_item_t *, const char * ) );
/********************************************************
/*************************** Item deletion **************************/
VLC_EXPORT( int, playlist_ItemDelete, ( playlist_item_t * ) );
-VLC_EXPORT( int, playlist_DeleteAllFromInput, ( playlist_t *, int ) );
-VLC_EXPORT( int, playlist_DeleteFromInput, ( playlist_t *, int, playlist_item_t *, vlc_bool_t ) );
-VLC_EXPORT( int, playlist_DeleteFromItemId, ( playlist_t *, int ) );
-VLC_EXPORT( int, playlist_LockDelete, ( playlist_t *, int ) );
-VLC_EXPORT( int, playlist_LockDeleteAllFromInput, ( playlist_t *, int ) );
+VLC_EXPORT( int, playlist_DeleteFromInput, ( playlist_t *, int, vlc_bool_t ) );
/*************************** Item fields accessors **************************/
VLC_EXPORT( int, playlist_ItemSetName, (playlist_item_t *, const char * ) );
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( 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( int, playlist_BothAddInput, ( playlist_t *, input_item_t *,playlist_item_t *,int , int, int*, int* ) );
/********************** Misc item operations **********************/
-VLC_EXPORT( playlist_item_t*, playlist_ItemToNode, (playlist_t *,playlist_item_t *) );
-VLC_EXPORT( playlist_item_t*, playlist_LockItemToNode, (playlist_t *,playlist_item_t *) );
+VLC_EXPORT( playlist_item_t*, playlist_ItemToNode, (playlist_t *,playlist_item_t *, vlc_bool_t) );
playlist_item_t *playlist_ItemFindFromInputAndRoot( playlist_t *p_playlist,
int i_input_id, playlist_item_t *p_root,
vlc_bool_t );
/********************************** Item search *************************/
-VLC_EXPORT( playlist_item_t *, playlist_ItemGetById, (playlist_t *, int) );
-VLC_EXPORT( playlist_item_t *, playlist_ItemGetByInput, (playlist_t *,input_item_t * ) );
-
-static inline playlist_item_t *playlist_LockItemGetById( playlist_t *p_playlist,
- int i_id)
-{
- playlist_item_t *p_ret;
- vlc_mutex_lock( &p_playlist->object_lock );
- p_ret = playlist_ItemGetById( p_playlist, i_id );
- vlc_mutex_unlock( &p_playlist->object_lock );
- return p_ret;
-}
-
-static inline playlist_item_t *playlist_LockItemGetByInput(
- playlist_t *p_playlist, input_item_t *p_item )
-{
- playlist_item_t *p_ret;
- vlc_mutex_lock( &p_playlist->object_lock );
- p_ret = playlist_ItemGetByInput( p_playlist, p_item );
- vlc_mutex_unlock( &p_playlist->object_lock );
- return p_ret;
-}
+VLC_EXPORT( playlist_item_t *, playlist_ItemGetById, (playlist_t *, int, vlc_bool_t) );
+VLC_EXPORT( playlist_item_t *, playlist_ItemGetByInput, (playlist_t *,input_item_t *, vlc_bool_t ) );
VLC_EXPORT( int, playlist_LiveSearchUpdate, (playlist_t *, playlist_item_t *, const char *) );
/** Tell the number of items in the current playing context */
#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 )
{
PL_UNLOCK;
}
-/**
- * @}
- */
+/** @} */
#endif
void (*__vlc_object_release_inner) (vlc_object_t *);
vlc_list_t * (*__vlc_list_find_inner) (vlc_object_t *, int, int);
void (*vlc_list_release_inner) (vlc_list_t *);
- int (*playlist_Control_inner) (playlist_t *, int, ...);
- int (*playlist_LockControl_inner) (playlist_t *, int, ...);
- void (*playlist_Clear_inner) (playlist_t *);
- void (*playlist_LockClear_inner) (playlist_t *);
+ int (*playlist_Control_inner) (playlist_t *, int, vlc_bool_t, ...);
+ void *playlist_LockControl_deprecated;
+ void (*playlist_Clear_inner) (playlist_t *, vlc_bool_t);
+ void *playlist_LockClear_deprecated;
int (*playlist_PreparseEnqueue_inner) (playlist_t *, input_item_t *);
int (*playlist_ServicesDiscoveryAdd_inner) (playlist_t *, const char *);
int (*playlist_ServicesDiscoveryRemove_inner) (playlist_t *, const char *);
int (*playlist_Add_inner) (playlist_t *, const char *, const char *, int, int, vlc_bool_t);
int (*playlist_AddExt_inner) (playlist_t *, const char *, const char *, int, int, mtime_t, const char *const *,int, vlc_bool_t);
void *playlist_ItemAdd_deprecated;
- void (*playlist_NodeAddItem_inner) (playlist_t *, playlist_item_t *, playlist_item_t *,int , int);
+ void *playlist_NodeAddItem_deprecated;
void *playlist_Delete_deprecated;
- int (*playlist_LockDelete_inner) (playlist_t *, int);
+ void *playlist_LockDelete_deprecated;
void *playlist_Disable_deprecated;
void *playlist_Enable_deprecated;
- playlist_item_t* (*playlist_ItemToNode_inner) (playlist_t *,playlist_item_t *);
- playlist_item_t* (*playlist_LockItemToNode_inner) (playlist_t *,playlist_item_t *);
+ playlist_item_t* (*playlist_ItemToNode_inner) (playlist_t *,playlist_item_t *, vlc_bool_t);
+ void *playlist_LockItemToNode_deprecated;
void *playlist_Replace_deprecated;
void *playlist_LockReplace_deprecated;
- playlist_item_t * (*playlist_ItemGetById_inner) (playlist_t *, int);
+ playlist_item_t * (*playlist_ItemGetById_inner) (playlist_t *, int, vlc_bool_t);
void *playlist_LockItemGetById_deprecated;
void *playlist_ItemGetByPos_deprecated;
void *playlist_LockItemGetByPos_deprecated;
- playlist_item_t * (*playlist_ItemGetByInput_inner) (playlist_t *,input_item_t *);
+ playlist_item_t * (*playlist_ItemGetByInput_inner) (playlist_t *,input_item_t *, vlc_bool_t);
void *playlist_LockItemGetByInput_deprecated;
void *playlist_GetPositionById_deprecated;
void *playlist_ItemAddOption_deprecated;
void *playlist_PlaylistAdd_deprecated;
void *playlist_PlaylistAddExt_deprecated;
void *playlist_PlaylistAddInput_deprecated;
- int (*playlist_BothAddInput_inner) (playlist_t *, input_item_t *,playlist_item_t *,int , int);
+ int (*playlist_BothAddInput_inner) (playlist_t *, input_item_t *,playlist_item_t *,int , int, int*, int*);
playlist_item_t * (*__playlist_ItemNewFromInput_inner) (vlc_object_t *p_obj,input_item_t *p_input);
input_item_t * (*input_ItemGetById_inner) (playlist_t *, int);
int (*playlist_LiveSearchUpdate_inner) (playlist_t *, playlist_item_t *, const char *);
void *vlc_input_item_AddOption_deprecated;
- 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);
+ int (*playlist_DeleteFromInput_inner) (playlist_t *, int, vlc_bool_t);
+ void *playlist_DeleteAllFromInput_deprecated;
+ void *playlist_LockDeleteAllFromInput_deprecated;
void *playlist_AddWhereverNeeded_deprecated;
- int (*playlist_DeleteFromItemId_inner) (playlist_t *, int);
+ void *playlist_DeleteFromItemId_deprecated;
void (*playlist_NodeDump_inner) (playlist_t *p_playlist, playlist_item_t *p_item, int i_level);
void *__intf_UserOkayCancel_deprecated;
int (*__intf_UserStringInput_inner) (vlc_object_t*, const char*, const char*, char **);
# define __vlc_list_find (p_symbols)->__vlc_list_find_inner
# define vlc_list_release (p_symbols)->vlc_list_release_inner
# define playlist_Control (p_symbols)->playlist_Control_inner
-# define playlist_LockControl (p_symbols)->playlist_LockControl_inner
# define playlist_Clear (p_symbols)->playlist_Clear_inner
-# define playlist_LockClear (p_symbols)->playlist_LockClear_inner
# define playlist_PreparseEnqueue (p_symbols)->playlist_PreparseEnqueue_inner
# define playlist_ServicesDiscoveryAdd (p_symbols)->playlist_ServicesDiscoveryAdd_inner
# define playlist_ServicesDiscoveryRemove (p_symbols)->playlist_ServicesDiscoveryRemove_inner
# define playlist_NodeEmpty (p_symbols)->playlist_NodeEmpty_inner
# define playlist_Add (p_symbols)->playlist_Add_inner
# define playlist_AddExt (p_symbols)->playlist_AddExt_inner
-# define playlist_NodeAddItem (p_symbols)->playlist_NodeAddItem_inner
-# define playlist_LockDelete (p_symbols)->playlist_LockDelete_inner
# define playlist_ItemToNode (p_symbols)->playlist_ItemToNode_inner
-# define playlist_LockItemToNode (p_symbols)->playlist_LockItemToNode_inner
# define playlist_ItemGetById (p_symbols)->playlist_ItemGetById_inner
# define playlist_ItemGetByInput (p_symbols)->playlist_ItemGetByInput_inner
# define playlist_NodeSort (p_symbols)->playlist_NodeSort_inner
# define input_ItemGetById (p_symbols)->input_ItemGetById_inner
# define playlist_LiveSearchUpdate (p_symbols)->playlist_LiveSearchUpdate_inner
# 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_DeleteFromItemId (p_symbols)->playlist_DeleteFromItemId_inner
# define playlist_NodeDump (p_symbols)->playlist_NodeDump_inner
# define __intf_UserStringInput (p_symbols)->__intf_UserStringInput_inner
# define input_AddSubtitles (p_symbols)->input_AddSubtitles_inner
((p_symbols)->__vlc_list_find_inner) = __vlc_list_find; \
((p_symbols)->vlc_list_release_inner) = vlc_list_release; \
((p_symbols)->playlist_Control_inner) = playlist_Control; \
- ((p_symbols)->playlist_LockControl_inner) = playlist_LockControl; \
((p_symbols)->playlist_Clear_inner) = playlist_Clear; \
- ((p_symbols)->playlist_LockClear_inner) = playlist_LockClear; \
((p_symbols)->playlist_PreparseEnqueue_inner) = playlist_PreparseEnqueue; \
((p_symbols)->playlist_ServicesDiscoveryAdd_inner) = playlist_ServicesDiscoveryAdd; \
((p_symbols)->playlist_ServicesDiscoveryRemove_inner) = playlist_ServicesDiscoveryRemove; \
((p_symbols)->playlist_NodeEmpty_inner) = playlist_NodeEmpty; \
((p_symbols)->playlist_Add_inner) = playlist_Add; \
((p_symbols)->playlist_AddExt_inner) = playlist_AddExt; \
- ((p_symbols)->playlist_NodeAddItem_inner) = playlist_NodeAddItem; \
- ((p_symbols)->playlist_LockDelete_inner) = playlist_LockDelete; \
((p_symbols)->playlist_ItemToNode_inner) = playlist_ItemToNode; \
- ((p_symbols)->playlist_LockItemToNode_inner) = playlist_LockItemToNode; \
((p_symbols)->playlist_ItemGetById_inner) = playlist_ItemGetById; \
((p_symbols)->playlist_ItemGetByInput_inner) = playlist_ItemGetByInput; \
((p_symbols)->playlist_NodeSort_inner) = playlist_NodeSort; \
((p_symbols)->input_ItemGetById_inner) = input_ItemGetById; \
((p_symbols)->playlist_LiveSearchUpdate_inner) = playlist_LiveSearchUpdate; \
((p_symbols)->playlist_DeleteFromInput_inner) = playlist_DeleteFromInput; \
- ((p_symbols)->playlist_DeleteAllFromInput_inner) = playlist_DeleteAllFromInput; \
- ((p_symbols)->playlist_LockDeleteAllFromInput_inner) = playlist_LockDeleteAllFromInput; \
- ((p_symbols)->playlist_DeleteFromItemId_inner) = playlist_DeleteFromItemId; \
((p_symbols)->playlist_NodeDump_inner) = playlist_NodeDump; \
((p_symbols)->__intf_UserStringInput_inner) = __intf_UserStringInput; \
((p_symbols)->input_AddSubtitles_inner) = input_AddSubtitles; \
(p_symbols)->sout_CfgCreate_deprecated = NULL; \
(p_symbols)->vlc_input_item_GetInfo_deprecated = NULL; \
(p_symbols)->vlc_input_item_AddInfo_deprecated = NULL; \
+ (p_symbols)->playlist_LockControl_deprecated = NULL; \
+ (p_symbols)->playlist_LockClear_deprecated = NULL; \
(p_symbols)->__playlist_ItemNew_deprecated = NULL; \
(p_symbols)->__playlist_ItemCopy_deprecated = NULL; \
(p_symbols)->playlist_ItemAddParent_deprecated = NULL; \
(p_symbols)->playlist_ViewDump_deprecated = NULL; \
(p_symbols)->playlist_ViewEmpty_deprecated = NULL; \
(p_symbols)->playlist_ItemAdd_deprecated = NULL; \
+ (p_symbols)->playlist_NodeAddItem_deprecated = NULL; \
(p_symbols)->playlist_Delete_deprecated = NULL; \
+ (p_symbols)->playlist_LockDelete_deprecated = NULL; \
(p_symbols)->playlist_Disable_deprecated = NULL; \
(p_symbols)->playlist_Enable_deprecated = NULL; \
+ (p_symbols)->playlist_LockItemToNode_deprecated = NULL; \
(p_symbols)->playlist_Replace_deprecated = NULL; \
(p_symbols)->playlist_LockReplace_deprecated = NULL; \
(p_symbols)->playlist_LockItemGetById_deprecated = NULL; \
(p_symbols)->playlist_PlaylistAddExt_deprecated = NULL; \
(p_symbols)->playlist_PlaylistAddInput_deprecated = NULL; \
(p_symbols)->vlc_input_item_AddOption_deprecated = NULL; \
+ (p_symbols)->playlist_DeleteAllFromInput_deprecated = NULL; \
+ (p_symbols)->playlist_LockDeleteAllFromInput_deprecated = NULL; \
(p_symbols)->playlist_AddWhereverNeeded_deprecated = NULL; \
+ (p_symbols)->playlist_DeleteFromItemId_deprecated = NULL; \
(p_symbols)->__intf_UserOkayCancel_deprecated = NULL; \
(p_symbols)->playlist_NodesCreateForSD_deprecated = NULL; \
(p_symbols)->stats_TimerClean_deprecated = NULL; \
{
input_item_t *p_current = ( (input_thread_t*)p_access->p_parent)->
input.p_item;
- p_item = playlist_LockItemGetByInput( p_playlist, p_current );
+ p_item = playlist_ItemGetByInput( p_playlist, p_current, VLC_FALSE );
if( !p_item )
{
return VLC_EGENERIC;
}
- p_item_in_category = playlist_LockItemToNode( p_playlist, p_parent );
+ p_item_in_category = playlist_ItemToNode( p_playlist, p_parent, VLC_FALSE );
psz_name = strdup( "Audio CD" );
vlc_mutex_lock( &p_playlist->object_lock );
playlist_ItemSetName( p_parent, psz_name );
}
#endif
playlist_BothAddInput( p_playlist, p_input_item, p_item_in_category,
- PLAYLIST_APPEND, PLAYLIST_END );
+ PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL );
free( psz_uri ); free( psz_opt ); free( psz_name );
free( psz_first ); free( psz_last );
}
free(psz_title);
if( !p_child ) return NULL;
-#if 0
- playlist_NodeAddItem( p_playlist, p_child,
- p_item->p_parent->i_view,
- p_item, PLAYLIST_APPEND, PLAYLIST_END );
- playlist_CopyParents( p_item, p_child );
-#endif
return p_child;
}
if (p_playlist) {
- p_item = playlist_LockItemGetByInput( p_playlist,
- ((input_thread_t *)p_access->p_parent)->input.p_item );
+ p_item = playlist_ItemGetByInput( p_playlist,
+ ((input_thread_t *)p_access->p_parent)->input.p_item, VLC_FALSE );
if( p_item == p_playlist->status.p_item && !b_single_track )
{
if( b_play )
{
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE,
p_playlist->status.p_item, NULL );
}
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 );
+ playlist_ItemGetByInput( p_playlist, p_current_input, VLC_FALSE );
char *psz_name = strdup (p_access->psz_path);
if( psz_name == NULL )
msg_Dbg( p_access, "opening directory `%s'", p_access->psz_path );
p_current->p_input->i_type = ITEM_TYPE_DIRECTORY;
- p_item_in_category = playlist_LockItemToNode( p_playlist, p_current );
+ p_item_in_category = playlist_ItemToNode( p_playlist, p_current, VLC_FALSE );
i_activity = var_GetInteger( p_playlist, "activity" );
var_SetInteger( p_playlist, "activity", i_activity +
playlist_BothAddInput( p_playlist, p_input,
p_parent_category,
PLAYLIST_APPEND|PLAYLIST_PREPARSE,
- PLAYLIST_END );
+ PLAYLIST_END, NULL, NULL );
}
}
}
msg_Dbg( p_intf, "calling browser_Open with \"%s\"", psz_url );
#endif
(void) browser_Open( psz_url );
- playlist_Control( p_playlist, PLAYLIST_PAUSE, 0 );
+ playlist_Control( p_playlist, PLAYLIST_PAUSE, VLC_TRUE, 0 );
}
free( psz_uri_to_load );
FOREACH_ARRAY( playlist_item_t *p_item, p_playlist->items )
if( !strcmp( psz_bookmark, p_item->p_input->psz_uri ) )
{
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, NULL, p_item );
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE,
+ NULL, p_item );
break;
}
FOREACH_END();
+ PL_UNLOCK;
vlc_object_release( p_playlist );
}
break;
}
playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
- NULL,
+ VLC_TRUE, NULL,
playlist_ItemGetById( p_sys->p_playlist,
- i_item ) );
+ i_item, VLC_TRUE ) );
msg_Dbg( p_intf, "requested playlist item: %i", i_item );
break;
}
case MVLC_STOP:
- playlist_Control( p_sys->p_playlist, PLAYLIST_STOP );
+ playlist_Control( p_sys->p_playlist, PLAYLIST_STOP,
+ VLC_TRUE );
msg_Dbg( p_intf, "requested playlist stop" );
break;
case MVLC_PAUSE:
- playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE );
+ playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE,
+ VLC_TRUE );
msg_Dbg( p_intf, "requested playlist pause" );
break;
case MVLC_NEXT:
- playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, 1 );
+ playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP,
+ VLC_TRUE, 1 );
msg_Dbg( p_intf, "requested playlist next" );
break;
case MVLC_PREVIOUS:
- playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, -1 );
+ playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP,
+ VLC_TRUE, -1 );
msg_Dbg( p_intf, "requested playlist previous" );
break;
case MVLC_FULLSCREEN:
int i;
for( i = 0; i < i_nb_items; i++ )
{
- playlist_LockDeleteAllFromInput( p_sys->p_playlist,
- p_items[i] );
+ playlist_DeleteFromInput( p_sys->p_playlist,
+ p_items[i], VLC_FALSE );
msg_Dbg( p_intf, "requested playlist delete: %d",
p_items[i] );
p_items[i] = -1;
}
if( j == i_nb_items )
{
- playlist_LockDeleteAllFromInput( p_sys->p_playlist,
- p_sys->p_playlist->items.p_elems[i]->p_input->i_id );
+ playlist_DeleteFromInput( p_sys->p_playlist,
+ p_sys->p_playlist->items.p_elems[i]->p_input->i_id,
+ VLC_FALSE );
msg_Dbg( p_intf, "requested playlist delete: %d",
i );
}
}
case MVLC_EMPTY:
{
- playlist_LockClear( p_sys->p_playlist );
+ playlist_Clear( p_sys->p_playlist, VLC_FALSE );
msg_Dbg( p_intf, "requested playlist empty" );
break;
}
if( !strcmp( type , "title" ) )
{
- playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
+ playlist_RecursiveNodeSort( p_sys->p_playlist,
/* Ugly hack,but not worse than before ... */
p_sys->p_playlist->p_root_onelevel,
SORT_TITLE_NODES_FIRST,
int i_id = E_(SSPopN)( st, vars );
int i_ret;
- i_ret = playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
+ i_ret = playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE,
NULL,
playlist_ItemGetById( p_sys->p_playlist,
- i_id ) );
+ i_id, VLC_TRUE ) );
msg_Dbg( p_intf, "requested playlist item: %i", i_id );
E_(SSPushN)( st, i_ret );
}
else if( !strcmp( s, "vlc_stop" ) )
{
- playlist_Control( p_sys->p_playlist, PLAYLIST_STOP );
+ playlist_Control( p_sys->p_playlist, VLC_TRUE, PLAYLIST_STOP );
msg_Dbg( p_intf, "requested playlist stop" );
}
else if( !strcmp( s, "vlc_pause" ) )
{
- playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE );
+ playlist_Control( p_sys->p_playlist, VLC_TRUE, PLAYLIST_PAUSE );
msg_Dbg( p_intf, "requested playlist pause" );
}
else if( !strcmp( s, "vlc_next" ) )
{
- playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, 1 );
+ playlist_Control( p_sys->p_playlist, VLC_TRUE, PLAYLIST_SKIP, 1 );
msg_Dbg( p_intf, "requested playlist next" );
}
else if( !strcmp( s, "vlc_previous" ) )
{
- playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, -1 );
+ playlist_Control( p_sys->p_playlist, VLC_TRUE, PLAYLIST_SKIP, -1 );
msg_Dbg( p_intf, "requested playlist previous" );
}
else if( !strcmp( s, "vlc_seek" ) )
}
else if( !strcmp( s, "playlist_empty" ) )
{
- playlist_LockClear( p_sys->p_playlist );
+ playlist_Clear( p_sys->p_playlist, VLC_FALSE );
msg_Dbg( p_intf, "requested playlist empty" );
}
else if( !strcmp( s, "playlist_delete" ) )
{
int i_id = E_(SSPopN)( st, vars );
- playlist_LockDeleteAllFromInput( p_sys->p_playlist, i_id );
+ playlist_DeleteFromInput( p_sys->p_playlist, i_id, VLC_FALSE );
msg_Dbg( p_intf, "requested playlist delete: %d", i_id );
}
else if( !strcmp( s, "playlist_move" ) )
else if( !strcmp( psz_cmd, "clear" ) )
{
playlist_Stop( p_playlist );
- vlc_mutex_lock( &p_playlist->object_lock );
- playlist_Clear( p_playlist );
- vlc_mutex_unlock( &p_playlist->object_lock );
+ playlist_Clear( p_playlist, VLC_FALSE );
}
else if( !strcmp( psz_cmd, "add" ) &&
newval.psz_string && *newval.psz_string )
if( p_playlist )
{
b_play = FindItem( p_demux, p_playlist, &p_current );
- p_item_in_category = playlist_ItemToNode( p_playlist, p_current );
+ p_item_in_category = playlist_ItemToNode( p_playlist, p_current, VLC_TRUE );
p_current->p_input->i_type = ITEM_TYPE_PLAYLIST;
for( i = 0; i < i_count; i++ )
input_ItemCopyOptions( p_current->p_input, p_input );
playlist_BothAddInput( p_playlist, p_input,
p_item_in_category,
- PLAYLIST_APPEND, PLAYLIST_END );
+ PLAYLIST_APPEND, PLAYLIST_END,
+ NULL, NULL);
}
}
else
if( b_play && p_playlist->status.p_item &&
p_playlist->status.p_item->i_children > 0)
{
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE,
p_playlist->status.p_item, NULL );
}
vlc_object_release( p_playlist );
{
input_item_t *p_current = ( (input_thread_t*)p_demux->p_parent)->
input.p_item;
- *pp_item = playlist_LockItemGetByInput( p_playlist, p_current );
+ *pp_item = playlist_ItemGetByInput( p_playlist, p_current, VLC_FALSE );
if( !*pp_item )
{
msg_Dbg( p_playlist, "unable to find item in playlist");
playlist_BothAddInput( p_playlist, p_input,
p_item_in_category,
PLAYLIST_APPEND|PLAYLIST_SPREPARSE,
- PLAYLIST_END );
+ PLAYLIST_END, NULL, NULL );
free( psz_string );
}
else continue;
playlist_BothAddInput( p_playlist, p_entry,
p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE
- , PLAYLIST_END);
+ , PLAYLIST_END, NULL, NULL);
free( psz_string );
}
else continue;
playlist_BothAddInput( p_playlist, p_input,
p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
- PLAYLIST_END );
+ PLAYLIST_END, NULL, NULL );
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 );
+ PLAYLIST_END, NULL, NULL );
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 );
+ PLAYLIST_END, NULL, NULL );
}
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 );
+ PLAYLIST_END, NULL, NULL );
free( psz_mrl );
}
input_item_t *p_current_input = ( (input_thread_t*)p_demux->p_parent)-> \
input.p_item; \
playlist_item_t *p_current = \
- playlist_LockItemGetByInput( p_playlist, p_current_input ); \
+ playlist_ItemGetByInput( p_playlist, p_current_input, VLC_FALSE ); \
playlist_item_t *p_item_in_category = \
- playlist_ItemToNode( p_playlist, p_current ); \
+ playlist_ItemToNode( p_playlist, p_current, \
+ VLC_TRUE ); \
b_play = b_play && p_current == p_playlist->status.p_item; \
if( p_item_in_category ) \
p_item_in_category->p_input->i_type = ITEM_TYPE_PLAYLIST;
#define HANDLE_PLAY_AND_RELEASE \
/* Go back and play the playlist */ \
if( b_play && p_item_in_category && p_item_in_category->i_children > 0 ) \
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, p_item_in_category, \
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, p_item_in_category, \
NULL ); \
vlc_object_release( p_playlist );
input_ItemCopyOptions( p_current->p_input, p_input );
playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
- PLAYLIST_END );
+ PLAYLIST_END, NULL, NULL );
}
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 );
+ PLAYLIST_END, NULL, NULL );
free( psz_mrl_orig );
psz_mrl = NULL;
}
playlist_BothAddInput( p_playlist, p_input,
p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE
- , PLAYLIST_END );
+ , PLAYLIST_END, NULL, NULL );
FREENULL( psz_item_name );
FREENULL( psz_item_mrl );
FREENULL( psz_item_size );
FULLSCREEN_HALF,
FULLSCREEN_CURRENT,
FULLSCREEN_FULL } qtl_fullscreen_t;
-char* ppsz_fullscreen[] = { "normal", "double", "half", "current", "full" };
+const char* ppsz_fullscreen[] = { "normal", "double", "half", "current", "full" };
typedef enum { LOOP_TRUE,
LOOP_FALSE,
LOOP_PALINDROME } qtl_loop_t;
-char* ppsz_loop[] = { "true", "false", "palindrome" };
+const char* ppsz_loop[] = { "true", "false", "palindrome" };
/*****************************************************************************
* Local prototypes
playlist_BothAddInput( p_sys->p_playlist, p_input,
p_sys->p_item_in_category,
PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
- PLAYLIST_END );
+ PLAYLIST_END, NULL, NULL );
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 );
+ PLAYLIST_END, NULL, NULL );
}
}
}
playlist_BothAddInput( p_playlist, p_child, p_item_in_category,
- PLAYLIST_APPEND | PLAYLIST_SPREPARSE, PLAYLIST_END );
+ PLAYLIST_APPEND | PLAYLIST_SPREPARSE, PLAYLIST_END,
+ NULL, NULL);
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 );
+ PLAYLIST_END, NULL, NULL );
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 );
+ PLAYLIST_END, NULL, NULL );
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 );
+ PLAYLIST_END, NULL, NULL );
if( p_demux->p_sys->i_identifier <
p_demux->p_sys->i_tracklist_entries )
{
if( b_remove && p_playlist )
{
- playlist_Clear( p_playlist );
+ playlist_Clear( p_playlist, VLC_TRUE );
}
entry_ref ref;
/* Check if we need to start playing */
if( p_intf->b_play )
{
- playlist_LockControl( p_playlist, PLAYLIST_AUTOPLAY );
+ playlist_Control( p_playlist, PLAYLIST_AUTOPLAY, VLC_FALSE );
}
var_Create( p_playlist, "fullscreen", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
val.b_bool = VLC_FALSE;
p_item = NULL;
}
}
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, p_node, p_item );
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, p_node, p_item );
}
vlc_object_release( p_playlist );
}
}
else
{
- playlist_LockDelete( p_playlist, p_item->i_id );
+ playlist_DeleteFromInput( p_playlist, p_item->p_input->i_id );
}
}
[self playlistUpdated];
if( i_item == 0 && !b_enqueue )
{
playlist_item_t *p_item;
- p_item = playlist_ItemGetByInput( p_playlist, p_input );
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, NULL, p_item );
+ p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, NULL, p_item );
}
else
{
playlist_item_t *p_item;
- p_item = playlist_ItemGetByInput( p_playlist, p_input );
- playlist_Control( p_playlist, PLAYLIST_PREPARSE, p_item );
+ p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
+ playlist_Control( p_playlist, PLAYLIST_PREPARSE, VLC_TRUE, p_item );
}
}
[self playlistUpdated];
if( i_item == 0 && !b_enqueue )
{
playlist_item_t *p_item;
- p_item = playlist_ItemGetByInput( p_playlist, p_input );
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, NULL, p_item );
+ p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, NULL, p_item );
}
else
{
playlist_item_t *p_item;
- p_item = playlist_ItemGetByInput( p_playlist, p_input );
- playlist_Control( p_playlist, PLAYLIST_PREPARSE, p_item );
+ p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
+ playlist_Control( p_playlist, PLAYLIST_PREPARSE, VLC_TRUE, p_item );
}
}
[self playlistUpdated];
if( x == 0 )
{
/* play the first item and add the others afterwards */
- playlist_item_t *p_item = playlist_ItemGetByInput( p_playlist, p_input );
+ playlist_item_t *p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, NULL,
p_item );
}
p_item = p_sys->pp_plist[p_sys->i_box_plidx]->p_item;
if( p_item->i_children == -1 )
{
- playlist_DeleteFromItemId( p_playlist, p_item->i_id );
+ playlist_DeleteFromInput( p_playlist,
+ p_item->p_input->i_id );
}
else
{
== -1 )
{
playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
- NULL,
+ VLC_TRUE, NULL,
p_sys->pp_plist[p_sys->i_box_plidx]->p_item );
}
else
{
playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
+ VLC_TRUE,
p_sys->pp_plist[p_sys->i_box_plidx]->p_item,
NULL );
}
gint item;
gtk_tree_model_get(p_model, &iter, 2, &item, -1);
- playlist_LockDelete(p_playlist, item);
+ msg_Err( p_playlist, "PDA delete broken");
}
}
}
for(item = p_playlist->i_size - 1; item >= 0 ;item-- )
{
- playlist_LockDelete( p_playlist, item);
+ msg_Err( p_playlist "fix pda delete");
}
vlc_object_release( p_playlist );
void StandardPLPanel::setRoot( int i_root_id )
{
- playlist_item_t *p_item = playlist_ItemGetById( THEPL, i_root_id );
+ playlist_item_t *p_item = playlist_ItemGetById( THEPL, i_root_id,
+ VLC_TRUE );
assert( p_item );
p_item = playlist_GetPreferredNode( THEPL, p_item );
assert( p_item );
PL_LOCK;
playlist_item_t *p_target =
- playlist_ItemGetById( p_playlist, targetItem->i_id );
- playlist_item_t *p_src = playlist_ItemGetById( p_playlist, srcId );
+ playlist_ItemGetById( p_playlist, targetItem->i_id,
+ VLC_TRUE );
+ playlist_item_t *p_src = playlist_ItemGetById( p_playlist, srcId,
+ VLC_TRUE );
if( !p_target || !p_src )
{
PLItem *parentItem = targetItem->parent();
assert( parentItem );
playlist_item_t *p_parent =
- playlist_ItemGetById( p_playlist, parentItem->i_id );
+ playlist_ItemGetById( p_playlist, parentItem->i_id,
+ VLC_TRUE );
if( !p_parent )
{
PL_UNLOCK;
PLItem *item = static_cast<PLItem*>(index.internalPointer());
assert( item );
PL_LOCK;
- playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id,
+ VLC_TRUE);
activateItem( p_item );
PL_UNLOCK;
}
p_parent = p_parent->p_parent;
}
if( p_parent )
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, p_parent, p_item );
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, p_parent, p_item );
}
/****************** Base model mandatory implementations *****************/
PL_LOCK;
if( !nodeItem ) goto end;
- p_item = playlist_ItemGetById( p_playlist, p_add->i_item );
+ p_item = playlist_ItemGetById( p_playlist, p_add->i_item, VLC_TRUE );
if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) goto end;
if( i_depth == 1 && p_item->p_parent &&
p_item->p_parent->i_id != rootItem->i_id )
/* This function must be entered WITH the playlist lock */
void PLModel::UpdateNodeChildren( PLItem *root )
{
- playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id );
+ playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id,
+ VLC_TRUE );
UpdateNodeChildren( p_node, root );
}
/* This function must be entered WITH the playlist lock */
void PLModel::UpdateTreeItem( PLItem *item, bool signal, bool force )
{
- playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id,
+ VLC_TRUE );
UpdateTreeItem( p_item, item, signal, force );
}
fullList->removeAll( deleteIndex );
PL_LOCK;
- playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id,
+ VLC_TRUE );
if( !p_item )
{
PL_UNLOCK; return;
}
if( p_item->i_children == -1 )
- playlist_DeleteAllFromInput( p_playlist, item->i_input_id );
+ playlist_DeleteFromInput( p_playlist, item->i_input_id, VLC_TRUE );
else
playlist_NodeDelete( p_playlist, p_item, VLC_TRUE, VLC_FALSE );
/* And finally, remove it from the tree */
void PLModel::sort( int column, Qt::SortOrder order )
{
PL_LOCK;
- playlist_item_t *p_root = playlist_ItemGetById( p_playlist, rootItem->i_id );
- int i_mode;
- switch( column )
{
- case 0: i_mode = SORT_TITLE_NODES_FIRST;break;
- case 1: i_mode = SORT_ARTIST;break;
- case 2: i_mode = SORT_DURATION; break;
- default: i_mode = SORT_TITLE_NODES_FIRST; break;
+ playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
+ rootItem->i_id,
+ VLC_TRUE );
+ int i_mode;
+ switch( column )
+ {
+ case 0: i_mode = SORT_TITLE_NODES_FIRST;break;
+ case 1: i_mode = SORT_ARTIST;break;
+ case 2: i_mode = SORT_DURATION; break;
+ default: i_mode = SORT_TITLE_NODES_FIRST; break;
+ }
+ if( p_root )
+ playlist_RecursiveNodeSort( p_playlist, p_root, i_mode,
+ order == Qt::AscendingOrder ?
+ ORDER_NORMAL : ORDER_REVERSE );
}
- if( p_root )
- playlist_RecursiveNodeSort( p_playlist, p_root, i_mode,
- order == Qt::AscendingOrder ? ORDER_NORMAL :
- ORDER_REVERSE );
PL_UNLOCK
rebuild();
}
{
/** \todo Fire the search with a small delay ? */
PL_LOCK;
- playlist_item_t *p_root = playlist_ItemGetById( p_playlist,rootItem->i_id );
- assert( p_root );
- char *psz_name = search_text.toUtf8().data();
- playlist_LiveSearchUpdate( p_playlist , p_root, psz_name );
+ {
+ playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
+ rootItem->i_id,
+ VLC_TRUE );
+ assert( p_root );
+ char *psz_name = search_text.toUtf8().data();
+ playlist_LiveSearchUpdate( p_playlist , p_root, psz_name );
+ }
PL_UNLOCK;
rebuild();
}
assert( index.isValid() );
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
- itemId( index ) );
+ itemId( index ), VLC_TRUE );
if( p_item )
{
i_popup_item = p_item->i_id;
void PLModel::popupPlay()
{
PL_LOCK;
- playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_popup_item );
- activateItem( p_item );
+ {
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
+ i_popup_item,VLC_TRUE );
+ activateItem( p_item );
+ }
PL_UNLOCK;
}
FIND_ANYWHERE );
if( p_playlist )
{
- playlist_LockControl( p_playlist, PLAYLIST_AUTOPLAY );
+ playlist_Control( p_playlist, PLAYLIST_AUTOPLAY, VLC_FALSE );
vlc_object_release( p_playlist );
}
}
playlist_item_t *p_item = (playlist_item_t *)(it->m_pData);
if( p_item->i_children == -1 )
{
- playlist_DeleteFromItemId( getIntf()->p_sys->p_playlist,
- p_item->i_id );
+ playlist_DeleteFromInput( getIntf()->p_sys->p_playlist,
+ p_item->p_input->i_id, VLC_TRUE );
it2 = getNextVisibleItem( it ) ;
it->parent()->removeChild( it );
it = it2;
if( p_parent )
{
- playlist_Control( m_pPlaylist, PLAYLIST_VIEWPLAY, p_parent, p_item );
+ playlist_Control( m_pPlaylist, PLAYLIST_VIEWPLAY, VLC_TRUE, p_parent, p_item );
}
vlc_mutex_unlock( &m_pPlaylist->object_lock );
}
if( item == end() )
{
playlist_item_t *p_item = playlist_ItemGetById(
- m_pPlaylist, p_add->i_item );
+ m_pPlaylist, p_add->i_item, VLC_TRUE );
if( !p_item ) return;
UString *pName = new UString( getIntf(),
p_item->p_input->psz_name );
if( !p_data ) return;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
- ((PlaylistItem *)p_data)->i_id );
+ ((PlaylistItem *)p_data)->i_id, VLC_TRUE );
if( !p_item )
{
UnlockPlaylist( p_intf->p_sys, p_playlist );
node = FindItem( treectrl->GetRootItem(), p_add->i_node );
if( !node.IsOk() ) goto update;
- p_item = playlist_ItemGetById( p_playlist, p_add->i_item );
+ p_item = playlist_ItemGetById( p_playlist, p_add->i_item, VLC_TRUE );
if( !p_item ) goto update;
if( (p_item->i_flags & PLAYLIST_DBL_FLAG ) ) goto update;
{
playlist_item_t *p_item;
LockPlaylist( p_intf->p_sys, p_playlist );
- p_item = playlist_ItemGetById( p_playlist, ((PlaylistItem *)treectrl->GetItemData( item ))->i_id );
+ p_item = playlist_ItemGetById( p_playlist, ((PlaylistItem *)treectrl->GetItemData( item ))->i_id, VLC_TRUE );
if( p_item && p_item->i_children == -1 )
count++;
UnlockPlaylist( p_intf->p_sys, p_playlist );
p_wxitem = (PlaylistItem *)treectrl->GetItemData( item );
LockPlaylist( p_intf->p_sys, p_playlist );
- p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id );
+ p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id, VLC_TRUE );
if( !p_item )
{
{
case SortTitle_Event:
playlist_RecursiveNodeSort( p_playlist,
- playlist_ItemGetById( p_playlist, p_wxitem->i_id ),
+ playlist_ItemGetById( p_playlist, p_wxitem->i_id,
+ VLC_TRUE ),
SORT_TITLE_NODES_FIRST, ORDER_NORMAL );
break;
case RSortTitle_Event:
playlist_RecursiveNodeSort( p_playlist,
- playlist_ItemGetById( p_playlist, p_wxitem->i_id ),
+ playlist_ItemGetById( p_playlist, p_wxitem->i_id,
+ VLC_TRUE ),
SORT_TITLE_NODES_FIRST, ORDER_REVERSE );
}
UnlockPlaylist( p_intf->p_sys, p_playlist );
wxString search_string = search_text->GetValue();
PlaylistItem *p_wxroot;
p_wxroot = (PlaylistItem *)treectrl->GetItemData( treectrl->GetRootItem() );
- playlist_item_t *p_root = playlist_ItemGetById( p_playlist, p_wxroot->i_id );
+ playlist_item_t *p_root = playlist_ItemGetById( p_playlist, p_wxroot->i_id,
+ VLC_TRUE );
assert( p_root );
char *psz_name = wxFromLocale( search_string );
UnlockPlaylist( p_intf->p_sys, p_playlist );
return;
}
- p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id );
+ p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id, VLC_TRUE );
p_parent = p_item;
while( p_parent )
if( p_parent )
{
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, p_parent, p_item );
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, p_parent, p_item );
}
UnlockPlaylist( p_intf->p_sys, p_playlist );
}
}
playlist_item_t *p_drageditem =
- playlist_ItemGetById(p_playlist, p_wxdrageditem->i_id );
+ playlist_ItemGetById(p_playlist, p_wxdrageditem->i_id, VLC_TRUE );
playlist_item_t *p_destitem =
- playlist_ItemGetById(p_playlist, p_wxdestitem->i_id );
+ playlist_ItemGetById(p_playlist, p_wxdestitem->i_id, VLC_TRUE );
if( !p_drageditem || !p_destitem )
{
UnlockPlaylist( p_intf->p_sys, p_playlist );
return;
}
playlist_item_t *p_destitem2 =
- playlist_ItemGetById( p_playlist, p_parent->i_id );
+ playlist_ItemGetById( p_playlist, p_parent->i_id, VLC_TRUE );
if( !p_destitem2 )
{
UnlockPlaylist( p_intf->p_sys, p_playlist );
{
PlaylistItem *p_plitem =
(PlaylistItem *)p->treectrl->GetItemData( item );
- p_dest = playlist_ItemGetById( p->p_playlist, p_plitem->i_id );
+ p_dest = playlist_ItemGetById( p->p_playlist, p_plitem->i_id, VLC_TRUE );
if( p_dest->i_children == -1 )
{
return FALSE;
}
playlist_item_t *p_node =
- playlist_ItemGetById( p->p_playlist, p_parent->i_id );
+ playlist_ItemGetById( p->p_playlist, p_parent->i_id, VLC_TRUE );
if( !p_node )
{
UnlockPlaylist( p->p_intf->p_sys, p->p_playlist );
treectrl->SelectItem( i_wx_popup_item );
LockPlaylist( p_intf->p_sys, p_playlist );
- p_item = playlist_ItemGetById( p_playlist, i_popup_item );
+ p_item = playlist_ItemGetById( p_playlist, i_popup_item, VLC_TRUE );
if( !p_item )
{
{
playlist_item_t *p_popup_item, *p_popup_parent;
LockPlaylist( p_intf->p_sys, p_playlist );
- p_popup_item = playlist_ItemGetById( p_playlist, i_popup_item );
+ p_popup_item = playlist_ItemGetById( p_playlist, i_popup_item, VLC_TRUE );
p_popup_parent = p_popup_item;
while( p_popup_parent )
if( p_popup_parent )
{
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, p_popup_parent,
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, p_popup_parent,
p_popup_item );
}
UnlockPlaylist( p_intf->p_sys, p_playlist );
{
playlist_item_t *p_popup_item;
LockPlaylist( p_intf->p_sys, p_playlist );
- p_popup_item = playlist_ItemGetById( p_playlist, i_popup_item );
+ p_popup_item = playlist_ItemGetById( p_playlist, i_popup_item, VLC_TRUE );
if( p_popup_item != NULL )
{
p_wxitem = (PlaylistItem *)treectrl->GetItemData( i_wx_popup_item );
LockPlaylist( p_intf->p_sys, p_playlist );
- p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id );
+ p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id, VLC_TRUE );
if( p_item->i_children >= 0 )
{
playlist_RecursiveNodeSort( p_playlist, p_item,
void Playlist::OnPopupInfo( wxCommandEvent& event )
{
LockPlaylist( p_intf->p_sys, p_playlist );
- playlist_item_t *p_popup_item = playlist_ItemGetById( p_playlist, i_popup_item );
+ playlist_item_t *p_popup_item = playlist_ItemGetById( p_playlist,
+ i_popup_item,
+ VLC_TRUE );
if( p_popup_item )
{
iteminfo_dialog = new ItemInfoDialog( p_intf, p_popup_item, this );
p_wxitem = (PlaylistItem *)treectrl->GetItemData( i_wx_popup_item );
- p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id );
+ p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id, VLC_TRUE );
playlist_NodeCreate( p_playlist, psz_name, p_item );
if( p_current_treeroot && i_id != p_current_treeroot->i_id )
{
- playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id,
+ VLC_TRUE );
if( p_item ) p_current_treeroot = p_item;
Rebuild( VLC_TRUE );
}
p_node = p_item;
p_item = NULL;
}
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, p_node, p_item );
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, p_node, p_item );
UnlockPlaylist( p_intf->p_sys, p_playlist );
}
FIND_ANYWHERE );
if( p_playlist )
{
- playlist_LockControl( p_playlist, PLAYLIST_AUTOPLAY );
+ playlist_Control( p_playlist, PLAYLIST_AUTOPLAY, VLC_FALSE );
vlc_object_release( p_playlist );
}
}
SOURCES_test2 = test2.cpp
SOURCES_test3 = test3.m
SOURCES_test4 = test4.c
-SOURCES_test_playlist = playlist.c
+++ /dev/null
-/*****************************************************************************
- * playlist.c : Playlist testsuite
- *****************************************************************************
- * Copyright (C) 2004 the VideoLAN team
- * $Id$
- *
- * Authors : Clément Stenac <zorglub@videolan.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-/* To run these tests, run vlc with
- * --playlist-test --quiet --no-plugins-cache -I dummy */
-
-/* greek tree used for tests, borrowed from the SubVersion project
- *
-
- A iota
- _______________________//|\
- / ______________/ | \_____________
- mu / | \
- / | \
- B C D
- _____/|\_____ _____________/|\
- / | \ / | \
- / | \ / / \___
- lambda | F / / \
- E gamma / \
- / \ / |
- / \ ________/ |
- alpha beta / H
- / _______/|\______
- / / | \
- G / | \
- ________/|\_______ chi psi omega
- / | \
- / | \
- / | \
- pi rho tau
-
- */
-
-/*****************************************************************************
- * Preamble
- *****************************************************************************/
-#include <vlc/vlc.h>
-
-#include <vlc_input.h>
-#include <vlc_playlist.h>
-
-#include <stdlib.h>
-
-/*****************************************************************************
- * Local prototypes.
- *****************************************************************************/
-int PlaylistTest ( vlc_object_t *, char const *,
- vlc_value_t, vlc_value_t, void * );
-
-static int Callback( vlc_object_t *, char *, vlc_value_t, vlc_value_t,void*);
-
-static void Assert( intf_sys_t *p_sys,const char* psz_text, int condition );
-
-static void StressTest (vlc_object_t *);
-
-#define MAX_ITEMS 100
-
-#define CREATE_GT 1000
-
-struct intf_sys_t
-{
- char *ppsz_names[MAX_ITEMS];
- playlist_t *p_playlist;
- int i_names;
- int i_current;
- vlc_bool_t b_error;
-};
-
-/*****************************************************************************
- * Module descriptor.
- *****************************************************************************/
-vlc_module_begin();
- set_description( _("Playlist stress tests") );
- add_bool( "playlist-test" , VLC_FALSE , PlaylistTest , "" , "" ,
- VLC_TRUE );
-vlc_module_end();
-
-/*****************************************************************************
- * PlaylistTest: callback function, spawns the tester thread
- *****************************************************************************/
-int PlaylistTest( vlc_object_t *p_this, char const *psz_cmd,
- vlc_value_t oldval, vlc_value_t newval, void *p_data )
-{
- if( newval.b_bool == VLC_FALSE ) return VLC_SUCCESS;
-
- if( vlc_thread_create( p_this, "playlist tester", StressTest,
- VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
- {
- msg_Err( p_this, "unable to spawn playlist test thread" );
- return VLC_EGENERIC;
- }
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * Tester thread
- *****************************************************************************/
-static void StressTest( vlc_object_t *p_this )
-{
- playlist_t *p_playlist = NULL;
- playlist_view_t *p_view;
- int i;
- mtime_t i_start;
- playlist_item_t *p_item,*p_a,*p_b,*p_c,*p_d,*p_e,*p_f,*p_g,*p_h, *p_gamma;
-
- intf_sys_t *p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );
- p_sys->b_error = VLC_FALSE;
-
- fprintf( stderr, "beginning playlist test\n" );
- while( p_playlist == NULL )
- {
- msleep( INTF_IDLE_SLEEP );
- p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- }
- fprintf( stderr, "Attached to playlist\n");
-
- p_sys->p_playlist = p_playlist;
-
- /* let time for vlc initialization */
- sleep( 3 );
-
- var_AddCallback( p_playlist, "playlist-current", Callback, p_sys );
-
-
- /* Test 1 : Create a greek tree */
- fprintf(stderr,"1/ Creating greek tree pattern (except H)\n");
-
- p_view = playlist_ViewFind( p_playlist, VIEW_CATEGORY );
- i_start = mdate();
-
- playlist_Stop( p_playlist );
- Assert( p_sys, "Checking playlist status STOPPED ...",
- p_playlist->status.i_status == PLAYLIST_STOPPED );
-
- p_a = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "A", p_view->p_root );
- p_item = playlist_ItemNew(p_playlist, "mu","mu" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_a, PLAYLIST_APPEND, PLAYLIST_END );
- p_b = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "B", p_a );
- p_c = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "C", p_a );
- p_d = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "D", p_a );
- p_item = playlist_ItemNew(p_playlist, "lambda","lambda" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_b, PLAYLIST_APPEND, PLAYLIST_END );
- p_e = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "E", p_b );
- p_f = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "F", p_b );
- p_gamma = p_item = playlist_ItemNew(p_playlist, "gamma","gamma" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_d, PLAYLIST_APPEND, PLAYLIST_END );
- p_g = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "G", p_d );
- p_item = playlist_ItemNew(p_playlist, "beta","beta" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_e, PLAYLIST_INSERT, 0 );
- p_item = playlist_ItemNew(p_playlist, "alpha","alpha" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_e, PLAYLIST_INSERT, 0 );
- p_item = playlist_ItemNew(p_playlist, "pi","pi" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_g, PLAYLIST_APPEND, PLAYLIST_END );
- p_item = playlist_ItemNew(p_playlist, "tau","tau" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_g, PLAYLIST_APPEND, PLAYLIST_END );
- p_item = playlist_ItemNew(p_playlist, "rho","rho" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_g, PLAYLIST_INSERT, 1 );
- /* Create H as an item, we'll expand it later */
- p_item = playlist_ItemNew(p_playlist, "H","H" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_d, PLAYLIST_INSERT, 1 );
-
- fprintf( stderr, "Created in "I64Fi " us\n", mdate() - i_start );
-
- fprintf(stderr,"Dumping category view\n" );
- playlist_ViewDump( p_playlist, p_view );
-
- Assert( p_sys, "Checking playlist status STOPPED ...",
- p_playlist->status.i_status == PLAYLIST_STOPPED );
-
-// Assert( p_sys, "Checking 0 items in VIEW_SIMPLE ...",
- // playlist_ViewItemsCount( p_playlist, VIEW_SIMPLE ) == 0 );
- // Assert( p_sys, "Checking 9 items in VIEW_ALL ...",
- // playlist_ViewItemsCount( p_playlist, VIEW_ALL ) == 9 );
-
-
- p_sys->ppsz_names[0] = strdup("mu");
- p_sys->ppsz_names[1]= strdup("lambda");
- p_sys->ppsz_names[2] = strdup("beta");
- p_sys->ppsz_names[3] = strdup("alpha");
- p_sys->ppsz_names[4] = strdup("gamma");
- p_sys->ppsz_names[5] = strdup("pi");
- p_sys->ppsz_names[6] = strdup("tau");
- p_sys->ppsz_names[7] = strdup("rho");
- p_sys->ppsz_names[8] = strdup("H");
- p_sys->i_names = 9;
- p_sys->i_current = 0;
-
- fprintf( stderr, "Starting playlist\n");
-
- playlist_Play( p_playlist );
-
- sleep( 1 );
-
- Assert( p_sys, "Checking nothing was played ...",
- (p_sys->i_current == 0) );
- fprintf(stderr,"played : %i\n",p_sys->i_current );
-
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VIEW_CATEGORY,
- p_view->p_root, NULL );
-
- Assert( p_sys, "Checking playlist RUNNING ...",
- p_playlist->status.i_status == 1 );
-
- /* Wait for everything to have played */
-#if 0
- while( p_sys->i_current != 8 );// && p_sys->b_error == VLC_FALSE )
- {
- msleep( INTF_IDLE_SLEEP );
- }
- fprintf(stderr,"finished\n" );
-#endif
-
- /* Let some more time */
- sleep( 5 );
- Assert( p_sys, "Checking playlist status STOPPED ...",
- (p_playlist->status.i_status == PLAYLIST_STOPPED) );
-
- p_sys->i_names = -1;
-
- /* Test 2 : Repeat */
- fprintf( stderr, "2/ Checking repeat\n" );
- var_SetBool( p_playlist, "repeat", VLC_TRUE );
- playlist_Goto( p_playlist, 4 );
- msleep( 100 );
- Assert( p_sys, "Checking playing of gamma ...",
- p_playlist->status.p_item == p_gamma );
- sleep( 2 );
- Assert( p_sys, "Checking still playing gamma ...",
- p_playlist->status.p_item == p_gamma );
- Assert( p_sys, "Checking playlist still running ...",
- p_playlist->status.i_status == PLAYLIST_RUNNING );
-
- /* Test 3: Play and stop */
- fprintf( stderr, "3/ Checking play and stop\n" );
- playlist_Stop( p_playlist );
- var_SetBool( p_playlist, "repeat", VLC_FALSE );
- var_SetBool( p_playlist, "play-and-stop", VLC_TRUE );
- playlist_Skip( p_playlist, 1 );
- Assert( p_sys, "Checking playlist status RUNNING ...",
- p_playlist->status.i_status == PLAYLIST_RUNNING );
- sleep( 2 );
- Assert( p_sys, "Checking playlist stopped ...",
- p_playlist->status.i_status == PLAYLIST_STOPPED );
-
- /* Test 4 : Simple adding of iota */
- fprintf( stderr, "4/ Checking simple add\n" );
- p_item = playlist_ItemNew( p_playlist, "iota","iota" );
- playlist_AddItem( p_playlist, p_item, PLAYLIST_APPEND, PLAYLIST_END );
-
- /* Check items counts */
-// Assert( p_sys, "Checking 1 item in VIEW_SIMPLE ...",
- // playlist_ViewItemsCount( p_playlist, VIEW_SIMPLE ) == 1 );
-// Assert( p_sys, "Checking 10 items in VIEW_CATEGORY ...",
- // playlist_ViewItemsCount( p_playlist, VIEW_CATEGORY ) == 10 );
-
- /* Test 5:Expand H : it was added only to view_category so the children
- * should not appear in VIEW_SIMPLE */
- fprintf( stderr, "5/ ItemToNode - Parent inheritance\n" );
-
-
- /* Test 6 : Add many items */
- fprintf( stderr, "6/ Adding %i items", 12*CREATE_GT );
-
- i_start = mdate();
-
- for( i = CREATE_GT ; i >= 0 ; i-- )
- {
- GreekTree( p_playlist, p_view->p_root );
- }
-
- fprintf( stderr, "Created in "I64Fi " us\n", mdate() - i_start );
-
- vlc_object_release( p_playlist );
-
- if( p_sys->b_error == VLC_FALSE )
- {
- p_this->p_libvlc->b_die = VLC_TRUE;
- }
- else
- {
- exit( 1 );
- }
- return;
-}
-
-static inline void GreekTree( playlist_t *p_playlist, playlist_item_t *p_node )
-{
- playlist_item_t *p_item,*p_a,*p_b,*p_c,*p_d,*p_e,*p_f,*p_g,*p_h;
- p_a = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "A", p_node );
- p_item = playlist_ItemNew(p_playlist, "mu","mu" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_a, PLAYLIST_APPEND, PLAYLIST_END );
- p_b = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "B", p_a );
- p_c = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "C", p_a );
- p_d = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "D", p_a );
- p_item = playlist_ItemNew(p_playlist, "lambda","lambda" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_b, PLAYLIST_APPEND, PLAYLIST_END );
- p_e = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "E", p_b );
- p_f = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "F", p_b );
- p_item = playlist_ItemNew(p_playlist, "gamma","gamma" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_d, PLAYLIST_APPEND, PLAYLIST_END );
- p_g = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "G", p_d );
- p_item = playlist_ItemNew(p_playlist, "beta","beta" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_e, PLAYLIST_INSERT, 0 );
- p_item = playlist_ItemNew(p_playlist, "alpha","alpha" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_e, PLAYLIST_INSERT, 0 );
- p_item = playlist_ItemNew(p_playlist, "pi","pi" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_g, PLAYLIST_APPEND, PLAYLIST_END );
- p_item = playlist_ItemNew(p_playlist, "tau","tau" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_g, PLAYLIST_APPEND, PLAYLIST_END );
- p_item = playlist_ItemNew(p_playlist, "rho","rho" );
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_g, PLAYLIST_INSERT, 1 );
- p_g = playlist_NodeCreate( p_playlist, VIEW_CATEGORY, "H", p_d );
-}
-
-static void Assert( intf_sys_t *p_sys,const char* psz_text, int condition )
-{
- fprintf( stderr, "%s", psz_text );
- if( condition == 0 )
- {
- fprintf( stderr, "Fail\n" );
- p_sys->b_error = VLC_TRUE;
- }
- else
- {
- fprintf(stderr,"Pass\n" );
- }
- return;
-}
-
-
-static int Callback( vlc_object_t *p_this, char *psz_cmd,
- vlc_value_t ov, vlc_value_t nv,void *param)
-{
- intf_sys_t *p_sys = (intf_sys_t*) param;
- playlist_t *p_playlist = (playlist_t*)p_this;
- char *psz_name;
- playlist_item_t *p_item;
-
- if( p_sys->i_names == -1 ) return;
-
- p_item= playlist_ItemGetById( p_sys->p_playlist,nv.i_int );
- psz_name = strdup (p_item->input.psz_name );
-
- if( p_sys->i_current >= p_sys->i_names )
- {
- fprintf( stderr,"Error, we read too many items\n" );
- p_sys->b_error = VLC_TRUE;
- return;
- }
-
- if( !strcmp( p_sys->ppsz_names[p_sys->i_current], psz_name ) )
- {
- p_sys->i_current++;
- fprintf(stderr,"playing %s\n",p_sys->ppsz_names[p_sys->i_current-1]);
- }
- else
- {
- fprintf( stderr, "Error, we read %s, %s expected",
- psz_name , p_sys->ppsz_names[p_sys->i_current] );
- p_sys->b_error = VLC_TRUE;
- }
-
- return VLC_SUCCESS;
-}
SOURCES_sap = sap.c
SOURCES_hal = hal.c
-SOURCES_daap = daap.c
SOURCES_shout = shout.c
SOURCES_upnp_cc = upnp_cc.cpp
SOURCES_upnp_intel = upnp_intel.cpp
msg_Err( p_sd, "failed to find service '%s' in playlist", name );
else
{
- playlist_LockDeleteAllFromInput( p_sys->p_playlist,
- p_item->p_input->i_id );
+ playlist_DeleteFromInput( p_sys->p_playlist, p_item->p_input->i_id,
+ VLC_FALSE );
}
}
}
+++ /dev/null
-/*****************************************************************************
- * daap.c : Apple DAAP discovery module
- *****************************************************************************
- * Copyright (C) 2004 the VideoLAN team
- * $Id$
- *
- * Authors: Clément Stenac <zorglub@videolan.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-/*****************************************************************************
- * Includes
- *****************************************************************************/
-#include <stdlib.h> /* malloc(), free() */
-
-#include <vlc/vlc.h>
-#include <vlc/intf.h>
-
-#include "vlc_url.h"
-
-#include <vlc/input.h>
-
-#include <daap/client.h>
-
-/************************************************************************
- * Macros and definitions
- ************************************************************************/
-
-/*****************************************************************************
- * Module descriptor
- *****************************************************************************/
-
-/* Callbacks */
- static int Open ( vlc_object_t * );
- static void Close( vlc_object_t * );
- static int OpenAccess ( vlc_object_t * );
- static void CloseAccess( vlc_object_t * );
-
-vlc_module_begin();
- set_description( _("DAAP shares") );
- set_category( CAT_PLAYLIST );
- set_subcategory( SUBCAT_PLAYLIST_SD );
-
- set_capability( "services_discovery", 0 );
- set_callbacks( Open, Close );
-
- add_submodule();
- set_description( _( "DAAP access") );
- set_capability( "access2", 0 );
- set_callbacks( OpenAccess, CloseAccess );
-vlc_module_end();
-
-
-/*****************************************************************************
- * Local structures
- *****************************************************************************/
-
-typedef struct dhost_s {
- char *psz_name;
- int i_id;
-
- DAAP_SClientHost *p_host;
- vlc_bool_t b_updated;
- vlc_bool_t b_new;
- int i_database_id;
-
- playlist_item_t *p_node;
-
- DAAP_ClientHost_DatabaseItem *p_songs;
- int i_songs;
-} dhost_t;
-
-typedef struct daap_db_s {
- dhost_t **pp_hosts;
- int i_hosts;
-
- int i_last_id;
-
- vlc_mutex_t search_lock;
-} daap_db_t;
-
-struct services_discovery_sys_t {
- playlist_item_t *p_node;
-
- DAAP_SClient *p_client;
- DAAP_SClientHost *p_host;
-
- daap_db_t *p_db;
-};
-
-struct access_sys_t {
- vlc_url_t url;
-
- dhost_t *p_host;
- int i_host;
- int i_song;
-
- daap_db_t *p_db;
-
- DAAP_ClientHost_Song song;
- DAAP_ClientHost_DatabaseItem songdata;
- int i_orig_size;
- void *p_orig_buffer;
-};
-
-/*****************************************************************************
- * Local prototypes
- *****************************************************************************/
-
-/* Main functions */
- static void Run ( services_discovery_t *p_sd );
- static void Callback( DAAP_SClient *p_client, DAAP_Status status,
- int i_pos, void *p_context );
- static int EnumerateCallback( DAAP_SClient *p_client,
- DAAP_SClientHost *p_host,
- void *p_context );
- static void OnHostsUpdate( services_discovery_t *p_sd );
- static void ProcessHost( services_discovery_t *p_sd, dhost_t *p_host );
- static void FreeHost( services_discovery_t *p_sd, dhost_t *p_host );
-
- static int Control( access_t *p_access, int i_query, va_list args );
- static int Read( access_t *, uint8_t *, int );
- static int Seek( access_t *, int64_t );
-
-/*****************************************************************************
- * Open: initialize and create stuff
- *****************************************************************************/
-static int Open( vlc_object_t *p_this )
-{
- services_discovery_t *p_sd = ( services_discovery_t* )p_this;
- services_discovery_sys_t *p_sys = (services_discovery_sys_t *)
- malloc( sizeof( services_discovery_sys_t ) );
-
- playlist_t *p_playlist;
- playlist_view_t *p_view;
- vlc_value_t val;
-
- p_sd->pf_run = Run;
- p_sd->p_sys = p_sys;
-
- p_sys->p_db = (daap_db_t *)malloc( sizeof( daap_db_t ) );
- if( !p_sys->p_db )
- {
- return VLC_EGENERIC;
- }
- p_sys->p_db->pp_hosts = NULL;
- p_sys->p_db->i_hosts = 0;
-
- var_Create( p_sd->p_libvlc, "daap-db", VLC_VAR_ADDRESS );
- val.p_address = p_sys->p_db;
- var_Set( p_sd->p_libvlc, "daap-db", val );
-
- vlc_mutex_init( p_sd, &p_sys->p_db->search_lock );
-
- /* Init DAAP */
- p_sys->p_client = DAAP_Client_Create( Callback, p_sd );
- p_sys->p_db->i_last_id = 0;
-
- /* TODO: Set debugging correctly */
-// DAAP_Client_SetDebug( p_sys->p_client, "+trace" );
-
-
- /* Create our playlist node */
- p_playlist = (playlist_t *)vlc_object_find( p_sd, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- if( !p_playlist )
- {
- msg_Warn( p_sd, "unable to find playlist, cancelling DAAP" );
- return VLC_EGENERIC;
- }
- msg_Err( p_sd, "DAAP IS BROKEN !! Fix it if you want it !" );
- return VLC_EGENERIC;
-
-#if 0
- p_sys->p_node = playlist_NodeCreate( p_playlist, VIEW_CATEGORY,
- _("DAAP shares"), p_view->p_root );
- p_sys->p_node->i_flags |= PLAYLIST_RO_FLAG;
-
- val.b_bool = VLC_TRUE;
- var_Set( p_playlist, "intf-change", val );
- vlc_object_release( p_playlist );
-
- return VLC_SUCCESS;
-#endif
-}
-
-static int OpenAccess( vlc_object_t *p_this )
-{
-#if 0
- access_t *p_access = (access_t*)p_this;
- access_sys_t *p_sys;
- vlc_value_t val;
- vlc_bool_t b_found = VLC_FALSE;
- int i, i_ret;
-
- p_access->pf_read = Read;
- p_access->pf_block = NULL;
- p_access->pf_control = Control;
- p_access->pf_seek = Seek;
- p_access->info.i_update = 0;
- p_access->info.i_size = 0;
- p_access->info.i_pos = 0;
- p_access->info.b_eof = VLC_FALSE;
- p_access->info.i_title = 0;
- p_access->info.i_seekpoint = 0;
- p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
- memset( p_sys, 0, sizeof( access_sys_t ) );
-
- i_ret = var_Get( p_access->p_libvlc , "daap-db", &val );
- p_sys->p_db = val.p_address;
-
- if( p_sys->p_db == NULL || i_ret )
- {
- msg_Err( p_access, "the DAAP services_discovery module must be enabled" );
- return VLC_EGENERIC;
- }
-
- vlc_UrlParse( &p_sys->url, p_access->psz_path, 0 );
-
- p_sys->p_host = NULL;
- p_sys->i_host = atoi( p_sys->url.psz_host ) ;
- p_sys->i_song = p_sys->url.i_port;
-
- if( !p_sys->i_host || !p_sys->i_song )
- {
- msg_Err( p_access, "invalid host or song" );
- return VLC_EGENERIC;
- }
-
- /* Search the host */
- vlc_mutex_lock( &p_sys->p_db->search_lock );
- for( i = 0 ; i < p_sys->p_db->i_hosts ; i++ )
- {
- if( p_sys->p_db->pp_hosts[i]->i_id == p_sys->i_host )
- {
- p_sys->p_host = p_sys->p_db->pp_hosts[i];
- break;
- }
- }
- if( p_sys->p_host )
- {
- for( i = 0 ; i < p_sys->p_host->i_songs ; i++ )
- {
- if( p_sys->p_host->p_songs[i].id == p_sys->i_song )
- {
- p_sys->songdata = p_sys->p_host->p_songs[i];
- b_found = VLC_TRUE;
- break;
- }
- }
- if( !b_found )
- {
- msg_Err( p_access, "invalid song (not found in %i)",
- p_sys->p_host->i_songs );
- }
- }
- else
- {
- msg_Warn( p_access, "invalid host (not found in %i)",
- p_sys->p_db->i_hosts );
- }
- vlc_mutex_unlock( &p_sys->p_db->search_lock );
-
- if( !p_sys->p_host || !b_found )
- {
- return VLC_EGENERIC;
- }
-
-
- msg_Dbg( p_access, "downloading %s song %i (db %i)",
- p_sys->songdata.songformat,
- p_sys->i_song, p_sys->p_host->i_database_id );
-
- /* FIXME: wait for better method by upstream */
- i_ret = DAAP_ClientHost_GetAudioFile( p_sys->p_host->p_host,
- p_sys->p_host->i_database_id,
- p_sys->i_song,
- p_sys->songdata.songformat,
- &(p_sys->song) );
-
- msg_Dbg( p_access, "finished downloading, read %i bytes (ret %i)",
- p_sys->song.size, i_ret );
-
- p_access->info.i_size = p_sys->song.size;
-
- if( i_ret != 0 )
- return VLC_EGENERIC;
-#endif
- return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * Close:
- *****************************************************************************/
-static void Close( vlc_object_t *p_this )
-{
-#if 0
- services_discovery_t *p_sd = ( services_discovery_t* )p_this;
- services_discovery_sys_t *p_sys = p_sd->p_sys;
-
- playlist_t *p_playlist;
- int i;
-
- p_playlist = (playlist_t *) vlc_object_find( p_sd, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
-
- for( i = 0 ; i< p_sys->p_db->i_hosts ; i++ )
- {
- FreeHost( p_sd, p_sys->p_db->pp_hosts[i] );
- }
-
- var_Destroy( p_sd->p_libvlc, "daap-db" );
-
- if( p_playlist )
- {
- playlist_NodeDelete( p_playlist, p_sys->p_node, VLC_TRUE, VLC_TRUE );
- vlc_object_release( p_playlist );
- }
-
- free( p_sys );
-#endif
-}
-
-static void CloseAccess( vlc_object_t *p_this )
-{
- access_t *p_access = (access_t*) p_this;
- access_sys_t *p_sys = p_access->p_sys;
-
- if( p_sys )
- {
- if( p_sys->p_host )
- {
- p_sys->song.data = p_sys->p_orig_buffer;
- p_sys->song.size = p_sys->i_orig_size;
- DAAP_ClientHost_FreeAudioFile( p_sys->p_host->p_host, &p_sys->song );
- }
- free( p_sys );
- }
-}
-
-/*****************************************************************************
- * Run: main DAAP thread
- *****************************************************************************/
-static void Run( services_discovery_t *p_sd )
-{
- while( !p_sd->b_die )
- {
- msleep( 100000 );
- }
-}
-
-/*****************************************************************************
- * Access functions
- *****************************************************************************/
-static int Control( access_t *p_access, int i_query, va_list args )
-{
- vlc_bool_t *pb_bool;
- int64_t *pi_64;
- switch( i_query )
- {
- case ACCESS_CAN_SEEK:
- case ACCESS_CAN_FASTSEEK:
- pb_bool = (vlc_bool_t *)va_arg( args, vlc_bool_t *);
- *pb_bool = VLC_TRUE;
- break;
- case ACCESS_CAN_PAUSE:
- case ACCESS_CAN_CONTROL_PACE:
- pb_bool = (vlc_bool_t *)va_arg( args, vlc_bool_t *);
- *pb_bool = VLC_TRUE;
- break;
-
- case ACCESS_GET_PTS_DELAY:
- pi_64 = (int64_t *)va_arg( args, int64_t *);
- *pi_64 = (int64_t)300000;
- break;
-
- case ACCESS_SET_PAUSE_STATE:
- break;
-
- case ACCESS_GET_TITLE_INFO:
- case ACCESS_SET_TITLE:
- case ACCESS_SET_SEEKPOINT:
- case ACCESS_SET_PRIVATE_ID_STATE:
- return VLC_EGENERIC;
-
- default:
- msg_Warn( p_access, "unimplemented query control %i", i_query );
- return VLC_EGENERIC;
- }
- return VLC_SUCCESS;
-}
-
-static int Read( access_t *p_access, uint8_t *p_buffer, int i_size )
-{
- access_sys_t *p_sys = (access_sys_t *)p_access->p_sys;
- int i_send;
-
- if( i_size < p_sys->song.size && p_sys->song.size > 0 )
- {
- i_send = i_size;
- }
- else if( p_sys->song.size == 0 )
- {
- return 0;
- }
- else
- {
- i_send = p_sys->song.size;
- }
-
- memcpy( p_buffer, p_sys->song.data, i_send );
- p_sys->song.size -= i_send;
- p_sys->song.data += i_send;
-
- return i_send;
-}
-
-static int Seek( access_t *p_access, int64_t i_pos )
-{
- if( i_pos > p_access->p_sys->i_orig_size )
- {
- return VLC_EGENERIC;
- }
- p_access->p_sys->song.size = p_access->p_sys->i_orig_size - i_pos;
- p_access->p_sys->song.data = p_access->p_sys->p_orig_buffer + i_pos;
- return VLC_SUCCESS;
-}
-
-/**************************************************************
- * Local functions
- **************************************************************/
-static void Callback( DAAP_SClient *p_client, DAAP_Status status,
- int i_pos, void *p_context )
-{
- services_discovery_t *p_sd = (services_discovery_t *)p_context;
-
- if( status == DAAP_STATUS_hostschanged )
- {
- OnHostsUpdate( p_sd );
- }
- else if( status == DAAP_STATUS_downloading )
- {
- }
-}
-
-static void OnHostsUpdate( services_discovery_t *p_sd )
-{
- int i;
-
- for( i = 0 ; i< p_sd->p_sys->p_db->i_hosts ; i ++ )
- {
- p_sd->p_sys->p_db->pp_hosts[i]->b_updated = VLC_FALSE;
- p_sd->p_sys->p_db->pp_hosts[i]->b_new = VLC_FALSE;
- }
-
- vlc_mutex_lock( &p_sd->p_sys->p_db->search_lock );
- DAAP_Client_EnumerateHosts( p_sd->p_sys->p_client, EnumerateCallback, p_sd);
-
- for( i = 0 ; i< p_sd->p_sys->p_db->i_hosts ; i ++ )
- {
- if( p_sd->p_sys->p_db->pp_hosts[i]->b_updated == VLC_FALSE )
- {
- dhost_t *p_host = p_sd->p_sys->p_db->pp_hosts[i];
- FreeHost( p_sd, p_host );
- REMOVE_ELEM( p_sd->p_sys->p_db->pp_hosts,
- p_sd->p_sys->p_db->i_hosts, i );
- }
- }
- vlc_mutex_unlock( &p_sd->p_sys->p_db->search_lock );
-
- for( i = 0 ; i< p_sd->p_sys->p_db->i_hosts ; i ++ )
- {
- if( p_sd->p_sys->p_db->pp_hosts[i]->b_new )
- ProcessHost( p_sd, p_sd->p_sys->p_db->pp_hosts[i] );
- }
-}
-
-static int EnumerateCallback( DAAP_SClient *p_client,
- DAAP_SClientHost *p_host,
- void *p_context )
-{
- int i;
- int i_size = DAAP_ClientHost_GetSharename( p_host, NULL, 0 );
- vlc_bool_t b_found = VLC_FALSE;
- char *psz_buffer = (char *)malloc( i_size );
- DAAP_ClientHost_GetSharename( p_host, psz_buffer, i_size );
-
- services_discovery_t *p_sd = (services_discovery_t *)p_context;
- services_discovery_sys_t *p_sys = p_sd->p_sys;
-
- for( i = 0 ; i< p_sys->p_db->i_hosts; i++ )
- {
- if( !strcmp( p_sys->p_db->pp_hosts[i]->psz_name, psz_buffer ) )
- {
- p_sys->p_db->pp_hosts[i]->b_updated = VLC_TRUE;
- b_found = VLC_TRUE;
- break;
- }
- }
-
- if( !b_found )
- {
- dhost_t *p_vlchost = (dhost_t *)malloc( sizeof( dhost_t ) );
- p_vlchost->p_node = NULL;
- p_vlchost->p_host = p_host;
- p_vlchost->psz_name = psz_buffer;
- p_vlchost->b_new = VLC_TRUE;
- p_vlchost->b_updated = VLC_TRUE;
- INSERT_ELEM( p_sys->p_db->pp_hosts, p_sys->p_db->i_hosts,
- p_sys->p_db->i_hosts, p_vlchost );
- }
-
- return VLC_SUCCESS;
-}
-
-static void ProcessHost( services_discovery_t *p_sd, dhost_t *p_host )
-{
-#if 0
- int i_dbsize, i_db, i, i_songsize, i_ret;
- int i_size = DAAP_ClientHost_GetSharename( p_host->p_host, NULL, 0 );
-
- playlist_t *p_playlist;
-
- p_playlist = (playlist_t *) vlc_object_find( p_sd, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
-
- if( !p_playlist )
- {
- return;
- }
-
- /* Connect to host */
- if( p_host->b_new )
- {
- p_host->psz_name = (char *)malloc( i_size );
- p_host->b_new = VLC_FALSE;
- DAAP_ClientHost_GetSharename( p_host->p_host, p_host->psz_name ,
- i_size );
-
- msg_Dbg( p_sd, "new share %s", p_host->psz_name );
- DAAP_ClientHost_AddRef( p_host->p_host );
- i_ret = DAAP_ClientHost_Connect( p_host->p_host );
- if( i_ret )
- {
- msg_Warn( p_sd, "unable to connect to DAAP host %s",
- p_host->psz_name );
-// DAAP_ClientHost_Release( p_host->p_host );
- vlc_object_release( p_playlist );
- return;
- }
-
- p_host->p_node = playlist_NodeCreate( p_playlist, VIEW_CATEGORY,
- p_host->psz_name,
- p_sd->p_sys->p_node );
- p_host->i_id = ++p_sd->p_sys->p_db->i_last_id;
- }
-
- /* Get DB */
- i_dbsize = DAAP_ClientHost_GetDatabases( p_host->p_host, NULL, NULL, 0 );
-
- DAAP_ClientHost_Database *p_database = malloc( i_dbsize );
- DAAP_ClientHost_GetDatabases( p_host->p_host, p_database, &i_db, i_dbsize );
-
-
- if( !i_db || !p_database )
- {
- msg_Warn( p_sd, "no database on DAAP host %s", p_host->psz_name );
- vlc_object_release( p_playlist );
- return;
- }
-
- /* We only use the first database */
- p_host->i_database_id = p_database[0].id;
-
- /* Get songs */
- i_songsize = DAAP_ClientHost_GetDatabaseItems( p_host->p_host,
- p_host->i_database_id,
- NULL, NULL, 0 );
- if( !i_songsize )
- {
- vlc_object_release( p_playlist );
- return;
- }
- p_host->p_songs = malloc( i_songsize );
-
- DAAP_ClientHost_GetDatabaseItems( p_host->p_host ,
- p_host->i_database_id,
- p_host->p_songs,
- &p_host->i_songs, i_songsize );
-
- for( i = 0; i< p_host->i_songs; i++ )
- {
- playlist_item_t *p_item;
- int i_len = 7 + 10 + 1 + 10 ; /* "daap://" + host + ":" + song */
- char *psz_buff = (char *)malloc( i_len );
-
- snprintf( psz_buff, i_len, "daap://%i:%i", p_host->i_id,
- p_host->p_songs[i].id );
- p_item = playlist_ItemNew( p_sd, psz_buff,
- p_host->p_songs[i].itemname );
- input_ItemAddInfo( &p_item->input, _(VLC_META_INFO_CAT),
- _(VLC_META_ARTIST), p_host->p_songs[i].songartist );
- input_ItemAddInfo( &p_item->input, _(VLC_META_INFO_CAT),
- _(VLC_META_COLLECTION), p_host->p_songs[i].songalbum );
-
- playlist_NodeAddItem( p_playlist, p_item, VIEW_CATEGORY,
- p_host->p_node, PLAYLIST_APPEND, PLAYLIST_END );
-
- }
-
- DAAP_ClientHost_AsyncWaitUpdate( p_host->p_host );
-
- vlc_object_release( p_playlist );
-#endif
-}
-
-static void FreeHost( services_discovery_t *p_sd, dhost_t *p_host )
-{
- playlist_t *p_playlist;
-
- if( p_host->p_host )
- {
- DAAP_ClientHost_Disconnect( p_host->p_host );
- DAAP_ClientHost_Release( p_host->p_host );
- }
-
- p_playlist = (playlist_t *) vlc_object_find( p_sd, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- if( p_playlist )
- {
- if( p_host->p_node )
- playlist_NodeDelete( p_playlist, p_host->p_node, VLC_TRUE ,
- VLC_TRUE);
- vlc_object_release( p_playlist );
- }
-
- if( p_host->p_songs ) free( p_host->p_songs );
-}
{
if( strcmp( psz_udi, p_sys->pp_devices[i]->psz_udi ) == 0 )
{
- playlist_DeleteFromItemId( p_playlist, p_sys->pp_devices[i]->i_id );
+ msg_Err(p_sd, "HAL delete must be fixed");
+/* playlist_DeleteFromItemId( p_playlist, p_sys->pp_devices[i]->i_id );*/
TAB_REMOVE( p_sys->i_devices_number, p_sys->pp_devices,
p_sys->pp_devices[i] );
}
playlist_NodesPairCreate( pl_Get( p_sd ), _("SAP sessions"),
&p_sys->p_node_cat, &p_sys->p_node_one,
VLC_TRUE );
-
+ p_sys->p_node_cat->p_input->b_prefers_tree = VLC_TRUE;
p_sys->i_announces = 0;
p_sys->pp_announces = NULL;
if( p_playlist->status.p_item &&
p_playlist->status.p_item->p_input == p_parent_input )
{
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE,
p_playlist->status.p_node, p_playlist->status.p_item );
}
}
if( p_announce->i_input_id > -1 )
- playlist_LockDeleteAllFromInput( pl_Get(p_sd), p_announce->i_input_id );
+ playlist_DeleteFromInput( pl_Get(p_sd), p_announce->i_input_id, VLC_FALSE );
for( i = 0; i< p_sd->p_sys->i_announces; i++)
{
* $Id$
*
* Authors: Rémi Denis-Courmont <rem # videolan.org>
- *
+ *
* Based on original wxWindows patch for VLC, and dependant on CyberLink
* UPnP library from :
* Satoshi Konno <skonno@cybergarage.org>
struct services_discovery_sys_t
{
- /* playlist node */
- playlist_item_t *p_node;
+ playlist_item_t *p_node_one;
playlist_item_t *p_node_cat;
- playlist_t *p_playlist;
};
/*****************************************************************************
p_sd->pf_run = Run;
p_sd->p_sys = p_sys;
- /* Create our playlist node */
- p_sys->p_playlist = (playlist_t *)vlc_object_find( p_sd,
- VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- if( !p_sys->p_playlist )
- {
- msg_Warn( p_sd, "unable to find playlist, cancelling UPnP listening");
- return VLC_EGENERIC;
- }
-
- playlist_NodesPairCreate( p_sys->p_playlist, _("Devices"),
- &p_sys->p_node_cat, &p_sys->p_node,
+ playlist_NodesPairCreate( pl_Get( p_sd ), _("Devices"),
+ &p_sys->p_node_cat, &p_sys->p_node_one,
VLC_TRUE );
return VLC_SUCCESS;
}
{
services_discovery_t *p_sd = ( services_discovery_t* )p_this;
services_discovery_sys_t *p_sys = p_sd->p_sys;
-
- if( p_sys->p_playlist )
- {
- playlist_NodeDelete( p_sys->p_playlist, p_sys->p_node, VLC_TRUE,
- VLC_TRUE );
- playlist_NodeDelete( p_sys->p_playlist, p_sys->p_node_cat, VLC_TRUE,
- VLC_TRUE );
- vlc_object_release( p_sys->p_playlist );
- }
-
+ playlist_t *p_playlist = pl_Yield( p_sd );
+ playlist_NodeDelete( p_playlist, p_sys->p_node_one, VLC_TRUE,
+ VLC_TRUE );
+ playlist_NodeDelete( p_playlist, p_sys->p_node_cat, VLC_TRUE,
+ VLC_TRUE );
+ pl_Release();
free( p_sys );
}
*/
char *str = strdup( dev->getFriendlyName( ) );
- p_item = playlist_NodeCreate( p_sys->p_playlist, str, p_sys->p_node );
+ p_item = playlist_NodeCreate( p_sys->p_playlist, str, p_sys->p_node_cat );
p_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
msg_Dbg( p_sd, "device %s added", str );
free( str );
msg_Dbg( p_sd, "title = %s", title );
- if ( node->isItemNode() )
+ if ( node->isItemNode() )
{
ItemNode *iNode = (ItemNode *)node;
-
- playlist_item_t *p_item;
- p_item = playlist_ItemNew( p_sd, iNode->getResource(), title );
-
- playlist_NodeAddItem( p_sys->p_playlist, p_item,
- p_parent, PLAYLIST_APPEND, PLAYLIST_END );
-
- } else if ( node->isContainerNode() )
+ 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 );
+ } else if ( node->isContainerNode() )
{
ContainerNode *conNode = (ContainerNode *)node;
- char* p_name = strdup(title); /* See other comment on strdup */
- playlist_item_t* p_node = playlist_NodeCreate( p_sys->p_playlist,
- p_name, p_parent );
- free(p_name);
+ char* p_name = strdup(title); /* See other comment on strdup */
+ playlist_item_t* p_node = playlist_NodeCreate( p_sys->p_playlist,
+ p_name, p_parent );
+ free(p_name);
- unsigned nContentNodes = conNode->getNContentNodes();
+ unsigned nContentNodes = conNode->getNContentNodes();
- for( unsigned n = 0; n < nContentNodes; n++ )
- AddContent( p_node, conNode->getContentNode( n ) );
+ for( unsigned n = 0; n < nContentNodes; n++ )
+ AddContent( p_node, conNode->getContentNode( n ) );
}
}
struct services_discovery_sys_t
{
playlist_item_t *p_node_cat;
- playlist_item_t *p_node;
- playlist_t *p_playlist;
+ playlist_item_t *p_node_one;
};
p_sd->p_sys = p_sys;
/* Create our playlist node */
- p_sys->p_playlist = ( playlist_t * )vlc_object_find( p_sd,
- VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- if( !p_sys->p_playlist )
- {
- msg_Warn( p_sd, "unable to find playlist, cancelling UPnP listening" );
- return VLC_EGENERIC;
- }
-
- playlist_NodesPairCreate( p_sys->p_playlist, _("Devices"),
- &p_sys->p_node_cat, &p_sys->p_node,
+ playlist_NodesPairCreate( pl_Get( p_sd ), _("Devices"),
+ &p_sys->p_node_cat, &p_sys->p_node_one,
VLC_TRUE );
return VLC_SUCCESS;
services_discovery_t *p_sd = ( services_discovery_t* )p_this;
services_discovery_sys_t *p_sys = p_sd->p_sys;
- if( p_sys->p_playlist )
- {
- playlist_NodeDelete( p_sys->p_playlist, p_sys->p_node, VLC_TRUE,
- VLC_TRUE );
- playlist_NodeDelete( p_sys->p_playlist, p_sys->p_node_cat, VLC_TRUE,
- VLC_TRUE );
- vlc_object_release( p_sys->p_playlist );
- }
+ playlist_NodeDelete( pl_Get( p_sd ), p_sys->p_node_one, VLC_TRUE,
+ VLC_TRUE );
+ playlist_NodeDelete( pl_Get( p_sd ), p_sys->p_node_cat, VLC_TRUE,
+ VLC_TRUE );
free( p_sys );
}
res = UpnpInit( 0, 0 );
if( res != UPNP_E_SUCCESS )
{
- msg_Err( p_sd, "%s", UpnpGetErrorMessage( res ) );
- return;
+ msg_Err( p_sd, "%s", UpnpGetErrorMessage( res ) );
+ return;
}
Cookie cookie;
res = UpnpRegisterClient( Callback, &cookie, &cookie.clientHandle );
if( res != UPNP_E_SUCCESS )
{
- msg_Err( p_sd, "%s", UpnpGetErrorMessage( res ) );
- goto shutDown;
+ msg_Err( p_sd, "%s", UpnpGetErrorMessage( res ) );
+ goto shutDown;
}
res = UpnpSearchAsync( cookie.clientHandle, 5, MEDIA_SERVER_DEVICE_TYPE, &cookie );
if( res != UPNP_E_SUCCESS )
{
- msg_Err( p_sd, "%s", UpnpGetErrorMessage( res ) );
- goto shutDown;
+ msg_Err( p_sd, "%s", UpnpGetErrorMessage( res ) );
+ goto shutDown;
}
msg_Dbg( p_sd, "UPnP discovery started" );
while( !p_sd->b_die )
{
- msleep( 500 );
+ msleep( 500 );
}
msg_Dbg( p_sd, "UPnP discovery stopped" );
const char* resultString = ixmlNode_getNodeValue( textNode );
char* resultXML = strdup( resultString );
-
+
resolve_xml_special_chars( resultXML );
IXML_Document* browseDoc = ixmlParseBuffer( resultXML );
{
if ( _contents )
{
- playlist_NodeDelete( _cookie->serviceDiscovery->p_sys->p_playlist,
- _playlistNode,
- true,
- true );
+ playlist_NodeDelete( pl_Get( _cookie->serviceDiscovery ) ,
+ _playlistNode, VLC_TRUE, VLC_TRUE );
}
delete _contents;
void MediaServer::fetchContents()
{
Container* root = new Container( 0, "0", getFriendlyName() );
+ playlist_t * p_playlist = pl_Get( _cookie->serviceDiscovery );
_fetchContents( root );
if ( _contents )
{
- vlc_mutex_lock( &_cookie->serviceDiscovery->p_sys->p_playlist->object_lock );
-
- playlist_NodeEmpty( _cookie->serviceDiscovery->p_sys->p_playlist,
- _playlistNode,
- true );
-
- vlc_mutex_unlock( &_cookie->serviceDiscovery->p_sys->p_playlist->object_lock );
-
- delete _contents;
+ PL_LOCK;
+ playlist_NodeEmpty( p_playlist, _playlistNode, VLC_TRUE );
+ PL_UNLOCK;
+ delete _contents;
}
_contents = root;
void MediaServer::_buildPlaylist( Container* parent )
{
+ playlist_t *p_playlist = pl_Get( _cookie->serviceDiscovery );
for ( unsigned int i = 0; i < parent->getNumContainers(); i++ )
{
- Container* container = parent->getContainer( i );
- playlist_item_t* parentNode = parent->getPlaylistNode();
+ Container* container = parent->getContainer( i );
+ playlist_item_t* parentNode = parent->getPlaylistNode();
- char* title = strdup( container->getTitle() );
- playlist_item_t* node = playlist_NodeCreate( _cookie->serviceDiscovery->p_sys->p_playlist,
- title,
- parentNode );
- free( title );
+ char* title = strdup( container->getTitle() );
+ playlist_item_t* node = playlist_NodeCreate( p_playlist, title, parentNode );
+ free( title );
- container->setPlaylistNode( node );
- _buildPlaylist( container );
+ container->setPlaylistNode( node );
+ _buildPlaylist( container );
}
for ( unsigned int i = 0; i < parent->getNumItems(); i++ )
{
- Item* item = parent->getItem( i );
- playlist_item_t* parentNode = parent->getPlaylistNode();
-
- playlist_item_t* node = playlist_ItemNew( _cookie->serviceDiscovery,
- item->getResource(),
- item->getTitle() );
-
- playlist_NodeAddItem( _cookie->serviceDiscovery->p_sys->p_playlist,
- node,
- parentNode, PLAYLIST_APPEND, PLAYLIST_END );
-
- item->setPlaylistNode( node );
+ Item* item = parent->getItem( i );
+ playlist_item_t* parentNode = parent->getPlaylistNode();
+
+ input_item_t* p_input = input_ItemNew( _cookie->serviceDiscovery,
+ item->getResource(),
+ item->getTitle() );
+ int i_cat;
+ playlist_BothAddInput( p_playlist, p_input, parentNode,
+ PLAYLIST_APPEND, PLAYLIST_END, &i_cat, NULL );
+ /* TODO: do this better by storing ids */
+ playlist_item_t *p_node = playlist_ItemGetById( p_playlist, i_cat, VLC_FALSE );
+ assert( p_node );
+ item->setPlaylistNode( p_node );
}
}
_list.push_back( s );
char* name = strdup( s->getFriendlyName() );
- playlist_item_t* node = playlist_NodeCreate( _cookie->serviceDiscovery->p_sys->p_playlist,
- name,
- _cookie->serviceDiscovery->p_sys->p_node );
+ playlist_item_t* node = playlist_NodeCreate( pl_Get( _cookie->serviceDiscovery ),
+ name,
+ _cookie->serviceDiscovery->p_sys->p_node_cat );
free( name );
s->setPlaylistNode( node );
if( PL->items.i_size == 0 ) RAISEVOID( "Empty playlist" );
if( i_id > 0 )
{
- playlist_item_t *p_item = playlist_ItemGetById( PL,
- i_id );
+ playlist_item_t *p_item = playlist_ItemGetById( PL, i_id, VLC_TRUE );
if( !p_item ) RAISEVOID( "Unable to find item" );
- playlist_LockControl( PL, PLAYLIST_VIEWPLAY,
- PL->status.p_node, p_item );
+ playlist_Control( PL, PLAYLIST_VIEWPLAY, VLC_FALSE,
+ PL->status.p_node, p_item );
}
else
{
libvlc_exception_t *p_e )
{
assert( PL );
- playlist_LockClear( PL );
+ playlist_Clear( PL, VLC_FALSE );
}
void libvlc_playlist_next( libvlc_instance_t *p_instance,
int libvlc_playlist_delete_item( libvlc_instance_t *p_instance, int i_id,
libvlc_exception_t *p_e )
{
+ playlist_item_t *p_item;
assert( PL );
- return playlist_DeleteFromItemId( PL, i_id );
+ vlc_mutex_lock( &PL->object_lock );
+ p_item = playlist_ItemGetById( PL, i_id, VLC_TRUE );
+ if( p_item && p_item->p_input ) {
+ int i_ret = playlist_DeleteFromInput( PL, p_item->p_input->i_id, VLC_TRUE );
+ if( i_ret ) {
+ libvlc_exception_raise( p_e, "delete failed" );
+ vlc_mutex_unlock( &PL->object_lock );
+ return VLC_EGENERIC;
+ }
+ else {
+ vlc_mutex_unlock( &PL->object_lock );
+ return VLC_SUCCESS;
+ }
+ }
+ libvlc_exception_raise( p_e, "item not found" );
+ vlc_mutex_unlokc( &PL->object_lock );
+ return VLC_EGENERIC;
}
uint32_t *pi_mandatory, uint32_t *pi_optional )
{
*pi_mandatory = VLC_META_ENGINE_TITLE | VLC_META_ENGINE_ARTIST;
+ assert( p_item->p_meta );
uint32_t i_meta = input_CurrentMetaFlags( p_item->p_meta );
*pi_mandatory &= ~i_meta;
struct meta_engine_t *p_me;
uint32_t i_mandatory, i_optional;
- if( !p_item->p_meta ) return VLC_EGENERIC;
+ assert( p_item->p_meta );
input_MetaSatisfied( p_playlist, p_item, &i_mandatory, &i_optional );
// Meta shouldn't magically appear
int VLC_PlaylistClear( int i_object )
{
LIBVLC_PLAYLIST_FUNC;
- playlist_Clear( p_libvlc->p_playlist );
+ playlist_Clear( p_libvlc->p_playlist, VLC_TRUE );
LIBVLC_PLAYLIST_FUNC_END;
return VLC_SUCCESS;
}
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args );
+static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args );
-void PreparseEnqueueItemSub( playlist_t *, playlist_item_t * );
-
-playlist_item_t *playlist_RecursiveFindLast(playlist_t *p_playlist,
- playlist_item_t *p_node );
+static void PreparseEnqueueItemSub( playlist_t *, playlist_item_t * );
/*****************************************************************************
* Playlist control
*****************************************************************************/
-/**
- * Do a playlist action. Should be entered without playlist lock
- * \see playlist_Control
- */
-int playlist_LockControl( playlist_t * p_playlist, int i_query, ... )
-{
- va_list args;
- int i_result;
- va_start( args, i_query );
- vlc_mutex_lock( &p_playlist->object_lock );
- i_result = PlaylistVAControl( p_playlist, i_query, args );
- va_end( args );
- vlc_mutex_unlock( &p_playlist->object_lock );
- return i_result;
-}
-
/**
* Do a playlist action.
* If there is something in the playlist then you can do playlist actions.
* \param variable number of arguments
* \return VLC_SUCCESS or an error
*/
-int playlist_Control( playlist_t * p_playlist, int i_query, ... )
+int playlist_Control( playlist_t * p_playlist, int i_query, vlc_bool_t b_locked, ... )
{
va_list args;
int i_result;
- va_start( args, i_query );
+ va_start( args, b_locked );
+ if( !b_locked ) PL_LOCK;
i_result = PlaylistVAControl( p_playlist, i_query, args );
va_end( args );
+ if( !b_locked ) PL_UNLOCK;
return i_result;
}
-int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args )
+static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args )
{
playlist_item_t *p_item, *p_node;
vlc_value_t val;
- if( p_playlist->items.i_size <= 0 )
+ if( playlist_IsEmpty( p_playlist ) )
return VLC_EGENERIC;
switch( i_query )
return VLC_SUCCESS;
}
-void PreparseEnqueueItemSub( playlist_t *p_playlist,
- playlist_item_t *p_item )
+static void PreparseEnqueueItemSub( playlist_t *p_playlist,
+ playlist_item_t *p_item )
{
int i;
if( p_item->i_children == -1 )
p_playlist->p_root_category = playlist_NodeCreate( p_playlist, NULL, NULL);
p_playlist->p_root_onelevel = playlist_NodeCreate( p_playlist, NULL, NULL);
+ if( !p_playlist->p_root_category || !p_playlist->p_root_onelevel )
+ return NULL;
+
/* Create playlist and media library */
p_playlist->p_local_category = playlist_NodeCreate( p_playlist,
_( "Playlist" ),p_playlist->p_root_category );
p_playlist->p_local_category->i_flags |= PLAYLIST_RO_FLAG;
p_playlist->p_local_onelevel->i_flags |= PLAYLIST_RO_FLAG;
+ if( !p_playlist->p_local_category || !p_playlist->p_local_onelevel ||
+ !p_playlist->p_local_category->p_input ||
+ !p_playlist->p_local_onelevel->p_input )
+ return NULL;
+
/* Link the nodes together. Todo: actually create them from the same input*/
p_playlist->p_local_onelevel->p_input->i_id =
p_playlist->p_local_category->p_input->i_id;
_( "Media Library" ), p_playlist->p_root_category );
p_playlist->p_ml_onelevel = playlist_NodeCreate( p_playlist,
_( "Media Library" ), p_playlist->p_root_onelevel );
+
+ if(!p_playlist->p_ml_category || !p_playlist->p_ml_onelevel)
+ return NULL;
+
p_playlist->p_ml_category->i_flags |= PLAYLIST_RO_FLAG;
p_playlist->p_ml_onelevel->i_flags |= PLAYLIST_RO_FLAG;
p_playlist->p_ml_onelevel->p_input->i_id =
vlc_object_destroy( p_playlist->p_fetcher );
vlc_object_detach( p_playlist );
vlc_object_destroy( p_playlist );
-
}
/* Destroy remaining objects */
* This only checks for meta, not for art
* \todo don't do this for things we won't get meta for, like vids
*/
- if( !input_MetaSatisfied( p_playlist, p_current, &i_m, &i_o ) )
+ if( p_current->p_meta &&
+ !input_MetaSatisfied( p_playlist, p_current, &i_m, &i_o ) )
{
preparse_item_t p;
PL_DEBUG("need to fetch meta for %s", p_current->psz_name );
vlc_mutex_lock( &p_playlist->p_fetcher->object_lock );
INSERT_ELEM( p_playlist->p_fetcher->p_waiting,
p_playlist->p_fetcher->i_waiting,
- p_playlist->p_fetcher->i_waiting,
- p );
+ p_playlist->p_fetcher->i_waiting, p);
vlc_mutex_unlock( &p_playlist->p_fetcher->object_lock );
vlc_cond_signal( &p_playlist->p_fetcher->object_wait );
}
/* We already have all needed meta, but we need art right now */
- else if( p_playlist->p_fetcher->i_art_policy == ALBUM_ART_ALL &&
+ else if( p_current->p_meta &&
+ p_playlist->p_fetcher->i_art_policy == ALBUM_ART_ALL &&
EMPTY_STR( p_current->p_meta->psz_arturl ) )
{
preparse_item_t p;
p.p_item = p_current;
p.b_fetch_art = VLC_TRUE;
vlc_mutex_lock( &p_playlist->p_fetcher->object_lock );
- INSERT_ELEM( p_playlist->p_fetcher->p_waiting,
- p_playlist->p_fetcher->i_waiting,
- p_playlist->p_fetcher->i_waiting,
- p );
+ TAB_APPEND( p_playlist->p_fetcher->i_waiting,
+ p_playlist->p_fetcher->p_waiting,
+ p );
vlc_mutex_unlock( &p_playlist->p_fetcher->object_lock );
vlc_cond_signal( &p_playlist->p_fetcher->object_wait );
}
else
{
PL_DEBUG( "no fetch required for %s (art currently %s)",
- p_current->psz_name, p_current->p_meta->psz_arturl );
+ p_current->psz_name,
+ p_current->p_meta ? p_current->p_meta->psz_arturl:
+ "null" );
vlc_gc_decref( p_current );
}
PL_UNLOCK;
vlc_mutex_unlock( &p_obj->object_lock );
if( p_item )
{
+ assert( p_item->p_meta );
if( !b_fetch_art )
{
input_MetaFetch( p_playlist, p_item );
return VLC_SUCCESS;
}
-/** Remove an input item from ONELEVEL and CATEGORY */
-int playlist_DeleteAllFromInput( playlist_t *p_playlist, int i_input_id )
-{
- playlist_DeleteFromInput( p_playlist, i_input_id,
- p_playlist->p_root_category, VLC_TRUE );
- playlist_DeleteFromInput( p_playlist, i_input_id,
- p_playlist->p_root_onelevel, VLC_TRUE );
- return VLC_SUCCESS;
-}
-
-/** Remove an input item from ONELEVEL and CATEGORY.
- * This function must be entered without the playlist lock */
-int playlist_LockDeleteAllFromInput( playlist_t * p_playlist, int i_id )
-{
- int i_ret;
- vlc_mutex_lock( &p_playlist->object_lock );
- i_ret = playlist_DeleteAllFromInput( p_playlist, i_id );
- vlc_mutex_unlock( &p_playlist->object_lock );
- return i_ret;
-}
-
/** Remove an input item when it appears from a root playlist item */
-int playlist_DeleteFromInput( playlist_t *p_playlist, int i_input_id,
- playlist_item_t *p_root, vlc_bool_t b_do_stop )
+static int DeleteFromInput( playlist_t *p_playlist, int i_input_id,
+ playlist_item_t *p_root, vlc_bool_t b_do_stop )
{
int i;
for( i = 0 ; i< p_root->i_children ; i++ )
}
else if( p_root->pp_children[i]->i_children >= 0 )
{
- int i_ret = playlist_DeleteFromInput( p_playlist, i_input_id,
- p_root->pp_children[i], b_do_stop );
+ int i_ret = DeleteFromInput( p_playlist, i_input_id,
+ p_root->pp_children[i], b_do_stop );
if( i_ret == VLC_SUCCESS ) return VLC_SUCCESS;
}
}
return VLC_EGENERIC;
}
-/** Remove a playlist item from the playlist, given its id */
-int playlist_DeleteFromItemId( playlist_t *p_playlist, int i_id )
-{
- playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
- if( !p_item ) return VLC_EGENERIC;
- return DeleteInner( p_playlist, p_item, VLC_TRUE );
-}
-
-/** Remove a playlist item from the playlist, given its id
- * This function should be entered without the playlist lock */
-int playlist_LockDelete( playlist_t * p_playlist, int i_id )
+/** Remove an input item from ONELEVEL and CATEGORY */
+int playlist_DeleteFromInput( playlist_t *p_playlist, int i_input_id,
+ vlc_bool_t b_locked )
{
- int i_ret;
- vlc_mutex_lock( &p_playlist->object_lock );
- i_ret = playlist_DeleteFromItemId( p_playlist, i_id );
- vlc_mutex_unlock( &p_playlist->object_lock );
- return i_ret;
+ if( !b_locked ) PL_LOCK;
+ DeleteFromInput( p_playlist, i_input_id,
+ p_playlist->p_root_category, VLC_TRUE );
+ DeleteFromInput( p_playlist, i_input_id,
+ p_playlist->p_root_onelevel, VLC_TRUE );
+ if( !b_locked ) PL_UNLOCK;
+ return VLC_SUCCESS;
}
/** Clear the playlist */
-void playlist_Clear( playlist_t * p_playlist )
+void playlist_Clear( playlist_t * p_playlist, vlc_bool_t b_locked )
{
+ if( !b_locked ) PL_LOCK;
playlist_NodeEmpty( p_playlist, p_playlist->p_root_category, VLC_TRUE );
playlist_NodeEmpty( p_playlist, p_playlist->p_root_onelevel, VLC_TRUE );
+ if( !b_locked ) PL_UNLOCK;
}
-/** Clear the playlist. This function must be entered without the lock */
-void playlist_LockClear( playlist_t *p_playlist )
+
+/** Remove a playlist item from the playlist, given its id
+ * This function is to be used only by the playlist */
+int playlist_DeleteFromItemId( playlist_t *p_playlist, int i_id )
{
- vlc_mutex_lock( &p_playlist->object_lock );
- playlist_Clear( p_playlist );
- vlc_mutex_unlock( &p_playlist->object_lock );
+ 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_BothAddInput( playlist_t *p_playlist,
input_item_t *p_input,
playlist_item_t *p_direct_parent,
- int i_mode, int i_pos )
+ int i_mode, int i_pos,
+ int *i_cat, int *i_one )
{
playlist_item_t *p_item_cat, *p_item_one, *p_up;
int i_top;
}
GoAndPreparse( p_playlist, i_mode, p_item_cat, p_item_one );
+ 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 );
return VLC_SUCCESS;
}
return p_item;
}
-/** Add a playlist item to a given node */
-void playlist_NodeAddItem( playlist_t *p_playlist, playlist_item_t *p_item,
- playlist_item_t *p_parent, int i_mode, int i_pos )
-{
- vlc_mutex_lock( &p_playlist->object_lock );
- AddItem( p_playlist, p_item, p_parent, i_pos );
- vlc_mutex_unlock( &p_playlist->object_lock );
-}
-
/*****************************************************************************
* Playlist item misc operations
*****************************************************************************/
* This function must be entered without the playlist lock
*/
playlist_item_t *playlist_ItemToNode( playlist_t *p_playlist,
- playlist_item_t *p_item )
+ playlist_item_t *p_item,
+ vlc_bool_t b_locked )
{
playlist_item_t *p_item_in_category;
* useful for later BothAddInput )
*/
+ if( !b_locked ) PL_LOCK;
+
/* Fast track the media library, no time to loose */
- if( p_item == p_playlist->p_ml_category )
+ if( p_item == p_playlist->p_ml_category ) {
+ if( !b_locked ) PL_UNLOCK;
return p_item;
+ }
/** \todo First look if we don't already have it */
p_item_in_category = playlist_ItemFindFromInputAndRoot(
ChangeToNode( p_playlist, p_item_in_one );
else
{
- playlist_DeleteFromInput( p_playlist, p_item_in_one->p_input->i_id,
- p_playlist->p_root_onelevel, VLC_FALSE );
+ DeleteFromInput( p_playlist, p_item_in_one->p_input->i_id,
+ p_playlist->p_root_onelevel, VLC_FALSE );
}
p_playlist->b_reset_currently_playing = VLC_TRUE;
vlc_cond_signal( &p_playlist->object_wait );
var_SetInteger( p_playlist, "item-change", p_item_in_category->
p_input->i_id );
+ if( !b_locked ) PL_UNLOCK;
return p_item_in_category;
}
else
{
ChangeToNode( p_playlist, p_item );
+ if( !b_locked ) PL_UNLOCK;
return NULL;
}
}
-/** Transform an item to a node
- * This function must be entered without the playlist lock
- * \see playlist_ItemToNode
- */
-playlist_item_t * playlist_LockItemToNode( playlist_t *p_playlist,
- playlist_item_t *p_item )
-{
- playlist_item_t *p_ret;
- vlc_mutex_lock( &p_playlist->object_lock );
- p_ret = playlist_ItemToNode( p_playlist, p_item );
- vlc_mutex_unlock( &p_playlist->object_lock );
- return p_ret;
-}
-
/** Find an item within a root, given its input id.
* \return the first found item, or NULL if not found
*/
playlist_item_t *playlist_GetLastLeaf( playlist_t *p_playlist,
playlist_item_t *p_root );
+int playlist_DeleteFromItemId( playlist_t*, int );
+
/**
* @}
*/
//#undef PLAYLIST_DEBUG
#ifdef PLAYLIST_DEBUG
-#define PL_DEBUG( msg, args... ) msg_Dbg( p_playlist, msg, ## args )
+ #define PL_DEBUG( msg, args... ) msg_Dbg( p_playlist, msg, ## args )
+ #ifdef PLAYLIST_DEBUG2
+ #define PL_DEBUG2( msg, args... ) msg_Dbg( p_playlist, msg, ## args )
+ #else
+ #define PL_DEBUG2( msg, args... ) {}
+ #endif
#else
-#define PL_DEBUG( msg, args ... ) {}
+ #define PL_DEBUG( msg, args ... ) {}
+ #define PL_DEBUG2( msg, args... ) {}
#endif
-#define PLI_NAME( p ) p ? p->p_input->psz_name : "null"
+#define PLI_NAME( p ) p && p->p_input ? p->p_input->psz_name : "null"
* \param i_id the id to find
* \return the item or NULL on failure
*/
-playlist_item_t * playlist_ItemGetById( playlist_t * p_playlist , int i_id )
+playlist_item_t * playlist_ItemGetById( playlist_t * p_playlist , int i_id,
+ vlc_bool_t b_locked )
{
int i;
+ if( !b_locked ) PL_LOCK;
ARRAY_BSEARCH( p_playlist->all_items,->i_id, int, i_id, i );
- if( i != -1 )
+ if( i != -1 ) {
+ if( !b_locked ) PL_UNLOCK;
return ARRAY_VAL( p_playlist->all_items, i );
+ }
+ if( !b_locked ) PL_UNLOCK;
return NULL;
}
* \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,
+ vlc_bool_t b_locked )
{
int i;
+ if( !b_locked ) PL_LOCK;
if( p_playlist->status.p_item &&
p_playlist->status.p_item->p_input == p_item )
{
+ if( !b_locked ) PL_UNLOCK;
return p_playlist->status.p_item;
}
/** \todo Check if this is always incremental and whether we can bsearch */
for( i = 0 ; i < p_playlist->all_items.i_size; i++ )
{
if( ARRAY_VAL(p_playlist->all_items, i)->p_input->i_id == p_item->i_id )
+ {
+ if( !b_locked ) PL_UNLOCK;
return ARRAY_VAL(p_playlist->all_items, i);
+ }
}
+ if( !b_locked ) PL_UNLOCK;
return NULL;
}
assert( p_root && p_root->i_children != -1 );
-#ifdef PLAYLIST_DEBUG
- if( p_item != NULL )
- msg_Dbg( p_playlist, "finding next of %s within %s",
- p_item->p_input->psz_name, p_root->p_input->psz_name );
- else
- msg_Dbg( p_playlist, "finding something to play within %s",
- p_root->p_input->psz_name );
-#endif
+ PL_DEBUG2( "finding next of %s within %s",
+ PLI_NAME( p_item ), PLI_NAME( p_root ) );
/* Now, walk the tree until we find a suitable next item */
p_next = p_item;
if( b_ena_ok && b_unplayed_ok ) break;
}
}
-#ifdef PLAYLIST_DEBUG
- if( p_next == NULL )
- msg_Dbg( p_playlist, "At end of node" );
-#endif
+ if( p_next == NULL ) PL_DEBUG2( "at end of node" );
return p_next;
}
{
playlist_item_t *p_prev;
-#ifdef PLAYLIST_DEBUG
- if( p_item != NULL )
- msg_Dbg( p_playlist, "finding previous of %s within %s",
- p_item->p_input->psz_name, p_root->p_input->psz_name );
- else
- msg_Dbg( p_playlist, "finding previous to play within %s",
- p_root->p_input->psz_name );
-#endif
+ PL_DEBUG2( "finding previous os %s within %s", PLI_NAME( p_item ),
+ PLI_NAME( p_root ) );
assert( p_root && p_root->i_children != -1 );
/* Now, walk the tree until we find a suitable previous item */
if( b_ena_ok && b_unplayed_ok ) break;
}
}
-#ifdef PLAYLIST_DEBUG
- if( p_prev == NULL )
- msg_Dbg( p_playlist, "At beginning of node" );
-#endif
+ if( p_prev == NULL ) PL_DEBUG2( "at beginning of node" );
return p_prev;
}
if( i+1 >= p_parent->i_children )
{
/* Was already the last sibling. Look for uncles */
- PL_DEBUG( "Current item is the last of the node,"
- "looking for uncle from %s",
- p_parent->p_input->psz_name );
+ PL_DEBUG2( "Current item is the last of the node,"
+ "looking for uncle from %s",
+ p_parent->p_input->psz_name );
if( p_parent == p_root )
{
- PL_DEBUG( "already at root" );
+ PL_DEBUG2( "already at root" );
return NULL;
}
return GetNextUncle( p_playlist, p_item, p_root );
{
if( p_parent == p_grandparent->pp_children[i] )
{
- PL_DEBUG( "parent %s found as child %i of grandparent %s",
- p_parent->p_input->psz_name, i,
- p_grandparent->p_input->psz_name );
+ PL_DEBUG2( "parent %s found as child %i of grandparent %s",
+ p_parent->p_input->psz_name, i,
+ p_grandparent->p_input->psz_name );
b_found = VLC_TRUE;
break;
}
if( i-1 < 0 )
{
/* Was already the first sibling. Look for uncles */
- PL_DEBUG( "current item is the first of its node,"
- "looking for uncle from %s",
- p_parent->p_input->psz_name );
+ PL_DEBUG2( "current item is the first of its node,"
+ "looking for uncle from %s",
+ p_parent->p_input->psz_name );
if( p_parent == p_root )
{
- PL_DEBUG( "already at root" );
+ PL_DEBUG2( "already at root" );
return NULL;
}
return GetPrevUncle( p_playlist, p_item, p_root );