]> git.sesse.net Git - vlc/blobdiff - src/input/es_out.c
Use var_Inherit* instead of var_CreateGet*.
[vlc] / src / input / es_out.c
index 1468ba4a7cf6bbddbe88e2a888104cc626134788..635b2e9893e310cd60edef9842e26e9c1ccc8da0 100644 (file)
@@ -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" );
@@ -948,12 +951,12 @@ static void EsOutESVarUpdateGeneric( es_out_t *out, int i_id,
     {
         if( psz_language && *psz_language )
         {
-            if( asprintf( &text.psz_string, "%s %i - [%s]", _( "Track" ), val.i_int, psz_language ) == -1 )
+            if( asprintf( &text.psz_string, "%s %"PRId64" - [%s]", _( "Track" ), val.i_int, psz_language ) == -1 )
                 text.psz_string = NULL;
         }
         else
         {
-            if( asprintf( &text.psz_string, "%s %i", _( "Track" ), val.i_int ) == -1 )
+            if( asprintf( &text.psz_string, "%s %"PRId64, _( "Track" ), val.i_int ) == -1 )
                 text.psz_string = NULL;
         }
     }
@@ -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 );
@@ -2692,7 +2712,7 @@ static char *LanguageGetName( const char *psz_code )
 {
     const iso639_lang_t *pl;
 
-    if( psz_code == NULL )
+    if( psz_code == NULL || !strcmp( psz_code, "und" ) )
     {
         return strdup( "" );
     }
@@ -2842,7 +2862,7 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
     if( !p_cat )
         return;
 
-    /* Add informations */
+    /* Add information */
     const char *psz_type;
     switch( fmt->i_cat )
     {
@@ -2869,7 +2889,8 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
 
     const char *psz_codec_description =
         vlc_fourcc_GetDescription( p_fmt_es->i_cat, p_fmt_es->i_codec );
-    const vlc_fourcc_t i_codec_fourcc = p_fmt_es->i_original_fourcc ?: p_fmt_es->i_codec;
+    const vlc_fourcc_t i_codec_fourcc = ( p_fmt_es->i_original_fourcc )?
+                               p_fmt_es->i_original_fourcc : p_fmt_es->i_codec;
     if( psz_codec_description )
         info_category_AddInfo( p_cat, _("Codec"), "%s (%.4s)",
                                psz_codec_description, (char*)&i_codec_fourcc );