[vlc-devel] [PATCH 3/4] input: use "time" and "position" vars to seek at start
Thomas Guillem
thomas at gllm.fr
Thu Jun 9 18:16:50 CEST 2016
The input_thead_t parent could set one of these 2 variable in order to start
the input_thread_t at a given time or position.
---
src/input/input.c | 28 ++++++++++++++++++++++------
src/input/var.c | 4 ++--
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/src/input/input.c b/src/input/input.c
index 2bcb16b..0920fe4 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -915,6 +915,11 @@ static void StartTitle( input_thread_t * p_input )
else
p_input->p->i_stop += p_input->p->i_start;
}
+ if( p_input->p->i_stop > 0 && p_input->p->i_stop <= p_input->p->i_start )
+ {
+ msg_Warn( p_input, "invalid stop-time ignored" );
+ p_input->p->i_stop = 0;
+ }
if( p_input->p->i_start > 0 )
{
@@ -922,13 +927,24 @@ static void StartTitle( input_thread_t * p_input )
(int)( p_input->p->i_start / CLOCK_FREQ ) );
var_SetInteger( p_input, "time", p_input->p->i_start );
- }
- else
- input_SendEventPosition( p_input, 0.0, 0 );
- if( p_input->p->i_stop > 0 && p_input->p->i_stop <= p_input->p->i_start )
+ } else
{
- msg_Warn( p_input, "invalid stop-time ignored" );
- p_input->p->i_stop = 0;
+ /* "position" and "time" vars may have been set by a parent without
+ * triggering a callback. Trigger a callback in that case in order to
+ * do the actual seeking */
+
+ float f_position = var_GetFloat( p_input, "position" );
+
+ if( f_position > 0.0f && f_position < 1.0f )
+ var_TriggerCallback( p_input, "position" );
+ else
+ {
+ int64_t i_time = var_GetInteger( p_input, "time" );
+ if( i_time > 0 )
+ var_TriggerCallback( p_input, "time" );
+ else
+ input_SendEventPosition( p_input, 0.0, 0 );
+ }
}
p_input->p->b_fast_seek = var_GetBool( p_input, "input-fast-seek" );
}
diff --git a/src/input/var.c b/src/input/var.c
index 6534603..8c9dfb1 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -145,11 +145,11 @@ void input_ControlVarInit ( input_thread_t *p_input )
var_Create( p_input, "frame-next", VLC_VAR_VOID );
/* Position */
- var_Create( p_input, "position", VLC_VAR_FLOAT );
+ var_Create( p_input, "position", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT );
var_Create( p_input, "position-offset", VLC_VAR_FLOAT );
/* Time */
- var_Create( p_input, "time", VLC_VAR_INTEGER );
+ var_Create( p_input, "time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Create( p_input, "time-offset", VLC_VAR_INTEGER ); /* relative */
/* Bookmark */
--
2.8.1
More information about the vlc-devel
mailing list