mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
[VCM] Fix issues on certain systems (#12481)
- Don't depend on System.Windows.Forms in the Settings -> use callback instead - Fix overlay image setting saving - Use dynamic DLL loading in Interop - Load VCM only when mf.dll is available
This commit is contained in:
@@ -78,7 +78,7 @@
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<AdditionalDependencies>mfplat.lib;mf.lib;mfreadwrite.lib;mfuuid.lib;shlwapi.lib;gdiplus.lib;dwmapi.lib;uxtheme.lib;shcore.lib;Wtsapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>shlwapi.lib;gdiplus.lib;dwmapi.lib;uxtheme.lib;shcore.lib;Wtsapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>xcopy /y /I "$(ProjectDir)Icons\*" "$(OutDir)Icons"
|
||||
@@ -101,7 +101,7 @@ xcopy /y /I "$(ProjectDir)black.bmp*" "$(OutDir)"</Command>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<AdditionalDependencies>mfplat.lib;mf.lib;mfreadwrite.lib;mfuuid.lib;shlwapi.lib;gdiplus.lib;dwmapi.lib;uxtheme.lib;shcore.lib;Wtsapi32.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>shlwapi.lib;gdiplus.lib;dwmapi.lib;uxtheme.lib;shcore.lib;Wtsapi32.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>xcopy /y /I "$(ProjectDir)Icons\*" "$(OutDir)Icons"
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <wil/resource.h>
|
||||
#include <wil/com.h>
|
||||
|
||||
#include <mfapi.h>
|
||||
#include <mfidl.h>
|
||||
#include <mftransform.h>
|
||||
#include <dshow.h>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
</Lib>
|
||||
<PreBuildEvent Condition="'$(Platform)'=='x64'">
|
||||
<Command>call "$(ProjectDir)build_vcm_x86.cmd"</Command>
|
||||
</PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<PropertyGroup Condition="'$(Platform)'!='Win32'">
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\VideoConference\</OutDir>
|
||||
@@ -87,7 +87,7 @@
|
||||
<RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>$(OutDir)VideoConferenceShared.lib;mfplat.lib;Mfsensorgroup.lib;OneCoreUAP.lib;Mf.lib;Shlwapi.lib;Strmiids.lib;%(AdditionalDependencies);</AdditionalDependencies>
|
||||
<AdditionalDependencies>$(OutDir)VideoConferenceShared.lib;Windowscodecs.lib;Wtsapi32.lib;mfplat.lib;WindowsApp.lib;Mfsensorgroup.lib;Mf.lib;Shlwapi.lib;Strmiids.lib;%(AdditionalDependencies);</AdditionalDependencies>
|
||||
<ModuleDefinitionFile>module.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
|
||||
#define DECLARE_DLL_FUNCTION(NAME) \
|
||||
std::function<decltype(::NAME)> NAME = (std::add_pointer_t<decltype(::NAME)>)GetProcAddress(_library_handle, #NAME);
|
||||
|
||||
#define DECLARE_DLL_PROVIDER_BEGIN(DLL_NAME) \
|
||||
class DLL_NAME##APIProvider final \
|
||||
{ \
|
||||
HMODULE _library_handle; \
|
||||
DLL_NAME##APIProvider(HMODULE h) : _library_handle{ h } {} \
|
||||
\
|
||||
public: \
|
||||
~DLL_NAME##APIProvider() { FreeLibrary(_library_handle); } \
|
||||
static std::optional<DLL_NAME##APIProvider> create() \
|
||||
{ \
|
||||
HMODULE h = LoadLibraryA(#DLL_NAME ".dll"); \
|
||||
std::optional<DLL_NAME##APIProvider> result; \
|
||||
if (!h) \
|
||||
return result; \
|
||||
result.emplace(DLL_NAME##APIProvider{ h }); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
#define DECLAR_DLL_PROVIDER_END \
|
||||
} \
|
||||
;
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
|
||||
#include <initguid.h>
|
||||
#include <mfapi.h>
|
||||
|
||||
#pragma warning(disable : 4127)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <mfapi.h>
|
||||
#include <mfidl.h>
|
||||
|
||||
#include "DLLProviderHelpers.h"
|
||||
|
||||
DECLARE_DLL_PROVIDER_BEGIN(mfplat)
|
||||
DECLARE_DLL_FUNCTION(MFCreateAttributes)
|
||||
DECLAR_DLL_PROVIDER_END
|
||||
|
||||
DECLARE_DLL_PROVIDER_BEGIN(mf)
|
||||
DECLARE_DLL_FUNCTION(MFEnumDeviceSources)
|
||||
DECLAR_DLL_PROVIDER_END
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "VideoCaptureDeviceList.h"
|
||||
#include "Logging.h"
|
||||
#include "MediaFoundationAPIProvider.h"
|
||||
#include <mfapi.h>
|
||||
#include <Mfidl.h>
|
||||
|
||||
@@ -32,11 +33,17 @@ HRESULT VideoCaptureDeviceList::EnumerateDevices()
|
||||
HRESULT hr = S_OK;
|
||||
wil::com_ptr<IMFAttributes> pAttributes;
|
||||
Clear();
|
||||
auto mfplatAPI = mfplatAPIProvider::create();
|
||||
auto mfAPI = mfAPIProvider::create();
|
||||
if (!mfplatAPI || !mfAPI)
|
||||
{
|
||||
return ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
// Initialize an attribute store. We will use this to
|
||||
// specify the enumeration parameters.
|
||||
|
||||
hr = MFCreateAttributes(&pAttributes, 1);
|
||||
hr = mfplatAPI->MFCreateAttributes(&pAttributes, 1);
|
||||
|
||||
// Ask for source type = video capture devices
|
||||
if (SUCCEEDED(hr))
|
||||
@@ -52,14 +59,13 @@ HRESULT VideoCaptureDeviceList::EnumerateDevices()
|
||||
// Enumerate devices.
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = MFEnumDeviceSources(pAttributes.get(), &m_ppDevices, &m_numberDevices);
|
||||
hr = mfAPI->MFEnumDeviceSources(pAttributes.get(), &m_ppDevices, &m_numberDevices);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("VideoCaptureDeviceList::EnumerateDevices(): Couldn't SetGUID");
|
||||
}
|
||||
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
LOG("VideoCaptureDeviceList::EnumerateDevices(): MFEnumDeviceSources failed");
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</ItemGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<Link>
|
||||
<AdditionalDependencies>mfplat.lib;Mfsensorgroup.lib;OneCoreUAP.lib;Mf.lib;Shlwapi.lib;Strmiids.lib;%(AdditionalDependencies);</AdditionalDependencies>
|
||||
<AdditionalDependencies>mfplat.lib;Mfsensorgroup.lib;Mf.lib;Shlwapi.lib;Strmiids.lib;%(AdditionalDependencies);</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
@@ -116,7 +116,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CameraStateUpdateChannels.h" />
|
||||
<ClInclude Include="DLLProviderHelpers.h" />
|
||||
<ClInclude Include="Logging.h" />
|
||||
<ClInclude Include="MediaFoundationAPIProvider.h" />
|
||||
<ClInclude Include="SerializedSharedMemory.h" />
|
||||
<ClInclude Include="naming.h" />
|
||||
<ClInclude Include="MicrophoneDevice.h" />
|
||||
|
||||
Reference in New Issue
Block a user