[vlc-devel] [PATCH 11/18] input: move input_AddSlave to vlc_player

Thomas Guillem thomas at gllm.fr
Fri May 10 16:03:15 CEST 2019


---
 include/vlc_input.h | 13 -------------
 src/input/control.c | 44 --------------------------------------------
 src/input/player.c  | 30 ++++++++++++++++++++++++++++--
 3 files changed, 28 insertions(+), 59 deletions(-)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index 4da5d09c6f..91594dfd0f 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -552,11 +552,6 @@ enum input_query_e
     /** Activate disc Root Menu. res=can fail */
     INPUT_NAV_MENU,
 
-    /* On the fly input slave */
-    INPUT_ADD_SLAVE,       /* arg1= enum slave_type, arg2= const char *,
-                            * arg3= bool forced, arg4= bool notify,
-                            * arg5= bool check_extension */
-
     /* Viewpoint */
     INPUT_UPDATE_VIEWPOINT, /* arg1=(const vlc_viewpoint_t*), arg2=bool b_absolute */
     INPUT_SET_INITIAL_VIEWPOINT, /* arg1=(const vlc_viewpoint_t*) */
@@ -653,14 +648,6 @@ static inline vout_thread_t *input_GetVout( input_thread_t *p_input )
      return p_vout;
 }
 
-static inline int input_AddSlave( input_thread_t *p_input, enum slave_type type,
-                                  const char *psz_uri, bool b_forced,
-                                  bool b_notify, bool b_check_ext )
-{
-    return input_Control( p_input, INPUT_ADD_SLAVE, type, psz_uri, b_forced,
-                          b_notify, b_check_ext );
-}
-
 /**
  * Update the viewpoint of the input thread. The viewpoint will be applied to
  * all vouts and aouts.
diff --git a/src/input/control.c b/src/input/control.c
index 14d871072d..368886b50a 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -81,50 +81,6 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
                                + INPUT_CONTROL_NAV_ACTIVATE, NULL );
             return VLC_SUCCESS;
 
-        case INPUT_ADD_SLAVE:
-        {
-            enum slave_type type =  va_arg( args, enum slave_type );
-            psz = va_arg( args, char * );
-            b_bool = va_arg( args, int );
-            bool b_notify = va_arg( args, int );
-            bool b_check_ext = va_arg( args, int );
-
-            if( !psz || ( type != SLAVE_TYPE_SPU && type != SLAVE_TYPE_AUDIO ) )
-                return VLC_EGENERIC;
-            if( b_check_ext && type == SLAVE_TYPE_SPU &&
-                !subtitles_Filter( psz ) )
-                return VLC_EGENERIC;
-
-            input_item_slave_t *p_slave =
-                input_item_slave_New( psz, type, SLAVE_PRIORITY_USER );
-            if( !p_slave )
-                return VLC_ENOMEM;
-            p_slave->b_forced = b_bool;
-
-            val.p_address = p_slave;
-            input_ControlPushHelper( p_input, INPUT_CONTROL_ADD_SLAVE, &val );
-            if( b_notify )
-            {
-                vout_thread_t *p_vout = input_GetVout( p_input );
-                if( p_vout )
-                {
-                    switch( type )
-                    {
-                        case SLAVE_TYPE_AUDIO:
-                            vout_OSDMessage(p_vout, VOUT_SPU_CHANNEL_OSD, "%s",
-                                            vlc_gettext("Audio track added"));
-                            break;
-                        case SLAVE_TYPE_SPU:
-                            vout_OSDMessage(p_vout, VOUT_SPU_CHANNEL_OSD, "%s",
-                                            vlc_gettext("Subtitle track added"));
-                            break;
-                    }
-                    vout_Release(p_vout);
-                }
-            }
-            return VLC_SUCCESS;
-        }
-
         case INPUT_UPDATE_VIEWPOINT:
         case INPUT_SET_INITIAL_VIEWPOINT:
         {
diff --git a/src/input/player.c b/src/input/player.c
index 21b2f2b5a9..ae5876955d 100644
--- a/src/input/player.c
+++ b/src/input/player.c
@@ -2118,7 +2118,7 @@ vlc_player_AddAssociatedMedia(vlc_player_t *player,
 {
     struct vlc_player_input *input = vlc_player_get_input_locked(player);
 
-    if (!input)
+    if (!input || !uri)
         return VLC_EGENERIC;
 
     enum slave_type type;
@@ -2133,7 +2133,33 @@ vlc_player_AddAssociatedMedia(vlc_player_t *player,
         default:
             return VLC_EGENERIC;
     }
-    return input_AddSlave(input->thread, type, uri, select, notify, check_ext);
+
+    if (check_ext && type == SLAVE_TYPE_SPU && !subtitles_Filter(uri))
+        return VLC_EGENERIC;
+
+    input_item_slave_t *slave =
+        input_item_slave_New(uri, type, SLAVE_PRIORITY_USER);
+    if (!slave)
+        return VLC_ENOMEM;
+    slave->b_forced = select;
+
+    vlc_value_t val = { .p_address = slave };
+    input_ControlPushHelper(input->thread, INPUT_CONTROL_ADD_SLAVE, &val);
+    if (notify)
+    {
+        switch( type )
+        {
+            case SLAVE_TYPE_AUDIO:
+                vlc_player_vout_OSDMessage(player, "%s",
+                                           vlc_gettext("Audio track added"));
+                break;
+            case SLAVE_TYPE_SPU:
+                vlc_player_vout_OSDMessage(player, "%s",
+                                vlc_gettext("Subtitle track added"));
+                break;
+        }
+    }
+    return VLC_SUCCESS;
 }
 
 void
-- 
2.20.1



More information about the vlc-devel mailing list