[vlc-devel] [PATCH 2/7] input: move demux seek helpers to input.c

Thomas Guillem thomas at gllm.fr
Wed Oct 30 15:56:56 CET 2019


Since these 2 helpers are only used one time now.
---
 include/vlc_demux.h | 36 ------------------------------------
 src/input/input.c   | 36 +++++++++++++++++++++++++++++++-----
 2 files changed, 31 insertions(+), 41 deletions(-)

diff --git a/include/vlc_demux.h b/include/vlc_demux.h
index 5d67813fc0e..7a13469575a 100644
--- a/include/vlc_demux.h
+++ b/include/vlc_demux.h
@@ -369,42 +369,6 @@ static inline bool demux_IsForced( demux_t *p_demux, const char *psz_name )
     return true;
 }
 
-static inline int demux_SetPosition( demux_t *p_demux, double pos, bool precise,
-                                     bool absolute)
-{
-    if( !absolute )
-    {
-        double current_pos;
-        int ret = demux_Control( p_demux, DEMUX_GET_POSITION, &current_pos );
-        if( ret != VLC_SUCCESS )
-            return ret;
-        pos += current_pos;
-    }
-
-    if( pos < 0.f )
-        pos = 0.f;
-    else if( pos > 1.f )
-        pos = 1.f;
-    return demux_Control( p_demux, DEMUX_SET_POSITION, pos, precise );
-}
-
-static inline int demux_SetTime( demux_t *p_demux, vlc_tick_t time, bool precise,
-                                 bool absolute )
-{
-    if( !absolute )
-    {
-        vlc_tick_t current_time;
-        int ret = demux_Control( p_demux, DEMUX_GET_TIME, &current_time );
-        if( ret != VLC_SUCCESS )
-            return ret;
-        time += current_time;
-    }
-
-    if( time < 0 )
-        time = 0;
-    return demux_Control( p_demux, DEMUX_SET_TIME, time, precise );
-}
-
 /**
  * This function will create a packetizer suitable for a demuxer that parses
  * elementary stream.
diff --git a/src/input/input.c b/src/input/input.c
index b041cd8d580..120066aca71 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1819,7 +1819,20 @@ static int SetPosition( input_thread_t *p_input, double pos, bool fastseek,
     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 ) )
+    if( !absolute )
+    {
+        double current_pos;
+        if( demux_Control( p_demux, DEMUX_GET_POSITION, &current_pos ) )
+            return VLC_EGENERIC;
+        pos += current_pos;
+    }
+
+    if( pos < 0.f )
+        pos = 0.f;
+    else if( pos > 1.f )
+        pos = 1.f;
+
+    if( demux_Control( p_demux, DEMUX_SET_POSITION, pos, !fastseek ) )
         return VLC_EGENERIC;
 
     PostSeek( p_input );
@@ -1832,7 +1845,23 @@ static int SetTime( input_thread_t *p_input, vlc_tick_t time, bool fastseek,
     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 ) )
+    if( !absolute )
+    {
+        vlc_tick_t current_time;
+        if( demux_Control( p_demux, DEMUX_GET_TIME, &current_time ) )
+            goto set_position_fallback;
+        time += current_time;
+    }
+
+    if( time < 0 )
+        time = 0;
+    if( demux_Control( p_demux, DEMUX_SET_TIME, time, !fastseek ) )
+        goto set_position_fallback;
+
+    PostSeek( p_input );
+    return VLC_SUCCESS;
+
+set_position_fallback:
     {
         vlc_tick_t length;
 
@@ -1843,9 +1872,6 @@ static int SetTime( input_thread_t *p_input, vlc_tick_t time, bool fastseek,
         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,
-- 
2.20.1



More information about the vlc-devel mailing list