]> git.sesse.net Git - vlc/commitdiff
Allow --sub-track to work with EIA-608 captions, and fix crash on exit
authorDevin Heitmueller <dheitmueller@kernellabs.com>
Sun, 21 Sep 2014 16:54:54 +0000 (12:54 -0400)
committerRafaël Carré <funman@videolan.org>
Tue, 23 Sep 2014 11:14:16 +0000 (13:14 +0200)
Prior to this patch, if the user specified the --sub-track argument on
the command line, it would not work with MPEG2 streams that contain
EIA-608 closed captions.  It would also cause an abort() on exit.

The crash was because the various functions that select/unselect
streams would check for the p_master member, which isn't set until
after EsOutAdd().  The call to EsOutAdd itself though would call
EsSelect(), which would treat the ES as a regular subtitle stream
and cause a resource leak -- which would cause an abort at exit.

The other change actually makes --sub-track work with the special
case of EIA-608 captions.

Signed-off-by: Rafaël Carré <funman@videolan.org>
src/input/es_out.c

index dafaaecff10ac6e2bd1b27606169f84dd690172c..6709bdeee40bf07b19d1f3411cb2642b7886fb07 100644 (file)
@@ -1816,6 +1816,16 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force )
                         i_wanted = es->i_channel;
                 }
             }
+            else if ( es->fmt.i_codec == EsOutFourccClosedCaptions[0] ||
+                      es->fmt.i_codec == EsOutFourccClosedCaptions[1] ||
+                      es->fmt.i_codec == EsOutFourccClosedCaptions[2] ||
+                      es->fmt.i_codec == EsOutFourccClosedCaptions[3])
+            {
+                    /* We don't want to enable on initial create since p_master
+                       isn't set yet (otherwise we will think it's a standard
+                       ES_SUB stream and cause a resource leak) */
+                    return;
+            }
             else
             {
                 /* If there is no user preference, select the default subtitle 
@@ -2000,6 +2010,10 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
 
         /* */
         es->pb_cc_present[i] = true;
+
+        /* Enable if user specified on command line */
+        if (p_sys->i_sub_last == i)
+            EsOutSelect(out, es->pp_cc_es[i], true);
     }
 
     vlc_mutex_unlock( &p_sys->lock );