[vlc-commits] rd: simplify events handling

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


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun May 14 22:26:05 2017 +0300| [c91959027c95c3fecb51df3f6cd83af30ef2a7b8] | committer: Rémi Denis-Courmont

rd: simplify events handling

Use fixed owner structure instead of deprecated VLC events.

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

 include/vlc_events.h                      | 14 -----
 include/vlc_renderer_discovery.h          | 39 +++++++------
 lib/renderer_discoverer.c                 | 52 ++++++++---------
 modules/gui/macosx/VLCRendererDiscovery.m | 87 +++++++++++++---------------
 modules/gui/qt/actions_manager.cpp        | 96 +++++++++++++++----------------
 modules/gui/qt/actions_manager.hpp        |  5 +-
 src/libvlccore.sym                        |  1 -
 src/misc/renderer_discovery.c             | 36 +-----------
 8 files changed, 139 insertions(+), 191 deletions(-)

diff --git a/include/vlc_events.h b/include/vlc_events.h
index aef8301cdc..2dd154c1d1 100644
--- a/include/vlc_events.h
+++ b/include/vlc_events.h
@@ -120,10 +120,6 @@ typedef enum vlc_event_type_t {
     vlc_InputItemInfoChanged,
     vlc_InputItemErrorWhenReadingChanged,
     vlc_InputItemPreparseEnded,
-
-    /* Renderer Discovery events */
-    vlc_RendererDiscoveryItemAdded=vlc_InputItemPreparseEnded+6,
-    vlc_RendererDiscoveryItemRemoved,
 } vlc_event_type_t;
 
 /* Event definition */
@@ -170,16 +166,6 @@ typedef struct vlc_event_t
         {
             int new_status;
         } input_item_preparse_ended;
-
-        /* Renderer discovery events */
-        struct vlc_renderer_discovery_item_added
-        {
-            vlc_renderer_item_t * p_new_item;
-        } renderer_discovery_item_added;
-        struct vlc_renderer_discovery_item_removed
-        {
-            vlc_renderer_item_t * p_item;
-        } renderer_discovery_item_removed;
     } u;
 } vlc_event_t;
 
diff --git a/include/vlc_renderer_discovery.h b/include/vlc_renderer_discovery.h
index 3ed26b56ea..2a9f18f2d8 100644
--- a/include/vlc_renderer_discovery.h
+++ b/include/vlc_renderer_discovery.h
@@ -22,7 +22,6 @@
 #define VLC_RENDERER_DISCOVERY_H 1
 
 #include <vlc_input.h>
-#include <vlc_events.h>
 #include <vlc_probe.h>
 #include <vlc_url.h>
 
@@ -115,6 +114,7 @@ vlc_renderer_item_flags(const vlc_renderer_item_t *p_item);
  */
 
 typedef struct vlc_renderer_discovery_sys vlc_renderer_discovery_sys;
+struct vlc_renderer_discovery_owner;
 
 /**
  * Return a list of renderer discovery modules
@@ -141,20 +141,12 @@ vlc_rd_get_names(vlc_object_t *p_obj, char ***pppsz_names,
  * vlc_rd_release()
  */
 VLC_API vlc_renderer_discovery_t *
-vlc_rd_new(vlc_object_t *p_obj, const char *psz_name) VLC_USED;
+vlc_rd_new(vlc_object_t *p_obj, const char *psz_name,
+           const struct vlc_renderer_discovery_owner *owner) VLC_USED;
 
 VLC_API void vlc_rd_release(vlc_renderer_discovery_t *p_rd);
 
 /**
- * Get the event manager of the renderer discovery module
- *
- * @see vlc_RendererDiscoveryItemAdded
- * @see vlc_RendererDiscoveryItemRemoved
- */
-VLC_API vlc_event_manager_t *
-vlc_rd_event_manager(vlc_renderer_discovery_t *p_rd);
-
-/**
  * Start the renderer discovery module
  *
  * Once started, the module can send new vlc_renderer_item_t via the
@@ -169,12 +161,21 @@ vlc_rd_start(vlc_renderer_discovery_t *p_rd);
  * @{
  */
 
