d3d11: Don't accept buffer pool which holds different device
authorSeungha Yang <seungha@centricular.com>
Fri, 23 Apr 2021 09:44:41 +0000 (18:44 +0900)
committerSeungha Yang <seungha@centricular.com>
Tue, 27 Apr 2021 15:25:57 +0000 (00:25 +0900)
At the moment, d3d11 plugin doesn't support texture sharing between
different device

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2191>

sys/d3d11/gstd3d11compositor.cpp
sys/d3d11/gstd3d11convert.cpp
sys/d3d11/gstd3d11deinterlace.cpp
sys/d3d11/gstd3d11desktopdupsrc.cpp
sys/d3d11/gstd3d11upload.cpp

index a187b39..7852598 100644 (file)
@@ -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) {
index 4f6c2c0..8f272e6 100644 (file)
@@ -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;
index 2ddd490..f1315c3 100644 (file)
@@ -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;
index ff47b5d..372addc 100644 (file)
@@ -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);
index 030f4ae..a0bce4c 100644 (file)
@@ -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;