[vlc-commits] Keep the selected languages at segment change

Denis Charmet git at videolan.org
Fri May 9 18:30:25 CEST 2014


vlc | branch: master | Denis Charmet <typx at dinauz.org> | Fri May  9 18:27:42 2014 +0200| [03f53a779660358a00ba0c5c4d0e5cac5b324fa9] | committer: Denis Charmet

Keep the selected languages at segment change

Fix #11118

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=03f53a779660358a00ba0c5c4d0e5cac5b324fa9
---

 modules/demux/mkv/virtual_segment.cpp |   27 +++++++++++++++++++++++++++
 src/input/es_out.c                    |    3 +++
 2 files changed, 30 insertions(+)

diff --git a/modules/demux/mkv/virtual_segment.cpp b/modules/demux/mkv/virtual_segment.cpp
index 3b1b68e..362fc3c 100644
--- a/modules/demux/mkv/virtual_segment.cpp
+++ b/modules/demux/mkv/virtual_segment.cpp
@@ -623,6 +623,24 @@ void virtual_chapter_c::print()
 void virtual_segment_c::ChangeSegment( matroska_segment_c * p_old, matroska_segment_c * p_new, mtime_t i_start_time )
 {
     size_t i, j;
+    char *sub_lang = NULL, *aud_lang = NULL;
+    for( i = 0; i < p_old->tracks.size(); i++)
+    {
+        mkv_track_t *p_tk = p_old->tracks[i];
+        es_format_t *p_ofmt = &p_tk->fmt;
+        if( p_tk->p_es )
+        {
+            bool state = false;
+            es_out_Control( p_old->sys.demuxer.out, ES_OUT_GET_ES_STATE, p_tk->p_es, &state );
+            if( state )
+            {
+                if( p_ofmt->i_cat == AUDIO_ES )
+                    aud_lang = p_tk->fmt.psz_language;
+                else if( p_ofmt->i_cat == SPU_ES )
+                    sub_lang = p_tk->fmt.psz_language;
+            }
+        }
+    }
     for( i = 0; i < p_new->tracks.size(); i++)
     {
         mkv_track_t *p_tk = p_new->tracks[i];
@@ -661,6 +679,15 @@ void virtual_segment_c::ChangeSegment( matroska_segment_c * p_old, matroska_segm
                 }
             }
         }
+        p_tk->fmt.i_priority &= ~(0x10);
+        if( ( sub_lang && p_nfmt->i_cat == SPU_ES && !strcasecmp(sub_lang, p_nfmt->psz_language) ) ||
+            ( aud_lang && p_nfmt->i_cat == AUDIO_ES && !strcasecmp(aud_lang, p_nfmt->psz_language) ) )
+        {
+            msg_Warn( &p_old->sys.demuxer, "Since previous segment used lang %s forcing track %zu",
+                      p_nfmt->psz_language, i);
+            p_tk->fmt.i_priority |= 0x10;
+            p_tk->b_forced = true;
+        }
     }
     p_new->Select( i_start_time );
     p_old->UnSelect();
diff --git a/src/input/es_out.c b/src/input/es_out.c
index c8ae945..bda051c 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -1843,6 +1843,9 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force )
                     ( p_sys->p_es_sub && 
                       p_sys->p_es_sub->fmt.i_priority < es->fmt.i_priority ) )
                     i_wanted = es->i_channel;
+                else if( p_sys->p_es_sub &&
+                         p_sys->p_es_sub->fmt.i_priority >= es->fmt.i_priority )
+                    i_wanted = p_sys->p_es_sub->i_channel;
             }
 
             if( p_sys->i_sub_last >= 0 )



More information about the vlc-commits mailing list