diff --git a/src/output/plugins/PulseOutputPlugin.cxx b/src/output/plugins/PulseOutputPlugin.cxx index 79d7f2ba8..cae66eb36 100644 --- a/src/output/plugins/PulseOutputPlugin.cxx +++ b/src/output/plugins/PulseOutputPlugin.cxx @@ -61,6 +61,8 @@ class PulseOutput { size_t writable; + bool pause; + explicit PulseOutput(const ConfigBlock &block); public: @@ -674,6 +676,8 @@ PulseOutput::Open(AudioFormat &audio_format) throw MakePulseError(context, "pa_stream_connect_playback() has failed"); } + + pause = false; } inline void @@ -723,13 +727,13 @@ PulseOutput::WaitStream() } void -PulseOutput::StreamPause(bool pause) +PulseOutput::StreamPause(bool _pause) { assert(mainloop != nullptr); assert(context != nullptr); assert(stream != nullptr); - pa_operation *o = pa_stream_cork(stream, pause, + pa_operation *o = pa_stream_cork(stream, _pause, pulse_output_stream_success_cb, this); if (o == nullptr) throw MakePulseError(context, @@ -746,7 +750,7 @@ PulseOutput::Delay() noexcept Pulse::LockGuard lock(mainloop); auto result = std::chrono::steady_clock::duration::zero(); - if (base.pause && pa_stream_is_corked(stream) && + if (pause && pa_stream_is_corked(stream) && pa_stream_get_state(stream) == PA_STREAM_READY) /* idle while paused */ result = std::chrono::seconds(1); @@ -762,6 +766,8 @@ PulseOutput::Play(const void *chunk, size_t size) Pulse::LockGuard lock(mainloop); + pause = false; + /* check if the stream is (already) connected */ WaitStream(); @@ -836,6 +842,8 @@ PulseOutput::Pause() Pulse::LockGuard lock(mainloop); + pause = true; + /* check if the stream is (already/still) connected */ WaitStream();