diff options
author | Max Kellermann <max@duempel.org> | 2013-11-24 20:20:57 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-11-25 22:09:46 +0100 |
commit | 51de8fd10a98e6ed9a2ac10a796236c5b3fe2bf8 (patch) | |
tree | 2d908b259fa90cafd765566cbf24ef7f325fca93 /src/OutputControl.cxx | |
parent | 2ef6052536b91d9312191ca91de663b73249aea5 (diff) | |
download | mpd-51de8fd10a98e6ed9a2ac10a796236c5b3fe2bf8.tar.gz mpd-51de8fd10a98e6ed9a2ac10a796236c5b3fe2bf8.tar.xz mpd-51de8fd10a98e6ed9a2ac10a796236c5b3fe2bf8.zip |
Volume, Output: use new class PeriodClock instead of GTimer
Diffstat (limited to '')
-rw-r--r-- | src/OutputControl.cxx | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/OutputControl.cxx b/src/OutputControl.cxx index 553507a2a..b2e9b284f 100644 --- a/src/OutputControl.cxx +++ b/src/OutputControl.cxx @@ -32,8 +32,6 @@ #include "util/Error.hxx" #include "Log.hxx" -#include <glib.h> - #include <assert.h> #include <stdlib.h> @@ -152,10 +150,7 @@ audio_output_open(struct audio_output *ao, assert(ao->allow_play); assert(audio_format.IsValid()); - if (ao->fail_timer != nullptr) { - g_timer_destroy(ao->fail_timer); - ao->fail_timer = nullptr; - } + ao->fail_timer.Reset(); if (ao->open && audio_format == ao->in_audio_format) { assert(ao->pipe == &mp || @@ -213,14 +208,12 @@ audio_output_close_locked(struct audio_output *ao) if (ao->mixer != nullptr) mixer_auto_close(ao->mixer); - assert(!ao->open || ao->fail_timer == nullptr); + assert(!ao->open || !ao->fail_timer.IsDefined()); if (ao->open) ao_command(ao, AO_COMMAND_CLOSE); - else if (ao->fail_timer != nullptr) { - g_timer_destroy(ao->fail_timer); - ao->fail_timer = nullptr; - } + else + ao->fail_timer.Reset(); } bool @@ -231,8 +224,7 @@ audio_output_update(struct audio_output *ao, const ScopeLock protect(ao->mutex); if (ao->enabled && ao->really_enabled) { - if (ao->fail_timer == nullptr || - g_timer_elapsed(ao->fail_timer, nullptr) > REOPEN_AFTER) { + if (ao->fail_timer.Check(REOPEN_AFTER * 1000)) { return audio_output_open(ao, audio_format, mp); } } else if (audio_output_is_open(ao)) @@ -312,7 +304,7 @@ audio_output_release(struct audio_output *ao) void audio_output_close(struct audio_output *ao) { assert(ao != nullptr); - assert(!ao->open || ao->fail_timer == nullptr); + assert(!ao->open || !ao->fail_timer.IsDefined()); const ScopeLock protect(ao->mutex); audio_output_close_locked(ao); @@ -322,7 +314,7 @@ void audio_output_finish(struct audio_output *ao) { audio_output_close(ao); - assert(ao->fail_timer == nullptr); + assert(!ao->fail_timer.IsDefined()); if (ao->thread.IsDefined()) { assert(ao->allow_play); |