[vlc-devel] [PATCH 1/2] cdda: use time<->position helpers
Steve Lhomme
robux4 at ycbcr.xyz
Fri Apr 2 05:22:58 UTC 2021
On 2021-04-01 17:01, Thomas Guillem wrote:
> ---
> modules/access/cdda.c | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/modules/access/cdda.c b/modules/access/cdda.c
> index 9260b833eda..541e043a574 100644
> --- a/modules/access/cdda.c
> +++ b/modules/access/cdda.c
> @@ -178,6 +178,16 @@ static int Demux(demux_t *demux)
> return VLC_DEMUXER_SUCCESS;
> }
>
> +static inline vlc_tick_t PositionToTime(unsigned position)
> +{
> + return (INT64_C(40000) * position) / 3;
This is very suspicious to convert to/from vlc_tick_t without ever
involving CLOCK_FREQ.
You can probably use vlc_tick_from_samples() and samples_from_vlc_tick().
> +}
> +
> +static inline unsigned TimeToPosition(vlc_tick_t time)
> +{
> + return time * 3 / INT64_C(40000);
> +}
> +
> static int DemuxControl(demux_t *demux, int query, va_list args)
> {
> demux_sys_t *sys = demux->p_sys;
> @@ -211,14 +221,17 @@ static int DemuxControl(demux_t *demux, int query, va_list args)
> break;
>
> case DEMUX_GET_LENGTH:
> - *va_arg(args, vlc_tick_t *) = (INT64_C(40000) * sys->length) / 3;
> + *va_arg(args, vlc_tick_t *) = PositionToTime(sys->length);
> break;
> case DEMUX_GET_TIME:
> - *va_arg(args, vlc_tick_t *) = (INT64_C(40000) * sys->position) / 3;
> + *va_arg(args, vlc_tick_t *) = PositionToTime(sys->position);
> break;
> case DEMUX_SET_TIME:
> - sys->position = (va_arg(args, vlc_tick_t) * 3) / INT64_C(40000);
> + {
> + vlc_tick_t time = va_arg(args, vlc_tick_t);
> + sys->position = TimeToPosition(time);
> break;
> + }
>
> default:
> return VLC_EGENERIC;
> --
> 2.30.0
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
More information about the vlc-devel
mailing list