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/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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 // importantly it prevents instability on certain systems. | 97 // importantly it prevents instability on certain systems. |
| 98 // See bug: http://crbug.com/30242. | 98 // See bug: http://crbug.com/30242. |
| 99 if (num_output_streams_ >= max_num_output_streams_) { | 99 if (num_output_streams_ >= max_num_output_streams_) { |
| 100 DLOG(ERROR) << "Number of opened output audio streams " | 100 DLOG(ERROR) << "Number of opened output audio streams " |
| 101 << num_output_streams_ | 101 << num_output_streams_ |
| 102 << " exceed the max allowed number " | 102 << " exceed the max allowed number " |
| 103 << max_num_output_streams_; | 103 << max_num_output_streams_; |
| 104 return NULL; | 104 return NULL; |
| 105 } | 105 } |
| 106 | 106 |
| 107 // If there are no audio output devices we should use a FakeAudioOutputStream | |
| 108 // to ensure video playback continues to work. | |
| 109 bool audio_output_disabled = | |
| 110 params.format() == AudioParameters::AUDIO_FAKE || | |
| 111 !HasAudioOutputDevices(); | |
|
scherkus (not reviewing)
2013/02/15 18:43:37
FYI this appeared to be the only production code u
DaleCurtis
2013/02/15 18:51:39
Yeah, that's why I was looking at this originally.
| |
| 112 | |
| 113 AudioOutputStream* stream = NULL; | 107 AudioOutputStream* stream = NULL; |
| 114 if (virtual_audio_input_stream_) { | 108 if (virtual_audio_input_stream_) { |
| 115 #if defined(OS_IOS) | 109 #if defined(OS_IOS) |
| 116 // We do not currently support iOS. It does not link. | 110 // We do not currently support iOS. It does not link. |
| 117 NOTIMPLEMENTED(); | 111 NOTIMPLEMENTED(); |
| 118 return NULL; | 112 return NULL; |
| 119 #else | 113 #else |
| 120 stream = new VirtualAudioOutputStream( | 114 stream = new VirtualAudioOutputStream( |
| 121 params, message_loop_, virtual_audio_input_stream_, | 115 params, message_loop_, virtual_audio_input_stream_, |
| 122 base::Bind(&AudioManagerBase::ReleaseVirtualOutputStream, | 116 base::Bind(&AudioManagerBase::ReleaseVirtualOutputStream, |
| 123 base::Unretained(this))); | 117 base::Unretained(this))); |
| 124 #endif | 118 #endif |
| 125 } else if (audio_output_disabled) { | 119 } else if (params.format() == AudioParameters::AUDIO_FAKE) { |
| 126 stream = FakeAudioOutputStream::MakeFakeStream(this, params); | 120 stream = FakeAudioOutputStream::MakeFakeStream(this, params); |
| 127 } else if (params.format() == AudioParameters::AUDIO_PCM_LINEAR) { | 121 } else if (params.format() == AudioParameters::AUDIO_PCM_LINEAR) { |
| 128 stream = MakeLinearOutputStream(params); | 122 stream = MakeLinearOutputStream(params); |
| 129 } else if (params.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY) { | 123 } else if (params.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY) { |
| 130 stream = MakeLowLatencyOutputStream(params); | 124 stream = MakeLowLatencyOutputStream(params); |
| 131 } | 125 } |
| 132 | 126 |
| 133 if (stream) | 127 if (stream) |
| 134 ++num_output_streams_; | 128 ++num_output_streams_; |
| 135 | 129 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 output_listeners_.RemoveObserver(listener); | 408 output_listeners_.RemoveObserver(listener); |
| 415 } | 409 } |
| 416 | 410 |
| 417 void AudioManagerBase::NotifyAllOutputDeviceChangeListeners() { | 411 void AudioManagerBase::NotifyAllOutputDeviceChangeListeners() { |
| 418 DCHECK(message_loop_->BelongsToCurrentThread()); | 412 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 419 DVLOG(1) << "Firing OnDeviceChange() notifications."; | 413 DVLOG(1) << "Firing OnDeviceChange() notifications."; |
| 420 FOR_EACH_OBSERVER(AudioDeviceListener, output_listeners_, OnDeviceChange()); | 414 FOR_EACH_OBSERVER(AudioDeviceListener, output_listeners_, OnDeviceChange()); |
| 421 } | 415 } |
| 422 | 416 |
| 423 } // namespace media | 417 } // namespace media |
| OLD | NEW |