diff options
Diffstat (limited to '')
-rw-r--r-- | src/OutputThread.cxx | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/OutputThread.cxx b/src/OutputThread.cxx index 30d3ba30f..c65309503 100644 --- a/src/OutputThread.cxx +++ b/src/OutputThread.cxx @@ -35,8 +35,6 @@ #include "Log.hxx" #include "Compiler.h" -#include <glib.h> - #include <assert.h> #include <string.h> @@ -137,14 +135,7 @@ ao_open(struct audio_output *ao) assert(ao->chunk == nullptr); assert(ao->in_audio_format.IsValid()); - if (ao->fail_timer != nullptr) { - /* this can only happen when this - output thread fails while - audio_output_open() is run in the - player thread */ - g_timer_destroy(ao->fail_timer); - ao->fail_timer = nullptr; - } + ao->fail_timer.Reset(); /* enable the device (just in case the last enable has failed) */ @@ -160,7 +151,7 @@ ao_open(struct audio_output *ao) FormatError(error, "Failed to open filter for \"%s\" [%s]", ao->name, ao->plugin->name); - ao->fail_timer = g_timer_new(); + ao->fail_timer.Update(); return; } @@ -180,11 +171,19 @@ ao_open(struct audio_output *ao) ao->name, ao->plugin->name); ao_filter_close(ao); - ao->fail_timer = g_timer_new(); + ao->fail_timer.Update(); return; } - convert_filter_set(ao->convert_filter, ao->out_audio_format); + if (!convert_filter_set(ao->convert_filter, ao->out_audio_format, + error)) { + FormatError(error, "Failed to convert for \"%s\" [%s]", + ao->name, ao->plugin->name); + + ao_filter_close(ao); + ao->fail_timer.Update(); + return; + } ao->open = true; @@ -233,7 +232,9 @@ ao_reopen_filter(struct audio_output *ao) ao_filter_close(ao); const AudioFormat filter_audio_format = ao_filter_open(ao, ao->in_audio_format, error); - if (!filter_audio_format.IsDefined()) { + if (!filter_audio_format.IsDefined() || + !convert_filter_set(ao->convert_filter, ao->out_audio_format, + error)) { FormatError(error, "Failed to open filter for \"%s\" [%s]", ao->name, ao->plugin->name); @@ -246,7 +247,7 @@ ao_reopen_filter(struct audio_output *ao) ao->chunk = nullptr; ao->open = false; - ao->fail_timer = g_timer_new(); + ao->fail_timer.Update(); ao->mutex.unlock(); ao_plugin_close(ao); @@ -254,8 +255,6 @@ ao_reopen_filter(struct audio_output *ao) return; } - - convert_filter_set(ao->convert_filter, ao->out_audio_format); } static void @@ -437,7 +436,7 @@ ao_play_chunk(struct audio_output *ao, const struct music_chunk *chunk) /* don't automatically reopen this device for 10 seconds */ - ao->fail_timer = g_timer_new(); + ao->fail_timer.Update(); return false; } @@ -461,8 +460,8 @@ ao_play_chunk(struct audio_output *ao, const struct music_chunk *chunk) /* don't automatically reopen this device for 10 seconds */ - assert(ao->fail_timer == nullptr); - ao->fail_timer = g_timer_new(); + assert(!ao->fail_timer.IsDefined()); + ao->fail_timer.Update(); return false; } |