[vlc-commits] input: add a META_REQUEST flag to force user interaction

Thomas Guillem git at videolan.org
Thu Feb 4 15:28:07 CET 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Feb  3 17:47:16 2016 +0100| [fb7313e0ca7af2e56cfb993f32beeb9002fb87e5] | committer: Thomas Guillem

input: add a META_REQUEST flag to force user interaction

It this flag is set, user interaction will be forced when preparsing the item
given by libvlc_MetaRequest (there won't be user interactions for sub items).

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

 include/vlc_input_item.h |    6 +++++-
 src/input/input.c        |   23 +++++++++++++++--------
 src/libvlc.c             |    2 ++
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index 1587e53..4391c72 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -94,6 +94,9 @@ struct input_item_t
 
     int         i_preparse_depth;    /**< How many level of sub items can be preparsed:
                                           -1: recursive, 0: none, >0: n levels */
+
+    bool        b_preparse_interact; /**< Force interaction with the user when
+                                          preparsing.*/
 };
 
 TYPEDEF_ARRAY(input_item_t*, input_item_array_t)
@@ -320,7 +323,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 72f1b3c..9836b78 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -355,6 +355,21 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
             p_item->i_preparse_depth = -1;
     }
 
+    /* */
+    if( p_input->b_preparsing )
+        p_input->i_flags |= OBJECT_FLAGS_QUIET | OBJECT_FLAGS_NOINTERACT;
+
+    /* Make sure the interaction option is honored */
+    if( !var_InheritBool( p_input, "interact" ) )
+        p_input->i_flags |= OBJECT_FLAGS_NOINTERACT;
+    else if( p_item->b_preparse_interact )
+    {
+        /* If true, this item was asked explicitly to interact with the user
+         * (via libvlc_MetaRequest). Sub items created from this input won't
+         * have this flag and won't interact with the user */
+        p_input->i_flags &= ~OBJECT_FLAGS_NOINTERACT;
+    }
+
     vlc_mutex_unlock( &p_item->lock );
 
     /* No slave */
@@ -439,14 +454,6 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     input_SendEventMeta( p_input );
 
     /* */
-    if( p_input->b_preparsing )
-        p_input->i_flags |= OBJECT_FLAGS_QUIET | OBJECT_FLAGS_NOINTERACT;
-
-    /* Make sure the interaction option is honored */
-    if( !var_InheritBool( p_input, "interact" ) )
-        p_input->i_flags |= OBJECT_FLAGS_NOINTERACT;
-
-    /* */
     memset( &p_input->p->counters, 0, sizeof( p_input->p->counters ) );
     vlc_mutex_init( &p_input->p->counters.counters_lock );
 
diff --git a/src/libvlc.c b/src/libvlc.c
index 404d315..ff0b618 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -621,6 +621,8 @@ int libvlc_MetaRequest(libvlc_int_t *libvlc, input_item_t *item,
     vlc_mutex_lock( &item->lock );
     if( item->i_preparse_depth == 0 )
         item->i_preparse_depth = 1;
+    if( i_options & META_REQUEST_OPTION_DO_INTERACT )
+        item->b_preparse_interact = true;
     vlc_mutex_unlock( &item->lock );
     playlist_preparser_Push(priv->parser, item, i_options);
     return VLC_SUCCESS;



More information about the vlc-commits mailing list