]> git.sesse.net Git - vlc/blobdiff - src/input/es_out.c
Removes trailing spaces. Removes tabs.
[vlc] / src / input / es_out.c
index 517a3787565d61f6703978f0431af9cef2baacd9..84f356d0da8dc50293611ae5bd994d89f80690bf 100644 (file)
@@ -28,7 +28,6 @@
 #include <vlc/vlc.h>
 
 #include <stdio.h>
-#include <stdlib.h>
 
 #include <vlc_input.h>
 #include <vlc_es_out.h>
@@ -109,6 +108,7 @@ struct es_out_sys_t
     /* es to select */
     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 */
     char        **ppsz_audio_language;
     char        **ppsz_sub_language;
 
@@ -180,6 +180,8 @@ es_out_t *input_EsOutNew( input_thread_t *p_input )
     var_Get( p_input, "sub-track", &val );
     p_sys->i_sub_last = val.i_int;
 
+    p_sys->i_default_sub_id   = -1;
+
     if( !p_input->b_preparsing )
     {
         var_Get( p_input, "audio-language", &val );
@@ -737,7 +739,6 @@ static void EsOutProgramEpg( es_out_t *out, int i_group, vlc_epg_t *p_epg )
     input_thread_t    *p_input = p_sys->p_input;
     es_out_pgrm_t     *p_pgrm = NULL;
     char *psz_cat;
-    char *psz_epg;
     int i;
 
     /* Find program */
@@ -760,7 +761,9 @@ static void EsOutProgramEpg( es_out_t *out, int i_group, vlc_epg_t *p_epg )
     /* Update info */
     psz_cat = EsOutProgramGetMetaName( p_pgrm );
 #ifdef HAVE_LOCALTIME_R
-    asprintf( &psz_epg, "EPG %s", psz_cat );
+    char *psz_epg;
+    if( asprintf( &psz_epg, "EPG %s", psz_cat ) == -1 )
+        psz_epg = NULL;
     input_Control( p_input, INPUT_DEL_INFO, psz_epg, NULL );
     msg_Dbg( p_input, "EsOutProgramEpg: number=%d name=%s", i_group, p_pgrm->p_epg->psz_name );
     for( i = 0; i < p_pgrm->p_epg->i_event; i++ )
@@ -1128,6 +1131,12 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_force )
 
                 i_wanted  = es->i_channel;
             }
+            else if( p_sys->i_default_sub_id >= 0 )
+            {
+                if( es->i_id == p_sys->i_default_sub_id )
+                    i_wanted = es->i_channel;
+            }
+
             if( p_sys->i_sub_last >= 0 )
                 i_wanted  = p_sys->i_sub_last;
 
@@ -1491,6 +1500,42 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args )
                 pl_Release( p_playlist );
             }
             return VLC_SUCCESS;
+        case ES_OUT_SET_DEFAULT:
+        {
+            es = (es_out_id_t*) va_arg( args, es_out_id_t * );
+
+            if( es == NULL )
+            {
+                /*p_sys->i_default_video_id = -1;*/
+                /*p_sys->i_default_audio_id = -1;*/
+                p_sys->i_default_sub_id = -1;
+            }
+            else if( es == (es_out_id_t*)((uint8_t*)NULL+AUDIO_ES) )
+            {
+                /*p_sys->i_default_video_id = -1;*/
+            }
+            else if( es == (es_out_id_t*)((uint8_t*)NULL+VIDEO_ES) )
+            {
+                /*p_sys->i_default_audio_id = -1;*/
+            }
+            else if( es == (es_out_id_t*)((uint8_t*)NULL+SPU_ES) )
+            {
+                p_sys->i_default_sub_id = -1;
+            }
+            else
+            {
+                /*if( es->fmt.i_cat == VIDEO_ES )
+                    p_sys->i_default_video_id = es->i_id;
+                else
+                if( es->fmt.i_cat == AUDIO_ES )
+                    p_sys->i_default_audio_id = es->i_id;
+                else*/
+                if( es->fmt.i_cat == SPU_ES )
+                    p_sys->i_default_sub_id = es->i_id;
+            }
+            return VLC_SUCCESS;
+        }
 
         case ES_OUT_SET_PCR:
         case ES_OUT_SET_GROUP_PCR: