output/pipewire: implement Delay(), fix busy loop while paused

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1265
This commit is contained in:
Max Kellermann 2021-09-24 11:26:07 +02:00
parent bad3283182
commit 57a1403f08
1 changed files with 14 additions and 0 deletions

View File

@ -179,6 +179,7 @@ private:
pw_thread_loop_signal(thread_loop, false);
}
std::chrono::steady_clock::duration Delay() const noexcept override;
size_t Play(const void *chunk, size_t size) override;
void Drain() override;
@ -493,6 +494,19 @@ PipeWireOutput::Process() noexcept
pw_thread_loop_signal(thread_loop, false);
}
std::chrono::steady_clock::duration
PipeWireOutput::Delay() const noexcept
{
const PipeWire::ThreadLoopLock lock(thread_loop);
auto result = std::chrono::steady_clock::duration::zero();
if (paused)
/* idle while paused */
result = std::chrono::seconds(1);
return result;
}
size_t
PipeWireOutput::Play(const void *chunk, size_t size)
{