diff --git a/source/dshow-base.hpp b/source/dshow-base.hpp index 5e90f8d..04313e7 100644 --- a/source/dshow-base.hpp +++ b/source/dshow-base.hpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "ComPtr.hpp" #include "CoTaskMemPtr.hpp" diff --git a/source/dshow-enum.cpp b/source/dshow-enum.cpp index 9dc104f..3205038 100644 --- a/source/dshow-enum.cpp +++ b/source/dshow-enum.cpp @@ -473,6 +473,30 @@ static bool EnumDevice(const GUID &type, IMoniker *deviceInfo, } propertyData->Read(L"DevicePath", &devicePath, NULL); + if (!devicePath.bstrVal) { + /* fall back to another method to get device path */ + LPMALLOC co_malloc = nullptr; + hr = CoGetMalloc(1, &co_malloc); + if (FAILED(hr)) + return true; + + ComPtr bind_ctx = nullptr; + hr = CreateBindCtx(0, &bind_ctx); + if (FAILED(hr)) + return true; + + LPOLESTR olestr = nullptr; + bool success = true; + hr = deviceInfo->GetDisplayName(bind_ctx, nullptr, &olestr); + if (SUCCEEDED(hr)) { + hr = InitVariantFromString(olestr, &devicePath); + if (FAILED(hr)) + success = false; + } + co_malloc->Free(olestr); + if (!success) + return true; + } hr = deviceInfo->BindToObject(NULL, 0, IID_IBaseFilter, (void **)&filter);