]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/hwcontext_d3d11va.c
avcodec/amfenc: move config.h include where it's needed
[ffmpeg] / libavutil / hwcontext_d3d11va.c
index 65dd6651fc1da5b488a1fe045495901efd4ca50e..2f97156a54ce1cc31fc939391ef05688f358109d 100644 (file)
@@ -458,20 +458,31 @@ static void d3d11va_device_uninit(AVHWDeviceContext *hwdev)
 {
     AVD3D11VADeviceContext *device_hwctx = hwdev->hwctx;
 
-    if (device_hwctx->device)
+    if (device_hwctx->device) {
         ID3D11Device_Release(device_hwctx->device);
+        device_hwctx->device = NULL;
+    }
 
-    if (device_hwctx->device_context)
+    if (device_hwctx->device_context) {
         ID3D11DeviceContext_Release(device_hwctx->device_context);
+        device_hwctx->device_context = NULL;
+    }
 
-    if (device_hwctx->video_device)
+    if (device_hwctx->video_device) {
         ID3D11VideoDevice_Release(device_hwctx->video_device);
+        device_hwctx->video_device = NULL;
+    }
 
-    if (device_hwctx->video_context)
+    if (device_hwctx->video_context) {
         ID3D11VideoContext_Release(device_hwctx->video_context);
+        device_hwctx->video_context = NULL;
+    }
 
-    if (device_hwctx->lock == d3d11va_default_lock)
+    if (device_hwctx->lock == d3d11va_default_lock) {
         CloseHandle(device_hwctx->lock_ctx);
+        device_hwctx->lock_ctx = INVALID_HANDLE_VALUE;
+        device_hwctx->lock = NULL;
+    }
 }
 
 static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device,
@@ -515,8 +526,15 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device,
 
     hr = mD3D11CreateDevice(pAdapter, pAdapter ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE, NULL, creationFlags, NULL, 0,
                    D3D11_SDK_VERSION, &device_hwctx->device, NULL, NULL);
-    if (pAdapter)
+    if (pAdapter) {
+        DXGI_ADAPTER_DESC2 desc;
+        hr = IDXGIAdapter2_GetDesc(pAdapter, &desc);
+        if (!FAILED(hr)) {
+            av_log(ctx, AV_LOG_INFO, "Using device %04x:%04x (%ls).\n",
+                   desc.VendorId, desc.DeviceId, desc.Description);
+        }
         IDXGIAdapter_Release(pAdapter);
+    }
     if (FAILED(hr)) {
         av_log(ctx, AV_LOG_ERROR, "Failed to create Direct3D device (%lx)\n", (long)hr);
         return AVERROR_UNKNOWN;