[vlc-devel] [PATCH 02/15] libvlc: factor input_item_preparsed_changed

Thomas Guillem thomas at gllm.fr
Thu Apr 14 17:44:51 CEST 2016


And don't re-send event, even if this can't happen with current vlc core.
---
 lib/media.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/lib/media.c b/lib/media.c
index 49f5132..e0a5423 100644
--- a/lib/media.c
+++ b/lib/media.c
@@ -213,17 +213,17 @@ static void input_item_duration_changed( const vlc_event_t *p_event,
     libvlc_event_send( p_md->p_event_manager, &event );
 }
 
-/**************************************************************************
- * input_item_preparsed_changed (Private) (vlc event Callback)
- **************************************************************************/
-static void input_item_preparsed_changed(const vlc_event_t *p_event,
-                                         void * user_data)
+static void send_preparsed_event(libvlc_media_t *media)
 {
-    libvlc_media_t *media = user_data;
     libvlc_event_t event;
 
     /* Eventually notify libvlc_media_parse() */
     vlc_mutex_lock(&media->parsed_lock);
+    if (media->is_parsed == true)
+    {
+        vlc_mutex_unlock(&media->parsed_lock);
+        return;
+    }
     media->is_parsed = true;
     vlc_cond_broadcast(&media->parsed_cond);
     vlc_mutex_unlock(&media->parsed_lock);
@@ -231,14 +231,24 @@ static void input_item_preparsed_changed(const vlc_event_t *p_event,
 
     /* Construct the event */
     event.type = libvlc_MediaParsedChanged;
-    event.u.media_parsed_changed.new_status =
-        p_event->u.input_item_preparsed_changed.new_status;
+    event.u.media_parsed_changed.new_status = true;
 
     /* Send the event */
     libvlc_event_send(media->p_event_manager, &event);
 }
 
 /**************************************************************************
+ * input_item_preparsed_changed (Private) (vlc event Callback)
+ **************************************************************************/
+static void input_item_preparsed_changed(const vlc_event_t *p_event,
+                                         void * user_data)
+{
+    VLC_UNUSED( p_event );
+    libvlc_media_t *media = user_data;
+    send_preparsed_event(media);
+}
+
+/**************************************************************************
  * input_item_preparse_ended (Private) (vlc event Callback)
  **************************************************************************/
 static void input_item_preparse_ended( const vlc_event_t * p_event,
-- 
2.8.0.rc3



More information about the vlc-devel mailing list