OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 140 |
141 // VolumeCallbacks implementation. | 141 // VolumeCallbacks implementation. |
142 void SetMicVolume(int volume) override { volume_ = volume; } | 142 void SetMicVolume(int volume) override { volume_ = volume; } |
143 int GetMicVolume() override { return volume_; } | 143 int GetMicVolume() override { return volume_; } |
144 | 144 |
145 private: | 145 private: |
146 GainControl* real_gain_control_; | 146 GainControl* real_gain_control_; |
147 int volume_; | 147 int volume_; |
148 }; | 148 }; |
149 | 149 |
| 150 const int AudioProcessing::kNativeSampleRatesHz[] = { |
| 151 AudioProcessing::kSampleRate8kHz, |
| 152 AudioProcessing::kSampleRate16kHz, |
| 153 AudioProcessing::kSampleRate32kHz, |
| 154 AudioProcessing::kSampleRate48kHz}; |
| 155 const size_t AudioProcessing::kNumNativeSampleRates = |
| 156 arraysize(AudioProcessing::kNativeSampleRatesHz); |
| 157 const int AudioProcessing::kMaxNativeSampleRateHz = AudioProcessing:: |
| 158 kNativeSampleRatesHz[AudioProcessing::kNumNativeSampleRates - 1]; |
| 159 |
150 AudioProcessing* AudioProcessing::Create() { | 160 AudioProcessing* AudioProcessing::Create() { |
151 Config config; | 161 Config config; |
152 return Create(config, nullptr); | 162 return Create(config, nullptr); |
153 } | 163 } |
154 | 164 |
155 AudioProcessing* AudioProcessing::Create(const Config& config) { | 165 AudioProcessing* AudioProcessing::Create(const Config& config) { |
156 return Create(config, nullptr); | 166 return Create(config, nullptr); |
157 } | 167 } |
158 | 168 |
159 AudioProcessing* AudioProcessing::Create(const Config& config, | 169 AudioProcessing* AudioProcessing::Create(const Config& config, |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 return kBadNumberChannelsError; | 403 return kBadNumberChannelsError; |
394 } | 404 } |
395 | 405 |
396 api_format_ = config; | 406 api_format_ = config; |
397 | 407 |
398 // We process at the closest native rate >= min(input rate, output rate)... | 408 // We process at the closest native rate >= min(input rate, output rate)... |
399 const int min_proc_rate = | 409 const int min_proc_rate = |
400 std::min(api_format_.input_stream().sample_rate_hz(), | 410 std::min(api_format_.input_stream().sample_rate_hz(), |
401 api_format_.output_stream().sample_rate_hz()); | 411 api_format_.output_stream().sample_rate_hz()); |
402 int fwd_proc_rate; | 412 int fwd_proc_rate; |
403 if (min_proc_rate > kSampleRate32kHz) { | 413 for (size_t i = 0; i < kNumNativeSampleRates; ++i) { |
404 fwd_proc_rate = kSampleRate48kHz; | 414 fwd_proc_rate = kNativeSampleRatesHz[i]; |
405 } else if (min_proc_rate > kSampleRate16kHz) { | 415 if (fwd_proc_rate >= min_proc_rate) { |
406 fwd_proc_rate = kSampleRate32kHz; | 416 break; |
407 } else if (min_proc_rate > kSampleRate8kHz) { | 417 } |
408 fwd_proc_rate = kSampleRate16kHz; | |
409 } else { | |
410 fwd_proc_rate = kSampleRate8kHz; | |
411 } | 418 } |
412 // ...with one exception. | 419 // ...with one exception. |
413 if (echo_control_mobile_->is_enabled() && min_proc_rate > kSampleRate16kHz) { | 420 if (echo_control_mobile_->is_enabled() && min_proc_rate > kSampleRate16kHz) { |
414 fwd_proc_rate = kSampleRate16kHz; | 421 fwd_proc_rate = kSampleRate16kHz; |
415 } | 422 } |
416 | 423 |
417 fwd_proc_format_ = StreamConfig(fwd_proc_rate); | 424 fwd_proc_format_ = StreamConfig(fwd_proc_rate); |
418 | 425 |
419 // We normally process the reverse stream at 16 kHz. Unless... | 426 // We normally process the reverse stream at 16 kHz. Unless... |
420 int rev_proc_rate = kSampleRate16kHz; | 427 int rev_proc_rate = kSampleRate16kHz; |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 int err = WriteMessageToDebugFile(); | 1249 int err = WriteMessageToDebugFile(); |
1243 if (err != kNoError) { | 1250 if (err != kNoError) { |
1244 return err; | 1251 return err; |
1245 } | 1252 } |
1246 | 1253 |
1247 return kNoError; | 1254 return kNoError; |
1248 } | 1255 } |
1249 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 1256 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
1250 | 1257 |
1251 } // namespace webrtc | 1258 } // namespace webrtc |
OLD | NEW |