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.
This commit is contained in:
Max Kellermann
2009-02-28 20:43:23 +01:00
parent a5c09c91c4
commit ec4fd9fd88
6 changed files with 35 additions and 16 deletions

View File

@@ -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);