diff options
author | Matthew Gregan <[email protected]> | 2018-03-14 09:56:22 +1300 |
---|---|---|
committer | Matthew Gregan <[email protected]> | 2018-03-21 09:29:30 +1300 |
commit | 13d9e2874cb13ece4d14efcf34b086770f0bd624 (patch) | |
tree | 7b1ef1e7b95602d9136627fd70c0d2a80741e499 /test | |
parent | 200bcbd920642d1f890bd4346c5f58f769ff4f06 (diff) | |
download | cubeb-13d9e2874cb13ece4d14efcf34b086770f0bd624.tar.gz cubeb-13d9e2874cb13ece4d14efcf34b086770f0bd624.zip |
wasapi: Remove COM initialization and require caller to complete.
This addresses the thread local COM initialization lifetime problem
discussed in issue #416 by moving the responsibility for COM
initialization from within cubeb to the caller.
Diffstat (limited to 'test')
-rw-r--r-- | test/common.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/common.h b/test/common.h index 032c635..43af6a9 100644 --- a/test/common.h +++ b/test/common.h @@ -11,6 +11,7 @@ #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif +#include <objbase.h> #include <windows.h> #else #include <unistd.h> @@ -109,4 +110,24 @@ int common_init(cubeb ** ctx, char const * ctx_name) return r; } +#if defined( _WIN32) +class TestEnvironment : public ::testing::Environment { +public: + void SetUp() override { + hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); + } + + void TearDown() override { + if (SUCCEEDED(hr)) { + CoUninitialize(); + } + } + +private: + HRESULT hr; +}; + +::testing::Environment* const foo_env = ::testing::AddGlobalTestEnvironment(new TestEnvironment); +#endif + #endif /* TEST_COMMON */ |