output/Thread: move OpenSoftwareMixer() to the end

This call cannot fail, but needs cleanup if others fail.  By moving it
to the end, we eliminate some cleanup.
This commit is contained in:
Max Kellermann 2017-08-07 18:36:04 +02:00
parent 4f7f577a57
commit d4ee165253

View File

@ -52,8 +52,6 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format)
{
assert(in_audio_format.IsValid());
output->OpenSoftwareMixer();
const auto cf = in_audio_format.WithMask(output->config_audio_format);
if (open && cf != output->filter_audio_format)
@ -64,13 +62,9 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format)
output->filter_audio_format = cf;
if (!open) {
try {
{
const ScopeUnlock unlock(mutex);
output->OpenOutputAndConvert(output->filter_audio_format);
} catch (...) {
const ScopeUnlock unlock(mutex);
output->CloseSoftwareMixer();
throw;
}
open = true;
@ -86,13 +80,18 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format)
{
const ScopeUnlock unlock(mutex);
output->Close(false);
output->CloseOutput(false);
}
std::throw_with_nested(FormatRuntimeError("Failed to convert for \"%s\" [%s]",
GetName(), output->plugin.name));
}
}
{
const ScopeUnlock unlock(mutex);
output->OpenSoftwareMixer();
}
}
inline bool