[vlc-devel] [PATCH 1/7] input: split SET/JUMP TIME/POS into several functions
Thomas Guillem
thomas at gllm.fr
Wed Oct 30 15:56:55 CET 2019
Not functional changes
---
src/input/input.c | 85 +++++++++++++++++++++++++++--------------------
1 file changed, 49 insertions(+), 36 deletions(-)
diff --git a/src/input/input.c b/src/input/input.c
index b8df8b69905..b041cd8d580 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1804,6 +1804,50 @@ void input_ControlSync(input_thread_t *p_input, int i_type,
Control( p_input, i_type, *param );
}
+static void PostSeek( input_thread_t *p_input )
+{
+ input_thread_private_t *priv = input_priv(p_input);
+ if( priv->i_slave > 0 )
+ SlaveSeek( p_input );
+ priv->master->b_eof = false;
+}
+
+static int SetPosition( input_thread_t *p_input, double pos, bool fastseek,
+ bool absolute )
+
+{
+ input_thread_private_t *priv = input_priv(p_input);
+ demux_t *p_demux = priv->master->p_demux;
+
+ if( demux_SetPosition( p_demux, pos, !fastseek, absolute ) )
+ return VLC_EGENERIC;
+
+ PostSeek( p_input );
+ return VLC_SUCCESS;
+}
+
+static int SetTime( input_thread_t *p_input, vlc_tick_t time, bool fastseek,
+ bool absolute )
+{
+ input_thread_private_t *priv = input_priv(p_input);
+ demux_t *p_demux = priv->master->p_demux;
+
+ if( demux_SetTime( p_demux, time, fastseek, absolute ) )
+ {
+ vlc_tick_t length;
+
+ /* Emulate it with a SET_POS */
+ if( demux_Control( p_demux, DEMUX_GET_LENGTH, &length ) || length <= 0 )
+ return VLC_EGENERIC;
+
+ double pos = (double)time / (double)length;
+ return SetPosition( p_input, pos, fastseek, absolute );
+ }
+
+ PostSeek( p_input );
+ return VLC_SUCCESS;
+}
+
static bool Control( input_thread_t *p_input,
int i_type, input_control_param_t param )
{
@@ -1827,22 +1871,15 @@ static bool Control( input_thread_t *p_input,
/* Reset the decoders states and clock sync (before calling the demuxer */
es_out_Control( priv->p_es_out, ES_OUT_RESET_PCR );
- if( demux_SetPosition( priv->master->p_demux, (double)param.pos.f_val,
- !param.pos.b_fast_seek, absolute ) )
- {
+
+ if( SetPosition( p_input, param.pos.f_val, param.pos.b_fast_seek,
+ i_type == INPUT_CONTROL_SET_POSITION ) )
msg_Err( p_input, "INPUT_CONTROL_SET_POSITION "
"%s%2.1f%% failed",
absolute ? "@" : param.pos.f_val >= 0 ? "+" : "",
param.pos.f_val * 100.f );
- }
else
- {
- if( priv->i_slave > 0 )
- SlaveSeek( p_input );
- priv->master->b_eof = false;
-
b_force_update = true;
- }
break;
}
@@ -1850,7 +1887,6 @@ static bool Control( input_thread_t *p_input,
case INPUT_CONTROL_JUMP_TIME:
{
const bool absolute = i_type == INPUT_CONTROL_SET_TIME;
- int i_ret;
if( priv->b_recording )
{
@@ -1861,37 +1897,14 @@ static bool Control( input_thread_t *p_input,
/* Reset the decoders states and clock sync (before calling the demuxer */
es_out_Control( priv->p_es_out, ES_OUT_RESET_PCR );
- i_ret = demux_SetTime( priv->master->p_demux, param.time.i_val,
- !param.time.b_fast_seek, absolute );
- if( i_ret )
- {
- vlc_tick_t i_length;
-
- /* Emulate it with a SET_POS */
- if( !demux_Control( priv->master->p_demux,
- DEMUX_GET_LENGTH, &i_length ) && i_length > 0 )
- {
- double f_pos = (double)param.time.i_val / (double)i_length;
- i_ret = demux_SetPosition( priv->master->p_demux, f_pos,
- !param.time.b_fast_seek,
- absolute );
- }
- }
- if( i_ret )
- {
+ if( SetTime( p_input, param.time.i_val, param.time.b_fast_seek,
+ absolute ) )
msg_Warn( p_input, "INPUT_CONTROL_SET_TIME %s%"PRId64
" failed or not possible",
absolute ? "@" : param.time.i_val >= 0 ? "+" : "",
param.time.i_val );
- }
else
- {
- if( priv->i_slave > 0 )
- SlaveSeek( p_input );
- priv->master->b_eof = false;
-
b_force_update = true;
- }
break;
}
--
2.20.1
More information about the vlc-devel
mailing list