[vlc-devel] [PATCH 11/20] input: pass vout and spu_order via events

Thomas Guillem thomas at gllm.fr
Thu Jun 20 17:23:54 CEST 2019


---
 src/input/decoder.c        | 39 +++++++++++++++++++++++++++++++-------
 src/input/event.h          |  9 +++++++++
 src/input/input_internal.h | 12 ++++++++++++
 3 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 3a47c01ddf..ea9373975b 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -611,12 +611,19 @@ static subpicture_t *spu_new_buffer( decoder_t *p_dec,
         msg_Warn( p_dec, "no vout found, dropping subpicture" );
         if( p_owner->p_vout )
         {
-            if (p_owner->i_spu_channel != -1)
-            {
-                vout_UnregisterSubpictureChannel(p_owner->p_vout,
-                                                 p_owner->i_spu_channel);
-                p_owner->i_spu_channel = -1;
-            }
+            assert(p_owner->i_spu_channel != -1);
+
+            if (p_owner->p_input)
+                input_SendEventSpu(p_owner->p_input,
+                    &(struct vlc_input_event_spu) {
+                        .vout = p_owner->p_vout,
+                        .channel_order = VLC_SPU_CHANNEL_ORDER_NONE,
+                        .id = p_owner->id,
+                    });
+
+            vout_UnregisterSubpictureChannel(p_owner->p_vout,
+                                             p_owner->i_spu_channel);
+            p_owner->i_spu_channel = -1;
 
             vlc_mutex_lock( &p_owner->lock );
             vout_Release(p_owner->p_vout);
@@ -629,13 +636,15 @@ static subpicture_t *spu_new_buffer( decoder_t *p_dec,
     if( p_owner->p_vout != p_vout )
     {
         ssize_t old_spu_channel = p_owner->i_spu_channel;
+        enum vlc_spu_channel_order channel_order;
         p_owner->i_spu_channel =
             vout_RegisterSubpictureChannelInternal(p_vout, p_owner->p_clock,
-                                                   NULL);
+                                                   &channel_order);
         p_owner->i_spu_order = 0;
 
         if (p_owner->i_spu_channel != -1)
         {
+            assert(channel_order != VLC_SPU_CHANNEL_ORDER_NONE);
             if (p_owner->p_vout && old_spu_channel != -1)
                 vout_UnregisterSubpictureChannel(p_owner->p_vout,
                                                  old_spu_channel);
@@ -644,6 +653,14 @@ static subpicture_t *spu_new_buffer( decoder_t *p_dec,
                 vout_Release(p_owner->p_vout);
             p_owner->p_vout = p_vout;
             vlc_mutex_unlock(&p_owner->lock);
+
+            if (p_owner->p_input)
+                input_SendEventSpu(p_owner->p_input,
+                    &(struct vlc_input_event_spu) {
+                        .vout = p_vout,
+                        .channel_order = channel_order,
+                        .id = p_owner->id,
+                    });
         }
     }
     else
@@ -1991,6 +2008,14 @@ static void DeleteDecoder( decoder_t * p_dec )
             if( p_owner->p_vout )
             {
                 assert( p_owner->i_spu_channel > 0 );
+                if (p_owner->p_input)
+                    input_SendEventSpu(p_owner->p_input,
+                        &(struct vlc_input_event_spu) {
+                            .vout = p_owner->p_vout,
+                            .channel_order = VLC_SPU_CHANNEL_ORDER_NONE,
+                            .id = p_owner->id,
+                        });
+
                 vout_UnregisterSubpictureChannel( p_owner->p_vout,
                                                   p_owner->i_spu_channel );
                 vout_Release(p_owner->p_vout);
diff --git a/src/input/event.h b/src/input/event.h
index 01163c479a..467d4ee799 100644
--- a/src/input/event.h
+++ b/src/input/event.h
@@ -281,6 +281,15 @@ static inline void input_SendEventVout(input_thread_t *p_input,
     });
 }
 
+static inline void input_SendEventSpu(input_thread_t *p_input,
+                                       const struct vlc_input_event_spu *event)
+{
+    input_SendEvent(p_input, &(struct vlc_input_event) {
+        .type = INPUT_EVENT_SPU,
+        .spu = *event,
+    });
+}
+
 /*****************************************************************************
  * Event for control.c/input.c
  *****************************************************************************/
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index b159033b1c..b68ad77b4f 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -169,6 +169,9 @@ typedef enum input_event_type_e
     /* A vout_thread_t object has been created/deleted by *the input* */
     INPUT_EVENT_VOUT,
 
+    /* A new SPU channel has been registered/unregistered */
+    INPUT_EVENT_SPU,
+
     /* (pre-)parsing events */
     INPUT_EVENT_SUBITEMS,
 
@@ -271,6 +274,13 @@ struct vlc_input_event_vout
     vlc_es_id_t *id;
 };
 
+struct vlc_input_event_spu
+{
+    vout_thread_t *vout;
+    enum vlc_spu_channel_order channel_order;
+    vlc_es_id_t *id;
+};
+
 struct vlc_input_event
 {
     input_event_type_e type;
@@ -304,6 +314,8 @@ struct vlc_input_event
         float cache;
         /* INPUT_EVENT_VOUT */
         struct vlc_input_event_vout vout;
+        /* INPUT_EVENT_SPU */
+        struct vlc_input_event_spu spu;
         /* INPUT_EVENT_SUBITEMS */
         input_item_node_t *subitems;
         /* INPUT_EVENT_VBI_PAGE */
-- 
2.20.1



More information about the vlc-devel mailing list