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/bind_helpers.h" | 8 #include "base/bind_helpers.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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 params.sample_rate(), params.bits_per_sample(), | 197 params.sample_rate(), params.bits_per_sample(), |
198 params.frames_per_buffer()); | 198 params.frames_per_buffer()); |
199 } | 199 } |
200 } | 200 } |
201 | 201 |
202 std::pair<AudioParameters, AudioParameters> dispatcher_key = | 202 std::pair<AudioParameters, AudioParameters> dispatcher_key = |
203 std::make_pair(params, output_params); | 203 std::make_pair(params, output_params); |
204 AudioOutputDispatchersMap::iterator it = | 204 AudioOutputDispatchersMap::iterator it = |
205 output_dispatchers_.find(dispatcher_key); | 205 output_dispatchers_.find(dispatcher_key); |
206 if (it != output_dispatchers_.end()) | 206 if (it != output_dispatchers_.end()) |
207 return new AudioOutputProxy(it->second); | 207 return new AudioOutputProxy(it->second.get()); |
208 | 208 |
209 const base::TimeDelta kCloseDelay = | 209 const base::TimeDelta kCloseDelay = |
210 base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds); | 210 base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds); |
211 | 211 |
212 if (output_params.format() != AudioParameters::AUDIO_FAKE) { | 212 if (output_params.format() != AudioParameters::AUDIO_FAKE) { |
213 scoped_refptr<AudioOutputDispatcher> dispatcher = | 213 scoped_refptr<AudioOutputDispatcher> dispatcher = |
214 new AudioOutputResampler(this, params, output_params, kCloseDelay); | 214 new AudioOutputResampler(this, params, output_params, kCloseDelay); |
215 output_dispatchers_[dispatcher_key] = dispatcher; | 215 output_dispatchers_[dispatcher_key] = dispatcher; |
216 return new AudioOutputProxy(dispatcher); | 216 return new AudioOutputProxy(dispatcher.get()); |
217 } | 217 } |
218 | 218 |
219 scoped_refptr<AudioOutputDispatcher> dispatcher = | 219 scoped_refptr<AudioOutputDispatcher> dispatcher = |
220 new AudioOutputDispatcherImpl(this, output_params, kCloseDelay); | 220 new AudioOutputDispatcherImpl(this, output_params, kCloseDelay); |
221 output_dispatchers_[dispatcher_key] = dispatcher; | 221 output_dispatchers_[dispatcher_key] = dispatcher; |
222 return new AudioOutputProxy(dispatcher); | 222 return new AudioOutputProxy(dispatcher.get()); |
223 #endif // defined(OS_IOS) | 223 #endif // defined(OS_IOS) |
224 } | 224 } |
225 | 225 |
226 void AudioManagerBase::ShowAudioInputSettings() { | 226 void AudioManagerBase::ShowAudioInputSettings() { |
227 } | 227 } |
228 | 228 |
229 void AudioManagerBase::GetAudioInputDeviceNames( | 229 void AudioManagerBase::GetAudioInputDeviceNames( |
230 media::AudioDeviceNames* device_names) { | 230 media::AudioDeviceNames* device_names) { |
231 } | 231 } |
232 | 232 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 #if defined(OS_IOS) | 288 #if defined(OS_IOS) |
289 return; | 289 return; |
290 #else | 290 #else |
291 // This should always be running on the audio thread, but since we've cleared | 291 // This should always be running on the audio thread, but since we've cleared |
292 // the audio_thread_ member pointer when we get here, we can't verify exactly | 292 // the audio_thread_ member pointer when we get here, we can't verify exactly |
293 // what thread we're running on. The method is not public though and only | 293 // what thread we're running on. The method is not public though and only |
294 // called from one place, so we'll leave it at that. | 294 // called from one place, so we'll leave it at that. |
295 AudioOutputDispatchersMap::iterator it = output_dispatchers_.begin(); | 295 AudioOutputDispatchersMap::iterator it = output_dispatchers_.begin(); |
296 for (; it != output_dispatchers_.end(); ++it) { | 296 for (; it != output_dispatchers_.end(); ++it) { |
297 scoped_refptr<AudioOutputDispatcher>& dispatcher = (*it).second; | 297 scoped_refptr<AudioOutputDispatcher>& dispatcher = (*it).second; |
298 if (dispatcher) { | 298 if (dispatcher.get()) { |
299 dispatcher->Shutdown(); | 299 dispatcher->Shutdown(); |
300 // All AudioOutputProxies must have been freed before Shutdown is called. | 300 // All AudioOutputProxies must have been freed before Shutdown is called. |
301 // If they still exist, things will go bad. They have direct pointers to | 301 // If they still exist, things will go bad. They have direct pointers to |
302 // both physical audio stream objects that belong to the dispatcher as | 302 // both physical audio stream objects that belong to the dispatcher as |
303 // well as the message loop of the audio thread that will soon go away. | 303 // well as the message loop of the audio thread that will soon go away. |
304 // So, better crash now than later. | 304 // So, better crash now than later. |
305 DCHECK(dispatcher->HasOneRef()) << "AudioOutputProxies are still alive"; | 305 DCHECK(dispatcher->HasOneRef()) << "AudioOutputProxies are still alive"; |
306 dispatcher = NULL; | 306 dispatcher = NULL; |
307 } | 307 } |
308 } | 308 } |
(...skipping 24 matching lines...) Expand all Loading... |
333 return GetPreferredOutputStreamParameters(AudioParameters()); | 333 return GetPreferredOutputStreamParameters(AudioParameters()); |
334 } | 334 } |
335 | 335 |
336 AudioParameters AudioManagerBase::GetInputStreamParameters( | 336 AudioParameters AudioManagerBase::GetInputStreamParameters( |
337 const std::string& device_id) { | 337 const std::string& device_id) { |
338 NOTREACHED(); | 338 NOTREACHED(); |
339 return AudioParameters(); | 339 return AudioParameters(); |
340 } | 340 } |
341 | 341 |
342 } // namespace media | 342 } // namespace media |
OLD | NEW |