Commit 7e1b5348 authored by Max Kellermann's avatar Max Kellermann

output/MultipleOutputs: parallelize EnableDisable()

parent 6425b4f9
......@@ -323,34 +323,34 @@ public:
void LockCommandWait(Command cmd);
/**
* Enables the device.
* Enables the device, but don't wait for completion.
*
* Caller must lock the mutex.
*/
void EnableWait();
void EnableAsync();
/**
* Disables the device.
* Disables the device, but don't wait for completion.
*
* Caller must lock the mutex.
*/
void DisableWait();
void DisableAsync();
/**
* Attempt to enable or disable the device as specified by the
* #enabled attribute; attempt to sync it with #really_enabled
* (wrapper for EnableWait() or DisableWait()).
* (wrapper for EnableAsync() or DisableAsync()).
*
* Caller must lock the mutex.
*/
void EnableDisableWait() {
void EnableDisableAsync() {
if (enabled == really_enabled)
return;
if (enabled)
EnableWait();
EnableAsync();
else
DisableWait();
DisableAsync();
}
void LockPauseAsync();
......
......@@ -107,9 +107,16 @@ MultipleOutputs::FindByName(const char *name) const
void
MultipleOutputs::EnableDisable()
{
/* parallel execution */
for (auto ao : outputs) {
const ScopeLock lock(ao->mutex);
ao->EnableDisableAsync();
}
for (auto ao : outputs) {
const ScopeLock lock(ao->mutex);
ao->EnableDisableWait();
ao->WaitForCommand();
}
}
......
......@@ -70,7 +70,7 @@ AudioOutput::LockCommandWait(Command cmd)
}
void
AudioOutput::EnableWait()
AudioOutput::EnableAsync()
{
if (!thread.IsDefined()) {
if (plugin.enable == nullptr) {
......@@ -84,11 +84,11 @@ AudioOutput::EnableWait()
StartThread();
}
CommandWait(Command::ENABLE);
CommandAsync(Command::ENABLE);
}
void
AudioOutput::DisableWait()
AudioOutput::DisableAsync()
{
if (!thread.IsDefined()) {
if (plugin.disable == nullptr)
......@@ -101,7 +101,7 @@ AudioOutput::DisableWait()
return;
}
CommandWait(Command::DISABLE);
CommandAsync(Command::DISABLE);
}
inline bool
......
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