output/Thread: reduce locking further in Open()
This commit is contained in:
parent
f8164a3dd1
commit
d44790b35f
@ -146,9 +146,10 @@ AudioOutput::Open()
|
|||||||
|
|
||||||
/* open the filter */
|
/* open the filter */
|
||||||
|
|
||||||
|
const ScopeUnlock unlock(mutex);
|
||||||
|
|
||||||
AudioFormat filter_audio_format;
|
AudioFormat filter_audio_format;
|
||||||
try {
|
try {
|
||||||
const ScopeUnlock unlock(mutex);
|
|
||||||
filter_audio_format = OpenFilter(in_audio_format);
|
filter_audio_format = OpenFilter(in_audio_format);
|
||||||
} catch (const std::runtime_error &e) {
|
} catch (const std::runtime_error &e) {
|
||||||
FormatError(e, "Failed to open filter for \"%s\" [%s]",
|
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);
|
out_audio_format = filter_audio_format.WithMask(config_audio_format);
|
||||||
|
|
||||||
mutex.unlock();
|
|
||||||
|
|
||||||
const AudioFormat retry_audio_format = out_audio_format;
|
const AudioFormat retry_audio_format = out_audio_format;
|
||||||
|
|
||||||
retry_without_dsd:
|
retry_without_dsd:
|
||||||
@ -174,13 +173,12 @@ AudioOutput::Open()
|
|||||||
name, plugin.name);
|
name, plugin.name);
|
||||||
|
|
||||||
CloseFilter();
|
CloseFilter();
|
||||||
mutex.lock();
|
|
||||||
|
const ScopeLock lock(mutex);
|
||||||
fail_timer.Update();
|
fail_timer.Update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex.lock();
|
|
||||||
|
|
||||||
assert(!open);
|
assert(!open);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -189,7 +187,6 @@ AudioOutput::Open()
|
|||||||
FormatError(e, "Failed to convert for \"%s\" [%s]",
|
FormatError(e, "Failed to convert for \"%s\" [%s]",
|
||||||
name, plugin.name);
|
name, plugin.name);
|
||||||
|
|
||||||
mutex.unlock();
|
|
||||||
ao_plugin_close(this);
|
ao_plugin_close(this);
|
||||||
|
|
||||||
if (out_audio_format.format == SampleFormat::DSD) {
|
if (out_audio_format.format == SampleFormat::DSD) {
|
||||||
@ -213,14 +210,12 @@ AudioOutput::Open()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CloseFilter();
|
CloseFilter();
|
||||||
mutex.lock();
|
|
||||||
|
|
||||||
|
const ScopeLock lock(mutex);
|
||||||
fail_timer.Update();
|
fail_timer.Update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
open = true;
|
|
||||||
|
|
||||||
FormatDebug(output_domain,
|
FormatDebug(output_domain,
|
||||||
"opened plugin=%s name=\"%s\" audio_format=%s",
|
"opened plugin=%s name=\"%s\" audio_format=%s",
|
||||||
plugin.name, name,
|
plugin.name, name,
|
||||||
@ -230,6 +225,9 @@ AudioOutput::Open()
|
|||||||
FormatDebug(output_domain, "converting from %s",
|
FormatDebug(output_domain, "converting from %s",
|
||||||
audio_format_to_string(in_audio_format,
|
audio_format_to_string(in_audio_format,
|
||||||
&af_string));
|
&af_string));
|
||||||
|
|
||||||
|
const ScopeLock lock(mutex);
|
||||||
|
open = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user