Commit fc046205 authored by Max Kellermann's avatar Max Kellermann

output/Internal: move code to ConfigureConvertFilter()

parent d4ee1652
...@@ -46,6 +46,17 @@ AudioOutput::Disable() noexcept ...@@ -46,6 +46,17 @@ AudioOutput::Disable() noexcept
} }
void void
AudioOutput::ConfigureConvertFilter()
{
try {
convert_filter_set(convert_filter.Get(), out_audio_format);
} catch (const std::runtime_error &e) {
std::throw_with_nested(FormatRuntimeError("Failed to convert for \"%s\" [%s]",
name, plugin.name));
}
}
void
AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format) AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
{ {
out_audio_format = desired_audio_format; out_audio_format = desired_audio_format;
...@@ -63,7 +74,7 @@ AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format) ...@@ -63,7 +74,7 @@ AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
ToString(out_audio_format).c_str()); ToString(out_audio_format).c_str());
try { try {
convert_filter_set(convert_filter.Get(), out_audio_format); ConfigureConvertFilter();
} catch (const std::runtime_error &e) { } catch (const std::runtime_error &e) {
ao_plugin_close(*this); ao_plugin_close(*this);
...@@ -82,8 +93,7 @@ AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format) ...@@ -82,8 +93,7 @@ AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
return; return;
} }
std::throw_with_nested(FormatRuntimeError("Failed to convert for \"%s\" [%s]", throw;
name, plugin.name));
} }
} }
......
...@@ -143,6 +143,8 @@ public: ...@@ -143,6 +143,8 @@ public:
*/ */
void Close(bool drain) noexcept; void Close(bool drain) noexcept;
void ConfigureConvertFilter();
/** /**
* Invoke OutputPlugin::open() and configure the * Invoke OutputPlugin::open() and configure the
* #ConvertFilter. * #ConvertFilter.
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "OutputPlugin.hxx" #include "OutputPlugin.hxx"
#include "Domain.hxx" #include "Domain.hxx"
#include "notify.hxx" #include "notify.hxx"
#include "filter/plugins/ConvertFilterPlugin.hxx"
#include "mixer/MixerInternal.hxx" #include "mixer/MixerInternal.hxx"
#include "thread/Util.hxx" #include "thread/Util.hxx"
#include "thread/Slack.hxx" #include "thread/Slack.hxx"
...@@ -73,8 +72,7 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format) ...@@ -73,8 +72,7 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format)
input AudioFormat */ input AudioFormat */
try { try {
convert_filter_set(output->convert_filter.Get(), output->ConfigureConvertFilter();
output->out_audio_format);
} catch (const std::runtime_error &e) { } catch (const std::runtime_error &e) {
open = false; open = false;
...@@ -83,8 +81,7 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format) ...@@ -83,8 +81,7 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format)
output->CloseOutput(false); output->CloseOutput(false);
} }
std::throw_with_nested(FormatRuntimeError("Failed to convert for \"%s\" [%s]", throw;
GetName(), output->plugin.name));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment