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__; |