[vlc-commits] lib: media: allocate event manager in-place

Rémi Denis-Courmont git at videolan.org
Mon May 15 21:32:09 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon May 15 20:16:45 2017 +0300| [db28adc700cf150b15f3b75988e7ef4a35704e5d] | committer: Rémi Denis-Courmont

lib: media: allocate event manager in-place

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

 lib/media.c          | 25 ++++++++++---------------
 lib/media_internal.h |  2 +-
 lib/media_player.c   |  2 +-
 3 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/lib/media.c b/lib/media.c
index 4c95c94c8e..4118c39886 100644
--- a/lib/media.c
+++ b/lib/media.c
@@ -172,7 +172,7 @@ static void input_item_subitem_added( const vlc_event_t *p_event,
     event.u.media_subitem_added.new_child = p_md_child;
 
     /* Send the event */
-    libvlc_event_send( p_md->p_event_manager, &event );
+    libvlc_event_send( &p_md->event_manager, &event );
     libvlc_media_release( p_md_child );
 }
 
@@ -191,7 +191,7 @@ static void input_item_subitemtree_added( const vlc_event_t * p_event,
     event.u.media_subitemtree_added.item = p_md;
 
     /* Send the event */
-    libvlc_event_send( p_md->p_event_manager, &event );
+    libvlc_event_send( &p_md->event_manager, &event );
 }
 
 /**************************************************************************
@@ -209,7 +209,7 @@ static void input_item_meta_changed( const vlc_event_t *p_event,
         vlc_to_libvlc_meta[p_event->u.input_item_meta_changed.meta_type];
 
     /* Send the event */
-    libvlc_event_send( p_md->p_event_manager, &event );
+    libvlc_event_send( &p_md->event_manager, &event );
 }
 
 /**************************************************************************
@@ -227,7 +227,7 @@ static void input_item_duration_changed( const vlc_event_t *p_event,
         from_mtime(p_event->u.input_item_duration_changed.new_duration);
 
     /* Send the event */
-    libvlc_event_send( p_md->p_event_manager, &event );
+    libvlc_event_send( &p_md->event_manager, &event );
 }
 
 static void send_parsed_changed( libvlc_media_t *p_md,
@@ -272,7 +272,7 @@ static void send_parsed_changed( libvlc_media_t *p_md,
     event.u.media_parsed_changed.new_status = new_status;
 
     /* Send the event */
-    libvlc_event_send( p_md->p_event_manager, &event );
+    libvlc_event_send( &p_md->event_manager, &event );
 }
 
 /**************************************************************************
@@ -396,12 +396,7 @@ libvlc_media_t * libvlc_media_new_from_input_item(
      * It can give a bunch of item to read. */
     p_md->p_subitems        = NULL;
 
-    p_md->p_event_manager = libvlc_event_manager_new( p_md );
-    if( unlikely(p_md->p_event_manager == NULL) )
-    {
-        free(p_md);
-        return NULL;
-    }
+    libvlc_event_manager_init( &p_md->event_manager, p_md );
 
     input_item_Hold( p_md->p_input_item );
 
@@ -567,9 +562,9 @@ void libvlc_media_release( libvlc_media_t *p_md )
     event.u.media_freed.md = p_md;
 
     /* Send the event */
-    libvlc_event_send( p_md->p_event_manager, &event );
+    libvlc_event_send( &p_md->event_manager, &event );
 
-    libvlc_event_manager_release( p_md->p_event_manager );
+    libvlc_event_manager_destroy( &p_md->event_manager );
     libvlc_release( p_md->p_libvlc_instance );
     free( p_md );
 }
@@ -673,7 +668,7 @@ libvlc_media_set_state( libvlc_media_t *p_md,
     event.u.media_state_changed.new_state = state;
 
     /* Send the event */
-    libvlc_event_send( p_md->p_event_manager, &event );
+    libvlc_event_send( &p_md->event_manager, &event );
 }
 
 /**************************************************************************
@@ -731,7 +726,7 @@ libvlc_media_event_manager( libvlc_media_t * p_md )
 {
     assert( p_md );
 
-    return p_md->p_event_manager;
+    return &p_md->event_manager;
 }
 
 /**************************************************************************
diff --git a/lib/media_internal.h b/lib/media_internal.h
index f063ddb5fa..5a67e9ff60 100644
--- a/lib/media_internal.h
+++ b/lib/media_internal.h
@@ -33,7 +33,7 @@
 
 struct libvlc_media_t
 {
-    libvlc_event_manager_t * p_event_manager;
+    libvlc_event_manager_t event_manager;
     input_item_t      *p_input_item;
     int                i_refcount;
     libvlc_instance_t *p_libvlc_instance;
diff --git a/lib/media_player.c b/lib/media_player.c
index f5ec04a10e..621e96533f 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -133,7 +133,7 @@ static void input_item_preparsed_changed( const vlc_event_t *p_event,
         libvlc_event_t event;
         event.type = libvlc_MediaParsedChanged;
         event.u.media_parsed_changed.new_status = libvlc_media_parsed_status_done;
-        libvlc_event_send( p_md->p_event_manager, &event );
+        libvlc_event_send( &p_md->event_manager, &event );
     }
 }
 



More information about the vlc-commits mailing list