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

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

Issue 10918098: Introduce AudioOutputResampler for browser side resampling. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Unittests! Bugs! Created 8 years, 3 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 | media/audio/audio_manager_base.h » ('j') | media/audio/audio_manager_base.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_impl.h" 5 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
10 #include "build/build_config.h" 11 #include "build/build_config.h"
11 #include "content/common/child_process.h" 12 #include "content/common/child_process.h"
12 #include "content/common/media/audio_messages.h" 13 #include "content/common/media/audio_messages.h"
13 #include "content/renderer/media/audio_hardware.h" 14 #include "content/renderer/media/audio_hardware.h"
14 #include "content/renderer/media/audio_message_filter.h" 15 #include "content/renderer/media/audio_message_filter.h"
15 #include "content/renderer/render_thread_impl.h" 16 #include "content/renderer/render_thread_impl.h"
17 #include "media/base/media_switches.h"
16 18
17 namespace content { 19 namespace content {
18 20
19 // static 21 // static
20 PepperPlatformAudioOutputImpl* PepperPlatformAudioOutputImpl::Create( 22 PepperPlatformAudioOutputImpl* PepperPlatformAudioOutputImpl::Create(
21 int sample_rate, 23 int sample_rate,
22 int frames_per_buffer, 24 int frames_per_buffer,
23 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) { 25 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) {
24 scoped_refptr<PepperPlatformAudioOutputImpl> audio_output( 26 scoped_refptr<PepperPlatformAudioOutputImpl> audio_output(
25 new PepperPlatformAudioOutputImpl()); 27 new PepperPlatformAudioOutputImpl());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 int sample_rate, 115 int sample_rate,
114 int frames_per_buffer, 116 int frames_per_buffer,
115 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) { 117 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) {
116 DCHECK(client); 118 DCHECK(client);
117 // Make sure we don't call init more than once. 119 // Make sure we don't call init more than once.
118 DCHECK_EQ(0, stream_id_); 120 DCHECK_EQ(0, stream_id_);
119 121
120 client_ = client; 122 client_ = client;
121 123
122 media::AudioParameters::Format format; 124 media::AudioParameters::Format format;
123 const int kMaxFramesForLowLatency = 2047; 125
124 // Use the low latency back end if the client request is compatible, and 126 // TODO(dalecurtis): Limit to windows and 2ch linux/mac only since neither of
scherkus (not reviewing) 2012/09/10 12:47:47 nit: proper capitalization on Windows/Linux/Mac a
DaleCurtis 2012/09/10 14:05:51 Removed comment. After thinking about it, I intend
125 // the sample count is low enough to justify using AUDIO_PCM_LOW_LATENCY. 127 // those support multichannel currently.
126 if (sample_rate == audio_hardware::GetOutputSampleRate() && 128 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
127 frames_per_buffer <= kMaxFramesForLowLatency && 129 if (cmd_line->HasSwitch(switches::kEnableAudioOutputResampler)) {
128 frames_per_buffer % audio_hardware::GetOutputBufferSize() == 0) {
129 format = media::AudioParameters::AUDIO_PCM_LOW_LATENCY; 130 format = media::AudioParameters::AUDIO_PCM_LOW_LATENCY;
henrika (OOO until Aug 14) 2012/09/10 12:41:17 Some comments here perhaps.
DaleCurtis 2012/09/10 14:05:51 Done.
130 } else { 131 } else {
131 format = media::AudioParameters::AUDIO_PCM_LINEAR; 132 const int kMaxFramesForLowLatency = 2047;
133 // Use the low latency back end if the client request is compatible, and
134 // the sample count is low enough to justify using AUDIO_PCM_LOW_LATENCY.
135 if (sample_rate == audio_hardware::GetOutputSampleRate() &&
136 frames_per_buffer <= kMaxFramesForLowLatency &&
137 frames_per_buffer % audio_hardware::GetOutputBufferSize() == 0) {
138 format = media::AudioParameters::AUDIO_PCM_LOW_LATENCY;
139 } else {
140 format = media::AudioParameters::AUDIO_PCM_LINEAR;
141 }
132 } 142 }
133 143
134 media::AudioParameters params(format, CHANNEL_LAYOUT_STEREO, sample_rate, 16, 144 media::AudioParameters params(format, CHANNEL_LAYOUT_STEREO, sample_rate, 16,
135 frames_per_buffer); 145 frames_per_buffer);
136 146
137 ChildProcess::current()->io_message_loop()->PostTask( 147 ChildProcess::current()->io_message_loop()->PostTask(
138 FROM_HERE, 148 FROM_HERE,
139 base::Bind(&PepperPlatformAudioOutputImpl::InitializeOnIOThread, 149 base::Bind(&PepperPlatformAudioOutputImpl::InitializeOnIOThread,
140 this, params)); 150 this, params));
141 return true; 151 return true;
(...skipping 22 matching lines...) Expand all
164 174
165 ipc_->CloseStream(stream_id_); 175 ipc_->CloseStream(stream_id_);
166 ipc_->RemoveDelegate(stream_id_); 176 ipc_->RemoveDelegate(stream_id_);
167 stream_id_ = 0; 177 stream_id_ = 0;
168 178
169 Release(); // Release for the delegate, balances out the reference taken in 179 Release(); // Release for the delegate, balances out the reference taken in
170 // PepperPluginDelegateImpl::CreateAudio. 180 // PepperPluginDelegateImpl::CreateAudio.
171 } 181 }
172 182
173 } // namespace content 183 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | media/audio/audio_manager_base.h » ('j') | media/audio/audio_manager_base.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698