[vlc-devel] [PATCH] oldrc: add relative seek support

Mike Frysinger vapier at gentoo.org
Wed Mar 16 02:10:09 CET 2011


Most of the time, I want to seek short bursts forward and back, not to
absolute positions.  So add support to the current "seek" function to
do just this.  Prefixing the time with a "+" or "-" will make the seek
relative accordingly.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 modules/control/rc.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/modules/control/rc.c b/modules/control/rc.c
index 473b81d..8daca18 100644
--- a/modules/control/rc.c
+++ b/modules/control/rc.c
@@ -1035,7 +1035,30 @@ static int Input( vlc_object_t *p_this, char const *psz_cmd,
         }
         else
         {
-            mtime_t t = ((int64_t)atoi( newval.psz_string )) * CLOCK_FREQ;
+            char op;
+            const char *psz_seek = newval.psz_string;
+            mtime_t t;
+            vlc_value_t time;
+
+            if ( !isdigit( *psz_seek ))
+            {
+                op = psz_seek[0];
+                psz_seek++;
+
+                var_Get( p_input, "time", &time );
+            }
+
+            t = ((int64_t)atoi( psz_seek )) * CLOCK_FREQ;
+            switch ( op )
+            {
+            case '-':
+                t = time.i_time - t;
+                break;
+            case '+':
+                t = time.i_time + t;
+                break;
+            }
+
             var_SetTime( p_input, "time", t );
         }
         i_error = VLC_SUCCESS;
-- 
1.7.4.1




More information about the vlc-devel mailing list