[vlc-commits] libvlc: factor input_item_preparsed_changed

Thomas Guillem git at videolan.org
Sun Apr 17 07:22:30 CEST 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Apr 14 15:20:24 2016 +0200| [be5d7c280564c7e91e553ca43d209b48a9ac959c] | committer: Thomas Guillem

libvlc: factor input_item_preparsed_changed

And don't re-send event, even if this can't happen with current vlc core.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=be5d7c280564c7e91e553ca43d209b48a9ac959c
---

 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,



More information about the vlc-commits mailing list