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

Unified Diff: media/mojo/services/test_mojo_media_client.cc

Issue 1806313003: Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments from patch 48 Created 4 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
« no previous file with comments | « media/mojo/services/test_mojo_media_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mojo/services/test_mojo_media_client.cc
diff --git a/media/mojo/services/test_mojo_media_client.cc b/media/mojo/services/test_mojo_media_client.cc
index 8dbd843c88ab56edbc30afcf88c4097e1b77e677..6388e5303033a92c57150a3fcf04ef669644c8d8 100644
--- a/media/mojo/services/test_mojo_media_client.cc
+++ b/media/mojo/services/test_mojo_media_client.cc
@@ -5,6 +5,8 @@
#include "media/mojo/services/test_mojo_media_client.h"
#include "base/memory/ptr_util.h"
+#include "base/run_loop.h"
+#include "base/thread_task_runner_handle.h"
#include "media/audio/audio_manager_base.h"
#include "media/audio/audio_output_stream_sink.h"
#include "media/base/audio_hardware_config.h"
@@ -25,12 +27,14 @@ void TestMojoMediaClient::Initialize() {
// TODO(dalecurtis): We should find a single owner per process for the audio
// manager or make it a lazy instance. It's not safe to call Get()/Create()
// across multiple threads...
- //
- // TODO(dalecurtis): Eventually we'll want something other than a fake audio
- // log factory here too. We should probably at least DVLOG() such info.
AudioManager* audio_manager = AudioManager::Get();
- if (!audio_manager)
- audio_manager = media::AudioManager::Create(&fake_audio_log_factory_);
+ if (!audio_manager) {
+ audio_manager_ = media::AudioManager::CreateForTesting(
+ base::ThreadTaskRunnerHandle::Get());
+ audio_manager = audio_manager_.get();
+ // Flush the message loop to ensure that the audio manager is initialized.
+ base::RunLoop().RunUntilIdle();
+ }
audio_hardware_config_.reset(new AudioHardwareConfig(
audio_manager->GetInputStreamParameters(
@@ -38,6 +42,15 @@ void TestMojoMediaClient::Initialize() {
audio_manager->GetDefaultOutputStreamParameters()));
}
+void TestMojoMediaClient::WillQuit() {
+ DVLOG(1) << __FUNCTION__;
+ // AudioManager destructor requires MessageLoop.
+ // Destroy it before the message loop goes away.
+ audio_manager_.reset();
+ // Flush the message loop to ensure that the audio manager is destroyed.
+ base::RunLoop().RunUntilIdle();
+}
+
std::unique_ptr<RendererFactory> TestMojoMediaClient::CreateRendererFactory(
const scoped_refptr<MediaLog>& media_log) {
DVLOG(1) << __FUNCTION__;
« no previous file with comments | « media/mojo/services/test_mojo_media_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698