mirror of
https://github.com/PCSX2/pcsx2.git
synced 2025-12-16 04:08:48 +00:00
usb_eyetoy: Clean up COM initialization, prevent a double-release
Some checks are pending
🐧 Linux Builds / AppImage (push) Waiting to run
🐧 Linux Builds / Flatpak (push) Waiting to run
🍎 MacOS Builds / Defaults (push) Waiting to run
🖥️ Windows Builds / Lint VS Project Files (push) Waiting to run
🖥️ Windows Builds / SSE4 (push) Blocked by required conditions
🖥️ Windows Builds / AVX2 (push) Blocked by required conditions
🖥️ Windows Builds / CMake (push) Waiting to run
Some checks are pending
🐧 Linux Builds / AppImage (push) Waiting to run
🐧 Linux Builds / Flatpak (push) Waiting to run
🍎 MacOS Builds / Defaults (push) Waiting to run
🖥️ Windows Builds / Lint VS Project Files (push) Waiting to run
🖥️ Windows Builds / SSE4 (push) Blocked by required conditions
🖥️ Windows Builds / AVX2 (push) Blocked by required conditions
🖥️ Windows Builds / CMake (push) Waiting to run
If the EyeToy camera was enabled in the settings, but not enabled by the game, it would call CoUninitialize without having called CoInitializeEx first.
This commit is contained in:
parent
521b32c253
commit
3cf21e0ab6
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
|
||||
#include "common/Console.h"
|
||||
#include "common/Error.h"
|
||||
#include "common/StringUtil.h"
|
||||
|
||||
#include "videodev.h"
|
||||
@ -527,7 +528,13 @@ namespace usb_eyetoy
|
||||
|
||||
int DirectShow::Open(int width, int height, FrameFormat format, int mirror)
|
||||
{
|
||||
dshowCoInitialize = wil::CoInitializeEx_failfast(COINIT_MULTITHREADED);
|
||||
const HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Console.ErrorFmt("CoInitializeEx failed: {}", Error::CreateHResult(hr).GetDescription());
|
||||
return -1;
|
||||
}
|
||||
wil::unique_couninitialize_call uninit;
|
||||
|
||||
frame_width = width;
|
||||
frame_height = height;
|
||||
@ -545,7 +552,7 @@ namespace usb_eyetoy
|
||||
int ret = InitializeDevice(StringUtil::UTF8StringToWideString(mHostDevice));
|
||||
if (ret < 0)
|
||||
{
|
||||
Console.Warning("Camera: cannot find '%s'", mHostDevice.c_str());
|
||||
Console.WarningFmt("Camera: cannot find '{}'", mHostDevice);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -559,6 +566,7 @@ namespace usb_eyetoy
|
||||
return -1;
|
||||
}
|
||||
|
||||
dshowCoInitialize = std::move(uninit);
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ namespace usb_eyetoy
|
||||
int InitializeDevice(const std::wstring& selectedDevice);
|
||||
|
||||
private:
|
||||
wil::unique_couninitialize_call dshowCoInitialize;
|
||||
wil::unique_couninitialize_call dshowCoInitialize{false};
|
||||
ICaptureGraphBuilder2* pGraphBuilder;
|
||||
IFilterGraph2* pGraph;
|
||||
IMediaControl* pControl;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user