diff options
author | Max Kellermann <max@musicpd.org> | 2016-12-29 23:20:26 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2016-12-29 23:20:26 +0100 |
commit | db95aa250d4ad26d44451fcce679a44cb2d3ee5a (patch) | |
tree | 31feef294d1dcac1ba336bb506dc28241185d868 | |
parent | 982d1bf66261f91cae5b16f7210d910c634376b4 (diff) |
output/Control: pass "force" flag to LockUpdate()
Reduce overhead by eliminating MultipleOutputs::ResetReopen().
-rw-r--r-- | src/output/Internal.hxx | 4 | ||||
-rw-r--r-- | src/output/MultipleOutputs.cxx | 26 | ||||
-rw-r--r-- | src/output/MultipleOutputs.hxx | 9 | ||||
-rw-r--r-- | src/output/OutputControl.cxx | 5 |
4 files changed, 12 insertions, 32 deletions
diff --git a/src/output/Internal.hxx b/src/output/Internal.hxx index 307b2a034..4973b0bee 100644 --- a/src/output/Internal.hxx +++ b/src/output/Internal.hxx @@ -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(); diff --git a/src/output/MultipleOutputs.cxx b/src/output/MultipleOutputs.cxx index 8751b105a..3d0e13816 100644 --- a/src/output/MultipleOutputs.cxx +++ b/src/output/MultipleOutputs.cxx @@ -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(); diff --git a/src/output/MultipleOutputs.hxx b/src/output/MultipleOutputs.hxx index 2814d3ecd..850984ad1 100644 --- a/src/output/MultipleOutputs.hxx +++ b/src/output/MultipleOutputs.hxx @@ -237,19 +237,12 @@ 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? diff --git a/src/output/OutputControl.cxx b/src/output/OutputControl.cxx index 8ffc8e02d..fd20a6dd2 100644 --- a/src/output/OutputControl.cxx +++ b/src/output/OutputControl.cxx @@ -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); } |