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

Side by Side Diff: media/mojo/services/test_mojo_media_client.cc

Issue 1901583005: Revert of Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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"
10 #include "media/audio/audio_manager_base.h" 8 #include "media/audio/audio_manager_base.h"
11 #include "media/audio/audio_output_stream_sink.h" 9 #include "media/audio/audio_output_stream_sink.h"
12 #include "media/base/audio_hardware_config.h" 10 #include "media/base/audio_hardware_config.h"
13 #include "media/base/media.h" 11 #include "media/base/media.h"
14 #include "media/base/null_video_sink.h" 12 #include "media/base/null_video_sink.h"
15 #include "media/cdm/default_cdm_factory.h" 13 #include "media/cdm/default_cdm_factory.h"
16 #include "media/renderers/default_renderer_factory.h" 14 #include "media/renderers/default_renderer_factory.h"
17 #include "media/renderers/gpu_video_accelerator_factories.h" 15 #include "media/renderers/gpu_video_accelerator_factories.h"
18 16
19 namespace media { 17 namespace media {
20 18
21 TestMojoMediaClient::TestMojoMediaClient() {} 19 TestMojoMediaClient::TestMojoMediaClient() {}
22 20
23 TestMojoMediaClient::~TestMojoMediaClient() {} 21 TestMojoMediaClient::~TestMojoMediaClient() {}
24 22
25 void TestMojoMediaClient::Initialize() { 23 void TestMojoMediaClient::Initialize() {
26 InitializeMediaLibrary(); 24 InitializeMediaLibrary();
27 // TODO(dalecurtis): We should find a single owner per process for the audio 25 // TODO(dalecurtis): We should find a single owner per process for the audio
28 // manager or make it a lazy instance. It's not safe to call Get()/Create() 26 // manager or make it a lazy instance. It's not safe to call Get()/Create()
29 // across multiple threads... 27 // 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.
30 AudioManager* audio_manager = AudioManager::Get(); 31 AudioManager* audio_manager = AudioManager::Get();
31 if (!audio_manager) { 32 if (!audio_manager)
32 audio_manager_ = media::AudioManager::CreateForTesting( 33 audio_manager = media::AudioManager::Create(&fake_audio_log_factory_);
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 }
38 34
39 audio_hardware_config_.reset(new AudioHardwareConfig( 35 audio_hardware_config_.reset(new AudioHardwareConfig(
40 audio_manager->GetInputStreamParameters( 36 audio_manager->GetInputStreamParameters(
41 AudioManagerBase::kDefaultDeviceId), 37 AudioManagerBase::kDefaultDeviceId),
42 audio_manager->GetDefaultOutputStreamParameters())); 38 audio_manager->GetDefaultOutputStreamParameters()));
43 } 39 }
44 40
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
54 std::unique_ptr<RendererFactory> TestMojoMediaClient::CreateRendererFactory( 41 std::unique_ptr<RendererFactory> TestMojoMediaClient::CreateRendererFactory(
55 const scoped_refptr<MediaLog>& media_log) { 42 const scoped_refptr<MediaLog>& media_log) {
56 DVLOG(1) << __FUNCTION__; 43 DVLOG(1) << __FUNCTION__;
57 return base::WrapUnique(new DefaultRendererFactory( 44 return base::WrapUnique(new DefaultRendererFactory(
58 media_log, nullptr, DefaultRendererFactory::GetGpuFactoriesCB(), 45 media_log, nullptr, DefaultRendererFactory::GetGpuFactoriesCB(),
59 *audio_hardware_config_)); 46 *audio_hardware_config_));
60 } 47 }
61 48
62 AudioRendererSink* TestMojoMediaClient::CreateAudioRendererSink() { 49 AudioRendererSink* TestMojoMediaClient::CreateAudioRendererSink() {
63 if (!audio_renderer_sink_) 50 if (!audio_renderer_sink_)
(...skipping 13 matching lines...) Expand all
77 return video_renderer_sink_.get(); 64 return video_renderer_sink_.get();
78 } 65 }
79 66
80 std::unique_ptr<CdmFactory> TestMojoMediaClient::CreateCdmFactory( 67 std::unique_ptr<CdmFactory> TestMojoMediaClient::CreateCdmFactory(
81 shell::mojom::InterfaceProvider* /* interface_provider */) { 68 shell::mojom::InterfaceProvider* /* interface_provider */) {
82 DVLOG(1) << __FUNCTION__; 69 DVLOG(1) << __FUNCTION__;
83 return base::WrapUnique(new DefaultCdmFactory()); 70 return base::WrapUnique(new DefaultCdmFactory());
84 } 71 }
85 72
86 } // namespace media 73 } // 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