[vlc-devel] [PATCH 06/15] vlc_common: add helper fonctions to convert from mtime_t to floating point seconds

Rémi Denis-Courmont remi at remlab.net
Sat Jun 16 09:09:45 CEST 2018


Le perjantaina 15. kesäkuuta 2018, 18.09.17 EEST Steve Lhomme a écrit :
> ---
>  include/vlc_common.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/include/vlc_common.h b/include/vlc_common.h
> index 8b4baffcf27..fe1b125625f 100644
> --- a/include/vlc_common.h
> +++ b/include/vlc_common.h
> @@ -333,6 +333,16 @@ static inline int64_t nano_from_vtick(mtime_t tck)
>      return tck * INT64_C(1000000000) / CLOCK_FREQ;
>  }
> 
> +static inline double secf_from_vtick(mtime_t m)
> +{
> +    return (double)m / (double)CLOCK_FREQ;
> +}
> +static inline mtime_t vtick_from_secf(double secf)
> +{
> +    return secf * CLOCK_FREQ; /* TODO use llround */
> +}

Bleh. Why new macro identifiers? You can use _Generic and C++ overloading to 
separate float and integer.

-- 
Rémi Denis-Courmont
http://www.remlab.net/





More information about the vlc-devel mailing list