[vlc-commits] input: more precise vout events

Thomas Guillem git at videolan.org
Fri Sep 7 15:26:02 CEST 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Sep  7 14:58:03 2018 +0200| [4ae884a3a9cb1488ff0f0aef28c6e26feeab5077] | committer: Thomas Guillem

input: more precise vout events

Notify in the event which vout is removed or added, and send vout events from
the input resource for more controls.

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

 include/vlc_input.h              | 11 +++++++++++
 modules/gui/qt/input_manager.hpp |  4 ++--
 src/input/decoder.c              |  8 --------
 src/input/event.h                |  8 +++++---
 src/input/resource.c             | 15 +++++++++++++++
 5 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index 8076876506..e6622b386f 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -449,6 +449,15 @@ struct vlc_input_event_signal {
     float strength;
 };
 
+struct vlc_input_event_vout
+{
+    enum {
+        VLC_INPUT_EVENT_VOUT_ADDED,
+        VLC_INPUT_EVENT_VOUT_REMOVED,
+    } action;
+    vout_thread_t *vout;
+};
+
 struct vlc_input_event
 {
     input_event_type_e type;
@@ -484,6 +493,8 @@ struct vlc_input_event
         vlc_tick_t subtitle_delay;
         /* INPUT_EVENT_CACHE */
         float cache;
+        /* INPUT_EVENT_VOUT */
+        struct vlc_input_event_vout vout;
         /* INPUT_EVENT_SUBITEMS */
         input_item_node_t *subitems;
     };
diff --git a/modules/gui/qt/input_manager.hpp b/modules/gui/qt/input_manager.hpp
index ce515cdaab..41b5a86340 100644
--- a/modules/gui/qt/input_manager.hpp
+++ b/modules/gui/qt/input_manager.hpp
@@ -66,8 +66,8 @@ public:
         ProgramChanged,
         RandomChanged,
         LoopOrRepeatChanged,
-        EPGEvent, /* 20 */
-        CapabilitiesChanged,
+        EPGEvent,
+        CapabilitiesChanged, /* 20 */
     /*    SignalChanged, */
 
         FullscreenControlToggle = QEvent::User + IMEventTypeOffset + 50,
diff --git a/src/input/decoder.c b/src/input/decoder.c
index c4ad7ab551..ba36492b0d 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -305,13 +305,10 @@ static vout_thread_t *aout_request_vout( void *p_private,
 {
     decoder_t *p_dec = p_private;
     struct decoder_owner *p_owner = dec_get_owner( p_dec );
-    input_thread_t *p_input = p_owner->p_input;
 
     p_vout = input_resource_RequestVout( p_owner->p_resource,
         &(vout_configuration_t){ .vout = p_vout, .fmt = p_fmt, .dpb_size = 1 },
         b_recyle );
-    if( p_input != NULL )
-        input_SendEventVout( p_input );
 
     return p_vout;
 }
@@ -550,8 +547,6 @@ static int vout_update_format( decoder_t *p_dec )
         p_owner->fmt.video.i_chroma = p_dec->fmt_out.i_codec;
         vlc_mutex_unlock( &p_owner->lock );
 
-        if( p_owner->p_input != NULL )
-            input_SendEventVout( p_owner->p_input );
         if( p_vout == NULL )
         {
             msg_Err( p_dec, "failed to create video output" );
@@ -1913,9 +1908,6 @@ static void DeleteDecoder( decoder_t * p_dec )
 
                 input_resource_RequestVout( p_owner->p_resource,
                     &(vout_configuration_t) { .vout = p_owner->p_vout }, true );
-
-                if( p_owner->p_input != NULL )
-                    input_SendEventVout( p_owner->p_input );
             }
             break;
         case SPU_ES:
diff --git a/src/input/event.h b/src/input/event.h
index 03774a8d2c..6027b3e06f 100644
--- a/src/input/event.h
+++ b/src/input/event.h
@@ -250,12 +250,14 @@ static inline void input_SendEventParsing(input_thread_t *p_input,
 }
 
 /*****************************************************************************
- * Event for decoder.c
+ * Event for resource.c
  *****************************************************************************/
-static inline void input_SendEventVout(input_thread_t *p_input)
+static inline void input_SendEventVout(input_thread_t *p_input,
+                                       const struct vlc_input_event_vout *event)
 {
     input_SendEvent(p_input, &(struct vlc_input_event) {
-        .type = INPUT_EVENT_VOUT
+        .type = INPUT_EVENT_VOUT,
+        .vout = *event,
     });
 }
 
diff --git a/src/input/resource.c b/src/input/resource.c
index e19a9fd1d7..58829a977e 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -41,6 +41,7 @@
 #include "../audio_output/aout_internal.h"
 #include "../video_output/vout_internal.h"
 #include "input_interface.h"
+#include "event.h"
 #include "resource.h"
 
 struct input_resource_t
@@ -247,6 +248,13 @@ static vout_thread_t *RequestVout( input_resource_t *p_resource,
         TAB_APPEND( p_resource->i_vout, p_resource->pp_vout, p_vout );
         vlc_mutex_unlock( &p_resource->lock_hold );
 
+        if( p_resource->p_input && cfg.vout != p_vout )
+            input_SendEventVout( p_resource->p_input,
+                &(struct vlc_input_event_vout) {
+                    .action = VLC_INPUT_EVENT_VOUT_ADDED,
+                    .vout = p_vout,
+                });
+
         return p_vout;
     }
     else
@@ -258,6 +266,13 @@ static vout_thread_t *RequestVout( input_resource_t *p_resource,
         const int i_vout_active = p_resource->i_vout;
         vlc_mutex_unlock( &p_resource->lock_hold );
 
+        if( p_resource->p_input )
+            input_SendEventVout( p_resource->p_input,
+                &(struct vlc_input_event_vout) {
+                    .action = VLC_INPUT_EVENT_VOUT_REMOVED,
+                    .vout = cfg.vout,
+                });
+
         if( p_resource->p_vout_free || i_vout_active > 0 || !b_recycle )
         {
             if( b_recycle )



More information about the vlc-commits mailing list