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/macros.h" | 10 #include "base/macros.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 // All the input streams should have been deleted. | 98 // All the input streams should have been deleted. |
99 CHECK_EQ(0, num_input_streams_); | 99 CHECK_EQ(0, num_input_streams_); |
100 } | 100 } |
101 | 101 |
102 base::string16 AudioManagerBase::GetAudioInputDeviceModel() { | 102 base::string16 AudioManagerBase::GetAudioInputDeviceModel() { |
103 return base::string16(); | 103 return base::string16(); |
104 } | 104 } |
105 | 105 |
106 AudioOutputStream* AudioManagerBase::MakeAudioOutputStream( | 106 AudioOutputStream* AudioManagerBase::MakeAudioOutputStream( |
107 const AudioParameters& params, | 107 const AudioParameters& params, |
108 const std::string& device_id) { | 108 const std::string& device_id, |
109 const StatisticsCallback& statistics_callback) { | |
109 // TODO(miu): Fix ~50 call points across several unit test modules to call | 110 // TODO(miu): Fix ~50 call points across several unit test modules to call |
110 // this method on the audio thread, then uncomment the following: | 111 // this method on the audio thread, then uncomment the following: |
111 // DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 112 // DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
112 | 113 |
113 if (!params.IsValid()) { | 114 if (!params.IsValid()) { |
114 DLOG(ERROR) << "Audio parameters are invalid"; | 115 DLOG(ERROR) << "Audio parameters are invalid"; |
115 return NULL; | 116 return NULL; |
116 } | 117 } |
117 | 118 |
118 // Limit the number of audio streams opened. This is to prevent using | 119 // Limit the number of audio streams opened. This is to prevent using |
119 // excessive resources for a large number of audio streams. More | 120 // excessive resources for a large number of audio streams. More |
120 // importantly it prevents instability on certain systems. | 121 // importantly it prevents instability on certain systems. |
121 // See bug: http://crbug.com/30242. | 122 // See bug: http://crbug.com/30242. |
122 if (num_output_streams_ >= max_num_output_streams_) { | 123 if (num_output_streams_ >= max_num_output_streams_) { |
123 DLOG(ERROR) << "Number of opened output audio streams " | 124 DLOG(ERROR) << "Number of opened output audio streams " |
124 << num_output_streams_ | 125 << num_output_streams_ |
125 << " exceed the max allowed number " | 126 << " exceed the max allowed number " |
126 << max_num_output_streams_; | 127 << max_num_output_streams_; |
127 return NULL; | 128 return NULL; |
128 } | 129 } |
129 | 130 |
130 AudioOutputStream* stream; | 131 AudioOutputStream* stream; |
131 switch (params.format()) { | 132 switch (params.format()) { |
132 case AudioParameters::AUDIO_PCM_LINEAR: | 133 case AudioParameters::AUDIO_PCM_LINEAR: |
133 DCHECK(AudioDeviceDescription::IsDefaultDevice(device_id)) | 134 DCHECK(AudioDeviceDescription::IsDefaultDevice(device_id)) |
134 << "AUDIO_PCM_LINEAR supports only the default device."; | 135 << "AUDIO_PCM_LINEAR supports only the default device."; |
135 stream = MakeLinearOutputStream(params); | 136 stream = MakeLinearOutputStream(params); |
o1ka
2016/05/18 14:00:16
Why there is no logging for linear?
Henrik Grunell
2016/05/23 17:13:55
I've added linear as well now.
| |
136 break; | 137 break; |
137 case AudioParameters::AUDIO_PCM_LOW_LATENCY: | 138 case AudioParameters::AUDIO_PCM_LOW_LATENCY: |
138 stream = MakeLowLatencyOutputStream(params, device_id); | 139 stream = |
140 MakeLowLatencyOutputStream(params, device_id, statistics_callback); | |
139 break; | 141 break; |
140 case AudioParameters::AUDIO_FAKE: | 142 case AudioParameters::AUDIO_FAKE: |
141 stream = FakeAudioOutputStream::MakeFakeStream(this, params); | 143 stream = FakeAudioOutputStream::MakeFakeStream(this, params); |
142 break; | 144 break; |
143 default: | 145 default: |
144 stream = NULL; | 146 stream = NULL; |
145 break; | 147 break; |
146 } | 148 } |
147 | 149 |
148 if (stream) { | 150 if (stream) { |
149 ++num_output_streams_; | 151 ++num_output_streams_; |
150 } | 152 } |
151 | 153 |
152 return stream; | 154 return stream; |
153 } | 155 } |
154 | 156 |
155 AudioInputStream* AudioManagerBase::MakeAudioInputStream( | 157 AudioInputStream* AudioManagerBase::MakeAudioInputStream( |
o1ka
2016/05/18 14:00:16
Do you want to log for input, output, or both?
Henrik Grunell
2016/05/23 17:13:54
Output was intended first. But now I've added both
| |
156 const AudioParameters& params, | 158 const AudioParameters& params, |
157 const std::string& device_id) { | 159 const std::string& device_id) { |
158 // TODO(miu): Fix ~20 call points across several unit test modules to call | 160 // TODO(miu): Fix ~20 call points across several unit test modules to call |
159 // this method on the audio thread, then uncomment the following: | 161 // this method on the audio thread, then uncomment the following: |
160 // DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 162 // DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
161 | 163 |
162 if (!params.IsValid() || (params.channels() > kMaxInputChannels) || | 164 if (!params.IsValid() || (params.channels() > kMaxInputChannels) || |
163 device_id.empty()) { | 165 device_id.empty()) { |
164 DLOG(ERROR) << "Audio parameters are invalid for device " << device_id; | 166 DLOG(ERROR) << "Audio parameters are invalid for device " << device_id; |
165 return NULL; | 167 return NULL; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
361 | 363 |
362 return 0; | 364 return 0; |
363 } | 365 } |
364 | 366 |
365 std::unique_ptr<AudioLog> AudioManagerBase::CreateAudioLog( | 367 std::unique_ptr<AudioLog> AudioManagerBase::CreateAudioLog( |
366 AudioLogFactory::AudioComponent component) { | 368 AudioLogFactory::AudioComponent component) { |
367 return audio_log_factory_->CreateAudioLog(component); | 369 return audio_log_factory_->CreateAudioLog(component); |
368 } | 370 } |
369 | 371 |
370 } // namespace media | 372 } // namespace media |
OLD | NEW |