output/pipewire: implement Pause()
This commit is contained in:
parent
52577ac87a
commit
4d1ce7023b
@ -58,6 +58,7 @@ class PipeWireOutput final : AudioOutput {
|
|||||||
|
|
||||||
bool disconnected;
|
bool disconnected;
|
||||||
bool interrupted;
|
bool interrupted;
|
||||||
|
bool paused;
|
||||||
bool drained;
|
bool drained;
|
||||||
|
|
||||||
explicit PipeWireOutput(const ConfigBlock &block);
|
explicit PipeWireOutput(const ConfigBlock &block);
|
||||||
@ -139,7 +140,7 @@ private:
|
|||||||
|
|
||||||
void Drain() override;
|
void Drain() override;
|
||||||
void Cancel() noexcept override;
|
void Cancel() noexcept override;
|
||||||
// TODO: bool Pause() noexcept override;
|
bool Pause() noexcept override;
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr auto stream_events = PipeWireOutput::MakeStreamEvents();
|
static constexpr auto stream_events = PipeWireOutput::MakeStreamEvents();
|
||||||
@ -287,6 +288,7 @@ void
|
|||||||
PipeWireOutput::Open(AudioFormat &audio_format)
|
PipeWireOutput::Open(AudioFormat &audio_format)
|
||||||
{
|
{
|
||||||
disconnected = false;
|
disconnected = false;
|
||||||
|
paused = false;
|
||||||
drained = true;
|
drained = true;
|
||||||
|
|
||||||
auto props = pw_properties_new(PW_KEY_MEDIA_TYPE, "Audio",
|
auto props = pw_properties_new(PW_KEY_MEDIA_TYPE, "Audio",
|
||||||
@ -379,6 +381,9 @@ PipeWireOutput::Play(const void *chunk, size_t size)
|
|||||||
{
|
{
|
||||||
const PipeWire::ThreadLoopLock lock(thread_loop);
|
const PipeWire::ThreadLoopLock lock(thread_loop);
|
||||||
|
|
||||||
|
if (paused)
|
||||||
|
pw_stream_set_active(stream, true);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
CheckThrowError();
|
CheckThrowError();
|
||||||
|
|
||||||
@ -416,6 +421,18 @@ PipeWireOutput::Cancel() noexcept
|
|||||||
ring_buffer->reset();
|
ring_buffer->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
PipeWireOutput::Pause() noexcept
|
||||||
|
{
|
||||||
|
const PipeWire::ThreadLoopLock lock(thread_loop);
|
||||||
|
interrupted = false;
|
||||||
|
|
||||||
|
paused = true;
|
||||||
|
pw_stream_set_active(stream, false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const struct AudioOutputPlugin pipewire_output_plugin = {
|
const struct AudioOutputPlugin pipewire_output_plugin = {
|
||||||
"pipewire",
|
"pipewire",
|
||||||
nullptr,
|
nullptr,
|
||||||
|
Loading…
Reference in New Issue
Block a user