gavltime.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GAVLTIME_H_INCLUDED
00023 #define GAVLTIME_H_INCLUDED
00024
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028
00029 #include <inttypes.h>
00030 #include <gavl/gavldefs.h>
00031
00038 #define GAVL_TIME_SCALE 1000000
00043 #define GAVL_TIME_UNDEFINED 0x8000000000000000LL
00046 #define GAVL_TIME_MAX 0x7fffffffffffffffLL
00053 typedef int64_t gavl_time_t;
00054
00055
00056
00061 GAVL_PUBLIC
00062 gavl_time_t gavl_samples_to_time(int samplerate, int64_t samples);
00063
00071 GAVL_PUBLIC
00072 int64_t gavl_time_to_samples(int samplerate, gavl_time_t time);
00073
00078 GAVL_PUBLIC
00079 gavl_time_t gavl_frames_to_time(int rate_num, int rate_den, int64_t frames);
00080
00081
00090 GAVL_PUBLIC
00091 int64_t gavl_time_to_frames(int rate_num, int rate_den, gavl_time_t time);
00092
00100 GAVL_PUBLIC
00101 int64_t gavl_time_scale(int scale, gavl_time_t time);
00102
00110 GAVL_PUBLIC
00111 gavl_time_t gavl_time_unscale(int scale, int64_t time);
00112
00121 GAVL_PUBLIC
00122 int64_t gavl_time_rescale(int scale1, int scale2, int64_t time);
00123
00130 #define gavl_seconds_to_time(s) (gavl_time_t)((s)*(double)(GAVL_TIME_SCALE))
00131
00138 #define gavl_time_to_seconds(t) ((double)(t)/(double)(GAVL_TIME_SCALE))
00139
00145 GAVL_PUBLIC
00146 void gavl_time_delay(gavl_time_t * time);
00147
00152 #define GAVL_TIME_STRING_LEN 11
00153
00163 GAVL_PUBLIC void
00164 gavl_time_prettyprint(gavl_time_t time, char str[GAVL_TIME_STRING_LEN]);
00165
00170 #define GAVL_TIME_STRING_LEN_MS 15
00171
00183 GAVL_PUBLIC void
00184 gavl_time_prettyprint_ms(gavl_time_t time, char str[GAVL_TIME_STRING_LEN_MS]);
00185
00186
00187
00188
00189
00190 GAVL_PUBLIC
00191 int gavl_time_parse(const char * str, gavl_time_t * ret);
00192
00193
00194
00195
00210 typedef struct gavl_timer_s gavl_timer_t;
00211
00217 GAVL_PUBLIC
00218 gavl_timer_t * gavl_timer_create();
00219
00227 GAVL_PUBLIC
00228 void gavl_timer_destroy(gavl_timer_t * timer);
00229
00235 GAVL_PUBLIC
00236 void gavl_timer_start(gavl_timer_t * timer);
00237
00243 GAVL_PUBLIC
00244 void gavl_timer_stop(gavl_timer_t * timer);
00245
00252 GAVL_PUBLIC
00253 gavl_time_t gavl_timer_get(gavl_timer_t * timer);
00254
00261 GAVL_PUBLIC
00262 void gavl_timer_set(gavl_timer_t * timer, gavl_time_t t);
00263
00275 GAVL_PUBLIC
00276 uint64_t gavl_benchmark_get_time(int flags);
00277
00286 GAVL_PUBLIC
00287 const char * gavl_benchmark_get_desc(int flags);
00288
00289
00290 #ifdef __cplusplus
00291 }
00292 #endif
00293
00294 #endif
00295