[vlc-devel] [PATCH 5/6] coreaudio: add the HostTimeToTick() helper

Steve Lhomme robux4 at ycbcr.xyz
Mon Aug 19 14:12:28 CEST 2019


On 2019-08-16 10:55, Thomas Guillem wrote:
> ---
>   modules/audio_output/coreaudio_common.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/modules/audio_output/coreaudio_common.c b/modules/audio_output/coreaudio_common.c
> index a06fd7f173..8d3a78bede 100644
> --- a/modules/audio_output/coreaudio_common.c
> +++ b/modules/audio_output/coreaudio_common.c
> @@ -48,6 +48,13 @@ FramesToUs(struct aout_sys_common *p_sys, uint64_t i_nb_frames)
>       return vlc_tick_from_samples(i_nb_frames, p_sys->i_rate);
>   }
>   
> +static inline vlc_tick_t
> +HostTimeToTick(uint64_t i_host_time)
> +{
> +    assert(tinfo.denom != 0);
> +    return i_host_time * tinfo.numer / tinfo.denom / 1000;

This call to convert something to vlc_tick_t with a hardcoded value 
seems suspicious, CLOCK_FREQ is not even involved. You're probably 
looking for vlc_tick_from_samples()

> +}
> +
>   static void
>   ca_ClearOutBuffers(audio_output_t *p_aout)
>   {
> @@ -221,8 +228,7 @@ ca_TimeGet(audio_output_t *p_aout, vlc_tick_t *delay)
>           return -1;
>       }
>   
> -    const uint64_t i_render_time_us = p_sys->i_render_host_time
> -                                    * tinfo.numer / tinfo.denom / 1000;
> +    const uint64_t i_render_time_us = HostTimeToTick(p_sys->i_render_host_time);

The type of i_render_time_us should be vlc_tick_t.

>       const vlc_tick_t i_render_delay = i_render_time_us - vlc_tick_now();
>   
>       const int64_t i_out_frames = BytesToFrames(p_sys, p_sys->i_out_size);
> -- 
> 2.20.1
> 
> _______________________________________________
> 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