mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
va: vpp: global lock to handle shared buffers
Add a global mutex to exclusive access to shared stream buffers, such as DMABufs or VASurfaces after a tee: LIBVA_DRIVER_NAME=iHD \ gst-launch-1.0 v4l2src ! tee name=t t. ! queue ! \ vapostproc skin-tone=9 ! xvimagesink \ t. ! queue ! vapostproc ! xvimagesink Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1529>
This commit is contained in:
parent
9845ec68dc
commit
990d1bfbce
3 changed files with 24 additions and 9 deletions
|
@ -397,6 +397,7 @@ gst_va_filter_close (GstVaFilter * self)
|
|||
|
||||
GST_OBJECT_LOCK (self);
|
||||
g_clear_pointer (&self->available_filters, g_array_unref);
|
||||
g_clear_pointer (&self->filters, g_array_unref);
|
||||
gst_va_filter_init (self);
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
|
||||
|
|
|
@ -139,6 +139,8 @@ enum
|
|||
VPP_CONVERT_FEATURE = 1 << 4,
|
||||
};
|
||||
|
||||
extern GRecMutex GST_VA_SHARED_LOCK;
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
static const gchar *caps_str = GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("memory:VAMemory",
|
||||
"{ NV12, I420, YV12, YUY2, RGBA, BGRA, P010_10LE, ARGB, ABGR }") " ;"
|
||||
|
@ -1004,6 +1006,18 @@ _get_sinkpad_pool (GstVaVpp * self)
|
|||
return self->sinkpad_pool;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_try_import_buffer_unlocked (GstVaVpp * self, GstBuffer * inbuf)
|
||||
{
|
||||
VASurfaceID surface;
|
||||
|
||||
surface = gst_va_buffer_get_surface (inbuf, NULL);
|
||||
if (surface != VA_INVALID_ID)
|
||||
return TRUE;
|
||||
|
||||
return _try_import_dmabuf (self, inbuf);
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_va_vpp_import_input_buffer (GstVaVpp * self, GstBuffer * inbuf,
|
||||
GstBuffer ** buf)
|
||||
|
@ -1012,16 +1026,12 @@ gst_va_vpp_import_input_buffer (GstVaVpp * self, GstBuffer * inbuf,
|
|||
GstBufferPool *pool;
|
||||
GstFlowReturn ret;
|
||||
GstVideoFrame in_frame, out_frame;
|
||||
VASurfaceID surface;
|
||||
gboolean copied;
|
||||
gboolean imported, copied;
|
||||
|
||||
surface = gst_va_buffer_get_surface (inbuf, NULL);
|
||||
if (surface != VA_INVALID_ID) {
|
||||
*buf = gst_buffer_ref (inbuf);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
if (_try_import_dmabuf (self, inbuf)) {
|
||||
g_rec_mutex_lock (&GST_VA_SHARED_LOCK);
|
||||
imported = _try_import_buffer_unlocked (self, inbuf);
|
||||
g_rec_mutex_unlock (&GST_VA_SHARED_LOCK);
|
||||
if (imported) {
|
||||
*buf = gst_buffer_ref (inbuf);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
#define GST_CAT_DEFAULT gstva_debug
|
||||
GST_DEBUG_CATEGORY (gstva_debug);
|
||||
|
||||
/* big bad mutex to exclusive access to shared stream buffers, such as
|
||||
* DMABuf after a tee */
|
||||
GRecMutex GST_VA_SHARED_LOCK = { 0, };
|
||||
|
||||
static void
|
||||
plugin_add_dependencies (GstPlugin * plugin)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue