| 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" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (it != output_dispatchers_.end()) | 153 if (it != output_dispatchers_.end()) |
| 154 return new AudioOutputProxy(it->second); | 154 return new AudioOutputProxy(it->second); |
| 155 | 155 |
| 156 base::TimeDelta close_delay = | 156 base::TimeDelta close_delay = |
| 157 base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds); | 157 base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds); |
| 158 | 158 |
| 159 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 159 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 160 if (cmd_line->HasSwitch(switches::kEnableAudioOutputResampler) && | 160 if (cmd_line->HasSwitch(switches::kEnableAudioOutputResampler) && |
| 161 params.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY) { | 161 params.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY) { |
| 162 scoped_refptr<AudioOutputDispatcher> dispatcher = new AudioOutputResampler( | 162 scoped_refptr<AudioOutputDispatcher> dispatcher = new AudioOutputResampler( |
| 163 this, params, | 163 this, params, GetPreferredLowLatencyOutputStreamParameters(params), |
| 164 GetPreferredLowLatencyOutputStreamParameters(params.channel_layout()), | |
| 165 close_delay); | 164 close_delay); |
| 166 output_dispatchers_[params] = dispatcher; | 165 output_dispatchers_[params] = dispatcher; |
| 167 return new AudioOutputProxy(dispatcher); | 166 return new AudioOutputProxy(dispatcher); |
| 168 } | 167 } |
| 169 | 168 |
| 170 #if defined(ENABLE_AUDIO_MIXER) | 169 #if defined(ENABLE_AUDIO_MIXER) |
| 171 // TODO(dalecurtis): Browser side mixing has a couple issues that must be | 170 // TODO(dalecurtis): Browser side mixing has a couple issues that must be |
| 172 // fixed before it can be turned on by default: http://crbug.com/138098 and | 171 // fixed before it can be turned on by default: http://crbug.com/138098 and |
| 173 // http://crbug.com/140247 | 172 // http://crbug.com/140247 |
| 174 if (cmd_line->HasSwitch(switches::kEnableAudioMixer)) { | 173 if (cmd_line->HasSwitch(switches::kEnableAudioMixer)) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 DCHECK(dispatcher->HasOneRef()) << "AudioOutputProxies are still alive"; | 271 DCHECK(dispatcher->HasOneRef()) << "AudioOutputProxies are still alive"; |
| 273 dispatcher = NULL; | 272 dispatcher = NULL; |
| 274 } | 273 } |
| 275 } | 274 } |
| 276 | 275 |
| 277 output_dispatchers_.clear(); | 276 output_dispatchers_.clear(); |
| 278 #endif // defined(OS_IOS) | 277 #endif // defined(OS_IOS) |
| 279 } | 278 } |
| 280 | 279 |
| 281 AudioParameters AudioManagerBase::GetPreferredLowLatencyOutputStreamParameters( | 280 AudioParameters AudioManagerBase::GetPreferredLowLatencyOutputStreamParameters( |
| 282 ChannelLayout channel_layout) { | 281 const AudioParameters& input_params) { |
| 283 #if defined(OS_IOS) | 282 #if defined(OS_IOS) |
| 284 // IOS implements audio input only. | 283 // IOS implements audio input only. |
| 285 NOTIMPLEMENTED(); | 284 NOTIMPLEMENTED(); |
| 286 return AudioParameters(); | 285 return AudioParameters(); |
| 287 #else | 286 #else |
| 288 // TODO(dalecurtis): This should include bits per channel and channel layout | 287 // TODO(dalecurtis): This should include bits per channel and channel layout |
| 289 // eventually. | 288 // eventually. |
| 290 return AudioParameters( | 289 return AudioParameters( |
| 291 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, | 290 AudioParameters::AUDIO_PCM_LOW_LATENCY, input_params.channel_layout(), |
| 292 GetAudioHardwareSampleRate(), 16, GetAudioHardwareBufferSize()); | 291 GetAudioHardwareSampleRate(), 16, GetAudioHardwareBufferSize()); |
| 293 #endif // defined(OS_IOS) | 292 #endif // defined(OS_IOS) |
| 294 } | 293 } |
| 295 | 294 |
| 296 } // namespace media | 295 } // namespace media |
| OLD | NEW |