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

Side by Side Diff: media/audio/audio_manager_base.cc

Issue 12316131: Moved AudioUtil static functions to AudioManager interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: made the GetPreferredOutputStreamParameters protected Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « media/audio/audio_manager_base.h ('k') | media/audio/audio_output_proxy_unittest.cc » ('j') | no next file with comments »
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 "media/audio/audio_manager_base.h" 5 #include "media/audio/audio_manager_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 bool use_audio_output_resampler = 176 bool use_audio_output_resampler =
177 !CommandLine::ForCurrentProcess()->HasSwitch( 177 !CommandLine::ForCurrentProcess()->HasSwitch(
178 switches::kDisableAudioOutputResampler) && 178 switches::kDisableAudioOutputResampler) &&
179 params.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY; 179 params.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY;
180 180
181 // If we're not using AudioOutputResampler our output parameters are the same 181 // If we're not using AudioOutputResampler our output parameters are the same
182 // as our input parameters. 182 // as our input parameters.
183 AudioParameters output_params = params; 183 AudioParameters output_params = params;
184 if (use_audio_output_resampler) { 184 if (use_audio_output_resampler) {
185 output_params = GetPreferredLowLatencyOutputStreamParameters(params); 185 output_params = GetPreferredOutputStreamParameters(params);
186 186
187 // Ensure we only pass on valid output parameters. 187 // Ensure we only pass on valid output parameters.
188 if (!output_params.IsValid()) { 188 if (!output_params.IsValid()) {
189 // We've received invalid audio output parameters, so switch to a mock 189 // We've received invalid audio output parameters, so switch to a mock
190 // output device based on the input parameters. This may happen if the OS 190 // output device based on the input parameters. This may happen if the OS
191 // provided us junk values for the hardware configuration. 191 // provided us junk values for the hardware configuration.
192 LOG(ERROR) << "Invalid audio output parameters received; using fake " 192 LOG(ERROR) << "Invalid audio output parameters received; using fake "
193 << "audio path. Channels: " << output_params.channels() << ", " 193 << "audio path. Channels: " << output_params.channels() << ", "
194 << "Sample Rate: " << output_params.sample_rate() << ", " 194 << "Sample Rate: " << output_params.sample_rate() << ", "
195 << "Bits Per Sample: " << output_params.bits_per_sample() 195 << "Bits Per Sample: " << output_params.bits_per_sample()
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 // So, better crash now than later. 310 // So, better crash now than later.
311 DCHECK(dispatcher->HasOneRef()) << "AudioOutputProxies are still alive"; 311 DCHECK(dispatcher->HasOneRef()) << "AudioOutputProxies are still alive";
312 dispatcher = NULL; 312 dispatcher = NULL;
313 } 313 }
314 } 314 }
315 315
316 output_dispatchers_.clear(); 316 output_dispatchers_.clear();
317 #endif // defined(OS_IOS) 317 #endif // defined(OS_IOS)
318 } 318 }
319 319
320 AudioParameters AudioManagerBase::GetPreferredLowLatencyOutputStreamParameters(
321 const AudioParameters& input_params) {
322 #if defined(OS_IOS)
323 // IOS implements audio input only.
324 NOTIMPLEMENTED();
325 return AudioParameters();
326 #else
327 // TODO(dalecurtis): This should include bits per channel and channel layout
328 // eventually.
329 return AudioParameters(
330 AudioParameters::AUDIO_PCM_LOW_LATENCY,
331 input_params.channel_layout(), input_params.input_channels(),
332 GetAudioHardwareSampleRate(), 16, GetAudioHardwareBufferSize());
333 #endif // defined(OS_IOS)
334 }
335
336 void AudioManagerBase::AddOutputDeviceChangeListener( 320 void AudioManagerBase::AddOutputDeviceChangeListener(
337 AudioDeviceListener* listener) { 321 AudioDeviceListener* listener) {
338 DCHECK(message_loop_->BelongsToCurrentThread()); 322 DCHECK(message_loop_->BelongsToCurrentThread());
339 output_listeners_.AddObserver(listener); 323 output_listeners_.AddObserver(listener);
340 } 324 }
341 325
342 void AudioManagerBase::RemoveOutputDeviceChangeListener( 326 void AudioManagerBase::RemoveOutputDeviceChangeListener(
343 AudioDeviceListener* listener) { 327 AudioDeviceListener* listener) {
344 DCHECK(message_loop_->BelongsToCurrentThread()); 328 DCHECK(message_loop_->BelongsToCurrentThread());
345 output_listeners_.RemoveObserver(listener); 329 output_listeners_.RemoveObserver(listener);
346 } 330 }
347 331
348 void AudioManagerBase::NotifyAllOutputDeviceChangeListeners() { 332 void AudioManagerBase::NotifyAllOutputDeviceChangeListeners() {
349 DCHECK(message_loop_->BelongsToCurrentThread()); 333 DCHECK(message_loop_->BelongsToCurrentThread());
350 DVLOG(1) << "Firing OnDeviceChange() notifications."; 334 DVLOG(1) << "Firing OnDeviceChange() notifications.";
351 FOR_EACH_OBSERVER(AudioDeviceListener, output_listeners_, OnDeviceChange()); 335 FOR_EACH_OBSERVER(AudioDeviceListener, output_listeners_, OnDeviceChange());
352 } 336 }
353 337
338 AudioParameters AudioManagerBase::GetDefaultOutputStreamParameters() {
339 return GetPreferredOutputStreamParameters(AudioParameters());
340 }
341
342 AudioParameters AudioManagerBase::GetInputStreamParameters(
343 const std::string& device_id) {
344 NOTREACHED();
345 return AudioParameters();
346 }
347
354 } // namespace media 348 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_manager_base.h ('k') | media/audio/audio_output_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698