<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head></head><body><div style="font-size: 12pt; font-family: Calibri,sans-serif;"><div>AFAIK, ISO C reserves identifiers with leading underscore.</div><div><br></div><div>-- </div><div>Rémi Denis-Courmont</div><div>Sent from my NVIDIA Tegra-powered device</div><br><div id="htc_header">----- Reply message -----<br>De : "Thomas Guillem" <thomas@gllm.fr><br>Pour : <vlc-devel@videolan.org><br>Objet : [vlc-devel] [PATCH 2/2] libvlc: add libvlc_MediaListEndReached event<br>Date : sam., janv. 17, 2015 06:36</div></div><br><pre style="word-wrap: break-word; white-space: pre-wrap;">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.
---
 include/vlc/libvlc_events.h |  1 +
 lib/media.c                 | 11 ++++++++++-
 lib/media_discoverer.c      |  7 +++++++
 lib/media_list.c            | 13 +++++++++++++
 lib/media_list_internal.h   |  2 ++
 5 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
index 963163a..c99e25c 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -82,6 +82,7 @@ enum libvlc_event_e {
     libvlc_MediaListWillAddItem,
     libvlc_MediaListItemDeleted,
     libvlc_MediaListWillDeleteItem,
+    libvlc_MediaListEndReached,
 
     libvlc_MediaListViewItemAdded=0x300,
     libvlc_MediaListViewWillAddItem,
diff --git a/lib/media.c b/lib/media.c
index c6d2d56..da71c21 100644
--- a/lib/media.c
+++ b/lib/media.c
@@ -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_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;
@@ -225,7 +235,6 @@ static void input_item_preparsed_changed(const vlc_event_t *p_event,
     vlc_cond_broadcast(&media->parsed_cond);
     vlc_mutex_unlock(&media->parsed_lock);
 
-
     /* Construct the event */
     event.type = libvlc_MediaParsedChanged;
     event.u.media_parsed_changed.new_status =
diff --git a/lib/media_discoverer.c b/lib/media_discoverer.c
index a2532cb..e350f95 100644
--- a/lib/media_discoverer.c
+++ b/lib/media_discoverer.c
@@ -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_end_reached( p_mlist );
+    libvlc_media_list_unlock( p_mlist );
+
     event.type = libvlc_MediaDiscovererEnded;
     libvlc_event_send( p_mdis->p_event_manager, &event );
 }
diff --git a/lib/media_list.c b/lib/media_list.c
index b122345..8e75e85 100644
--- a/lib/media_list.c
+++ b/lib/media_list.c
@@ -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_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?
diff --git a/lib/media_list_internal.h b/lib/media_list_internal.h
index 04918ba..b45c7e1 100644
--- a/lib/media_list_internal.h
+++ b/lib/media_list_internal.h
@@ -68,4 +68,6 @@ void _libvlc_media_list_insert_media(
 int _libvlc_media_list_remove_index(
         libvlc_media_list_t * p_mlist, int index );
 
+void _libvlc_media_list_end_reached(
+        libvlc_media_list_t * p_mlist );
 #endif
-- 
2.1.3

_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
<a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a>

</pre></body></html>