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 <gavl/gavldefs.h>
00030
00037 #define GAVL_TIME_SCALE 1000000
00042 #define GAVL_TIME_UNDEFINED 0x8000000000000000LL
00045 #define GAVL_TIME_MAX 0x7fffffffffffffffLL
00052 typedef int64_t gavl_time_t;
00053
00054
00055
00060 GAVL_PUBLIC
00061 gavl_time_t gavl_samples_to_time(int samplerate, int64_t samples);
00062
00070 GAVL_PUBLIC
00071 int64_t gavl_time_to_samples(int samplerate, gavl_time_t time);
00072
00077 GAVL_PUBLIC
00078 gavl_time_t gavl_frames_to_time(int rate_num, int rate_den, int64_t frames);
00079
00080
00089 GAVL_PUBLIC
00090 int64_t gavl_time_to_frames(int rate_num, int rate_den, gavl_time_t time);
00091
00099 GAVL_PUBLIC
00100 int64_t gavl_time_scale(int scale, gavl_time_t time);
00101
00109 GAVL_PUBLIC
00110 gavl_time_t gavl_time_unscale(int scale, int64_t time);
00111
00120 GAVL_PUBLIC
00121 int64_t gavl_time_rescale(int scale1, int scale2, int64_t time);
00122
00129 #define gavl_seconds_to_time(s) (gavl_time_t)((s)*(double)(GAVL_TIME_SCALE))
00130
00137 #define gavl_time_to_seconds(t) ((double)(t)/(double)(GAVL_TIME_SCALE))
00138
00144 GAVL_PUBLIC
00145 void gavl_time_delay(gavl_time_t * time);
00146
00151 #define GAVL_TIME_STRING_LEN 11
00152
00162 GAVL_PUBLIC void
00163 gavl_time_prettyprint(gavl_time_t time, char str[GAVL_TIME_STRING_LEN]);
00164
00169 #define GAVL_TIME_STRING_LEN_MS 15
00170
00182 GAVL_PUBLIC void
00183 gavl_time_prettyprint_ms(gavl_time_t time, char str[GAVL_TIME_STRING_LEN_MS]);
00184
00185
00186
00187
00188
00189 GAVL_PUBLIC
00190 int gavl_time_parse(const char * str, gavl_time_t * ret);
00191
00192
00193
00194
00209 typedef struct gavl_timer_s gavl_timer_t;
00210
00216 GAVL_PUBLIC
00217 gavl_timer_t * gavl_timer_create();
00218
00226 GAVL_PUBLIC
00227 void gavl_timer_destroy(gavl_timer_t * timer);
00228
00234 GAVL_PUBLIC
00235 void gavl_timer_start(gavl_timer_t * timer);
00236
00242 GAVL_PUBLIC
00243 void gavl_timer_stop(gavl_timer_t * timer);
00244
00251 GAVL_PUBLIC
00252 gavl_time_t gavl_timer_get(gavl_timer_t * timer);
00253
00260 GAVL_PUBLIC
00261 void gavl_timer_set(gavl_timer_t * timer, gavl_time_t t);
00262
00274 GAVL_PUBLIC
00275 uint64_t gavl_benchmark_get_time(int flags);
00276
00284 GAVL_PUBLIC
00285 const char * gavl_benchmark_get_desc(int flags);
00286
00287
00288 #ifdef __cplusplus
00289 }
00290 #endif
00291
00292 #endif
00293