Commit 034ae114 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

programs is a string, which is a string, which is not a list

This fixes an assertion failure whenever --programs is used.
This should also fix a memory leak in the ES output.

This needs testing and backport to 1.1-bugfix.
parent 2cd8dae3
...@@ -1747,19 +1747,24 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force ) ...@@ -1747,19 +1747,24 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force )
} }
else if( p_sys->i_mode == ES_OUT_MODE_PARTIAL ) else if( p_sys->i_mode == ES_OUT_MODE_PARTIAL )
{ {
vlc_value_t val; char *prgms = var_GetNonEmptyString( p_sys->p_input, "programs" );
int i; if( prgms != NULL )
var_Get( p_sys->p_input, "programs", &val ); {
for ( i = 0; i < val.p_list->i_count; i++ ) char *buf;
for ( const char *prgm = strtok_r( prgms, ",", &buf );
prgm != NULL;
prgm = strtok_r( NULL, ",", &buf ) )
{ {
if ( val.p_list->p_values[i].i_int == es->p_pgrm->i_id || b_force ) if( atoi( prgm ) == es->p_pgrm->i_id || b_force )
{ {
if( !EsIsSelected( es ) ) if( !EsIsSelected( es ) )
EsSelect( out, es ); EsSelect( out, es );
break; break;
} }
} }
var_FreeList( &val, NULL ); free( prgms );
}
} }
else if( p_sys->i_mode == ES_OUT_MODE_AUTO ) else if( p_sys->i_mode == ES_OUT_MODE_AUTO )
{ {
......
...@@ -1139,7 +1139,7 @@ static void UpdatePtsDelay( input_thread_t *p_input ) ...@@ -1139,7 +1139,7 @@ static void UpdatePtsDelay( input_thread_t *p_input )
static void InitPrograms( input_thread_t * p_input ) static void InitPrograms( input_thread_t * p_input )
{ {
int i_es_out_mode; int i_es_out_mode;
vlc_value_t val; vlc_list_t list;
/* Compute correct pts_delay */ /* Compute correct pts_delay */
UpdatePtsDelay( p_input ); UpdatePtsDelay( p_input );
...@@ -1148,22 +1148,31 @@ static void InitPrograms( input_thread_t * p_input ) ...@@ -1148,22 +1148,31 @@ static void InitPrograms( input_thread_t * p_input )
i_es_out_mode = ES_OUT_MODE_AUTO; i_es_out_mode = ES_OUT_MODE_AUTO;
if( p_input->p->p_sout ) if( p_input->p->p_sout )
{ {
char *prgms;
if( var_GetBool( p_input, "sout-all" ) ) if( var_GetBool( p_input, "sout-all" ) )
{ {
i_es_out_mode = ES_OUT_MODE_ALL; i_es_out_mode = ES_OUT_MODE_ALL;
} }
else else
if( (prgms = var_GetNonEmptyString( p_input, "programs" )) != NULL )
{ {
var_Get( p_input, "programs", &val ); char *buf;
if( val.p_list && val.p_list->i_count )
TAB_INIT( list.i_count, list.p_values );
for( const char *prgm = strtok_r( prgms, ",", &buf );
prgm != NULL;
prgm = strtok_r( NULL, ",", &buf ) )
{ {
vlc_value_t val = { .i_int = atoi( prgm ) };
TAB_APPEND( list.i_count, list.p_values, val );
}
if( list.i_count > 0 )
i_es_out_mode = ES_OUT_MODE_PARTIAL; i_es_out_mode = ES_OUT_MODE_PARTIAL;
/* Note : we should remove the "program" callback. */ /* Note : we should remove the "program" callback. */
}
else free( prgms );
{
var_FreeList( &val, NULL );
}
} }
} }
es_out_SetMode( p_input->p->p_es_out, i_es_out_mode ); es_out_SetMode( p_input->p->p_es_out, i_es_out_mode );
...@@ -1176,7 +1185,8 @@ static void InitPrograms( input_thread_t * p_input ) ...@@ -1176,7 +1185,8 @@ static void InitPrograms( input_thread_t * p_input )
else if( i_es_out_mode == ES_OUT_MODE_PARTIAL ) else if( i_es_out_mode == ES_OUT_MODE_PARTIAL )
{ {
demux_Control( p_input->p->input.p_demux, DEMUX_SET_GROUP, -1, demux_Control( p_input->p->input.p_demux, DEMUX_SET_GROUP, -1,
val.p_list ); &list );
TAB_CLEAN( list.i_count, list.p_values );
} }
else else
{ {
......
...@@ -178,7 +178,7 @@ void input_ControlVarInit ( input_thread_t *p_input ) ...@@ -178,7 +178,7 @@ void input_ControlVarInit ( input_thread_t *p_input )
var_Change( p_input, "program", VLC_VAR_SETTEXT, &text, NULL ); var_Change( p_input, "program", VLC_VAR_SETTEXT, &text, NULL );
/* Programs */ /* Programs */
var_Create( p_input, "programs", VLC_VAR_LIST | VLC_VAR_DOINHERIT ); var_Create( p_input, "programs", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
text.psz_string = _("Programs"); text.psz_string = _("Programs");
var_Change( p_input, "programs", VLC_VAR_SETTEXT, &text, NULL ); var_Change( p_input, "programs", VLC_VAR_SETTEXT, &text, NULL );
......
...@@ -1048,12 +1048,7 @@ void var_OptionParse( vlc_object_t *p_obj, const char *psz_option, ...@@ -1048,12 +1048,7 @@ void var_OptionParse( vlc_object_t *p_obj, const char *psz_option,
if( psz_value != NULL ) if( psz_value != NULL )
*psz_value++ = '\0'; *psz_value++ = '\0';
/* FIXME: :programs should be handled generically */
if( !strcmp( psz_name, "programs" ) )
i_type = VLC_VAR_LIST;
else
i_type = config_GetType( p_obj, psz_name ); i_type = config_GetType( p_obj, psz_name );
if( !i_type && !psz_value ) if( !i_type && !psz_value )
{ {
/* check for "no-foo" or "nofoo" */ /* check for "no-foo" or "nofoo" */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment