From 7b7d32d22ccc90e1137c9f7eb2e8a360c426016a Mon Sep 17 00:00:00 2001 From: ItsTheSky Date: Wed, 15 Jul 2026 12:00:25 +0200 Subject: [PATCH] add logging for camera blacklist and COM initialization status --- source/webcam.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/source/webcam.cpp b/source/webcam.cpp index 05c62c2..8f82bc7 100644 --- a/source/webcam.cpp +++ b/source/webcam.cpp @@ -160,7 +160,11 @@ std::vector DisplayDeviceInformation(IEnumMoniker *pEnum) camera_ids.push_back(counter_device); return_id_device = counter_device; } - + else + { + __LOG_CAM__<<"CAM ID "< id_devices; HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); - if (SUCCEEDED(hr)) + char hr_buf[32]; + sprintf_s(hr_buf, "0x%08lX", (unsigned long)hr); + __LOG_CAM__ << "CoInitializeEx hr=" << hr_buf << "\n"; + // RPC_E_CHANGED_MODE : COM deja initialise (STA) sur ce thread, utilisable tel quel + bool com_usable = SUCCEEDED(hr) || hr == RPC_E_CHANGED_MODE; + bool com_owned = SUCCEEDED(hr); + if (com_usable) { IEnumMoniker *pEnum; - hr = EnumerateDevices(CLSID_VideoInputDeviceCategory, &pEnum); - if (SUCCEEDED(hr)) + HRESULT hr_enum = EnumerateDevices(CLSID_VideoInputDeviceCategory, &pEnum); + sprintf_s(hr_buf, "0x%08lX", (unsigned long)hr_enum); + __LOG_CAM__ << "EnumerateDevices hr=" << hr_buf << "\n"; + if (SUCCEEDED(hr_enum)) { id_devices = DisplayDeviceInformation(pEnum); pEnum->Release(); } - CoUninitialize(); + if (com_owned) + CoUninitialize(); + } + else + { + __LOG_CAM__ << "CoInitializeEx FAILED, enumeration skipped\n"; } if (id_devices.size() == 0) {