diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2017-01-23 11:21:51 +0200 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2017-01-23 11:21:51 +0200 |
commit | 1d71fee4c0ba9be181fc48a447b7287754dc9bd1 (patch) | |
tree | 0436c63d2a60ad0cacec79a627f5985d81868519 /glcapture.c | |
parent | 0b35be65b43f88f0a17a6f8830a52415c3ff1aa1 (diff) |
Move out non function hook code out of hooks.h
Also reorder the code a bit
Diffstat (limited to 'glcapture.c')
-rw-r--r-- | glcapture.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/glcapture.c b/glcapture.c index 2aefb69..8db96fe 100644 --- a/glcapture.c +++ b/glcapture.c @@ -103,12 +103,23 @@ struct fifo { #define ERRX(x, y, ...) do { errx(x, "glcapture: "y, ##__VA_ARGS__); } while (0) #define WARN_ONCE(x, ...) do { static bool o = false; if (!o) { WARNX(x, ##__VA_ARGS__); o = true; } } while (0) +// "entrypoints" exposed to hooks.h static void swap_buffers(void); static void alsa_writei(snd_pcm_t *pcm, const void *buffer, const snd_pcm_uframes_t size, const char *caller); +static uint64_t get_fake_time_ns(void); #include "hooks.h" #include "glwrangle.h" +static uint64_t +get_time_ns(void) +{ + struct timespec ts; + HOOK(clock_gettime); + _clock_gettime(CLOCK_MONOTONIC, &ts); + return (uint64_t)ts.tv_sec * (uint64_t)1e9 + (uint64_t)ts.tv_nsec; +} + static void reset_fifo(struct fifo *fifo) { @@ -447,3 +458,12 @@ alsa_writei(snd_pcm_t *pcm, const void *buffer, const snd_pcm_uframes_t size, co if (alsa_get_frame_info(pcm, &info, caller)) write_data(&info, buffer, snd_pcm_frames_to_bytes(pcm, size)); } + +static uint64_t +get_fake_time_ns(void) +{ + static __thread uint64_t base; + const uint64_t current = get_time_ns(); + base = (base ? base : current); + return base + (current - base) * SPEED_HACK; +} |