summaryrefslogtreecommitdiff
path: root/src/output/Timer.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2016-12-28 10:11:07 +0100
committerMax Kellermann <max@musicpd.org>2016-12-28 22:00:33 +0100
commit71e7d32b081aeb049258ab5f8a4752b68b5a39ae (patch)
treeb03e40292bc021009701a0287a0a9ca71042a1ba /src/output/Timer.hxx
parentd5e422970c8973947686ae698a366e07840afaa2 (diff)
output/Timer: use std::chrono
Diffstat (limited to 'src/output/Timer.hxx')
-rw-r--r--src/output/Timer.hxx16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/output/Timer.hxx b/src/output/Timer.hxx
index 40665a07f..0dfabcf35 100644
--- a/src/output/Timer.hxx
+++ b/src/output/Timer.hxx
@@ -20,13 +20,14 @@
#ifndef MPD_TIMER_HXX
#define MPD_TIMER_HXX
-#include <stdint.h>
-#include <stddef.h>
+#include <chrono>
struct AudioFormat;
class Timer {
- uint64_t time;
+ typedef std::chrono::microseconds Time;
+
+ Time time;
bool started = false;
const int rate;
public:
@@ -40,9 +41,14 @@ public:
void Add(size_t size);
/**
- * Returns the number of milliseconds to sleep to get back to sync.
+ * Returns the duration to sleep to get back to sync.
*/
- unsigned GetDelay() const;
+ std::chrono::steady_clock::duration GetDelay() const;
+
+private:
+ static Time Now() {
+ return std::chrono::duration_cast<Time>(std::chrono::steady_clock::now().time_since_epoch());
+ }
};
#endif