+struct vlc_renderer_discovery_owner
+{
+    void *sys;
+    void (*item_added)(struct vlc_renderer_discovery_t *,
+                       struct vlc_renderer_item_t *);
+    void (*item_removed)(struct vlc_renderer_discovery_t *,
+                         struct vlc_renderer_item_t *);
+};
+
 struct vlc_renderer_discovery_t
 {
     VLC_COMMON_MEMBERS
     module_t *          p_module;
 
-    vlc_event_manager_t event_manager;
+    struct vlc_renderer_discovery_owner owner;
 
     char *              psz_name;
     config_chain_t *    p_cfg;
@@ -187,16 +188,22 @@ struct vlc_renderer_discovery_t
  *
  * This will send the vlc_RendererDiscoveryItemAdded event
  */
-VLC_API void
-vlc_rd_add_item(vlc_renderer_discovery_t * p_rd, vlc_renderer_item_t * p_item);
+static inline void vlc_rd_add_item(vlc_renderer_discovery_t * p_rd,
+                                   vlc_renderer_item_t * p_item)
+{
+    p_rd->owner.item_added(p_rd, p_item);
+}
 
 /**
  * Add a new renderer item
  *
  * This will send the vlc_RendererDiscoveryItemRemoved event
  */
-VLC_API void
-vlc_rd_remove_item(vlc_renderer_discovery_t * p_rd, vlc_renderer_item_t * p_item);
+static inline void vlc_rd_remove_item(vlc_renderer_discovery_t * p_rd,
+                                      vlc_renderer_item_t * p_item)
+{
+    p_rd->owner.item_removed(p_rd, p_item);
+}
 
 /**
  * Renderer Discovery proble helpers
diff --git a/lib/renderer_discoverer.c b/lib/renderer_discoverer.c
index b9d49822b6..63614c40a0 100644
--- a/lib/renderer_discoverer.c
+++ b/lib/renderer_discoverer.c
@@ -34,11 +34,13 @@
 
 struct libvlc_renderer_discoverer_t
 {
+    vlc_object_t *          p_object;
     vlc_renderer_discovery_t *p_rd;
     libvlc_event_manager_t *p_event_manager;
 
     int                     i_items;
     vlc_renderer_item_t **  pp_items;
+    char                    name[];
 };
 
 static_assert( VLC_RENDERER_CAN_AUDIO == LIBVLC_RENDERER_CAN_AUDIO &&
@@ -51,12 +53,10 @@ libvlc_renderer_item_to_vlc( const libvlc_renderer_item_t *p_item )
     return (const vlc_renderer_item_t*) p_item;
 }
 
-static void
-renderer_discovery_item_added( const vlc_event_t *p_event, void *p_user_data )
+static void renderer_discovery_item_added( vlc_renderer_discovery_t *rd,
+                                           vlc_renderer_item_t *p_item )
 {
-    libvlc_renderer_discoverer_t *p_lrd = p_user_data;
-    vlc_renderer_item_t *p_item =
-        p_event->u.renderer_discovery_item_added.p_new_item;
+    libvlc_renderer_discoverer_t *p_lrd = rd->owner.sys;
 
     vlc_renderer_item_hold( p_item );
 
@@ -70,12 +70,10 @@ renderer_discovery_item_added( const vlc_event_t *p_event, void *p_user_data )
     libvlc_event_send( p_lrd->p_event_manager, &event );
 }
 
-static void
-renderer_discovery_item_removed( const vlc_event_t *p_event, void *p_user_data )
+static void renderer_discovery_item_removed( vlc_renderer_discovery_t *rd,
+                                             vlc_renderer_item_t *p_item )
 {
-    libvlc_renderer_discoverer_t *p_lrd = p_user_data;
-    vlc_renderer_item_t *p_item =
-        p_event->u.renderer_discovery_item_removed.p_item;
+    libvlc_renderer_discoverer_t *p_lrd = rd->owner.sys;
 
     int i_idx;
     TAB_FIND( p_lrd->i_items, p_lrd->pp_items, p_item, i_idx );
@@ -120,33 +118,21 @@ libvlc_renderer_discoverer_t *
 libvlc_renderer_discoverer_new( libvlc_instance_t *p_inst,
                                 const char *psz_name )
 {
-    libvlc_renderer_discoverer_t *p_lrd =
-        calloc( 1, sizeof(libvlc_renderer_discoverer_t) );
+    size_t len = strlen( psz_name ) + 1;
+    libvlc_renderer_discoverer_t *p_lrd = malloc( sizeof(*p_lrd) + len );
 
     if( unlikely(p_lrd == NULL) )
         return NULL;
 
-    p_lrd->p_rd = vlc_rd_new( VLC_OBJECT( p_inst->p_libvlc_int ), psz_name );
-    if( unlikely(p_lrd->p_rd == NULL) )
-        goto error;
-
+    p_lrd->p_object = VLC_OBJECT(p_inst->p_libvlc_int);
+    memcpy( p_lrd->name, psz_name, len );
     TAB_INIT( p_lrd->i_items, p_lrd->pp_items );
+    p_lrd->p_rd = NULL;
 
     p_lrd->p_event_manager = libvlc_event_manager_new( p_lrd );
     if( unlikely(p_lrd->p_event_manager == NULL) )
         goto error;
 
-    vlc_event_manager_t *p_rd_ev = vlc_rd_event_manager( p_lrd->p_rd );
-
-    if( vlc_event_attach( p_rd_ev, vlc_RendererDiscoveryItemAdded,
-                          renderer_discovery_item_added, p_lrd )
-                          != VLC_SUCCESS )
-        goto error;
-    if( vlc_event_attach( p_rd_ev, vlc_RendererDiscoveryItemRemoved,
-                          renderer_discovery_item_removed, p_lrd )
-                          != VLC_SUCCESS )
-        goto error;
-
     return p_lrd;
 
 error:
@@ -168,7 +154,17 @@ libvlc_renderer_discoverer_release( libvlc_renderer_discoverer_t *p_lrd )
 int
 libvlc_renderer_discoverer_start( libvlc_renderer_discoverer_t *p_lrd )
 {
-    return vlc_rd_start( p_lrd->p_rd );
+    assert( p_lrd->p_rd == NULL );
+
+    struct vlc_renderer_discovery_owner owner =
+    {
+        p_lrd,
+        renderer_discovery_item_added,
+        renderer_discovery_item_removed,
+    };
+
+    p_lrd->p_rd = vlc_rd_new( p_lrd->p_object, p_lrd->name, &owner );
+    return p_lrd->p_rd != NULL ? 0 : -1;
 }
 
 void
diff --git a/modules/gui/macosx/VLCRendererDiscovery.m b/modules/gui/macosx/VLCRendererDiscovery.m
index c6f0ad5faa..c52485da12 100644
--- a/modules/gui/macosx/VLCRendererDiscovery.m
+++ b/modules/gui/macosx/VLCRendererDiscovery.m
@@ -34,14 +34,23 @@
     vlc_renderer_discovery_t    *p_rd;
 }
 
-- (void)handleEvent:(const vlc_event_t *)event;
+- (void)handleItemAdded:(const vlc_renderer_item_t *)item;
+- (void)handleItemRemoved:(const vlc_renderer_item_t *)item;
 @end
 
-// C callback event handler function for vlc_event_manager
-static void renderer_event_received(const vlc_event_t *p_event, void *user_data)
+// C callback event handler functions
+static void renderer_event_item_added(vlc_renderer_discovery_t *rd,
+                                      vlc_renderer_item_t *item)
 {
-    VLCRendererDiscovery *target = (__bridge VLCRendererDiscovery*)user_data;
-    [target handleEvent:p_event];
+    VLCRendererDiscovery *target = (__bridge VLCRendererDiscovery*)rd->owner.sys;
+    [target handleItemAdded:item];
+}
+
+static void renderer_event_item_removed(vlc_renderer_discovery_t *rd,
+                                        vlc_renderer_item_t *item)
+{
+    VLCRendererDiscovery *target = (__bridge VLCRendererDiscovery*)rd->owner.sys;
+    [target handleItemRemoved:item];
 }
 
 @implementation VLCRendererDiscovery
@@ -67,11 +76,18 @@ static void renderer_event_received(const vlc_event_t *p_event, void *user_data)
 
 - (bool)startDiscovery
 {
+    struct vlc_renderer_discovery_owner owner =
+    {
+        self,
+        renderer_event_item_added,
+        renderer_event_item_removed,
+    };
+
     p_intf = getIntf();
 
     msg_Dbg(p_intf, "Starting renderer discovery service %s", _name.UTF8String);
     // Create renderer object
-    p_rd = vlc_rd_new(VLC_OBJECT(p_intf), _name.UTF8String);
+    p_rd = vlc_rd_new(VLC_OBJECT(p_intf), _name.UTF8String, &owner);
 
     if (p_rd) {
     } else {
@@ -79,11 +95,9 @@ static void renderer_event_received(const vlc_event_t *p_event, void *user_data)
         return false;
     }
 
-    [self attachEventHandlers];
     int ret = vlc_rd_start(p_rd);
     if (ret != VLC_SUCCESS) {
         msg_Err(p_intf, "Could not start '%s' renderer discovery", _name.UTF8String);
-        [self detachEventHandler];
         vlc_rd_release(p_rd);
         p_rd = NULL;
         return false;
@@ -94,56 +108,35 @@ static void renderer_event_received(const vlc_event_t *p_event, void *user_data)
 - (void)stopDiscovery
 {
     if (p_rd != NULL) {
-        [self detachEventHandler];
         vlc_rd_release(p_rd);
         p_rd = NULL;
     }
 }
 
-- (void)attachEventHandlers
-{
-    vlc_event_manager_t *em = vlc_rd_event_manager(p_rd);
-    vlc_event_attach(em, vlc_RendererDiscoveryItemAdded, renderer_event_received, (__bridge void *)self);
-    vlc_event_attach(em, vlc_RendererDiscoveryItemRemoved, renderer_event_received, (__bridge void *)self);
-}
-
-- (void)detachEventHandler
+- (void)handleItemAdded:(const vlc_renderer_item_t *)base_item
 {
-    vlc_event_manager_t *em = vlc_rd_event_manager(p_rd);
-    vlc_event_detach(em, vlc_RendererDiscoveryItemAdded, renderer_event_received, (__bridge void *)self);
-    vlc_event_detach(em, vlc_RendererDiscoveryItemRemoved, renderer_event_received, (__bridge void *)self);
+    VLCRendererItem *item = [[VLCRendererItem alloc] initWithRendererItem:base_item];
+    [_rendererItems addObject:item];
+    if (_delegate)
+        [_delegate addedRendererItem:item from:self];
 }
 
-- (void)handleEvent:(const vlc_event_t *)event
+- (void)handleItemRemoved:(const vlc_renderer_item_t *)base_item
 {
-    if (event->type == vlc_RendererDiscoveryItemAdded) {
-        vlc_renderer_item_t *base_item =  event->u.renderer_discovery_item_added.p_new_item;
-        VLCRendererItem *item = [[VLCRendererItem alloc] initWithRendererItem:base_item];
-        [_rendererItems addObject:item];
-        if (_delegate)
-            [_delegate addedRendererItem:item from:self];
-        return;
-    }
-    if (event->type == vlc_RendererDiscoveryItemRemoved) {
-        vlc_renderer_item_t *base_item =  event->u.renderer_discovery_item_removed.p_item;
-
-        VLCRendererItem *result_item = nil;
-        for (VLCRendererItem *item in _rendererItems) {
-            if (item.rendererItem == base_item) {
-                result_item = item;
-                return;
-            }
-        }
-        if (result_item) {
-            [_rendererItems removeObject:result_item];
-            if (_delegate)
-                [_delegate removedRendererItem:result_item from:self];
-        } else {
-            msg_Err(p_intf, "VLCRendererDiscovery could not find item to remove!");
+    VLCRendererItem *result_item = nil;
+    for (VLCRendererItem *item in _rendererItems) {
+        if (item.rendererItem == base_item) {
+            result_item = item;
+            return;
         }
-        return;
     }
-    msg_Err(p_intf, "VLCRendererDiscovery received event of unhandled type");
+    if (result_item) {
+        [_rendererItems removeObject:result_item];
+        if (_delegate)
+            [_delegate removedRendererItem:result_item from:self];
+    } else {
+        msg_Err(p_intf, "VLCRendererDiscovery could not find item to remove!");
+    }
 }
 
 @end
diff --git a/modules/gui/qt/actions_manager.cpp b/modules/gui/qt/actions_manager.cpp
index bc59217d0a..f81d9ec7d8 100644
--- a/modules/gui/qt/actions_manager.cpp
+++ b/modules/gui/qt/actions_manager.cpp
@@ -46,12 +46,7 @@ ActionsManager::ActionsManager( intf_thread_t * _p_i )
 ActionsManager::~ActionsManager()
 {
     if ( p_rd != NULL )
-    {
-        vlc_event_manager_t *em = vlc_rd_event_manager( p_rd );
-        vlc_event_detach( em, vlc_RendererDiscoveryItemAdded, renderer_event_received, p_intf);
-        vlc_event_detach( em, vlc_RendererDiscoveryItemRemoved, renderer_event_received, p_intf);
         vlc_rd_release( p_rd );
-    }
 }
 
 void ActionsManager::doAction( int id_action )
@@ -238,52 +233,54 @@ bool ActionsManager::isItemSout( QVariant & m_obj, const char *psz_sout, bool as
     return QString::compare( hash["sout"].toString(), renderer, Qt::CaseInsensitive) == 0;
 }
 
-void ActionsManager::renderer_event_received( const vlc_event_t * p_event, void * user_data )
+void ActionsManager::renderer_event_item_added(
+    vlc_renderer_discovery_t *rd, vlc_renderer_item_t *p_item )
 {
-    intf_thread_t *p_intf = reinterpret_cast<intf_thread_t*>(user_data);
+    intf_thread_t *p_intf = reinterpret_cast<intf_thread_t*>(rd->owner.sys);
+    QAction *firstSeparator = NULL;
 
-    if ( p_event->type == vlc_RendererDiscoveryItemAdded )
+    foreach (QAction* action, VLCMenuBar::rendererMenu->actions())
     {
-        vlc_renderer_item_t *p_item =  p_event->u.renderer_discovery_item_added.p_new_item;
-
-        QAction *firstSeparator = NULL;
-        foreach (QAction* action, VLCMenuBar::rendererMenu->actions())
+        if (action->isSeparator())
         {
-            if (action->isSeparator())
-            {
-                firstSeparator = action;
-                break;
-            }
-            QVariant v = action->data();
-            if ( isItemSout( v, vlc_renderer_item_sout( p_item ), false ) )
-                return; /* we already have this item */
+            firstSeparator = action;
+            break;
         }
