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

Unified Diff: media/audio/audio_manager.cc

Issue 1097553003: Switch to STA mode for audio thread and WASAPI I/O streams. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 5 years, 8 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
Index: media/audio/audio_manager.cc
diff --git a/media/audio/audio_manager.cc b/media/audio/audio_manager.cc
index 6ee61d16cd7bd6ad3beb3a2cf912b7f4ac1aeffe..2bbffa7eb6a33866c2e2089fa8be28453acccad6 100644
--- a/media/audio/audio_manager.cc
+++ b/media/audio/audio_manager.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/power_monitor/power_monitor.h"
+#include "base/synchronization/waitable_event.h"
#include "build/build_config.h"
#include "media/audio/fake_audio_log_factory.h"
@@ -157,7 +158,19 @@ AudioManager* AudioManager::CreateWithHangTimer(
// static
AudioManager* AudioManager::CreateForTesting() {
- return Create(g_helper.Pointer()->fake_log_factory());
+ AudioManager* manager = Create(g_helper.Pointer()->fake_log_factory());
+
+ // When created for testing, always ensure all methods are ready to run (even
+ // if they end up called from other threads.
+ if (!manager->GetTaskRunner()->BelongsToCurrentThread()) {
+ base::WaitableEvent event(false, false);
+ manager->GetTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event)));
+ event.Wait();
+ }
+
+ return manager;
}
// static

Powered by Google App Engine
This is Rietveld 408576698