add logging for camera blacklist and COM initialization status
This commit is contained in:
@ -160,6 +160,10 @@ std::vector<int> DisplayDeviceInformation(IEnumMoniker *pEnum)
|
||||
camera_ids.push_back(counter_device);
|
||||
return_id_device = counter_device;
|
||||
}
|
||||
else
|
||||
{
|
||||
__LOG_CAM__<<"CAM ID "<<counter_device<<" EXCLUDED BY BLACKLIST ("<<name.c_str()<<")\n";
|
||||
}
|
||||
|
||||
|
||||
__LOG_CAM__<<"RETURN DEVICE ID "<<return_id_device<<"\n";
|
||||
@ -210,19 +214,32 @@ bool Webcam::Open(int width_, int height_) {
|
||||
|
||||
std::vector<int> 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();
|
||||
}
|
||||
|
||||
if (com_owned)
|
||||
CoUninitialize();
|
||||
}
|
||||
else
|
||||
{
|
||||
__LOG_CAM__ << "CoInitializeEx FAILED, enumeration skipped\n";
|
||||
}
|
||||
|
||||
if (id_devices.size() == 0) {
|
||||
__LOG_CAM__ << "No camera found (devices empty)\n";
|
||||
|
||||
Reference in New Issue
Block a user