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

Pierre Ynard linkfanel at yahoo.fr
Wed Mar 16 02:48:11 CET 2011


Hello,

> 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.

I guess you don't like the lua rc interface, that already does this? :)

> 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++;

atoi() accepts strings starting with a sign, so no need for this. Also,
if op is not a sign, you're fetching the current time for nothing.

> +
> +                var_Get( p_input, "time", &time );

You can use var_GetTime()

> +            }
> +
> +            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;

Regards,

-- 
Pierre Ynard
"Une âme dans un corps, c'est comme un dessin sur une feuille de papier."



More information about the vlc-devel mailing list