[vlc-devel] Seek support in imem access module

Laurent Aimar fenrir at elivagar.org
Wed Jul 14 12:59:23 CEST 2010


Hi,

Just a few remarks,

On Wed, Jul 14, 2010 at 11:37:31AM +0200, Kamil Klimek wrote:
> Here is fixed patch. I didn't touch "not my part" as I'm not sure what intention author had.

> @@ -321,7 +335,7 @@ static int OpenAccess(vlc_object_t *object)
>      access->pf_control = ControlAccess;
>      access->pf_read    = NULL;
>      access->pf_block   = Block;
> -    access->pf_seek    = NULL;
> +    access->pf_seek    = (sys->source.seek == NULL ? NULL : Seek);
sys->source.seek ? Seek : NULL
Shorter and easier to read.
>      access->p_sys      = (access_sys_t*)sys;
>  
>      // we've got size as string, becouse we have no (u)int64_t var functions
> @@ -354,7 +368,7 @@ static int ControlAccess(access_t *access, int i_query, va_list args)
>      case ACCESS_CAN_SEEK:
>      case ACCESS_CAN_FASTSEEK: {
>          bool *b = va_arg( args, bool* );
> -        *b = false;
> +        *b = (sys->source.seek != NULL);
Useless parenthesis.

>          return VLC_SUCCESS;
>      }
>      case ACCESS_CAN_PAUSE:
> @@ -384,6 +398,19 @@ static int ControlAccess(access_t *access, int i_query, va_list args)
>  }
>  
>  /**
> + * It seeks through the stream using the seek() callback
> + */
> +static int Seek(access_t *access, uint64_t seekTo)
No camel case for variable, 'offset' for example.
> +{
> +    imem_sys_t * sys = (imem_sys_t*)access->p_sys;
 imem_sys_t *sys = access->p_sys
No space and no need to cast.

> +
> +    if(sys->source.seek)
 No need to test, as Seek() cannot be called if NULL.
> +        return sys->source.seek(sys->source.data, seekTo);
> +
> +    return VLC_EGENERIC;
> +}

Regards,

-- 
fenrir




More information about the vlc-devel mailing list