output/Control: pass "force" flag to LockUpdate()
Reduce overhead by eliminating MultipleOutputs::ResetReopen().
This commit is contained in:
parent
982d1bf662
commit
db95aa250d
@ -383,10 +383,12 @@ public:
|
||||
* Opens or closes the device, depending on the "enabled"
|
||||
* flag.
|
||||
*
|
||||
* @param force true to ignore the #fail_timer
|
||||
* @return true if the device is open
|
||||
*/
|
||||
bool LockUpdate(const AudioFormat audio_format,
|
||||
const MusicPipe &mp);
|
||||
const MusicPipe &mp,
|
||||
bool force);
|
||||
|
||||
void LockPlay();
|
||||
|
||||
|
@ -145,23 +145,8 @@ MultipleOutputs::AllowPlay()
|
||||
ao->LockAllowPlay();
|
||||
}
|
||||
|
||||
static void
|
||||
audio_output_reset_reopen(AudioOutput *ao)
|
||||
{
|
||||
const ScopeLock protect(ao->mutex);
|
||||
|
||||
ao->fail_timer.Reset();
|
||||
}
|
||||
|
||||
void
|
||||
MultipleOutputs::ResetReopen()
|
||||
{
|
||||
for (auto ao : outputs)
|
||||
audio_output_reset_reopen(ao);
|
||||
}
|
||||
|
||||
bool
|
||||
MultipleOutputs::Update()
|
||||
MultipleOutputs::Update(bool force)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
@ -169,7 +154,7 @@ MultipleOutputs::Update()
|
||||
return false;
|
||||
|
||||
for (auto ao : outputs)
|
||||
ret = ao->LockUpdate(input_audio_format, *pipe)
|
||||
ret = ao->LockUpdate(input_audio_format, *pipe, force)
|
||||
|| ret;
|
||||
|
||||
return ret;
|
||||
@ -190,7 +175,7 @@ MultipleOutputs::Play(MusicChunk *chunk)
|
||||
assert(chunk != nullptr);
|
||||
assert(chunk->CheckFormat(input_audio_format));
|
||||
|
||||
if (!Update())
|
||||
if (!Update(false))
|
||||
/* TODO: obtain real error */
|
||||
throw std::runtime_error("Failed to open audio output");
|
||||
|
||||
@ -224,9 +209,8 @@ MultipleOutputs::Open(const AudioFormat audio_format,
|
||||
|
||||
input_audio_format = audio_format;
|
||||
|
||||
ResetReopen();
|
||||
EnableDisable();
|
||||
Update();
|
||||
Update(true);
|
||||
|
||||
std::exception_ptr first_error;
|
||||
|
||||
@ -341,7 +325,7 @@ MultipleOutputs::Check()
|
||||
void
|
||||
MultipleOutputs::Pause()
|
||||
{
|
||||
Update();
|
||||
Update(false);
|
||||
|
||||
for (auto ao : outputs)
|
||||
ao->LockPauseAsync();
|
||||
|
@ -236,20 +236,13 @@ private:
|
||||
*/
|
||||
void AllowPlay();
|
||||
|
||||
/**
|
||||
* Resets the "reopen" flag on all audio devices. MPD should
|
||||
* immediately retry to open the device instead of waiting for
|
||||
* the timeout when the user wants to start playback.
|
||||
*/
|
||||
void ResetReopen();
|
||||
|
||||
/**
|
||||
* Opens all output devices which are enabled, but closed.
|
||||
*
|
||||
* @return true if there is at least open output device which
|
||||
* is open
|
||||
*/
|
||||
bool Update();
|
||||
bool Update(bool force);
|
||||
|
||||
/**
|
||||
* Has this chunk been consumed by all audio outputs?
|
||||
|
@ -159,12 +159,13 @@ AudioOutput::CloseWait()
|
||||
|
||||
bool
|
||||
AudioOutput::LockUpdate(const AudioFormat audio_format,
|
||||
const MusicPipe &mp)
|
||||
const MusicPipe &mp,
|
||||
bool force)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
|
||||
if (enabled && really_enabled) {
|
||||
if (!fail_timer.IsDefined() ||
|
||||
if (force || !fail_timer.IsDefined() ||
|
||||
fail_timer.Check(REOPEN_AFTER * 1000)) {
|
||||
return Open(audio_format, mp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user