Chromium Code Reviews| Index: media/audio/audio_manager.cc |
| diff --git a/media/audio/audio_manager.cc b/media/audio/audio_manager.cc |
| index 97076affb68de799697226aa81b1ef84d60c1a86..a3fda4899b90f95f040e5711e2e5359772e08ecc 100644 |
| --- a/media/audio/audio_manager.cc |
| +++ b/media/audio/audio_manager.cc |
| @@ -17,6 +17,10 @@ |
| #include "media/audio/fake_audio_log_factory.h" |
| #include "media/base/media_switches.h" |
| +#if defined(OS_WIN) |
| +#include "base/win/scoped_com_initializer.h" |
| +#endif |
| + |
| namespace media { |
| namespace { |
| @@ -119,6 +123,15 @@ class AudioManagerHelper : public base::PowerObserver { |
| AudioLogFactory* fake_log_factory() { return &fake_log_factory_; } |
| +#if defined(OS_WIN) |
| + // This should be called before creating an AudioManager in tests to ensure |
| + // that the creating thread is COM initialized. |
| + void InitializeCOMForTesting() { |
| + com_initializer_for_testing_.reset(new base::win::ScopedCOMInitializer( |
| + base::win::ScopedCOMInitializer::kMTA)); |
|
DaleCurtis
2015/05/07 02:11:12
Did using a regular initializer (i.e. w/ MTA) fail
|
| + } |
| +#endif |
| + |
| private: |
| FakeAudioLogFactory fake_log_factory_; |
| @@ -130,6 +143,10 @@ class AudioManagerHelper : public base::PowerObserver { |
| base::TimeTicks last_audio_thread_timer_tick_; |
| int hang_failures_; |
| +#if defined(OS_WIN) |
| + scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_for_testing_; |
| +#endif |
| + |
| DISALLOW_COPY_AND_ASSIGN(AudioManagerHelper); |
| }; |
| @@ -191,6 +208,9 @@ AudioManager* AudioManager::CreateWithHangTimer( |
| // static |
| AudioManager* AudioManager::CreateForTesting() { |
| +#if defined(OS_WIN) |
| + g_helper.Pointer()->InitializeCOMForTesting(); |
| +#endif |
| return Create(g_helper.Pointer()->fake_log_factory()); |
| } |