diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-05-22 12:52:36 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-05-22 13:29:44 +0200 |
commit | f65e2035abfbd2660ed91d7882a2bdcd9301db0a (patch) | |
tree | 3c7d7b3c648d8ed31f65174fc68c71adf9d1d36a /opentrack-compat | |
parent | c6819cfa0213a72be66c7e6c9808fd1b7ad9ce03 (diff) |
{compat,api}/camera: make CoInitializeEx use the right threading apartment
Diffstat (limited to 'opentrack-compat')
-rw-r--r-- | opentrack-compat/camera-names.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
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 <windows.h> # include <dshow.h> -#endif - -#if defined(OPENTRACK_API) && (defined(__unix) || defined(__linux) || defined(__APPLE__)) +#elif defined(__unix) || defined(__linux) || defined(__APPLE__) # include <unistd.h> #endif #ifdef __linux -#include <fcntl.h> -#include <sys/ioctl.h> -#include <linux/videodev2.h> -#include <cerrno> +# include <fcntl.h> +# include <sys/ioctl.h> +# include <linux/videodev2.h> +# include <cerrno> #endif #include <QDebug> @@ -33,9 +31,9 @@ OPENTRACK_COMPAT_EXPORT QList<QString> 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<QString> get_camera_names() { } #endif return ret; -}
\ No newline at end of file +} |