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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 assert(false); | 88 assert(false); |
89 return false; | 89 return false; |
90 } | 90 } |
91 | 91 |
92 bool is_multi_band(int sample_rate_hz) { | 92 bool is_multi_band(int sample_rate_hz) { |
93 return sample_rate_hz == AudioProcessing::kSampleRate32kHz || | 93 return sample_rate_hz == AudioProcessing::kSampleRate32kHz || |
94 sample_rate_hz == AudioProcessing::kSampleRate48kHz; | 94 sample_rate_hz == AudioProcessing::kSampleRate48kHz; |
95 } | 95 } |
96 | 96 |
97 int ClosestNativeRate(int min_proc_rate) { | 97 int ClosestHigherNativeRate(int min_proc_rate) { |
98 for (int rate : AudioProcessing::kNativeSampleRatesHz) { | 98 for (int rate : AudioProcessing::kNativeSampleRatesHz) { |
99 if (rate >= min_proc_rate) { | 99 if (rate >= min_proc_rate) { |
100 return rate; | 100 return rate; |
101 } | 101 } |
102 } | 102 } |
103 return AudioProcessing::kMaxNativeSampleRateHz; | 103 return AudioProcessing::kMaxNativeSampleRateHz; |
104 } | 104 } |
105 | 105 |
106 } // namespace | 106 } // namespace |
107 | 107 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 return kBadNumberChannelsError; | 355 return kBadNumberChannelsError; |
356 } | 356 } |
357 | 357 |
358 if (capture_nonlocked_.beamformer_enabled && | 358 if (capture_nonlocked_.beamformer_enabled && |
359 num_in_channels != capture_.array_geometry.size()) { | 359 num_in_channels != capture_.array_geometry.size()) { |
360 return kBadNumberChannelsError; | 360 return kBadNumberChannelsError; |
361 } | 361 } |
362 | 362 |
363 formats_.api_format = config; | 363 formats_.api_format = config; |
364 | 364 |
365 capture_nonlocked_.fwd_proc_format = StreamConfig(ClosestNativeRate(std::min( | 365 capture_nonlocked_.fwd_proc_format = StreamConfig(ClosestHigherNativeRate( |
366 formats_.api_format.input_stream().sample_rate_hz(), | 366 std::min(formats_.api_format.input_stream().sample_rate_hz(), |
367 formats_.api_format.output_stream().sample_rate_hz()))); | 367 formats_.api_format.output_stream().sample_rate_hz()))); |
368 | 368 |
369 // We normally process the reverse stream at 16 kHz. Unless... | 369 // We normally process the reverse stream at 16 kHz. Unless... |
370 int rev_proc_rate = kSampleRate16kHz; | 370 int rev_proc_rate = kSampleRate16kHz; |
371 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate8kHz) { | 371 if (capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate8kHz) { |
372 // ...the forward stream is at 8 kHz. | 372 // ...the forward stream is at 8 kHz. |
373 rev_proc_rate = kSampleRate8kHz; | 373 rev_proc_rate = kSampleRate8kHz; |
374 } else { | 374 } else { |
375 if (formats_.api_format.reverse_input_stream().sample_rate_hz() == | 375 if (formats_.api_format.reverse_input_stream().sample_rate_hz() == |
376 kSampleRate32kHz) { | 376 kSampleRate32kHz) { |
377 // ...or the input is at 32 kHz, in which case we use the splitting | 377 // ...or the input is at 32 kHz, in which case we use the splitting |
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1449 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); | 1449 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); |
1450 | 1450 |
1451 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), | 1451 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), |
1452 &debug_dump_.num_bytes_left_for_log_, | 1452 &debug_dump_.num_bytes_left_for_log_, |
1453 &crit_debug_, &debug_dump_.capture)); | 1453 &crit_debug_, &debug_dump_.capture)); |
1454 return kNoError; | 1454 return kNoError; |
1455 } | 1455 } |
1456 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 1456 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
1457 | 1457 |
1458 } // namespace webrtc | 1458 } // namespace webrtc |
OLD | NEW |