gst: keep track of queued buffers

Pipewire might update buffers that have not been recycled by GStreamer,
because they are still used downstream. There is nothing we can do about
it in the pipewiresrc.

If a buffer is sent downstream more than once, take an additional
reference to make sure that we don't queue a buffer that is still used
and print a warning.
This commit is contained in:
Michael Tretter 2020-05-05 13:07:12 +02:00 committed by Wim Taymans
parent 8adc4ad3b6
commit 52c14e2378
2 changed files with 8 additions and 0 deletions

View file

@ -56,6 +56,7 @@ struct _GstPipeWirePoolData {
goffset offset; goffset offset;
struct pw_buffer *b; struct pw_buffer *b;
GstBuffer *buf; GstBuffer *buf;
gboolean queued;
}; };
struct _GstPipeWirePool { struct _GstPipeWirePool {

View file

@ -373,6 +373,7 @@ buffer_recycle (GstMiniObject *obj)
GST_BUFFER_FLAGS (obj) = data->flags; GST_BUFFER_FLAGS (obj) = data->flags;
src = data->owner; src = data->owner;
data->queued = TRUE;
GST_LOG_OBJECT (obj, "recycle buffer"); GST_LOG_OBJECT (obj, "recycle buffer");
pw_thread_loop_lock (src->loop); pw_thread_loop_lock (src->loop);
@ -392,6 +393,7 @@ on_add_buffer (void *_data, struct pw_buffer *b)
gst_pipewire_pool_wrap_buffer (pwsrc->pool, b); gst_pipewire_pool_wrap_buffer (pwsrc->pool, b);
data = b->user_data; data = b->user_data;
data->owner = pwsrc; data->owner = pwsrc;
data->queued = TRUE;
GST_MINI_OBJECT_CAST (data->buf)->dispose = buffer_recycle; GST_MINI_OBJECT_CAST (data->buf)->dispose = buffer_recycle;
} }
@ -426,6 +428,11 @@ static GstBuffer *dequeue_buffer(GstPipeWireSrc *pwsrc)
GST_LOG_OBJECT (pwsrc, "got new buffer %p", buf); GST_LOG_OBJECT (pwsrc, "got new buffer %p", buf);
if (!data->queued) {
GST_WARNING_OBJECT (pwsrc, "buffer %p was not recycled", buf);
gst_buffer_ref (buf);
}
data->queued = FALSE;
GST_BUFFER_PTS (buf) = GST_CLOCK_TIME_NONE; GST_BUFFER_PTS (buf) = GST_CLOCK_TIME_NONE;
GST_BUFFER_DTS (buf) = GST_CLOCK_TIME_NONE; GST_BUFFER_DTS (buf) = GST_CLOCK_TIME_NONE;