[vlc-commits] input: merge position and length events

Thomas Guillem git at videolan.org
Thu Aug 8 11:12:25 CEST 2019


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Aug  2 09:48:58 2019 +0200| [d23b4527c2489fa47d236205d4f915229b6a65ee] | committer: Thomas Guillem

input: merge position and length events

>From the es_out, times are a triplet: pos, time, length. So they should be
sent via a single event and atomically.

This also suppress one player lock when times are updated.

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

 src/input/es_out.c         |  8 +++++---
 src/input/event.h          | 20 +++++---------------
 src/input/input.c          |  3 +--
 src/input/input_internal.h | 16 ++++++----------
 src/input/player.c         | 20 +++++++++-----------
 5 files changed, 26 insertions(+), 41 deletions(-)

diff --git a/src/input/es_out.c b/src/input/es_out.c
index 07e33647af..be19053e78 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -3279,8 +3279,6 @@ static int EsOutVaControlLocked( es_out_t *out, int i_query, va_list args )
         vlc_tick_t i_time = va_arg( args, vlc_tick_t );
         vlc_tick_t i_length = va_arg( args, vlc_tick_t );
 
-        input_SendEventLength( p_sys->p_input, i_length );
-
         if( !p_sys->b_buffering )
         {
             vlc_tick_t i_delay;
@@ -3301,8 +3299,12 @@ static int EsOutVaControlLocked( es_out_t *out, int i_query, va_list args )
             if( f_position < 0 )
                 f_position = 0;
 
-            input_SendEventPosition( p_sys->p_input, f_position, i_time );
+            input_SendEventTimes( p_sys->p_input, f_position, i_time,
+                                  i_length );
         }
+        else
+            input_SendEventTimes( p_sys->p_input, 0.0, VLC_TICK_INVALID,
+                                  i_length );
         return VLC_SUCCESS;
     }
     case ES_OUT_SET_JITTER:
diff --git a/src/input/event.h b/src/input/event.h
index 01163c479a..2d77461451 100644
--- a/src/input/event.h
+++ b/src/input/event.h
@@ -54,23 +54,13 @@ static inline void input_SendEventCapabilities(input_thread_t *p_input,
     });
 }
 
-static inline void input_SendEventPosition(input_thread_t *p_input,
-                                            double f_position,
-                                            vlc_tick_t i_time)
+static inline void input_SendEventTimes(input_thread_t *p_input,
+                                        double f_position, vlc_tick_t i_time,
+                                        vlc_tick_t i_length)
 {
     input_SendEvent(p_input, &(struct vlc_input_event) {
-        .type = INPUT_EVENT_POSITION,
-        .position = { f_position, i_time }
-    });
-}
-
-static inline void input_SendEventLength(input_thread_t *p_input,
-                                          vlc_tick_t i_length)
-{
-    input_item_SetDuration(input_priv(p_input)->p_item, i_length);
-    input_SendEvent(p_input, &(struct vlc_input_event) {
-        .type = INPUT_EVENT_LENGTH,
-        .length = i_length,
+        .type = INPUT_EVENT_TIMES,
+        .times = { f_position, i_time, i_length }
     });
 }
 
diff --git a/src/input/input.c b/src/input/input.c
index 9d0bc94e78..a15ce6cab9 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1272,9 +1272,8 @@ static int Init( input_thread_t * p_input )
         i_length = 0;
     if( i_length <= 0 )
         i_length = input_item_GetDuration( priv->p_item );
-    input_SendEventLength( p_input, i_length );
 
-    input_SendEventPosition( p_input, 0.0, 0 );
+    input_SendEventTimes( p_input, 0.0, 0, i_length );
 
     if( !priv->b_preparsing )
     {
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index b0bc7b6d16..8e837a8c61 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -87,11 +87,8 @@ typedef enum input_event_type_e
     /* "capabilities" has changed */
     INPUT_EVENT_CAPABILITIES,
 
-    /* At least one of "position" or "time" */
-    INPUT_EVENT_POSITION,
-
-    /* "length" has changed */
-    INPUT_EVENT_LENGTH,
+    /* At least one of "position", "time" "length" has changed */
+    INPUT_EVENT_TIMES,
 
     /* A title has been added or removed or selected.
      * It implies that the chapter has changed (no chapter event is sent) */
@@ -150,10 +147,11 @@ typedef enum input_event_type_e
 #define VLC_INPUT_CAPABILITIES_REWINDABLE (1<<3)
 #define VLC_INPUT_CAPABILITIES_RECORDABLE (1<<4)
 
-struct vlc_input_event_position
+struct vlc_input_event_times
 {
     float percentage;
     vlc_tick_t ms;
+    vlc_tick_t length;
 };
 
 struct vlc_input_event_title
@@ -243,10 +241,8 @@ struct vlc_input_event
         float rate;
         /* INPUT_EVENT_CAPABILITIES */
         int capabilities; /**< cf. VLC_INPUT_CAPABILITIES_* bitwise flags */
-        /* INPUT_EVENT_POSITION */
-        struct vlc_input_event_position position;
-        /* INPUT_EVENT_LENGTH */
-        vlc_tick_t length;
+        /* INPUT_EVENT_TIMES */
+        struct vlc_input_event_times times;
         /* INPUT_EVENT_TITLE */
         struct vlc_input_event_title title;
         /* INPUT_EVENT_CHAPTER */
diff --git a/src/input/player.c b/src/input/player.c
index 4d0e13c668..45c1ce876f 100644
--- a/src/input/player.c
+++ b/src/input/player.c
@@ -2198,25 +2198,23 @@ input_thread_Events(input_thread_t *input_thread,
                                  old_caps, input->capabilities);
             break;
         }
-        case INPUT_EVENT_POSITION:
-            if (input->time != event->position.ms ||
-                input->position != event->position.percentage)
+        case INPUT_EVENT_TIMES:
+            if (event->times.ms != VLC_TICK_INVALID
+             && (input->time != event->times.ms
+              || input->position != event->times.percentage))
             {
-                input->time = event->position.ms;
-                input->position = event->position.percentage;
+                input->time = event->times.ms;
+                input->position = event->times.percentage;
                 vlc_player_SendEvent(player, on_position_changed,
-                                     input->time,
-                                     input->position);
+                                     input->time, input->position);
 
                 if (input->abloop_state[0].set && input->abloop_state[1].set
                  && input == player->input)
                     vlc_player_HandleAtoBLoop(player);
             }
-            break;
-        case INPUT_EVENT_LENGTH:
-            if (input->length != event->length)
+            if (input->length != event->times.length)
             {
-                input->length = event->length;
+                input->length = event->times.length;
                 vlc_player_SendEvent(player, on_length_changed, input->length);
             }
             break;



More information about the vlc-commits mailing list