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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « media/mojo/services/test_mojo_media_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/mojo/services/test_mojo_media_client.h" 5 #include "media/mojo/services/test_mojo_media_client.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/run_loop.h"
9 #include "base/thread_task_runner_handle.h"
8 #include "media/audio/audio_manager_base.h" 10 #include "media/audio/audio_manager_base.h"
9 #include "media/audio/audio_output_stream_sink.h" 11 #include "media/audio/audio_output_stream_sink.h"
10 #include "media/base/audio_hardware_config.h" 12 #include "media/base/audio_hardware_config.h"
11 #include "media/base/media.h" 13 #include "media/base/media.h"
12 #include "media/base/null_video_sink.h" 14 #include "media/base/null_video_sink.h"
13 #include "media/cdm/default_cdm_factory.h" 15 #include "media/cdm/default_cdm_factory.h"
14 #include "media/renderers/default_renderer_factory.h" 16 #include "media/renderers/default_renderer_factory.h"
15 #include "media/renderers/gpu_video_accelerator_factories.h" 17 #include "media/renderers/gpu_video_accelerator_factories.h"
16 18
17 namespace media { 19 namespace media {
18 20
19 TestMojoMediaClient::TestMojoMediaClient() {} 21 TestMojoMediaClient::TestMojoMediaClient() {}
20 22
21 TestMojoMediaClient::~TestMojoMediaClient() {} 23 TestMojoMediaClient::~TestMojoMediaClient() {}
22 24
23 void TestMojoMediaClient::Initialize() { 25 void TestMojoMediaClient::Initialize() {
24 InitializeMediaLibrary(); 26 InitializeMediaLibrary();
25 // TODO(dalecurtis): We should find a single owner per process for the audio 27 // TODO(dalecurtis): We should find a single owner per process for the audio
26 // manager or make it a lazy instance. It's not safe to call Get()/Create() 28 // manager or make it a lazy instance. It's not safe to call Get()/Create()
27 // across multiple threads... 29 // across multiple threads...
28 //
29 // TODO(dalecurtis): Eventually we'll want something other than a fake audio
30 // log factory here too. We should probably at least DVLOG() such info.
31 AudioManager* audio_manager = AudioManager::Get(); 30 AudioManager* audio_manager = AudioManager::Get();
32 if (!audio_manager) 31 if (!audio_manager) {
33 audio_manager = media::AudioManager::Create(&fake_audio_log_factory_); 32 audio_manager_ = media::AudioManager::CreateForTesting(
33 base::ThreadTaskRunnerHandle::Get());
34 audio_manager = audio_manager_.get();
35 // Flush the message loop to ensure that the audio manager is initialized.
36 base::RunLoop().RunUntilIdle();
37 }
34 38
35 audio_hardware_config_.reset(new AudioHardwareConfig( 39 audio_hardware_config_.reset(new AudioHardwareConfig(
36 audio_manager->GetInputStreamParameters( 40 audio_manager->GetInputStreamParameters(
37 AudioManagerBase::kDefaultDeviceId), 41 AudioManagerBase::kDefaultDeviceId),
38 audio_manager->GetDefaultOutputStreamParameters())); 42 audio_manager->GetDefaultOutputStreamParameters()));
39 } 43 }
40 44
45 void TestMojoMediaClient::WillQuit() {
46 DVLOG(1) << __FUNCTION__;
47 // AudioManager destructor requires MessageLoop.
48 // Destroy it before the message loop goes away.
49 audio_manager_.reset();
50 // Flush the message loop to ensure that the audio manager is destroyed.
51 base::RunLoop().RunUntilIdle();
52 }
53
41 std::unique_ptr<RendererFactory> TestMojoMediaClient::CreateRendererFactory( 54 std::unique_ptr<RendererFactory> TestMojoMediaClient::CreateRendererFactory(
42 const scoped_refptr<MediaLog>& media_log) { 55 const scoped_refptr<MediaLog>& media_log) {
43 DVLOG(1) << __FUNCTION__; 56 DVLOG(1) << __FUNCTION__;
44 return base::WrapUnique(new DefaultRendererFactory( 57 return base::WrapUnique(new DefaultRendererFactory(
45 media_log, nullptr, DefaultRendererFactory::GetGpuFactoriesCB(), 58 media_log, nullptr, DefaultRendererFactory::GetGpuFactoriesCB(),
46 *audio_hardware_config_)); 59 *audio_hardware_config_));
47 } 60 }
48 61
49 AudioRendererSink* TestMojoMediaClient::CreateAudioRendererSink() { 62 AudioRendererSink* TestMojoMediaClient::CreateAudioRendererSink() {
50 if (!audio_renderer_sink_) 63 if (!audio_renderer_sink_)
(...skipping 13 matching lines...) Expand all
64 return video_renderer_sink_.get(); 77 return video_renderer_sink_.get();
65 } 78 }
66 79
67 std::unique_ptr<CdmFactory> TestMojoMediaClient::CreateCdmFactory( 80 std::unique_ptr<CdmFactory> TestMojoMediaClient::CreateCdmFactory(
68 shell::mojom::InterfaceProvider* /* interface_provider */) { 81 shell::mojom::InterfaceProvider* /* interface_provider */) {
69 DVLOG(1) << __FUNCTION__; 82 DVLOG(1) << __FUNCTION__;
70 return base::WrapUnique(new DefaultCdmFactory()); 83 return base::WrapUnique(new DefaultCdmFactory());
71 } 84 }
72 85
73 } // namespace media 86 } // namespace media
OLDNEW
« 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