[vlc-devel] [PATCH 09/16] Add secondary subtitle promotion

Roland Bewick roland.bewick at gmail.com
Tue May 21 20:08:33 CEST 2019


If a user selects two sub tracks and deselects the primary track,
the secondary sub track will be promoted to primary.
---
 src/input/decoder.c |  6 ++++++
 src/input/decoder.h |  1 +
 src/input/es_out.c  | 15 +++++++++++++++
 3 files changed, 22 insertions(+)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 023f487ed7..c26db520a3 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -2382,6 +2382,12 @@ int input_DecoderSetSpuId( decoder_t *dec, unsigned int i_spu_id )
     return VLC_SUCCESS;
 }
 
+unsigned int input_DecoderGetSpuId( decoder_t *dec )
+{
+    struct decoder_owner *p_owner = dec_get_owner( dec );
+    return p_owner->i_spu_id;
+}
+
 void input_DecoderChangePause( decoder_t *p_dec, bool b_paused, vlc_tick_t i_date )
 {
     struct decoder_owner *p_owner = dec_get_owner( p_dec );
diff --git a/src/input/decoder.h b/src/input/decoder.h
index ffe61bafb8..565c648208 100644
--- a/src/input/decoder.h
+++ b/src/input/decoder.h
@@ -114,6 +114,7 @@ size_t input_DecoderGetFifoSize( decoder_t *p_dec );
  * can be applied (Alignment, margin, delay etc).
  */
 int input_DecoderSetSpuId( decoder_t *dec, unsigned int i_spu_id );
+unsigned int input_DecoderGetSpuId( decoder_t *dec );
 
 void input_DecoderSetVoutMouseEvent( decoder_t *, vlc_mouse_event, void * );
 int  input_DecoderAddVoutOverlay( decoder_t *, subpicture_t *, int * );
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 5f0deae46d..0afa500f7c 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -2022,6 +2022,21 @@ static void EsOutUnselectEs( es_out_t *out, es_out_id_t *es, bool b_update )
         return;
     }
 
+    if ( es->fmt.i_cat == SPU_ES )
+    {
+        es_out_es_props_t *p_esprops = GetPropsByCat( p_sys, es->fmt.i_cat );
+        /* Promote other selected secondary SPU ES */
+        es_out_id_t *other;
+        foreach_es_then_es_slaves(other)
+            if( other->fmt.i_cat == SPU_ES && EsIsSelected( other ) &&
+                input_DecoderGetSpuId(other->p_dec) > input_DecoderGetSpuId(es->p_dec) )
+            {
+                /* SPU has higher spu id than the SPU to deselect - push it down */
+                unsigned int i_new_spu_id = input_DecoderGetSpuId(other->p_dec) - 1;
+                input_DecoderSetSpuId( other->p_dec, i_new_spu_id );
+            }
+    }
+
     if( es->p_master )
     {
         if( es->p_master->p_dec )
-- 
2.11.0



More information about the vlc-devel mailing list