output/Thread: move code to InternalCloseOutput()

This commit is contained in:
Max Kellermann 2017-08-07 17:35:43 +02:00
parent 4580c685f1
commit 3197c0fd7d
2 changed files with 19 additions and 6 deletions

View File

@ -429,6 +429,12 @@ private:
void InternalOpen(AudioFormat audio_format,
const MusicPipe &pipe) noexcept;
/**
* Runs inside the OutputThread.
* Caller must lock the mutex.
*/
void InternalCloseOutput(bool drain) noexcept;
/**
* Runs inside the OutputThread.
* Caller must lock the mutex.

View File

@ -60,14 +60,10 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format)
const auto cf = in_audio_format.WithMask(output->config_audio_format);
if (open && cf != output->filter_audio_format) {
if (open && cf != output->filter_audio_format)
/* if the filter's output format changes, the output
must be reopened as well */
open = false;
const ScopeUnlock unlock(mutex);
output->CloseOutput(true);
}
InternalCloseOutput(true);
output->filter_audio_format = cf;
@ -175,6 +171,17 @@ AudioOutputControl::InternalOpen(const AudioFormat in_audio_format,
ToString(output->out_audio_format).c_str());
}
inline void
AudioOutputControl::InternalCloseOutput(bool drain) noexcept
{
assert(IsOpen());
open = false;
const ScopeUnlock unlock(mutex);
output->CloseOutput(drain);
}
inline void
AudioOutputControl::InternalClose(bool drain) noexcept
{