[vlc-devel] [PATCH 03/15] vlc_common: add helper functions to convert (milli)seconds to/from mtime_t

Romain Vimont rom1v at videolabs.io
Fri Jun 15 19:35:53 CEST 2018


On Fri, Jun 15, 2018 at 05:09:14PM +0200, Steve Lhomme wrote:
> ---
>  include/vlc_common.h | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/include/vlc_common.h b/include/vlc_common.h
> index 3d17d8e6a63..d4186883df6 100644
> --- a/include/vlc_common.h
> +++ b/include/vlc_common.h
> @@ -294,6 +294,27 @@ typedef int64_t mtime_t;
>  #define SEC_FROM_VTICK(mt)  ((mt) / CLOCK_FREQ)      /* mtime_t in seconds */
>  #define VTICK_FROM_SEC(sec) ((mtime_t)((sec) * CLOCK_FREQ)) /* seconds in mtime_t */
>  
> +static inline mtime_t vtick_from_sec(int64_t sec)
> +{
> +    return sec * CLOCK_FREQ;
> +}
> +
> +static inline int64_t sec_from_vtick(mtime_t mt)
> +{
> +    return mt / CLOCK_FREQ;
> +}
> +
> +static inline mtime_t vtick_from_milli(int64_t ms)
> +{
> +    /* TODO refine if CLOCK_FREQ is not a multiple of 1000 */
> +    return ms * (CLOCK_FREQ / 1000);
> +}
> +
> +static inline int64_t milli_from_vtick(mtime_t mt)
> +{
> +    /* TODO refine if CLOCK_FREQ is not a multiple of 1000 */
> +    return mt / (CLOCK_FREQ / 1000);
> +}

Just for info, why static inline functions in addition to macros?

>  
>  /**
>   * The vlc_fourcc_t type.
> -- 
> 2.17.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