From 70c96cf0dd7079fa7e54f16304e963f12b0cf0dd Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Fri, 23 Apr 2021 18:44:41 +0900 Subject: [PATCH] d3d11: Don't accept buffer pool which holds different device At the moment, d3d11 plugin doesn't support texture sharing between different device Part-of: --- sys/d3d11/gstd3d11compositor.cpp | 11 ++++++++--- sys/d3d11/gstd3d11convert.cpp | 22 ++++++++++++++++------ sys/d3d11/gstd3d11deinterlace.cpp | 22 ++++++++++++++++------ sys/d3d11/gstd3d11desktopdupsrc.cpp | 14 +++++++++++--- sys/d3d11/gstd3d11upload.cpp | 11 ++++++++--- 5 files changed, 59 insertions(+), 21 deletions(-) diff --git a/sys/d3d11/gstd3d11compositor.cpp b/sys/d3d11/gstd3d11compositor.cpp index a187b39..7852598 100644 --- a/sys/d3d11/gstd3d11compositor.cpp +++ b/sys/d3d11/gstd3d11compositor.cpp @@ -1844,9 +1844,14 @@ gst_d3d11_compositor_decide_allocation (GstAggregator * aggregator, gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); /* create our own pool */ - if (pool && !GST_IS_D3D11_BUFFER_POOL (pool)) { - gst_object_unref (pool); - pool = NULL; + if (pool) { + if (!GST_IS_D3D11_BUFFER_POOL (pool)) { + gst_clear_object (&pool); + } else { + GstD3D11BufferPool *dpool = GST_D3D11_BUFFER_POOL (pool); + if (dpool->device != self->device) + gst_clear_object (&pool); + } } if (!pool) { diff --git a/sys/d3d11/gstd3d11convert.cpp b/sys/d3d11/gstd3d11convert.cpp index 4f6c2c0..8f272e6 100644 --- a/sys/d3d11/gstd3d11convert.cpp +++ b/sys/d3d11/gstd3d11convert.cpp @@ -1211,9 +1211,14 @@ gst_d3d11_base_convert_propose_allocation (GstBaseTransform * trans, n_pools = gst_query_get_n_allocation_pools (query); for (i = 0; i < n_pools; i++) { gst_query_parse_nth_allocation_pool (query, i, &pool, NULL, NULL, NULL); - if (!GST_IS_D3D11_BUFFER_POOL (pool)) { - gst_object_unref (pool); - pool = NULL; + if (pool) { + if (!GST_IS_D3D11_BUFFER_POOL (pool)) { + gst_clear_object (&pool); + } else { + GstD3D11BufferPool *dpool = GST_D3D11_BUFFER_POOL (pool); + if (dpool->device != filter->device) + gst_clear_object (&pool); + } } } @@ -1318,9 +1323,14 @@ gst_d3d11_base_convert_decide_allocation (GstBaseTransform * trans, if (gst_query_get_n_allocation_pools (query) > 0) { gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); - if (pool && !GST_IS_D3D11_BUFFER_POOL (pool)) { - gst_object_unref (pool); - pool = NULL; + if (pool) { + if (!GST_IS_D3D11_BUFFER_POOL (pool)) { + gst_clear_object (&pool); + } else { + GstD3D11BufferPool *dpool = GST_D3D11_BUFFER_POOL (pool); + if (dpool->device != filter->device) + gst_clear_object (&pool); + } } update_pool = TRUE; diff --git a/sys/d3d11/gstd3d11deinterlace.cpp b/sys/d3d11/gstd3d11deinterlace.cpp index 2ddd490..f1315c3 100644 --- a/sys/d3d11/gstd3d11deinterlace.cpp +++ b/sys/d3d11/gstd3d11deinterlace.cpp @@ -887,9 +887,14 @@ gst_d3d11_deinterlace_propose_allocation (GstBaseTransform * trans, n_pools = gst_query_get_n_allocation_pools (query); for (i = 0; i < n_pools; i++) { gst_query_parse_nth_allocation_pool (query, i, &pool, NULL, NULL, NULL); - if (!GST_IS_D3D11_BUFFER_POOL (pool)) { - gst_object_unref (pool); - pool = NULL; + if (pool) { + if (!GST_IS_D3D11_BUFFER_POOL (pool)) { + gst_clear_object (&pool); + } else { + GstD3D11BufferPool *dpool = GST_D3D11_BUFFER_POOL (pool); + if (dpool->device != self->device) + gst_clear_object (&pool); + } } } @@ -980,9 +985,14 @@ gst_d3d11_deinterlace_decide_allocation (GstBaseTransform * trans, if (gst_query_get_n_allocation_pools (query) > 0) { gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); - if (pool && !GST_IS_D3D11_BUFFER_POOL (pool)) { - gst_object_unref (pool); - pool = NULL; + if (pool) { + if (!GST_IS_D3D11_BUFFER_POOL (pool)) { + gst_clear_object (&pool); + } else { + GstD3D11BufferPool *dpool = GST_D3D11_BUFFER_POOL (pool); + if (dpool->device != self->device) + gst_clear_object (&pool); + } } update_pool = TRUE; diff --git a/sys/d3d11/gstd3d11desktopdupsrc.cpp b/sys/d3d11/gstd3d11desktopdupsrc.cpp index ff47b5d..372addc 100644 --- a/sys/d3d11/gstd3d11desktopdupsrc.cpp +++ b/sys/d3d11/gstd3d11desktopdupsrc.cpp @@ -352,11 +352,19 @@ gst_d3d11_desktop_dup_src_decide_allocation (GstBaseSrc * bsrc, update_pool = FALSE; } - if (!pool || !GST_IS_D3D11_BUFFER_POOL (pool)) { - gst_clear_object (&pool); - pool = gst_d3d11_buffer_pool_new (self->device); + if (pool) { + if (!GST_IS_D3D11_BUFFER_POOL (pool)) { + gst_clear_object (&pool); + } else { + GstD3D11BufferPool *dpool = GST_D3D11_BUFFER_POOL (pool); + if (dpool->device != self->device) + gst_clear_object (&pool); + } } + if (!pool) + pool = gst_d3d11_buffer_pool_new (self->device); + config = gst_buffer_pool_get_config (pool); gst_buffer_pool_config_set_params (config, caps, size, min, max); diff --git a/sys/d3d11/gstd3d11upload.cpp b/sys/d3d11/gstd3d11upload.cpp index 030f4ae..a0bce4c 100644 --- a/sys/d3d11/gstd3d11upload.cpp +++ b/sys/d3d11/gstd3d11upload.cpp @@ -404,9 +404,14 @@ gst_d3d11_upload_decide_allocation (GstBaseTransform * trans, GstQuery * query) if (gst_query_get_n_allocation_pools (query) > 0) { gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); - if (pool && !GST_IS_D3D11_BUFFER_POOL (pool)) { - gst_object_unref (pool); - pool = NULL; + if (pool) { + if (!GST_IS_D3D11_BUFFER_POOL (pool)) { + gst_clear_object (&pool); + } else { + GstD3D11BufferPool *dpool = GST_D3D11_BUFFER_POOL (pool); + if (dpool->device != filter->device) + gst_clear_object (&pool); + } } update_pool = TRUE; -- 2.7.4