[vlc-devel] [PATCH] input: merge position and length events
Thomas Guillem
thomas at gllm.fr
Fri Aug 2 10:01:25 CEST 2019
>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.
---
src/input/es_out.c | 5 ++---
src/input/event.h | 20 +++++---------------
src/input/input.c | 3 +--
src/input/input_internal.h | 16 ++++++----------
src/input/player.c | 16 +++++++---------
5 files changed, 21 insertions(+), 39 deletions(-)
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 07e33647af..c839218991 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,7 +3299,8 @@ 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 );
}
return VLC_SUCCESS;
}
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..8b84aa5c0b 100644
--- a/src/input/player.c
+++ b/src/input/player.c
@@ -2198,12 +2198,12 @@ 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 (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);
@@ -2212,11 +2212,9 @@ input_thread_Events(input_thread_t *input_thread,
&& 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;
--
2.20.1
More information about the vlc-devel
mailing list