From 3ab905644d0e89388186c2cde93fd9808c64df37 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 8 Aug 2017 18:41:35 +0200 Subject: [PATCH] output/Shout: open the encoder first, then open connection This order will be necessary for proper AudioFormat initialization, because the encoder may change the format. --- src/output/plugins/ShoutOutputPlugin.cxx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/output/plugins/ShoutOutputPlugin.cxx b/src/output/plugins/ShoutOutputPlugin.cxx index 09bb1b762..a5a8c9aa1 100644 --- a/src/output/plugins/ShoutOutputPlugin.cxx +++ b/src/output/plugins/ShoutOutputPlugin.cxx @@ -348,19 +348,13 @@ ShoutOpen(shout_t *shout_conn) void ShoutOutput::Open(AudioFormat &audio_format) { - ShoutOpen(shout_conn); + encoder = prepared_encoder->Open(audio_format); try { - encoder = prepared_encoder->Open(audio_format); - - try { - WritePage(); - } catch (const std::runtime_error &) { - delete encoder; - throw; - } - } catch (const std::runtime_error &) { - shout_close(shout_conn); + ShoutOpen(shout_conn); + WritePage(); + } catch (...) { + delete encoder; throw; } }