Commit 172c2460 authored by Laurent Aimar's avatar Laurent Aimar

Fixed --program behavior.

parent 3c1e28fa
......@@ -130,7 +130,8 @@ struct es_out_sys_t
int i_video;
int i_sub;
/* es to select */
/* es/group to select */
int i_group_id;
int i_audio_last, i_audio_id;
int i_sub_last, i_sub_id;
int i_default_sub_id; /* As specified in container; if applicable */
......@@ -259,6 +260,8 @@ es_out_t *input_EsOutNew( input_thread_t *p_input, int i_rate )
p_sys->i_sub = 0;
/* */
p_sys->i_group_id = var_GetInteger( p_input, "program" );
p_sys->i_audio_last = var_GetInteger( p_input, "audio-track" );
p_sys->i_sub_last = var_GetInteger( p_input, "sub-track" );
......@@ -978,6 +981,11 @@ static void EsOutESVarUpdate( es_out_t *out, es_out_id_t *es,
EsOutESVarUpdateGeneric( out, es->i_id, &es->fmt, es->psz_language, b_delete );
}
static bool EsOutIsProgramVisible( es_out_t *out, int i_group )
{
return out->p_sys->i_group_id == 0 || out->p_sys->i_group_id == i_group;
}
/* EsOutProgramSelect:
* Select a program and update the object variable
*/
......@@ -1076,9 +1084,10 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, int i_group )
TAB_APPEND( p_sys->i_pgrm, p_sys->pgrm, p_pgrm );
/* Update "program" variable */
input_SendEventProgramAdd( p_input, i_group, NULL );
if( EsOutIsProgramVisible( out, i_group ) )
input_SendEventProgramAdd( p_input, i_group, NULL );
if( i_group == var_GetInteger( p_input, "program" ) )
if( i_group == p_sys->i_group_id || ( !p_sys->p_pgrm && p_sys->i_group_id == 0 ) )
EsOutProgramSelect( out, p_pgrm );
return p_pgrm;
......@@ -1184,6 +1193,8 @@ static void EsOutProgramMeta( es_out_t *out, int i_group, const vlc_meta_t *p_me
return;
}
/* Find program */
if( !EsOutIsProgramVisible( out, i_group ) )
return;
p_pgrm = EsOutProgramFind( out, i_group );
if( !p_pgrm )
return;
......@@ -1275,6 +1286,8 @@ static void EsOutProgramEpg( es_out_t *out, int i_group, const vlc_epg_t *p_epg
char *psz_cat;
/* Find program */
if( !EsOutIsProgramVisible( out, i_group ) )
return;
p_pgrm = EsOutProgramFind( out, i_group );
if( !p_pgrm )
return;
......@@ -2144,6 +2157,13 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
return VLC_SUCCESS;
}
case ES_OUT_GET_GROUP_FORCED:
{
int *pi_group = va_arg( args, int * );
*pi_group = p_sys->i_group_id;
return VLC_SUCCESS;
}
case ES_OUT_SET_MODE:
{
const int i_mode = va_arg( args, int );
......
......@@ -80,6 +80,9 @@ enum es_out_query_private_e
/* Set jitter */
ES_OUT_SET_JITTER, /* arg1=mtime_t i_pts_delay arg2= mtime_t i_pts_jitter, arg2=int i_cr_average res=cannot fail */
/* Get forced group */
ES_OUT_GET_GROUP_FORCED, /* arg1=int * res=cannot fail */
};
static inline void es_out_SetMode( es_out_t *p_out, int i_mode )
......@@ -153,6 +156,13 @@ static inline int es_out_GetEsObjects( es_out_t *p_out, int i_id,
{
return es_out_Control( p_out, ES_OUT_GET_ES_OBJECTS_BY_ID, i_id, pp_decoder, pp_vout, pp_aout );
}
static inline int es_out_GetGroupForced( es_out_t *p_out )
{
int i_group;
int i_ret = es_out_Control( p_out, ES_OUT_GET_GROUP_FORCED, &i_group );
assert( !i_ret );
return i_group;
}
es_out_t *input_EsOutNew( input_thread_t *, int i_rate );
......
......@@ -633,7 +633,6 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
}
return es_out_Control( p_sys->p_out, ES_OUT_GET_ES_STATE, p_es->p_es, pb_enabled );
}
/* Special internal input control */
case ES_OUT_GET_EMPTY:
{
......@@ -694,6 +693,13 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
return es_out_ControlModifyPcrSystem( p_sys->p_out, b_absolute, i_system );
}
case ES_OUT_GET_GROUP_FORCED:
{
int *pi_group = va_arg( args, int * );
return es_out_Control( p_sys->p_out, ES_OUT_GET_GROUP_FORCED, pi_group );
}
default:
msg_Err( p_sys->p_input, "Unknown es_out_Control query !" );
assert(0);
......
......@@ -1193,7 +1193,7 @@ static void InitPrograms( input_thread_t * p_input )
else
{
demux_Control( p_input->p->input.p_demux, DEMUX_SET_GROUP,
(int) var_GetInteger( p_input, "program" ), NULL );
es_out_GetGroupForced( p_input->p->p_es_out ), NULL );
}
}
......
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