From fa477a4a250658f58f1f21a3fc4d2c844e3de89a Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Wed, 21 Feb 2024 00:57:32 +0900 Subject: [PATCH] amfcodec: Add plugin status message Part-of: --- .../gst-plugins-bad/sys/amfcodec/plugin.cpp | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/amfcodec/plugin.cpp b/subprojects/gst-plugins-bad/sys/amfcodec/plugin.cpp index f549a0e7c0..6e957cd9e2 100644 --- a/subprojects/gst-plugins-bad/sys/amfcodec/plugin.cpp +++ b/subprojects/gst-plugins-bad/sys/amfcodec/plugin.cpp @@ -37,6 +37,8 @@ #include "gstamfh265enc.h" #include "gstamfav1enc.h" +#include + /* *INDENT-OFF* */ using namespace Microsoft::WRL; using namespace amf; @@ -48,20 +50,28 @@ plugin_init (GstPlugin * plugin) AMFFactory *amf_factory; ComPtr < IDXGIFactory1 > factory; HRESULT hr; + bool have_amd_gpu = false; - if (!IsWindows8OrGreater ()) + if (!IsWindows8OrGreater ()) { + gst_plugin_add_status_warning (plugin, + N_("This plugin requires at least Windows 8 or newer.")); return TRUE; + } - if (!gst_amf_init_once ()) + if (!gst_amf_init_once () || !gst_amf_get_factory ()) { + gst_plugin_add_status_warning (plugin, + "AMF runtime library \"" AMF_DLL_NAMEA "\" was not found."); return TRUE; + } amf_factory = (AMFFactory *) gst_amf_get_factory (); - if (!amf_factory) - return TRUE; hr = CreateDXGIFactory1 (IID_PPV_ARGS (&factory)); - if (FAILED (hr)) + if (FAILED (hr)) { + /* Shouldn't happen, this means all DirectX bits would not be functional */ + gst_plugin_add_status_error (plugin, N_("Unable to enumerate GPUs.")); return TRUE; + } /* Enumerate AMD GPUs */ for (guint idx = 0;; idx++) { @@ -86,6 +96,7 @@ plugin_init (GstPlugin * plugin) if (desc.VendorId != 0x1002 && desc.VendorId != 0x1022) continue; + have_amd_gpu = true; luid = gst_d3d11_luid_to_int64 (&desc.AdapterLuid); device = gst_d3d11_device_new_for_adapter_luid (luid, D3D11_CREATE_DEVICE_BGRA_SUPPORT); @@ -116,6 +127,13 @@ plugin_init (GstPlugin * plugin) gst_clear_object (&device); } + if (!have_amd_gpu) { + /* A little unexpected case. AMF runtime (part of driver) is installed + * but AMD GPU is not detected */ + gst_plugin_add_status_warning (plugin, + N_("No AMD graphics cards detected!")); + } + return TRUE; }