d3d11device: Report alive d3d11 objects at the end
authorSeungha Yang <seungha.yang@navercorp.com>
Wed, 11 Dec 2019 11:21:42 +0000 (20:21 +0900)
committerSeungha Yang <seungha.yang@navercorp.com>
Wed, 11 Dec 2019 14:04:49 +0000 (23:04 +0900)
It would be useful for debugging d3d11 object leak.

sys/d3d11/gstd3d11device.c

index cd2d8da..b2739db 100644 (file)
@@ -35,6 +35,13 @@ GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_device_debug);
 
 #ifdef HAVE_D3D11SDKLAYER_H
 static GModule *sdk_layer = NULL;
+
+/* mingw header does not define D3D11_RLDO_IGNORE_INTERNAL
+ * D3D11_RLDO_SUMMARY = 0x1,
+   D3D11_RLDO_DETAIL = 0x2,
+ * D3D11_RLDO_IGNORE_INTERNAL = 0x4
+ */
+#define GST_D3D11_RLDO_FLAGS (0x2 | 0x4)
 #endif
 
 enum
@@ -314,7 +321,8 @@ gst_d3d11_device_constructed (GObject * object)
 
     if (SUCCEEDED (hr)) {
       GST_DEBUG_OBJECT (self, "D3D11Debug interface available");
-      ID3D11Debug_ReportLiveDeviceObjects (debug, D3D11_RLDO_DETAIL);
+      ID3D11Debug_ReportLiveDeviceObjects (debug,
+          (D3D11_RLDO_FLAGS) GST_D3D11_RLDO_FLAGS);
       priv->debug = debug;
     }
 
@@ -415,6 +423,31 @@ gst_d3d11_device_dispose (GObject * object)
 
   GST_LOG_OBJECT (self, "dispose");
 
+  if (priv->device) {
+    ID3D11Device_Release (priv->device);
+    priv->device = NULL;
+  }
+
+  if (priv->device_context) {
+    ID3D11DeviceContext_Release (priv->device_context);
+    priv->device_context = NULL;
+  }
+
+  if (priv->video_device) {
+    ID3D11VideoDevice_Release (priv->video_device);
+    priv->video_device = NULL;
+  }
+
+  if (priv->video_context) {
+    ID3D11VideoContext_Release (priv->video_context);
+    priv->video_context = NULL;
+  }
+
+  if (priv->factory) {
+    IDXGIFactory1_Release (priv->factory);
+    priv->factory = NULL;
+  }
+
   if (priv->loop) {
     g_main_loop_quit (priv->loop);
   }
@@ -435,42 +468,20 @@ gst_d3d11_device_dispose (GObject * object)
   }
 #ifdef HAVE_D3D11SDKLAYER_H
   if (priv->debug) {
+    ID3D11Debug_ReportLiveDeviceObjects (priv->debug,
+        (D3D11_RLDO_FLAGS) GST_D3D11_RLDO_FLAGS);
     ID3D11Debug_Release (priv->debug);
     priv->debug = NULL;
   }
 
   if (priv->info_queue) {
-    ID3D11InfoQueue_ClearStoredMessages (priv->info_queue);
+    gst_d3d11_device_get_message (self);
+
     ID3D11InfoQueue_Release (priv->info_queue);
     priv->info_queue = NULL;
   }
 #endif
 
-  if (priv->device) {
-    ID3D11Device_Release (priv->device);
-    priv->device = NULL;
-  }
-
-  if (priv->device_context) {
-    ID3D11DeviceContext_Release (priv->device_context);
-    priv->device_context = NULL;
-  }
-
-  if (priv->video_device) {
-    ID3D11VideoDevice_Release (priv->video_device);
-    priv->video_device = NULL;
-  }
-
-  if (priv->video_context) {
-    ID3D11VideoContext_Release (priv->video_context);
-    priv->video_context = NULL;
-  }
-
-  if (priv->factory) {
-    IDXGIFactory1_Release (priv->factory);
-    priv->factory = NULL;
-  }
-
   G_OBJECT_CLASS (parent_class)->dispose (object);
 }