diff options
author | Max Kellermann <max@musicpd.org> | 2016-12-13 21:26:28 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2016-12-13 21:26:28 +0100 |
commit | d44790b35f6c06b9a1144b4448fe0aac6d9805ba (patch) | |
tree | 544431b824c5ec5ede9521ec7dfc5526ca8b1794 | |
parent | f8164a3dd101d4352361f0a4e041736f1740c816 (diff) |
output/Thread: reduce locking further in Open()
-rw-r--r-- | src/output/OutputThread.cxx | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/output/OutputThread.cxx b/src/output/OutputThread.cxx index 25676f239..f3354bfe5 100644 --- a/src/output/OutputThread.cxx +++ b/src/output/OutputThread.cxx @@ -146,9 +146,10 @@ AudioOutput::Open() /* open the filter */ + const ScopeUnlock unlock(mutex); + AudioFormat filter_audio_format; try { - const ScopeUnlock unlock(mutex); filter_audio_format = OpenFilter(in_audio_format); } catch (const std::runtime_error &e) { FormatError(e, "Failed to open filter for \"%s\" [%s]", @@ -162,8 +163,6 @@ AudioOutput::Open() out_audio_format = filter_audio_format.WithMask(config_audio_format); - mutex.unlock(); - const AudioFormat retry_audio_format = out_audio_format; retry_without_dsd: @@ -174,13 +173,12 @@ AudioOutput::Open() name, plugin.name); CloseFilter(); - mutex.lock(); + + const ScopeLock lock(mutex); fail_timer.Update(); return; } - mutex.lock(); - assert(!open); try { @@ -189,7 +187,6 @@ AudioOutput::Open() FormatError(e, "Failed to convert for \"%s\" [%s]", name, plugin.name); - mutex.unlock(); ao_plugin_close(this); if (out_audio_format.format == SampleFormat::DSD) { @@ -213,14 +210,12 @@ AudioOutput::Open() } CloseFilter(); - mutex.lock(); + const ScopeLock lock(mutex); fail_timer.Update(); return; } - open = true; - FormatDebug(output_domain, "opened plugin=%s name=\"%s\" audio_format=%s", plugin.name, name, @@ -230,6 +225,9 @@ AudioOutput::Open() FormatDebug(output_domain, "converting from %s", audio_format_to_string(in_audio_format, &af_string)); + + const ScopeLock lock(mutex); + open = true; } void |