aboutsummaryrefslogtreecommitdiffstats
path: root/src/timer.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/timer.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/timer.c b/src/timer.c
index d9a143bcc..0b3b1198a 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2009 The Music Player Daemon Project
+ * Copyright (C) 2003-2010 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,6 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "config.h"
#include "timer.h"
#include "audio_format.h"
@@ -70,6 +71,19 @@ void timer_add(Timer *timer, int size)
timer->time += ((uint64_t)size * 1000000) / timer->rate;
}
+unsigned
+timer_delay(const Timer *timer)
+{
+ int64_t delay = (int64_t)(timer->time - now()) / 1000;
+ if (delay < 0)
+ return 0;
+
+ if (delay > G_MAXINT)
+ delay = G_MAXINT;
+
+ return delay / 1000;
+}
+
void timer_sync(Timer *timer)
{
int64_t sleep_duration;