From f65e2035abfbd2660ed91d7882a2bdcd9301db0a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 22 May 2016 12:52:36 +0200 Subject: {compat,api}/camera: make CoInitializeEx use the right threading apartment --- opentrack-compat/camera-names.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'opentrack-compat') diff --git a/opentrack-compat/camera-names.cpp b/opentrack-compat/camera-names.cpp index 72bcf41a..ef5c159d 100644 --- a/opentrack-compat/camera-names.cpp +++ b/opentrack-compat/camera-names.cpp @@ -1,20 +1,18 @@ #include "camera-names.hpp" -#if defined(OPENTRACK_API) && defined(_WIN32) +#ifdef _WIN32 # define NO_DSHOW_STRSAFE # include # include -#endif - -#if defined(OPENTRACK_API) && (defined(__unix) || defined(__linux) || defined(__APPLE__)) +#elif defined(__unix) || defined(__linux) || defined(__APPLE__) # include #endif #ifdef __linux -#include -#include -#include -#include +# include +# include +# include +# include #endif #include @@ -33,9 +31,9 @@ OPENTRACK_COMPAT_EXPORT QList get_camera_names() { #if defined(_WIN32) // Create the System Device Enumerator. HRESULT hr; - hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); + hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); if (FAILED(hr)) - qDebug() << "failed CoInitializeEx" << hr; + qDebug() << "failed CoInitializeEx" << hr << GetLastError(); ICreateDevEnum *pSysDevEnum = NULL; hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); if (FAILED(hr)) @@ -110,4 +108,4 @@ OPENTRACK_COMPAT_EXPORT QList get_camera_names() { } #endif return ret; -} \ No newline at end of file +} -- cgit v1.2.3