output/Thread: allow Delay() to return duration::max()
Eliminate the periodic wakeups while paused in some output plugins.
This commit is contained in:
parent
5b8ef9a62b
commit
12eaaef210
|
@ -136,6 +136,10 @@ public:
|
||||||
* instead of doing a sleep inside the plugin, because this
|
* instead of doing a sleep inside the plugin, because this
|
||||||
* allows MPD to listen to commands meanwhile.
|
* allows MPD to listen to commands meanwhile.
|
||||||
*
|
*
|
||||||
|
* As a special case, this method is allowed to return
|
||||||
|
* std::chrono::steady_clock::duration::max() which lets MPD
|
||||||
|
* sleep forever until a command is received.
|
||||||
|
*
|
||||||
* @return the duration to wait
|
* @return the duration to wait
|
||||||
*/
|
*/
|
||||||
virtual std::chrono::steady_clock::duration Delay() const noexcept {
|
virtual std::chrono::steady_clock::duration Delay() const noexcept {
|
||||||
|
|
|
@ -197,7 +197,10 @@ AudioOutputControl::WaitForDelay(std::unique_lock<Mutex> &lock) noexcept
|
||||||
if (delay <= std::chrono::steady_clock::duration::zero())
|
if (delay <= std::chrono::steady_clock::duration::zero())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
(void)wake_cond.wait_for(lock, delay);
|
if (delay >= std::chrono::steady_clock::duration::max())
|
||||||
|
wake_cond.wait(lock);
|
||||||
|
else
|
||||||
|
(void)wake_cond.wait_for(lock, delay);
|
||||||
|
|
||||||
if (command != Command::NONE)
|
if (command != Command::NONE)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -883,7 +883,7 @@ std::chrono::steady_clock::duration
|
||||||
AlsaOutput::Delay() const noexcept
|
AlsaOutput::Delay() const noexcept
|
||||||
{
|
{
|
||||||
if (paused)
|
if (paused)
|
||||||
return std::chrono::hours{1};
|
return std::chrono::steady_clock::duration::max();
|
||||||
|
|
||||||
return AudioOutput::Delay();
|
return AudioOutput::Delay();
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ public:
|
||||||
|
|
||||||
std::chrono::steady_clock::duration Delay() const noexcept override {
|
std::chrono::steady_clock::duration Delay() const noexcept override {
|
||||||
return pause && !LockWasShutdown()
|
return pause && !LockWasShutdown()
|
||||||
? std::chrono::seconds(1)
|
? std::chrono::steady_clock::duration::max()
|
||||||
: std::chrono::steady_clock::duration::zero();
|
: std::chrono::steady_clock::duration::zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -762,7 +762,7 @@ PulseOutput::Delay() const noexcept
|
||||||
if (pa_stream_is_corked(stream) &&
|
if (pa_stream_is_corked(stream) &&
|
||||||
pa_stream_get_state(stream) == PA_STREAM_READY)
|
pa_stream_get_state(stream) == PA_STREAM_READY)
|
||||||
/* idle while paused */
|
/* idle while paused */
|
||||||
result = std::chrono::seconds(1);
|
result = std::chrono::steady_clock::duration::max();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -684,7 +684,7 @@ WasapiOutput::Delay() const noexcept
|
||||||
{
|
{
|
||||||
if (paused) {
|
if (paused) {
|
||||||
// idle while paused
|
// idle while paused
|
||||||
return std::chrono::seconds(1);
|
return std::chrono::steady_clock::duration::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::chrono::steady_clock::duration::zero();
|
return std::chrono::steady_clock::duration::zero();
|
||||||
|
|
Loading…
Reference in New Issue