[vlc-commits] input: remove the last "*-es" var dependency

Thomas Guillem git at videolan.org
Mon Jul 23 12:56:28 CEST 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Jul 23 12:11:57 2018 +0200| [4bb07b176cb3a51671031d4f27c8f85e2d48c9b0] | committer: Thomas Guillem

input: remove the last "*-es" var dependency

It was used to get the es id added by an input slave in order to enable it.

There is no real clean way to enable a future es_out_id from a future input
slave. The dumb way to do it is to listen to ES events and recover the last id
(what this commit is doing).

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

 src/input/event.c          |  4 ++++
 src/input/input.c          | 44 ++++++++++++++------------------------------
 src/input/input_internal.h |  4 ++++
 3 files changed, 22 insertions(+), 30 deletions(-)

diff --git a/src/input/event.c b/src/input/event.c
index 84fb03a117..d4da9ce1ab 100644
--- a/src/input/event.c
+++ b/src/input/event.c
@@ -222,6 +222,10 @@ void input_SendEventEsAdd( input_thread_t *p_input,
                            enum es_format_category_e i_cat, int i_id,
                            const char *psz_text )
 {
+    input_thread_private_t *priv = input_priv(p_input);
+    priv->i_last_es_cat = i_cat;
+    priv->i_last_es_id = i_id;
+
     input_SendEvent( p_input, &(struct vlc_input_event) {
         .type = INPUT_EVENT_ES,
         .es = {
diff --git a/src/input/input.c b/src/input/input.c
index 6cd8ffb6c0..58a726bb97 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -363,6 +363,8 @@ static input_thread_t *Create( vlc_object_t *p_parent,
     else
         vlc_viewpoint_init( &priv->viewpoint );
 
+    priv->i_last_es_cat = UNKNOWN_ES;
+
     input_item_Hold( p_item ); /* Released in Destructor() */
     priv->p_item = p_item;
 
@@ -3222,32 +3224,30 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,
                                  unsigned i_flags )
 {
     input_thread_private_t *priv = input_priv(p_input);
-    size_t count;
-    const char *psz_es;
     const char *psz_forced_demux;
     const bool b_can_fail = i_flags & SLAVE_ADD_CANFAIL;
     const bool b_forced = i_flags & SLAVE_ADD_FORCED;
     const bool b_set_time = i_flags & SLAVE_ADD_SET_TIME;
+    enum es_format_category_e i_cat;
 
     switch( i_type )
     {
     case SLAVE_TYPE_SPU:
-        psz_es = "spu-es";
         psz_forced_demux = "subtitle";
+        i_cat = SPU_ES;
         break;
     case SLAVE_TYPE_AUDIO:
-        psz_es = "audio-es";
         psz_forced_demux = NULL;
+        i_cat = AUDIO_ES;
         break;
     default:
         vlc_assert_unreachable();
     }
 
-    if( b_forced )
-        var_Change( p_input, psz_es, VLC_VAR_CHOICESCOUNT, &count );
+    msg_Dbg( p_input, "loading %s slave: %s (forced: %d)",
+             i_cat == SPU_ES ? "spu" : "audio", psz_uri, b_forced );
 
-    msg_Dbg( p_input, "loading %s slave: %s (forced: %d)", psz_es, psz_uri,
-             b_forced );
+    priv->i_last_es_cat = UNKNOWN_ES;
 
     input_source_t *p_source = InputSourceNew( p_input, psz_uri,
                                                psz_forced_demux,
@@ -3291,31 +3291,15 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,
 
     TAB_APPEND( priv->i_slave, priv->slave, p_source );
 
-    if( !b_forced )
-        return VLC_SUCCESS;
-
-    /* Select the ES */
-    vlc_value_t *list;
-    size_t entries;
-
-    if( var_Change( p_input, psz_es, VLC_VAR_GETCHOICES,
-                    &entries, &list, (char ***)NULL ) )
+    if( !b_forced || priv->i_last_es_cat != i_cat )
         return VLC_SUCCESS;
 
-    if( count == 0 )
-        count++;
-    /* if it was first one, there is disable too */
-
-    if( count < entries )
-    {
-        const int i_id = list[count].i_int;
+    assert( priv->i_last_es_id != -1 );
 
-        es_out_Control( priv->p_es_out_display, ES_OUT_SET_ES_DEFAULT_BY_ID,
-                        i_id );
-        es_out_Control( priv->p_es_out_display, ES_OUT_SET_ES_BY_ID,
-                        i_id, false );
-    }
-    free(list);
+    es_out_Control( priv->p_es_out_display, ES_OUT_SET_ES_DEFAULT_BY_ID,
+                    priv->i_last_es_id );
+    es_out_Control( priv->p_es_out_display, ES_OUT_SET_ES_BY_ID,
+                    priv->i_last_es_id, false );
 
     return VLC_SUCCESS;
 }
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index cd34546976..512fa73ef8 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -161,6 +161,10 @@ typedef struct input_thread_private_t
     int            i_slave;
     input_source_t **slave;
 
+    /* Last ES added */
+    enum es_format_category_e i_last_es_cat;
+    int                       i_last_es_id;
+
     /* Resources */
     input_resource_t *p_resource;
     input_resource_t *p_resource_private;



More information about the vlc-commits mailing list