summaryrefslogtreecommitdiffstats
path: root/plugins/alsa/time_utils.c
blob: 6f22e9d0916b3df21a6bb173b9a3f5635a5bbcf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "time_utils.h"
#include "time.h"

__thread uint64_t last = 0;

uint64_t now_monotonic_usec() {
	struct timespec now;
	clock_gettime(CLOCK_MONOTONIC, &now);
	return now.tv_sec*1000000+now.tv_nsec/1000;
}

uint64_t ts() {
	uint64_t now = now_monotonic_usec();
	uint64_t elapsed = now-last;
	last = now;
	return elapsed;
}