output/Internal: remove mutex code from Close()

This commit is contained in:
Max Kellermann 2017-08-07 16:25:23 +02:00
parent 15dcaeda0f
commit 546b773b21
3 changed files with 17 additions and 4 deletions

View File

@ -108,8 +108,6 @@ AudioOutput::CloseFilter() noexcept
void
AudioOutput::Close(bool drain) noexcept
{
const ScopeUnlock unlock(mutex);
CloseOutput(drain);
CloseFilter();

View File

@ -142,6 +142,11 @@ public:
void Disable() noexcept;
/**
* Invoke OutputPlugin::close().
*
* Caller must not lock the mutex.
*/
void Close(bool drain) noexcept;
/**

View File

@ -87,7 +87,12 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format)
output->out_audio_format);
} catch (const std::runtime_error &e) {
open = false;
output->Close(false);
{
const ScopeUnlock unlock(mutex);
output->Close(false);
}
std::throw_with_nested(FormatRuntimeError("Failed to convert for \"%s\" [%s]",
GetName(), output->plugin.name));
}
@ -194,7 +199,12 @@ AudioOutputControl::InternalClose(bool drain) noexcept
assert(IsOpen());
open = false;
output->Close(drain);
{
const ScopeUnlock unlock(mutex);
output->Close(drain);
}
source.Close();
}