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

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

Issue 2886683003: media: Shutdown AudioManager in TestMojoMediaClient (Closed)
Patch Set: more fix Created 3 years, 7 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 | « no previous file | 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/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "media/audio/audio_device_description.h" 11 #include "media/audio/audio_device_description.h"
12 #include "media/audio/audio_manager.h" 12 #include "media/audio/audio_manager.h"
13 #include "media/audio/audio_output_stream_sink.h" 13 #include "media/audio/audio_output_stream_sink.h"
14 #include "media/audio/audio_thread_impl.h" 14 #include "media/audio/audio_thread_impl.h"
15 #include "media/base/cdm_factory.h" 15 #include "media/base/cdm_factory.h"
16 #include "media/base/media.h" 16 #include "media/base/media.h"
17 #include "media/base/media_log.h" 17 #include "media/base/media_log.h"
18 #include "media/base/null_video_sink.h" 18 #include "media/base/null_video_sink.h"
19 #include "media/base/renderer_factory.h" 19 #include "media/base/renderer_factory.h"
20 #include "media/cdm/default_cdm_factory.h" 20 #include "media/cdm/default_cdm_factory.h"
21 #include "media/renderers/default_renderer_factory.h" 21 #include "media/renderers/default_renderer_factory.h"
22 #include "media/renderers/gpu_video_accelerator_factories.h" 22 #include "media/renderers/gpu_video_accelerator_factories.h"
23 23
24 namespace media { 24 namespace media {
25 25
26 TestMojoMediaClient::TestMojoMediaClient() {} 26 TestMojoMediaClient::TestMojoMediaClient() {}
27 27
28 TestMojoMediaClient::~TestMojoMediaClient() { 28 TestMojoMediaClient::~TestMojoMediaClient() {
29 DVLOG(1) << __func__; 29 DVLOG(1) << __func__;
30 // AudioManager destructor requires MessageLoop. 30
31 // Destroy it before the message loop goes away. 31 if (audio_manager_) {
32 audio_manager_.reset(); 32 audio_manager_->Shutdown();
33 // Flush the message loop to ensure that the audio manager is destroyed. 33 // AudioManager destructor requires MessageLoop.
alokp 2017/05/16 16:52:26 You do not need to manually reset and flush the me
xhwang 2017/05/16 16:56:09 Done.
34 base::RunLoop().RunUntilIdle(); 34 // Destroy it before the message loop goes away.
35 audio_manager_.reset();
36 // Flush the message loop to ensure that the audio manager is destroyed.
37 base::RunLoop().RunUntilIdle();
38 }
35 } 39 }
36 40
37 void TestMojoMediaClient::Initialize( 41 void TestMojoMediaClient::Initialize(
38 service_manager::Connector* /* connector */) { 42 service_manager::Connector* /* connector */) {
39 InitializeMediaLibrary(); 43 InitializeMediaLibrary();
40 // TODO(dalecurtis): We should find a single owner per process for the audio 44 // TODO(dalecurtis): We should find a single owner per process for the audio
41 // manager or make it a lazy instance. It's not safe to call Get()/Create() 45 // manager or make it a lazy instance. It's not safe to call Get()/Create()
42 // across multiple threads... 46 // across multiple threads...
43 AudioManager* audio_manager = AudioManager::Get(); 47 AudioManager* audio_manager = AudioManager::Get();
44 if (!audio_manager) { 48 if (!audio_manager) {
45 audio_manager_ = media::AudioManager::CreateForTesting( 49 audio_manager_ = media::AudioManager::CreateForTesting(
46 base::MakeUnique<AudioThreadImpl>()); 50 base::MakeUnique<AudioThreadImpl>());
47 audio_manager = audio_manager_.get();
48 // Flush the message loop to ensure that the audio manager is initialized. 51 // Flush the message loop to ensure that the audio manager is initialized.
49 base::RunLoop().RunUntilIdle(); 52 base::RunLoop().RunUntilIdle();
50 } 53 }
51 } 54 }
52 55
53 scoped_refptr<AudioRendererSink> TestMojoMediaClient::CreateAudioRendererSink( 56 scoped_refptr<AudioRendererSink> TestMojoMediaClient::CreateAudioRendererSink(
54 const std::string& /* audio_device_id */) { 57 const std::string& /* audio_device_id */) {
55 return new AudioOutputStreamSink(); 58 return new AudioOutputStreamSink();
56 } 59 }
57 60
(...skipping 10 matching lines...) Expand all
68 media_log, nullptr, DefaultRendererFactory::GetGpuFactoriesCB()); 71 media_log, nullptr, DefaultRendererFactory::GetGpuFactoriesCB());
69 } 72 }
70 73
71 std::unique_ptr<CdmFactory> TestMojoMediaClient::CreateCdmFactory( 74 std::unique_ptr<CdmFactory> TestMojoMediaClient::CreateCdmFactory(
72 service_manager::mojom::InterfaceProvider* /* host_interfaces */) { 75 service_manager::mojom::InterfaceProvider* /* host_interfaces */) {
73 DVLOG(1) << __func__; 76 DVLOG(1) << __func__;
74 return base::MakeUnique<DefaultCdmFactory>(); 77 return base::MakeUnique<DefaultCdmFactory>();
75 } 78 }
76 79
77 } // namespace media 80 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698