[vlc-devel] [PATCH 1/2] input: add META_REQUEST flag to force user interaction

Thomas Guillem thomas at gllm.fr
Wed Feb 3 18:03:35 CET 2016


If this flag is set, the input thread will be able to fire up dialogs even when
preparsing.
---
 include/vlc_input_item.h    |  3 ++-
 src/input/input.c           | 15 +++++++++------
 src/input/input_interface.h |  4 +++-
 src/playlist/preparser.c    |  3 ++-
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index 1587e53..a9a9bc1 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -320,7 +320,8 @@ typedef enum input_item_meta_request_option_t
     META_REQUEST_OPTION_NONE          = 0x00,
     META_REQUEST_OPTION_SCOPE_LOCAL   = 0x01,
     META_REQUEST_OPTION_SCOPE_NETWORK = 0x02,
-    META_REQUEST_OPTION_SCOPE_ANY     = 0x03
+    META_REQUEST_OPTION_SCOPE_ANY     = 0x03,
+    META_REQUEST_OPTION_DO_INTERACT   = 0x04
 } input_item_meta_request_option_t;
 
 VLC_API int libvlc_MetaRequest(libvlc_int_t *, input_item_t *,
diff --git a/src/input/input.c b/src/input/input.c
index a5d408c..4fd0015 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -59,7 +59,7 @@ static  void *Run( void * );
 static  void *Preparse( void * );
 
 static input_thread_t * Create  ( vlc_object_t *, input_item_t *,
-                                  const char *, bool, input_resource_t * );
+                                  const char *, bool, input_resource_t *, bool );
 static  int             Init    ( input_thread_t *p_input );
 static void             End     ( input_thread_t *p_input );
 static void             MainLoop( input_thread_t *p_input, bool b_interactive );
@@ -123,7 +123,7 @@ input_thread_t *input_Create( vlc_object_t *p_parent,
                               input_item_t *p_item,
                               const char *psz_log, input_resource_t *p_resource )
 {
-    return Create( p_parent, p_item, psz_log, false, p_resource );
+    return Create( p_parent, p_item, psz_log, false, p_resource, false );
 }
 
 #undef input_Read
@@ -136,7 +136,7 @@ input_thread_t *input_Create( vlc_object_t *p_parent,
  */
 int input_Read( vlc_object_t *p_parent, input_item_t *p_item )
 {
-    input_thread_t *p_input = Create( p_parent, p_item, NULL, false, NULL );
+    input_thread_t *p_input = Create( p_parent, p_item, NULL, false, NULL, false );
     if( !p_input )
         return VLC_EGENERIC;
 
@@ -151,9 +151,9 @@ int input_Read( vlc_object_t *p_parent, input_item_t *p_item )
 }
 
 input_thread_t *input_CreatePreparser( vlc_object_t *parent,
-                                       input_item_t *item )
+                                       input_item_t *item, bool interact )
 {
-    return Create( parent, item, NULL, true, NULL );
+    return Create( parent, item, NULL, true, NULL, interact );
 }
 
 /**
@@ -274,7 +274,8 @@ input_item_t *input_GetItem( input_thread_t *p_input )
  *****************************************************************************/
 static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
                                const char *psz_header, bool b_quick,
-                               input_resource_t *p_resource )
+                               input_resource_t *p_resource,
+                               bool b_force_interact )
 {
     input_thread_t *p_input = NULL;                 /* thread descriptor */
 
@@ -445,6 +446,8 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     /* Make sure the interaction option is honored */
     if( !var_InheritBool( p_input, "interact" ) )
         p_input->i_flags |= OBJECT_FLAGS_NOINTERACT;
+    else if( b_force_interact )
+        p_input->i_flags &= ~OBJECT_FLAGS_NOINTERACT;
 
     /* */
     memset( &p_input->p->counters, 0, sizeof( p_input->p->counters ) );
diff --git a/src/input/input_interface.h b/src/input/input_interface.h
index a3890f7..6eb687d 100644
--- a/src/input/input_interface.h
+++ b/src/input/input_interface.h
@@ -45,9 +45,11 @@ void input_item_SetEpgOffline( input_item_t * );
  *
  * @param obj parent object
  * @param item input item to preparse
+ * @param interact true if the input can interact with the user (with dialogs)
  * @return an input thread or NULL on error
  */
-input_thread_t *input_CreatePreparser(vlc_object_t *obj, input_item_t *item)
+input_thread_t *input_CreatePreparser(vlc_object_t *obj, input_item_t *item,
+                                      bool interact)
 VLC_USED;
 
 /* misc/stats.c
diff --git a/src/playlist/preparser.c b/src/playlist/preparser.c
index 2870875..0d72834 100644
--- a/src/playlist/preparser.c
+++ b/src/playlist/preparser.c
@@ -183,8 +183,9 @@ static void Preparse( playlist_preparser_t *preparser, input_item_t *p_item,
     /* Do not preparse if it is already done (like by playing it) */
     if( b_preparse && !input_item_IsPreparsed( p_item ) )
     {
+        bool b_interact = i_options & META_REQUEST_OPTION_DO_INTERACT;
         input_thread_t *input = input_CreatePreparser( preparser->object,
-                                                       p_item );
+                                                       p_item, b_interact );
         if( input == NULL )
             return;
 
-- 
2.7.0.rc3



More information about the vlc-devel mailing list