+        QVariant v = action->data();
+        if ( isItemSout( v, vlc_renderer_item_sout( p_item ), false ) )
+            return; /* we already have this item */
+    }
 
-        QHash<QString,QVariant> itemData;
-        itemData.insert("sout", vlc_renderer_item_sout( p_item ));
-        itemData.insert("filter", vlc_renderer_item_demux_filter( p_item ));
-        QVariant data(itemData);
+    QHash<QString,QVariant> itemData;
+    itemData.insert("sout", vlc_renderer_item_sout( p_item ));
+    itemData.insert("filter", vlc_renderer_item_demux_filter( p_item ));
+    QVariant data(itemData);
 
-        QAction *action = new QAction( vlc_renderer_item_flags(p_item) & VLC_RENDERER_CAN_VIDEO ? QIcon( ":/sidebar/movie" ) : QIcon( ":/sidebar/music" ),
-                                       vlc_renderer_item_name(p_item), VLCMenuBar::rendererMenu );
-        action->setCheckable(true);
-        action->setData(data);
-        if (firstSeparator != NULL)
-        {
-            VLCMenuBar::rendererMenu->insertAction( firstSeparator, action );
-            VLCMenuBar::rendererGroup->addAction(action);
-        }
+    QAction *action = new QAction( vlc_renderer_item_flags(p_item) & VLC_RENDERER_CAN_VIDEO ? QIcon( ":/sidebar/movie" ) : QIcon( ":/sidebar/music" ),
+                                   vlc_renderer_item_name(p_item), VLCMenuBar::rendererMenu );
+    action->setCheckable(true);
+    action->setData(data);
+    if (firstSeparator != NULL)
+    {
+        VLCMenuBar::rendererMenu->insertAction( firstSeparator, action );
+        VLCMenuBar::rendererGroup->addAction(action);
+    }
 
