output/Thread: skip WaitForDelay() after resuming playback
This allows removing the "base.pause" check from the JACK output plugin, and will allow removing similar accesses from other plugins.
This commit is contained in:
parent
a50b2c3b85
commit
353299168a
@ -167,6 +167,13 @@ class AudioOutputControl {
|
|||||||
*/
|
*/
|
||||||
bool woken_for_play = false;
|
bool woken_for_play = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this flag is set, then the next WaitForDelay() call is
|
||||||
|
* skipped. This is used to avoid delays after resuming
|
||||||
|
* playback.
|
||||||
|
*/
|
||||||
|
bool skip_delay;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Mutex &mutex;
|
Mutex &mutex;
|
||||||
|
|
||||||
|
@ -209,6 +209,7 @@ AudioOutputControl::InternalOpen(const AudioFormat audio_format,
|
|||||||
{
|
{
|
||||||
last_error = nullptr;
|
last_error = nullptr;
|
||||||
fail_timer.Reset();
|
fail_timer.Reset();
|
||||||
|
skip_delay = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
output->Open(audio_format, pipe);
|
output->Open(audio_format, pipe);
|
||||||
@ -304,7 +305,9 @@ AudioOutputControl::PlayChunk() noexcept
|
|||||||
if (data.IsEmpty())
|
if (data.IsEmpty())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!WaitForDelay())
|
if (skip_delay)
|
||||||
|
skip_delay = false;
|
||||||
|
else if (!WaitForDelay())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
size_t nbytes;
|
size_t nbytes;
|
||||||
@ -425,6 +428,8 @@ AudioOutputControl::InternalPause() noexcept
|
|||||||
} while (command == Command::NONE);
|
} while (command == Command::NONE);
|
||||||
|
|
||||||
output->EndPause();
|
output->EndPause();
|
||||||
|
|
||||||
|
skip_delay = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -129,7 +129,7 @@ struct JackOutput {
|
|||||||
size_t WriteSamples(const float *src, size_t n_frames);
|
size_t WriteSamples(const float *src, size_t n_frames);
|
||||||
|
|
||||||
std::chrono::steady_clock::duration Delay() const noexcept {
|
std::chrono::steady_clock::duration Delay() const noexcept {
|
||||||
return base.pause && pause && !shutdown
|
return pause && !shutdown
|
||||||
? std::chrono::seconds(1)
|
? std::chrono::seconds(1)
|
||||||
: std::chrono::steady_clock::duration::zero();
|
: std::chrono::steady_clock::duration::zero();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user