output/MultipleOutputs: parallelize AudioOutput destruction
Reduce latency by stopping all AudioOutputs asynchronously.
This commit is contained in:
parent
fb907f5f76
commit
6425b4f9f5
@ -283,7 +283,8 @@ public:
|
|||||||
void StartThread();
|
void StartThread();
|
||||||
void StopThread();
|
void StopThread();
|
||||||
|
|
||||||
void Finish();
|
void BeginDestroy();
|
||||||
|
void FinishDestroy();
|
||||||
|
|
||||||
bool IsOpen() const {
|
bool IsOpen() const {
|
||||||
return open;
|
return open;
|
||||||
|
@ -43,8 +43,11 @@ MultipleOutputs::MultipleOutputs(MixerListener &_mixer_listener)
|
|||||||
|
|
||||||
MultipleOutputs::~MultipleOutputs()
|
MultipleOutputs::~MultipleOutputs()
|
||||||
{
|
{
|
||||||
|
/* parallel destruction */
|
||||||
for (auto i : outputs)
|
for (auto i : outputs)
|
||||||
i->Finish();
|
i->BeginDestroy();
|
||||||
|
for (auto i : outputs)
|
||||||
|
i->FinishDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
static AudioOutput *
|
static AudioOutput *
|
||||||
|
@ -274,13 +274,22 @@ AudioOutput::StopThread()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioOutput::Finish()
|
AudioOutput::BeginDestroy()
|
||||||
{
|
{
|
||||||
if (mixer != nullptr)
|
if (mixer != nullptr)
|
||||||
mixer_auto_close(mixer);
|
mixer_auto_close(mixer);
|
||||||
|
|
||||||
|
if (thread.IsDefined()) {
|
||||||
|
const ScopeLock protect(mutex);
|
||||||
|
CommandAsync(Command::KILL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioOutput::FinishDestroy()
|
||||||
|
{
|
||||||
if (thread.IsDefined())
|
if (thread.IsDefined())
|
||||||
StopThread();
|
thread.Join();
|
||||||
|
|
||||||
audio_output_free(this);
|
audio_output_free(this);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user