Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 11 #include "media/audio/audio_output_dispatcher_impl.h" | 11 #include "media/audio/audio_output_dispatcher_impl.h" |
| 12 #include "media/audio/audio_output_proxy.h" | 12 #include "media/audio/audio_output_proxy.h" |
| 13 #include "media/audio/audio_output_resampler.h" | |
| 14 #include "media/audio/audio_util.h" | |
| 13 #include "media/audio/fake_audio_input_stream.h" | 15 #include "media/audio/fake_audio_input_stream.h" |
| 14 #include "media/audio/fake_audio_output_stream.h" | 16 #include "media/audio/fake_audio_output_stream.h" |
| 15 #include "media/base/media_switches.h" | 17 #include "media/base/media_switches.h" |
| 16 | 18 |
| 17 // TODO(dalecurtis): Temporarily disabled while switching pipeline to use float, | 19 // TODO(dalecurtis): Temporarily disabled while switching pipeline to use float, |
| 18 // http://crbug.com/114700 | 20 // http://crbug.com/114700 |
| 19 #if defined(ENABLE_AUDIO_MIXER) | 21 #if defined(ENABLE_AUDIO_MIXER) |
| 20 #include "media/audio/audio_output_mixer.h" | 22 #include "media/audio/audio_output_mixer.h" |
| 21 #endif | 23 #endif |
| 22 | 24 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 NOTIMPLEMENTED(); | 147 NOTIMPLEMENTED(); |
| 146 return NULL; | 148 return NULL; |
| 147 #else | 149 #else |
| 148 DCHECK(GetMessageLoop()->BelongsToCurrentThread()); | 150 DCHECK(GetMessageLoop()->BelongsToCurrentThread()); |
| 149 | 151 |
| 150 scoped_refptr<AudioOutputDispatcher>& dispatcher = | 152 scoped_refptr<AudioOutputDispatcher>& dispatcher = |
| 151 output_dispatchers_[params]; | 153 output_dispatchers_[params]; |
| 152 if (!dispatcher) { | 154 if (!dispatcher) { |
| 153 base::TimeDelta close_delay = | 155 base::TimeDelta close_delay = |
| 154 base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds); | 156 base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds); |
| 157 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | |
| 158 if (cmd_line->HasSwitch(switches::kEnableAudioOutputResampler)) { | |
| 159 dispatcher = new AudioOutputResampler( | |
| 160 this, params, | |
| 161 GetPreferredLowLatencyOutputStreamParameters(params.channel_layout()), | |
| 162 close_delay); | |
|
scherkus (not reviewing)
2012/09/10 12:47:47
I think we can clean up the confusing #if code if
DaleCurtis
2012/09/10 14:05:51
Done.
| |
| 163 } else | |
| 164 #if defined(ENABLE_AUDIO_MIXER) | |
| 155 // TODO(dalecurtis): Browser side mixing has a couple issues that must be | 165 // TODO(dalecurtis): Browser side mixing has a couple issues that must be |
| 156 // fixed before it can be turned on by default: http://crbug.com/138098 and | 166 // fixed before it can be turned on by default: http://crbug.com/138098 and |
| 157 // http://crbug.com/140247 | 167 // http://crbug.com/140247 |
| 158 #if defined(ENABLE_AUDIO_MIXER) | 168 if (cmd_line->HasSwitch(switches::kEnableAudioMixer)) { |
| 159 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | |
| 160 if (cmd_line->HasSwitch(switches::kEnableAudioMixer)) | |
| 161 dispatcher = new AudioOutputMixer(this, params, close_delay); | 169 dispatcher = new AudioOutputMixer(this, params, close_delay); |
| 162 else | 170 } else |
| 163 #endif | 171 #endif |
| 164 dispatcher = new AudioOutputDispatcherImpl(this, params, close_delay); | 172 dispatcher = new AudioOutputDispatcherImpl(this, params, close_delay); |
| 165 } | 173 } |
| 166 return new AudioOutputProxy(dispatcher); | 174 return new AudioOutputProxy(dispatcher); |
| 167 #endif // defined(OS_IOS) | 175 #endif // defined(OS_IOS) |
| 168 } | 176 } |
| 169 | 177 |
| 170 bool AudioManagerBase::CanShowAudioInputSettings() { | 178 bool AudioManagerBase::CanShowAudioInputSettings() { |
| 171 return false; | 179 return false; |
| 172 } | 180 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 // So, better crash now than later. | 260 // So, better crash now than later. |
| 253 DCHECK(dispatcher->HasOneRef()) << "AudioOutputProxies are still alive"; | 261 DCHECK(dispatcher->HasOneRef()) << "AudioOutputProxies are still alive"; |
| 254 dispatcher = NULL; | 262 dispatcher = NULL; |
| 255 } | 263 } |
| 256 } | 264 } |
| 257 | 265 |
| 258 output_dispatchers_.clear(); | 266 output_dispatchers_.clear(); |
| 259 #endif // defined(OS_IOS) | 267 #endif // defined(OS_IOS) |
| 260 } | 268 } |
| 261 | 269 |
| 270 AudioParameters AudioManagerBase::GetPreferredLowLatencyOutputStreamParameters( | |
| 271 ChannelLayout channel_layout) { | |
| 272 // TODO(dalecurtis): This should include bits per channel and channel layout | |
| 273 // eventually. | |
| 274 return AudioParameters( | |
| 275 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, | |
| 276 GetAudioHardwareSampleRate(), 16, GetAudioHardwareBufferSize()); | |
| 277 } | |
| 278 | |
| 262 } // namespace media | 279 } // namespace media |
| OLD | NEW |