aboutsummaryrefslogtreecommitdiffstats
path: root/src/output_thread.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-02-28 20:43:23 +0100
committerMax Kellermann <max@duempel.org>2009-02-28 20:43:23 +0100
commitec4fd9fd88a10bfc88154e8e6791d5d69858a2e5 (patch)
treec98fe447adcafe85ba9ee94d93d98377f9ffdaeb /src/output_thread.c
parenta5c09c91c414ba08d915331797e717334ac06456 (diff)
downloadmpd-ec4fd9fd88a10bfc88154e8e6791d5d69858a2e5.tar.gz
mpd-ec4fd9fd88a10bfc88154e8e6791d5d69858a2e5.tar.xz
mpd-ec4fd9fd88a10bfc88154e8e6791d5d69858a2e5.zip
output: use GTimer instead of time_t for reopen after failure
time() is not a monotonic timer, and MPD might get confused by clock skews. clock_gettime() provides a monotonic clock, but is not portable to non-POSIX systems (i.e. Windows). This patch uses GLib's GTimer API, which aims to be portable.
Diffstat (limited to 'src/output_thread.c')
-rw-r--r--src/output_thread.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/output_thread.c b/src/output_thread.c
index b5a4c6117..c4d5b16ee 100644
--- a/src/output_thread.c
+++ b/src/output_thread.c
@@ -29,12 +29,6 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "output"
-enum {
- /** after a failure, wait this number of seconds before
- automatically reopening the device */
- REOPEN_AFTER = 10,
-};
-
static void ao_command_finished(struct audio_output *ao)
{
assert(ao->command != AO_COMMAND_NONE);
@@ -129,6 +123,7 @@ static gpointer audio_output_task(gpointer arg)
case AO_COMMAND_OPEN:
assert(!ao->open);
+ assert(ao->fail_timer == NULL);
error = NULL;
ret = ao_plugin_open(ao->plugin, ao->data,
@@ -145,7 +140,7 @@ static gpointer audio_output_task(gpointer arg)
error->message);
g_error_free(error);
- ao->reopen_after = time(NULL) + REOPEN_AFTER;
+ ao->fail_timer = g_timer_new();
}
ao_command_finished(ao);