[vlc-commits] mediadirs: use sub-item tree event rather than item event

Rémi Denis-Courmont git at videolan.org
Thu May 18 17:39:14 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed May 17 22:06:32 2017 +0300| [cf6691e002dae0ea73fccc1c4ffc6b8697827a78] | committer: Rémi Denis-Courmont

mediadirs: use sub-item tree event rather than item event

This makes no functional differences, but it dramatically reduces the
number of events.

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

 modules/services_discovery/mediadirs.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/modules/services_discovery/mediadirs.c b/modules/services_discovery/mediadirs.c
index 1a8e5fa580..69ded2d63f 100644
--- a/modules/services_discovery/mediadirs.c
+++ b/modules/services_discovery/mediadirs.c
@@ -97,7 +97,7 @@ vlc_module_end ()
 
 static void* Run( void* );
 
-static void input_item_subitem_added( const vlc_event_t*, void* );
+static void input_subnode_added( const vlc_event_t*, void* );
 static int onNewFileAdded( vlc_object_t*, char const *,
                            vlc_value_t, vlc_value_t, void *);
 
@@ -206,13 +206,13 @@ static void *Run( void *data )
 
 
         vlc_event_manager_t *p_em = &p_root->event_manager;
-        vlc_event_attach( p_em, vlc_InputItemSubItemAdded,
-                          input_item_subitem_added, p_sd );
+        vlc_event_attach( p_em, vlc_InputItemSubItemTreeAdded,
+                          input_subnode_added, p_sd );
 
         input_Read( p_sd, p_root );
 
-        vlc_event_detach( p_em, vlc_InputItemSubItemAdded,
-                          input_item_subitem_added, p_sd );
+        vlc_event_detach( p_em, vlc_InputItemSubItemTreeAdded,
+                          input_subnode_added, p_sd );
 
         input_item_Release( p_root );
         free( psz_uri );
@@ -242,19 +242,22 @@ static void Close( vlc_object_t *p_this )
 /*****************************************************************************
  * Callbacks and helper functions
  *****************************************************************************/
-static void input_item_subitem_added( const vlc_event_t * p_event,
-                                      void * user_data )
+static void input_subnode_added( const vlc_event_t *p_event, void *user_data )
 {
     services_discovery_t *p_sd = user_data;
     services_discovery_sys_t *p_sys = p_sd->p_sys;
+    input_item_node_t *root = p_event->u.input_item_subitem_tree_added.p_root;
 
-    /* retrieve new item */
-    input_item_t *p_item = p_event->u.input_item_subitem_added.p_new_child;
+    for( int i = 0; i < root->i_children; i++ )
+    {
+        input_item_node_t *child = root->pp_children[i];
+        input_item_t *item = child->p_item;
 
-    if( p_sys->i_type == Picture )
-        formatSnapshotItem( p_item );
+        if( p_sys->i_type == Picture )
+            formatSnapshotItem( item );
 
-    services_discovery_AddItem( p_sd, p_item );
+        services_discovery_AddItem( p_sd, item );
+    }
 }
 
 static int onNewFileAdded( vlc_object_t *p_this, char const *psz_var,



More information about the vlc-commits mailing list