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
}
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)
{
out_audio_format = desired_audio_format;
......@@ -63,7 +74,7 @@ AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
ToString(out_audio_format).c_str());
try {
convert_filter_set(convert_filter.Get(), out_audio_format);
ConfigureConvertFilter();
} catch (const std::runtime_error &e) {
ao_plugin_close(*this);
......@@ -82,8 +93,7 @@ AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
return;
}
std::throw_with_nested(FormatRuntimeError("Failed to convert for \"%s\" [%s]",
name, plugin.name));
throw;
}
}
......
......@@ -143,6 +143,8 @@ public:
*/
void Close(bool drain) noexcept;
void ConfigureConvertFilter();
/**
* Invoke OutputPlugin::open() and configure the
* #ConvertFilter.
......
......@@ -24,7 +24,6 @@
#include "OutputPlugin.hxx"
#include "Domain.hxx"
#include "notify.hxx"
#include "filter/plugins/ConvertFilterPlugin.hxx"
#include "mixer/MixerInternal.hxx"
#include "thread/Util.hxx"
#include "thread/Slack.hxx"
......@@ -73,8 +72,7 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format)
input AudioFormat */
try {
convert_filter_set(output->convert_filter.Get(),
output->out_audio_format);
output->ConfigureConvertFilter();
} catch (const std::runtime_error &e) {
open = false;
......@@ -83,8 +81,7 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format)
output->CloseOutput(false);
}
std::throw_with_nested(FormatRuntimeError("Failed to convert for \"%s\" [%s]",
GetName(), output->plugin.name));
throw;
}
}
......
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