Commit 1723d7e9 authored by Thomas Guillem's avatar Thomas Guillem Committed by Jean-Baptiste Kempf

libvlc: add libvlc_MediaListEndReached event

Expose an event to libvlc users which allows them to get notified when a media
list reached the end. That is, when the media list is attached to a media
(subitems) that completed a parsing. Or when the media list is attached to a
media discovery that stopped.
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent bcb1b3bd
......@@ -82,6 +82,7 @@ enum libvlc_event_e {
libvlc_MediaListWillAddItem,
libvlc_MediaListItemDeleted,
libvlc_MediaListWillDeleteItem,
libvlc_MediaListEndReached,
libvlc_MediaListViewItemAdded=0x300,
libvlc_MediaListViewWillAddItem,
......
......@@ -164,8 +164,18 @@ static void input_item_subitemtree_added( const vlc_event_t * p_event,
{
VLC_UNUSED( p_event );
libvlc_media_t * p_md = user_data;
libvlc_media_list_t *p_subitems;
libvlc_event_t event;
/* notify the media list */
p_subitems = media_get_subitems( p_md );
if( p_subitems != NULL )
{
libvlc_media_list_lock( p_subitems );
libvlc_media_list_internal_end_reached( p_subitems );
libvlc_media_list_unlock( p_subitems );
}
/* Construct the event */
event.type = libvlc_MediaSubItemTreeAdded;
event.u.media_subitemtree_added.item = p_md;
......
......@@ -169,8 +169,15 @@ static void services_discovery_ended( const vlc_event_t * p_event,
{
VLC_UNUSED(p_event);
libvlc_media_discoverer_t * p_mdis = user_data;
libvlc_media_list_t * p_mlist = p_mdis->p_mlist;
libvlc_event_t event;
p_mdis->running = false;
libvlc_media_list_lock( p_mlist );
libvlc_media_list_internal_end_reached( p_mlist );
libvlc_media_list_unlock( p_mlist );
event.type = libvlc_MediaDiscovererEnded;
libvlc_event_send( p_mdis->p_event_manager, &event );
}
......
......@@ -122,6 +122,17 @@ notify_item_deletion( libvlc_media_list_t * p_mlist,
libvlc_event_send( p_mlist->p_event_manager, &event );
}
/* LibVLC internal */
void libvlc_media_list_internal_end_reached( libvlc_media_list_t * p_mlist )
{
libvlc_event_t event;
event.type = libvlc_MediaListEndReached;
/* Send the event */
libvlc_event_send( p_mlist->p_event_manager, &event );
}
/**************************************************************************
* static mlist_is_writable (private)
**************************************************************************/
......@@ -176,6 +187,8 @@ libvlc_media_list_new( libvlc_instance_t * p_inst )
libvlc_MediaListItemDeleted );
libvlc_event_manager_register_event_type( p_mlist->p_event_manager,
libvlc_MediaListWillDeleteItem );
libvlc_event_manager_register_event_type( p_mlist->p_event_manager,
libvlc_MediaListEndReached );
vlc_mutex_init( &p_mlist->object_lock );
vlc_mutex_init( &p_mlist->refcount_lock ); // FIXME: spinlock?
......
......@@ -64,4 +64,6 @@ void libvlc_media_list_internal_insert_media(
int libvlc_media_list_internal_remove_index(
libvlc_media_list_t * p_mlist, int index );
void libvlc_media_list_internal_end_reached(
libvlc_media_list_t * p_mlist );
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment