[vlc-devel] [RFC PATCH 7/8] input: broadcast vlc_InputDecoderStateChanged event

Thomas Guillem thomas at gllm.fr
Thu Apr 21 18:24:37 CEST 2016


---
 include/vlc_events.h | 13 +++++++++++++
 include/vlc_input.h  |  2 ++
 src/input/input.c    | 18 ++++++++++++++++++
 3 files changed, 33 insertions(+)

diff --git a/include/vlc_events.h b/include/vlc_events.h
index 6d7ccad..a39558b 100644
--- a/include/vlc_events.h
+++ b/include/vlc_events.h
@@ -27,6 +27,7 @@
 
 #include <vlc_arrays.h>
 #include <vlc_meta.h>
+#include <vlc_codec.h>
 
 /**
  * \file
@@ -110,6 +111,9 @@ typedef struct vlc_event_manager_t
 
 /* List of event */
 typedef enum vlc_event_type_t {
+    /* Input (thread) events */
+    vlc_InputDecoderStateChanged,
+
     /* Input item events */
     vlc_InputItemMetaChanged,
     vlc_InputItemSubItemAdded,
@@ -141,6 +145,15 @@ typedef struct vlc_event_t
     void * p_obj; /* Sender object, automatically filled by vlc_event_send() */
     union vlc_event_type_specific
     {
+        /* Input (thread) events */
+        struct vlc_input_decoder_state_changed
+        {
+            int i_cat;
+            int i_es_id;
+            const char *psz_module_name;
+            enum decoder_state state;
+        } input_decoder_state_changed;
+
         /* Input item events */
         struct vlc_input_item_meta_changed
         {
diff --git a/include/vlc_input.h b/include/vlc_input.h
index 0bda6d4..9af7f24 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -233,6 +233,8 @@ struct input_thread_t
     bool b_preparsing;
     bool b_dead VLC_DEPRECATED;
 
+    vlc_event_manager_t event_manager;
+
     /* All other data is input_thread is PRIVATE. You can't access it
      * outside of src/input */
     input_thread_private_t *p;
diff --git a/src/input/input.c b/src/input/input.c
index 317155c..6633158 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -251,6 +251,9 @@ static void input_Destructor( vlc_object_t *obj )
 
     vlc_cond_destroy( &p_input->p->wait_control );
     vlc_mutex_destroy( &p_input->p->lock_control );
+
+    vlc_event_manager_fini( &p_input->event_manager );
+
     free( p_input->p );
 }
 
@@ -463,6 +466,10 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
     /* Set the destructor when we are sure we are initialized */
     vlc_object_set_destructor( p_input, input_Destructor );
 
+    vlc_event_manager_t *p_em = &p_input->event_manager;
+    vlc_event_manager_init( p_em, p_input );
+    vlc_event_manager_register_event_type( p_em, vlc_InputDecoderStateChanged );
+
     return p_input;
 }
 
@@ -1986,6 +1993,17 @@ static bool Control( input_thread_t *p_input,
         case INPUT_CONTROL_DECODER_STATE:
         {
             struct decoder_state_control *p_ctrl = val.p_address;
+            vlc_event_t event;
+
+            /* send event */
+            event.type = vlc_InputDecoderStateChanged;
+            struct vlc_input_decoder_state_changed *p_ev_state
+                = &event.u.input_decoder_state_changed;
+            p_ev_state->i_es_id = p_ctrl->i_es_id;
+            p_ev_state->i_cat = p_ctrl->i_cat;
+            p_ev_state->psz_module_name = p_ctrl->psz_module_name;
+            p_ev_state->state = p_ctrl->state;
+            vlc_event_send( &p_input->event_manager, &event );
 
             if( p_ctrl->state >= DECODER_ERROR_GENERIC )
             {
-- 
2.8.0.rc3



More information about the vlc-devel mailing list