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

Side by Side Diff: content/renderer/pepper/pepper_platform_audio_output.cc

Issue 2821203005: Add a mojo implementation of AudioOutputIPC. (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/pepper/pepper_platform_audio_output.h" 5 #include "content/renderer/pepper/pepper_platform_audio_output.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "content/child/child_process.h" 13 #include "content/child/child_process.h"
14 #include "content/common/media/audio_messages.h" 14 #include "content/common/media/audio_messages.h"
15 #include "content/public/common/content_features.h"
16 #include "content/renderer/media/audio_ipc_factory.h"
15 #include "content/renderer/media/audio_message_filter.h" 17 #include "content/renderer/media/audio_message_filter.h"
16 #include "content/renderer/pepper/audio_helper.h" 18 #include "content/renderer/pepper/audio_helper.h"
17 #include "content/renderer/render_thread_impl.h" 19 #include "content/renderer/render_thread_impl.h"
18 #include "ppapi/shared_impl/ppb_audio_config_shared.h" 20 #include "ppapi/shared_impl/ppb_audio_config_shared.h"
19 21
20 namespace content { 22 namespace content {
21 23
22 // static 24 // static
23 PepperPlatformAudioOutput* PepperPlatformAudioOutput::Create( 25 PepperPlatformAudioOutput* PepperPlatformAudioOutput::Create(
24 int sample_rate, 26 int sample_rate,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 io_task_runner_(ChildProcess::current()->io_task_runner()) { 130 io_task_runner_(ChildProcess::current()->io_task_runner()) {
129 } 131 }
130 132
131 bool PepperPlatformAudioOutput::Initialize(int sample_rate, 133 bool PepperPlatformAudioOutput::Initialize(int sample_rate,
132 int frames_per_buffer, 134 int frames_per_buffer,
133 int source_render_frame_id, 135 int source_render_frame_id,
134 AudioHelper* client) { 136 AudioHelper* client) {
135 DCHECK(client); 137 DCHECK(client);
136 client_ = client; 138 client_ = client;
137 139
138 RenderThreadImpl* const render_thread = RenderThreadImpl::current(); 140 if (base::FeatureList::IsEnabled(
139 ipc_ = render_thread->audio_message_filter()->CreateAudioOutputIPC( 141 features::kUseMojoAudioOutputStreamFactory)) {
o1ka 2017/04/20 10:36:00 Instead of doing it here and in AOD separately, ca
Max Morin 2017/05/05 13:10:59 I changed this, PTAL.
140 source_render_frame_id); 142 ipc_ = AudioIPCFactory::get()->CreateAudioOutputIPC(source_render_frame_id);
143 } else {
144 RenderThreadImpl* const render_thread = RenderThreadImpl::current();
145 ipc_ = render_thread->audio_message_filter()->CreateAudioOutputIPC(
146 source_render_frame_id);
147 }
141 CHECK(ipc_); 148 CHECK(ipc_);
142 149
143 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 150 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
144 media::CHANNEL_LAYOUT_STEREO, 151 media::CHANNEL_LAYOUT_STEREO,
145 sample_rate, 152 sample_rate,
146 ppapi::kBitsPerAudioOutputSample, 153 ppapi::kBitsPerAudioOutputSample,
147 frames_per_buffer); 154 frames_per_buffer);
148 155
149 io_task_runner_->PostTask( 156 io_task_runner_->PostTask(
150 FROM_HERE, base::Bind(&PepperPlatformAudioOutput::InitializeOnIOThread, 157 FROM_HERE, base::Bind(&PepperPlatformAudioOutput::InitializeOnIOThread,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 return; 192 return;
186 193
187 ipc_->CloseStream(); 194 ipc_->CloseStream();
188 ipc_.reset(); 195 ipc_.reset();
189 196
190 Release(); // Release for the delegate, balances out the reference taken in 197 Release(); // Release for the delegate, balances out the reference taken in
191 // PepperPlatformAudioOutput::Create. 198 // PepperPlatformAudioOutput::Create.
192 } 199 }
193 200
194 } // namespace content 201 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698