]> git.sesse.net Git - vlc/blobdiff - src/input/es_out.c
Allow to stop decoder even in infinite decoder loop (in case of broken decoder).
[vlc] / src / input / es_out.c
index bbafad2aa65c191f5a2ea609f64a2c3813610c68..f25f545dafbf18c1cbc3ff21b82b07602b8b912f 100644 (file)
@@ -29,7 +29,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 
 #include <stdio.h>
 
@@ -40,7 +40,6 @@
 
 #include "input_internal.h"
 
-#include "vlc_playlist.h"
 #include <vlc_iso_lang.h>
 /* FIXME we should find a better way than including that */
 #include "../text/iso-639_def.h"
@@ -183,12 +182,19 @@ es_out_t *input_EsOutNew( input_thread_t *p_input, int i_rate )
     vlc_value_t  val;
     int i;
 
+    if( !out ) return NULL;
+    if( !p_sys )
+    {
+        free( out );
+        return NULL;
+    }
+
     out->pf_add     = EsOutAdd;
     out->pf_send    = EsOutSend;
     out->pf_del     = EsOutDel;
     out->pf_control = EsOutControl;
     out->p_sys      = p_sys;
-    out->b_sout     = (p_input->p->p_sout != NULL ? true : false);
+    out->b_sout     = p_input->p->p_sout != NULL;
 
     p_sys->p_input = p_input;
 
@@ -570,6 +576,7 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, int i_group )
     vlc_value_t       val;
 
     es_out_pgrm_t *p_pgrm = malloc( sizeof( es_out_pgrm_t ) );
+    if( !p_pgrm ) return NULL;
 
     /* Init */
     p_pgrm->i_id = i_group;
@@ -889,9 +896,12 @@ static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt )
     es_out_pgrm_t     *p_pgrm = NULL;
     int i;
 
+    if( !es ) return NULL;
+
     if( fmt->i_group < 0 )
     {
         msg_Err( p_input, "invalid group number" );
+        free( es );
         return NULL;
     }
 
@@ -1046,8 +1056,7 @@ static void EsSelect( es_out_t *out, es_out_id_t *es )
     {
         if( es->fmt.i_cat == VIDEO_ES || es->fmt.i_cat == SPU_ES )
         {
-            if( !var_GetBool( p_input, "video" ) ||
-                ( p_input->p->p_sout && !var_GetBool( p_input, "sout-video" ) ) )
+            if( !var_GetBool( p_input, out->b_sout ? "sout-video" : "video" ) )
             {
                 msg_Dbg( p_input, "video is disabled, not selecting ES 0x%x",
                          es->i_id );
@@ -1057,8 +1066,7 @@ static void EsSelect( es_out_t *out, es_out_id_t *es )
         else if( es->fmt.i_cat == AUDIO_ES )
         {
             var_Get( p_input, "audio", &val );
-            if( !var_GetBool( p_input, "audio" ) ||
-                ( p_input->p->p_sout && !var_GetBool( p_input, "sout-audio" ) ) )
+            if( !var_GetBool( p_input, out->b_sout ? "sout-audio" : "audio" ) )
             {
                 msg_Dbg( p_input, "audio is disabled, not selecting ES 0x%x",
                          es->i_id );
@@ -1068,8 +1076,7 @@ static void EsSelect( es_out_t *out, es_out_id_t *es )
         if( es->fmt.i_cat == SPU_ES )
         {
             var_Get( p_input, "spu", &val );
-            if( !var_GetBool( p_input, "spu" ) ||
-                ( p_input->p->p_sout && !var_GetBool( p_input, "sout-spu" ) ) )
+            if( !var_GetBool( p_input, out->b_sout ? "sout-spu" : "spu" ) )
             {
                 msg_Dbg( p_input, "spu is disabled, not selecting ES 0x%x",
                          es->i_id );
@@ -1441,7 +1448,7 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
                 VLC_FOURCC('c', 'c', '3', ' '),
                 VLC_FOURCC('c', 'c', '4', ' '),
             };
-            static const char *ppsz_description[4] = {
+            static const char ppsz_description[4][18] = {
                 N_("Closed captions 1"),
                 N_("Closed captions 2"),
                 N_("Closed captions 3"),
@@ -1681,17 +1688,9 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args )
                 }
             }
             {
-                /* FIXME: we don't want to depend on the playlist */
-                playlist_t * p_playlist = vlc_object_find( p_sys->p_input,
-                    VLC_OBJECT_PLAYLIST, FIND_PARENT );
-                if( p_playlist )
-                {
-                    PL_LOCK;
-                    p_playlist->gc_date = mdate();
-                    vlc_object_signal_unlocked( p_playlist );
-                    PL_UNLOCK;
-                    vlc_object_release( p_playlist );
-                }
+                vlc_event_t event;
+                event.type = vlc_InputSelectedStreamChanged;
+                vlc_event_send( &p_sys->p_input->p->event_manager, &event );
             }
             return VLC_SUCCESS;