-        char *psz_renderer = var_InheritString( THEPL, "sout" );
-        if ( psz_renderer != NULL )
-        {
-            if ( isItemSout( data, psz_renderer, true ) )
-                action->setChecked( true );
-            free( psz_renderer );
-        }
+    char *psz_renderer = var_InheritString( THEPL, "sout" );
+    if ( psz_renderer != NULL )
+    {
+        if ( isItemSout( data, psz_renderer, true ) )
+            action->setChecked( true );
+        free( psz_renderer );
     }
 }
 
+void ActionsManager::renderer_event_item_removed(
+    vlc_renderer_discovery_t *rd, vlc_renderer_item_t *p_item )
+{
+    (void) rd; (void) p_item;
+}
+
 void ActionsManager::ScanRendererAction(bool checked)
 {
     if (checked == (p_rd != NULL))
@@ -320,6 +317,13 @@ void ActionsManager::ScanRendererAction(bool checked)
         if( vlc_rd_get_names( THEPL, &ppsz_names, &ppsz_longnames ) != VLC_SUCCESS )
             return;
 
+        struct vlc_renderer_discovery_owner owner =
+        {
+            p_intf,
+            renderer_event_item_added,
+            renderer_event_item_removed,
+        };
+
         char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
         for( ; *ppsz_name; ppsz_name++, ppsz_longname++ )
         {
@@ -327,7 +331,7 @@ void ActionsManager::ScanRendererAction(bool checked)
             msg_Dbg( p_intf, "starting renderer discovery service %s", *ppsz_longname );
             if ( p_rd == NULL )
             {
-                p_rd = vlc_rd_new( VLC_OBJECT(p_intf), *ppsz_name );
+                p_rd = vlc_rd_new( VLC_OBJECT(p_intf), *ppsz_name, &owner );
                 if( !p_rd )
                     msg_Err( p_intf, "Could not start renderer discovery services" );
             }
@@ -338,14 +342,8 @@ void ActionsManager::ScanRendererAction(bool checked)
 
         if ( p_rd != NULL )
         {
-            vlc_event_manager_t *em = vlc_rd_event_manager( p_rd );
-            vlc_event_attach( em, vlc_RendererDiscoveryItemAdded, renderer_event_received, p_intf);
-            vlc_event_attach( em, vlc_RendererDiscoveryItemRemoved, renderer_event_received, p_intf);
-
             if( vlc_rd_start( p_rd ) != VLC_SUCCESS )
             {
-                vlc_event_detach( em, vlc_RendererDiscoveryItemAdded, renderer_event_received, p_intf);
-                vlc_event_detach( em, vlc_RendererDiscoveryItemRemoved, renderer_event_received, p_intf);
                 vlc_rd_release( p_rd );
                 p_rd = NULL;
             }
@@ -355,10 +353,6 @@ void ActionsManager::ScanRendererAction(bool checked)
     {
         if ( p_rd != NULL )
         {
-            vlc_event_manager_t *em = vlc_rd_event_manager( p_rd );
-            vlc_event_detach( em, vlc_RendererDiscoveryItemAdded, renderer_event_received, p_intf);
-            vlc_event_detach( em, vlc_RendererDiscoveryItemRemoved, renderer_event_received, p_intf);
-
             vlc_rd_release( p_rd );
             p_rd = NULL;
         }
diff --git a/modules/gui/qt/actions_manager.hpp b/modules/gui/qt/actions_manager.hpp
index 9acdf34dab..04a299bbff 100644
--- a/modules/gui/qt/actions_manager.hpp
+++ b/modules/gui/qt/actions_manager.hpp
@@ -76,7 +76,10 @@ private:
     intf_thread_t* const p_intf;
     vlc_renderer_discovery_t *p_rd;
 
-    static void renderer_event_received( const vlc_event_t * p_event, void * user_data );
+    static void renderer_event_item_added( vlc_renderer_discovery_t *,
+                                           vlc_renderer_item_t * );
+    static void renderer_event_item_removed( vlc_renderer_discovery_t *,
+                                             vlc_renderer_item_t * );
     static bool isItemSout( QVariant & m_obj, const char *psz_sout, bool as_output );
 
 public slots:
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 5a1b571467..0cceb63341 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -765,7 +765,6 @@ vlc_renderer_item_flags
 vlc_rd_get_names
 vlc_rd_new
 vlc_rd_release
-vlc_rd_event_manager
 vlc_rd_start
 vlc_rd_add_item
 vlc_rd_remove_item
diff --git a/src/misc/renderer_discovery.c b/src/misc/renderer_discovery.c
index 45c776d0eb..6a8448e2f8 100644
--- a/src/misc/renderer_discovery.c
+++ b/src/misc/renderer_discovery.c
@@ -26,7 +26,6 @@
 
 #include <vlc_common.h>
 #include <vlc_atomic.h>
-#include <vlc_events.h>
 #include <vlc_renderer_discovery.h>
 #include <vlc_probe.h>
 #include <vlc_modules.h>
@@ -240,12 +239,12 @@ void vlc_rd_release(vlc_renderer_discovery_t *p_rd)
 
     config_ChainDestroy(p_rd->p_cfg);
     free(p_rd->psz_name);
-    vlc_event_manager_fini(&p_rd->event_manager);
     vlc_object_release(p_rd);
 }
 
 vlc_renderer_discovery_t *
-vlc_rd_new(vlc_object_t *p_obj, const char *psz_name)
+vlc_rd_new(vlc_object_t *p_obj, const char *psz_name,
+           const struct vlc_renderer_discovery_owner *restrict owner)
 {
     vlc_renderer_discovery_t *p_rd;
 
@@ -254,21 +253,12 @@ vlc_rd_new(vlc_object_t *p_obj, const char *psz_name)
         return NULL;
     free(config_ChainCreate(&p_rd->psz_name, &p_rd->p_cfg, psz_name));
 
-    vlc_event_manager_t *p_em = &p_rd->event_manager;
-    vlc_event_manager_init(p_em, p_rd);
-    vlc_event_manager_register_event_type(p_em, vlc_RendererDiscoveryItemAdded);
-    vlc_event_manager_register_event_type(p_em, vlc_RendererDiscoveryItemRemoved);
+    p_rd->owner = *owner;
 
     p_rd->p_module = NULL;
     return p_rd;
 }
 
-VLC_API vlc_event_manager_t *
-vlc_rd_event_manager(vlc_renderer_discovery_t *p_rd)
-{
-    return &p_rd->event_manager;
-}
-
 int
 vlc_rd_start(vlc_renderer_discovery_t *p_rd)
 {
@@ -284,23 +274,3 @@ vlc_rd_start(vlc_renderer_discovery_t *p_rd)
 
     return VLC_SUCCESS;
 }
-
-void
-vlc_rd_add_item(vlc_renderer_discovery_t * p_rd, vlc_renderer_item_t * p_item)
-{
-    vlc_event_t event;
-    event.type = vlc_RendererDiscoveryItemAdded;
-    event.u.renderer_discovery_item_added.p_new_item = p_item;
-
-    vlc_event_send(&p_rd->event_manager, &event);
-}
-
-void
-vlc_rd_remove_item(vlc_renderer_discovery_t * p_rd, vlc_renderer_item_t * p_item)
-{
-    vlc_event_t event;
-    event.type = vlc_RendererDiscoveryItemRemoved;
-    event.u.renderer_discovery_item_removed.p_item = p_item;
-
-    vlc_event_send(&p_rd->event_manager, &event);
-}



More information about the vlc-commits mailing list