summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorphintuka <phintuka>2012-02-17 09:15:42 +0000
committerphintuka <phintuka>2012-02-17 09:15:42 +0000
commitaf930b27a8a2a88d9629d35094f018eef5c3e417 (patch)
treef37e3642b52beda82fdf7df02a27b1ccf3450e2b /tools
parent693a9595e145d39b3375a39733331924455941c7 (diff)
downloadxineliboutput-af930b27a8a2a88d9629d35094f018eef5c3e417.tar.gz
xineliboutput-af930b27a8a2a88d9629d35094f018eef5c3e417.tar.bz2
moved time_ms() to tools/time_ms.h
Diffstat (limited to 'tools')
-rw-r--r--tools/time_ms.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/time_ms.h b/tools/time_ms.h
new file mode 100644
index 00000000..f49458bb
--- /dev/null
+++ b/tools/time_ms.h
@@ -0,0 +1,29 @@
+/*
+ * time_ms.h: simple current time interface
+ *
+ * See the main source file 'xineliboutput.c' for copyright information and
+ * how to reach the author.
+ *
+ * $Id: time_ms.h,v 1.1 2012-02-17 09:15:42 phintuka Exp $
+ *
+ */
+
+#ifndef XINELIBOUTPUT_TIME_MS_H_
+#define XINELIBOUTPUT_TIME_MS_H_
+
+#include <sys/time.h>
+
+static uint64_t time_ms(void)
+{
+ struct timeval t;
+ if (gettimeofday(&t, NULL) == 0)
+ return ((uint64_t)t.tv_sec) * 1000ULL + t.tv_usec / 1000ULL;
+ return 0;
+}
+
+static uint64_t elapsed(uint64_t t)
+{
+ return time_ms() - t;
+}
+
+#endif /* XINELIBOUTPUT_TIME_MS_H_ */