[vlc-devel] [PATCH 11/14] input: pass thread event callbacks to input_Read()

Romain Vimont rom1v at videolabs.io
Thu Aug 16 16:02:08 CEST 2018


Add parameters for callbacks and user data so that the caller may
receive input thread events (e.g. "subtree added").
---
 include/vlc_input.h                    | 5 +++--
 lib/media_list.c                       | 3 ++-
 modules/services_discovery/mediadirs.c | 2 +-
 src/input/input.c                      | 7 ++++---
 src/playlist/loadsave.c                | 2 +-
 5 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index 743f0e39bd..f6e687c73e 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -602,8 +602,9 @@ VLC_API int input_Start( input_thread_t * );
 
 VLC_API void input_Stop( input_thread_t * );
 
-VLC_API int input_Read( vlc_object_t *, input_item_t * );
-#define input_Read(a,b) input_Read(VLC_OBJECT(a),b)
+VLC_API int input_Read( vlc_object_t *, input_item_t *,
+                        input_thread_events_cb, void * );
+#define input_Read(a,b,c,d) input_Read(VLC_OBJECT(a),b,c,d)
 
 VLC_API int input_vaControl( input_thread_t *, int i_query, va_list  );
 
diff --git a/lib/media_list.c b/lib/media_list.c
index 7c93e41d5f..720c7d522f 100644
--- a/lib/media_list.c
+++ b/lib/media_list.c
@@ -257,7 +257,8 @@ libvlc_media_list_add_file_content( libvlc_media_list_t * p_mlist,
         return -1;
     }
 
-    input_Read( p_mlist->p_libvlc_instance->p_libvlc_int, p_input_item );
+    input_Read( p_mlist->p_libvlc_instance->p_libvlc_int, p_input_item,
+                NULL, NULL );
     return 0;
 }
 
diff --git a/modules/services_discovery/mediadirs.c b/modules/services_discovery/mediadirs.c
index 65ddb129c8..8f0c3025a0 100644
--- a/modules/services_discovery/mediadirs.c
+++ b/modules/services_discovery/mediadirs.c
@@ -209,7 +209,7 @@ static void *Run( void *data )
         vlc_event_attach( p_em, vlc_InputItemSubItemTreeAdded,
                           input_subnode_added, p_sd );
 
-        input_Read( p_sd, p_root );
+        input_Read( p_sd, p_root, NULL, NULL );
 
         vlc_event_detach( p_em, vlc_InputItemSubItemTreeAdded,
                           input_subnode_added, p_sd );
diff --git a/src/input/input.c b/src/input/input.c
index 58a726bb97..ebbebaa196 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -143,10 +143,11 @@ input_thread_t *input_Create( vlc_object_t *p_parent,
  * \param p_item an input item
  * \return an error code, VLC_SUCCESS on success
  */
-int input_Read( vlc_object_t *p_parent, input_item_t *p_item )
+int input_Read( vlc_object_t *p_parent, input_item_t *p_item,
+                input_thread_events_cb events_cb, void *events_data )
 {
-    input_thread_t *p_input = Create( p_parent, NULL, NULL, p_item, NULL, false,
-                                      NULL, NULL );
+    input_thread_t *p_input = Create( p_parent, events_cb, events_data, p_item,
+                                      NULL, false, NULL, NULL );
     if( !p_input )
         return VLC_EGENERIC;
 
diff --git a/src/playlist/loadsave.c b/src/playlist/loadsave.c
index 790aed4031..0f4d6480fa 100644
--- a/src/playlist/loadsave.c
+++ b/src/playlist/loadsave.c
@@ -103,7 +103,7 @@ int playlist_Import( playlist_t *p_playlist, const char *psz_file )
     vlc_object_t *dummy = vlc_object_create( p_playlist, sizeof (*dummy) );
     var_Create( dummy, "meta-file", VLC_VAR_VOID );
 
-    int ret = input_Read( dummy, p_input );
+    int ret = input_Read( dummy, p_input, NULL, NULL );
 
     vlc_object_release( dummy );
     return ret;
-- 
2.18.0



More information about the vlc-devel mailing list