22#ifndef GAVLTIME_H_INCLUDED
23#define GAVLTIME_H_INCLUDED
30#include <gavl/gavldefs.h>
38#define GAVL_TIME_SCALE 1000000
43#define GAVL_TIME_UNDEFINED 0x8000000000000000LL
46#define GAVL_TIME_MAX 0x7fffffffffffffffLL
130#define gavl_seconds_to_time(s) (gavl_time_t)((s)*(double)(GAVL_TIME_SCALE))
138#define gavl_time_to_seconds(t) ((double)(t)/(double)(GAVL_TIME_SCALE))
152#define GAVL_TIME_STRING_LEN 11
170#define GAVL_TIME_STRING_LEN_MS 15
191int gavl_time_parse(
const char * str,
gavl_time_t * ret);
#define GAVL_TIME_STRING_LEN_MS
Length of the string passed to gavl_time_prettyprint_ms.
Definition: gavltime.h:170
GAVL_PUBLIC int64_t gavl_time_to_frames(int rate_num, int rate_den, gavl_time_t time)
Convert a time to a number of video frames for a given framerate.
GAVL_PUBLIC void gavl_time_delay(gavl_time_t *time)
Sleep for a specified time.
#define GAVL_TIME_STRING_LEN
Length of the string passed to gavl_time_prettyprint.
Definition: gavltime.h:152
GAVL_PUBLIC gavl_time_t gavl_time_unscale(int scale, int64_t time)
Convert a time scaled by another base to a gavl time.
GAVL_PUBLIC gavl_time_t gavl_frames_to_time(int rate_num, int rate_den, int64_t frames)
Convert a number of video frames to a time for a given framerate.
GAVL_PUBLIC void gavl_time_prettyprint_ms(gavl_time_t time, char str[GAVL_TIME_STRING_LEN_MS])
Convert a time to a string with millisecond precision.
GAVL_PUBLIC gavl_time_t gavl_samples_to_time(int samplerate, int64_t samples)
Convert a number of samples to a time for a given samplerate.
GAVL_PUBLIC int64_t gavl_time_scale(int scale, gavl_time_t time)
Convert a gavl time to a time scaled by another base.
GAVL_PUBLIC int64_t gavl_time_rescale(int scale1, int scale2, int64_t time)
Convert a time scaled by one base to a time scaled by another base.
GAVL_PUBLIC int64_t gavl_time_to_samples(int samplerate, gavl_time_t time)
Convert a time to a number of audio samples for a given samplerate.
int64_t gavl_time_t
Times in gavl are 64 bit signed integers.
Definition: gavltime.h:53
GAVL_PUBLIC void gavl_time_prettyprint(gavl_time_t time, char str[GAVL_TIME_STRING_LEN])
Convert a time to a string.
GAVL_PUBLIC void gavl_timer_stop(gavl_timer_t *timer)
Stop a timer.
GAVL_PUBLIC gavl_timer_t * gavl_timer_create()
Create a timer.
GAVL_PUBLIC void gavl_timer_destroy(gavl_timer_t *timer)
Destroy a timer.
GAVL_PUBLIC void gavl_timer_start(gavl_timer_t *timer)
Start a timer.
GAVL_PUBLIC const char * gavl_benchmark_get_desc(int flags)
Get a description about the value returned by gavl_benchmark_get_time.
GAVL_PUBLIC uint64_t gavl_benchmark_get_time(int flags)
Get the current time for benchmarking.
GAVL_PUBLIC gavl_time_t gavl_timer_get(gavl_timer_t *timer)
Get the current time of the timer.
struct gavl_timer_s gavl_timer_t
Opaque timer structure.
Definition: gavltime.h:210
GAVL_PUBLIC void gavl_timer_set(gavl_timer_t *timer, gavl_time_t t)
Set the current time of the timer.