[vlc-devel] [PATCH 1/4] input: improve INPUT_CONTROL_ADD_SLAVE
Thomas Guillem
thomas at gllm.fr
Fri May 27 12:45:13 CEST 2016
It can now handle a slave type (via input_item_slave_t)
This control is unused for now.
---
src/input/control.c | 19 ++++++++++++++-----
src/input/input.c | 14 +++++++++++---
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/src/input/control.c b/src/input/control.c
index 7a2a5d3..16f5186 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -430,13 +430,22 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
}
case INPUT_ADD_SLAVE:
+ {
+ enum slave_type type = (enum slave_type) va_arg( args, enum slave_type );
psz = (char*)va_arg( args, char * );
- if( psz && *psz )
- {
- val.psz_string = strdup( psz );
- input_ControlPush( p_input, INPUT_CONTROL_ADD_SLAVE, &val );
- }
+
+ if( !psz || ( type != SLAVE_TYPE_SPU && type != SLAVE_TYPE_AUDIO ) )
+ return VLC_EGENERIC;
+
+ input_item_slave_t *p_slave =
+ input_item_slave_New( psz, type, SLAVE_PRIORITY_USER );
+ if( !p_slave )
+ return VLC_ENOMEM;
+
+ val.p_address = p_slave;
+ input_ControlPush( p_input, INPUT_CONTROL_ADD_SLAVE, &val );
return VLC_SUCCESS;
+ }
case INPUT_ADD_SUBTITLE:
psz = (char*)va_arg( args, char * );
diff --git a/src/input/input.c b/src/input/input.c
index d1b9b3e..ab5e85b 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1599,9 +1599,11 @@ static void ControlRelease( int i_type, vlc_value_t val )
switch( i_type )
{
case INPUT_CONTROL_ADD_SUBTITLE:
- case INPUT_CONTROL_ADD_SLAVE:
free( val.psz_string );
break;
+ case INPUT_CONTROL_ADD_SLAVE:
+ input_item_slave_Delete( val.p_address );
+ break;
default:
break;
@@ -1967,9 +1969,15 @@ static bool Control( input_thread_t *p_input,
break;
case INPUT_CONTROL_ADD_SLAVE:
- if( val.psz_string )
+ if( val.p_address )
{
- const char *uri = val.psz_string;
+ input_item_slave_t *p_item_slave = val.p_address;
+ if( p_item_slave->i_type == SLAVE_TYPE_SPU )
+ {
+ input_SubtitleAdd( p_input, p_item_slave->psz_uri, SUB_CANFAIL );
+ break;
+ }
+ const char *uri = p_item_slave->psz_uri;
input_source_t *slave = InputSourceNew( p_input, uri, NULL,
false );
if( slave == NULL )
--
2.8.1
More information about the vlc-devel
mailing list