Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: media/audio/audio_manager.cc

Issue 1130753005: Get audio_unittests passing with h/w on windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: MTA -> STA Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_input_volume_unittest.cc ('k') | media/audio/audio_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_manager.cc
diff --git a/media/audio/audio_manager.cc b/media/audio/audio_manager.cc
index 97076affb68de799697226aa81b1ef84d60c1a86..ed559f9fd93ba025a8c636d770e268f985dc9482 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,14 @@ 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());
+ }
+#endif
+
private:
FakeAudioLogFactory fake_log_factory_;
@@ -130,6 +142,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 +207,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());
}
« no previous file with comments | « media/audio/audio_input_volume_unittest.cc ('k') | media/audio/audio_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698