Skip to content

Prevent indefinite growing of queue in pipewiresrc by dropping buffers

Michael Tretter requested to merge m.tretter/pipewire:limit-queue into master

In #190 (closed), I mentioned that the queue in the pipewiresrc might grow indefinitely.

To prevent this, I am starting to drop buffers from the queue in certain conditions:

If the queue is getting above some (arbitrary) limit, start to drop the oldest buffer. Right now, the limit is hard coded to half of the default number of buffers for the pipewiresrc. I don't really like the limit and I think that something in relation to the negotiated number of buffers would be better, but not sure.

If Pipewire processes a buffer that is already on the queue, drop the existing buffer from the queue and queue the new buffer. As the old buffer references the same memory as the new buffer, we would start to reorder memories if we keep old buffers on the queue. The data of the old buffer is lost anyway, therefore, we should drop the buffer entirely.

Edited by Michael Tretter

Merge request reports