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
00035 #define GAVL_TIME_SCALE 1000000
00040 #define GAVL_TIME_UNDEFINED 0x8000000000000000LL
00043 #define GAVL_TIME_MAX 0x7fffffffffffffffLL
00050 typedef int64_t gavl_time_t;
00051
00052
00053
00058 gavl_time_t gavl_samples_to_time(int samplerate, int64_t samples);
00059
00067 int64_t gavl_time_to_samples(int samplerate, gavl_time_t time);
00068
00073 gavl_time_t gavl_frames_to_time(int rate_num, int rate_den, int64_t frames);
00074
00075
00084 int64_t gavl_time_to_frames(int rate_num, int rate_den, gavl_time_t time);
00085
00093 int64_t gavl_time_scale(int scale, gavl_time_t time);
00094
00102 gavl_time_t gavl_time_unscale(int scale, int64_t time);
00103
00112 int64_t gavl_time_rescale(int scale1, int scale2, int64_t time);
00113
00120 #define gavl_seconds_to_time(s) (gavl_time_t)((s)*(double)(GAVL_TIME_SCALE))
00121
00128 #define gavl_time_to_seconds(t) ((double)(t)/(double)(GAVL_TIME_SCALE))
00129
00135 void gavl_time_delay(gavl_time_t * time);
00136
00141 #define GAVL_TIME_STRING_LEN 11
00142
00152 void
00153 gavl_time_prettyprint(gavl_time_t time, char str[GAVL_TIME_STRING_LEN]);
00154
00155
00156
00157
00158
00159 int gavl_time_parse(const char * str, gavl_time_t * ret);
00160
00161
00162
00163
00178 typedef struct gavl_timer_s gavl_timer_t;
00179
00185 gavl_timer_t * gavl_timer_create();
00186
00194 void gavl_timer_destroy(gavl_timer_t * timer);
00195
00201 void gavl_timer_start(gavl_timer_t * timer);
00202
00208 void gavl_timer_stop(gavl_timer_t * timer);
00209
00216 gavl_time_t gavl_timer_get(gavl_timer_t * timer);
00217
00224 void gavl_timer_set(gavl_timer_t * timer, gavl_time_t t);
00225
00226 #ifdef __cplusplus
00227 }
00228 #endif
00229
00230 #endif
00231