[vlc-commits] input: Allow input_AddSlave to notify of the addition

Hugo Beauzée-Luyssen git at videolan.org
Thu Sep 21 17:49:08 CEST 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Sep 21 12:07:01 2017 +0200| [b6bbe81d35cb8da6d9a50b23ebeaf23703a0e270] | committer: Hugo Beauzée-Luyssen

input: Allow input_AddSlave to notify of the addition

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

 include/vlc_input.h |  6 +++---
 lib/media_player.c  |  2 +-
 src/input/control.c | 20 ++++++++++++++++++++
 3 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index 13fe107fb6..7fa33a2064 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -460,7 +460,7 @@ enum input_query_e
     INPUT_GET_ATTACHMENT,  /* arg1=input_attachment_t**, arg2=char*  res=can fail */
 
     /* On the fly input slave */
-    INPUT_ADD_SLAVE,       /* arg1= enum slave_type, arg2= const char *, arg3= bool */
+    INPUT_ADD_SLAVE,       /* arg1= enum slave_type, arg2= const char *, arg3= bool, arg4= bool */
     INPUT_ADD_SUBTITLE,    /* arg1= const char *, arg2=bool b_check_extension */
 
     /* On the fly record while playing */
@@ -598,9 +598,9 @@ static inline int input_AddSubtitleOSD( input_thread_t *p_input, const char *psz
 #define input_AddSubtitle(a, b, c) input_AddSubtitleOSD(a, b, c, false)
 
 static inline int input_AddSlave( input_thread_t *p_input, enum slave_type type,
-                                  const char *psz_uri, bool b_forced )
+                                  const char *psz_uri, bool b_forced, bool b_notify )
 {
-    return input_Control( p_input, INPUT_ADD_SLAVE, type, psz_uri, b_forced );
+    return input_Control( p_input, INPUT_ADD_SLAVE, type, psz_uri, b_forced, b_notify );
 }
 
 /**
diff --git a/lib/media_player.c b/lib/media_player.c
index b5677ae7ec..7da1bf25a8 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1941,7 +1941,7 @@ int libvlc_media_player_add_slave( libvlc_media_player_t *p_mi,
     else
     {
         int i_ret = input_AddSlave( p_input_thread, (enum slave_type) i_type,
-                                    psz_uri, b_select );
+                                    psz_uri, b_select, false );
         vlc_object_release( p_input_thread );
 
         return i_ret == VLC_SUCCESS ? 0 : -1;
diff --git a/src/input/control.c b/src/input/control.c
index 77e1490272..df3ab765a3 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -411,6 +411,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
             enum slave_type type =  (enum slave_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 );
 
             if( !psz || ( type != SLAVE_TYPE_SPU && type != SLAVE_TYPE_AUDIO ) )
                 return VLC_EGENERIC;
@@ -423,6 +424,25 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
 
             val.p_address = p_slave;
             input_ControlPush( 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;
+                    }
+                    vlc_object_release( (vlc_object_t *)p_vout );
+                }
+            }
             return VLC_SUCCESS;
         }
 



More information about the vlc-commits mailing list