Skip to content

Commit

Permalink
FIX(client): Prevent endless loop when disconnecting PipeWire stream
Browse files Browse the repository at this point in the history
Since version 0.3.51, PipeWire has support for buffers with a size of 0
being passed in the process callback. More specifically, this feature
was added in commit 96286fb8b11658a0fdaa61194504a3f9541b25e6 ("resample:
use a -1 buffer size to drain") in PipeWire [1].

Unfortunately, this causes an endless loop, because we try to destroy
the PipeWire stream, but it keeps waiting for the node to be completely
drained, which now never happens because it keeps calling
processCallback() where we feed buffers with a size of 0 to it.

To fix this problem, we stop passing buffers to PipeWire when we are
destroying PipeWireOutput by setting m_ok to false on destruction and
checking for isOk() in the callback.

Fixes #5647

[1] https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/96286fb8b11658a0fdaa61194504a3f9541b25e7
  • Loading branch information
vimpostor committed May 6, 2022
1 parent a23a71b commit 6e71c0a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mumble/PipeWire.cpp
Expand Up @@ -291,6 +291,7 @@ void PipeWireEngine::stop() {
if (m_loop) {
pws->pw_thread_loop_stop(m_thread);
}
m_ok = false;
}

pw_buffer *PipeWireEngine::dequeueBuffer() {
Expand Down Expand Up @@ -395,6 +396,10 @@ PipeWireOutput::~PipeWireOutput() {
void PipeWireOutput::processCallback(void *param) {
auto pwo = static_cast< PipeWireOutput * >(param);

if (!pwo->m_engine->isOk()) {
return;
}

pw_buffer *buffer = pwo->m_engine->dequeueBuffer();
if (!buffer) {
return;
Expand Down

0 comments on commit 6e71c0a

Please sign in to comment.