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

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


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

lib: media_discoverer: allocate event manager in-place

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

 lib/media_discoverer.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/lib/media_discoverer.c b/lib/media_discoverer.c
index 5c73174f2d..4f1f215062 100644
--- a/lib/media_discoverer.c
+++ b/lib/media_discoverer.c
@@ -41,7 +41,7 @@
 
 struct libvlc_media_discoverer_t
 {
-    libvlc_event_manager_t * p_event_manager;
+    libvlc_event_manager_t   event_manager;
     libvlc_instance_t *      p_libvlc_instance;
     services_discovery_t *   p_sd;
     libvlc_media_list_t *    p_mlist;
@@ -164,13 +164,7 @@ libvlc_media_discoverer_new( libvlc_instance_t * p_inst, const char * psz_name )
     p_mdis->p_sd = NULL;
 
     vlc_dictionary_init( &p_mdis->catname_to_submedialist, 0 );
-
-    p_mdis->p_event_manager = libvlc_event_manager_new( p_mdis );
-    if( unlikely(p_mdis->p_event_manager == NULL) )
-    {
-        free( p_mdis );
-        return NULL;
-    }
+    libvlc_event_manager_init( &p_mdis->event_manager, p_mdis );
 
     libvlc_retain( p_inst );
     strcpy( p_mdis->name, psz_name );
@@ -200,7 +194,7 @@ libvlc_media_discoverer_start( libvlc_media_discoverer_t * p_mdis )
 
     libvlc_event_t event;
     event.type = libvlc_MediaDiscovererStarted;
-    libvlc_event_send( p_mdis->p_event_manager, &event );
+    libvlc_event_send( &p_mdis->event_manager, &event );
     return 0;
 }
 
@@ -217,7 +211,7 @@ libvlc_media_discoverer_stop( libvlc_media_discoverer_t * p_mdis )
 
     libvlc_event_t event;
     event.type = libvlc_MediaDiscovererEnded;
-    libvlc_event_send( p_mdis->p_event_manager, &event );
+    libvlc_event_send( &p_mdis->event_manager, &event );
 
     vlc_sd_Destroy( p_mdis->p_sd );
     p_mdis->p_sd = NULL;
@@ -268,7 +262,7 @@ libvlc_media_discoverer_release( libvlc_media_discoverer_t * p_mdis )
     free( all_keys );
 
     vlc_dictionary_clear( &p_mdis->catname_to_submedialist, NULL, NULL );
-    libvlc_event_manager_release( p_mdis->p_event_manager );
+    libvlc_event_manager_destroy( &p_mdis->event_manager );
     libvlc_release( p_mdis->p_libvlc_instance );
 
     free( p_mdis );
@@ -301,7 +295,7 @@ libvlc_media_discoverer_media_list( libvlc_media_discoverer_t * p_mdis )
 libvlc_event_manager_t *
 libvlc_media_discoverer_event_manager( libvlc_media_discoverer_t * p_mdis )
 {
-    return p_mdis->p_event_manager;
+    return &p_mdis->event_manager;
 }
 
 



More information about the vlc-commits mailing list