pipewire/src/gst
Michael Olbrich 314ff82ff0 pipewiresrc: fix handling outstanding buffers when stopping
The current code has several issues if a pipewiresrc is stopped and deleted
while a buffer is still in use downstream.

 - pw_stream_queue_buffer() is never called for the corresponding
   pw_buffer. As a result, the busy counter is never decremented and
   pw_stream_dequeue_buffer() of the corresponding pipewire output will
   return NULL whenever it encounters this buffer.

 - The pipewiresrc does not own the buffer reference unless the buffer is
   queued in the source, so calling gst_buffer_unref() unconditionally
   causes refcount issues for the buffer.

 - buffer_recycle() can race with on_remove_buffer() and
   gst_pipewire_src_close(). As a result, buffer_recycle() may access pwsrc
   when it was already deleted.

The buffer has its own reference to the pool. So the pool object lock can
be used to ensure that the pwsrc, core and stream remain valid in.
buffer_recycle(). If the 'dispose' function pointer was already cleared,
then on_remove_buffer() has already finished, so abort early.

With the pool lock held, it is save to access the pipewire loop. Now the
loop lock can be used to synchronize with on_remove_buffer(). 'dispose'
must be checked again in case on_remove_buffer() was triggered by something
other than gst_pipewire_src_close().

In on_remove_buffer() unref the buffer if it is queued. Otherwise call
pw_stream_queue_buffer() to ensure that the busy counter is decremented
correctly.
2021-10-14 19:16:56 +00:00
..
.editorconfig add .editorconfig files 2019-02-13 11:19:21 +01:00
gstpipewire.c meson.build: drop VERSION, use PACKAGE_VERSION in the C sources 2021-06-10 09:30:56 +02:00
gstpipewireclock.c meson.build: drop HAVE_CONFIG_H 2021-06-10 09:04:16 +10:00
gstpipewireclock.h gst: replace tabs with spaces 2019-12-19 15:42:42 +01:00
gstpipewirecore.c gst: init last_error 2021-10-14 19:16:56 +00:00
gstpipewirecore.h gst: add 30 seconds timeout 2021-09-16 10:05:58 +02:00
gstpipewiredeviceprovider.c meson.build: drop HAVE_CONFIG_H 2021-06-10 09:04:16 +10:00
gstpipewiredeviceprovider.h meson.build: drop HAVE_CONFIG_H 2021-06-10 09:04:16 +10:00
gstpipewireformat.c gst: support ulaw/alaw conversion of caps 2021-08-17 17:34:14 +02:00
gstpipewireformat.h gst: replace tabs with spaces 2019-12-19 15:42:42 +01:00
gstpipewirepool.c meson.build: drop HAVE_CONFIG_H 2021-06-10 09:04:16 +10:00
gstpipewirepool.h gst: support VideoCrop meta 2020-07-31 11:44:46 +02:00
gstpipewiresink.c gst: add 30 seconds timeout 2021-09-16 10:05:58 +02:00
gstpipewiresink.h gst: share the core between connections 2020-07-13 18:38:19 +02:00
gstpipewiresrc.c pipewiresrc: fix handling outstanding buffers when stopping 2021-10-14 19:16:56 +00:00
gstpipewiresrc.h gst: don't do set_caps from the pipewire callback 2020-08-06 13:03:40 +02:00
meson.build meson.build: drop HAVE_CONFIG_H 2021-06-10 09:04:16 +10:00