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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 #define RETURN_ON_ERR(expr) \ | 63 #define RETURN_ON_ERR(expr) \ |
64 do { \ | 64 do { \ |
65 int err = (expr); \ | 65 int err = (expr); \ |
66 if (err != kNoError) { \ | 66 if (err != kNoError) { \ |
67 return err; \ | 67 return err; \ |
68 } \ | 68 } \ |
69 } while (0) | 69 } while (0) |
70 | 70 |
71 namespace webrtc { | 71 namespace webrtc { |
72 | 72 |
73 const int AudioProcessing::kNativeSampleRatesHz[] = { | 73 constexpr int AudioProcessing::kNativeSampleRatesHz[]; |
74 AudioProcessing::kSampleRate8kHz, | |
75 AudioProcessing::kSampleRate16kHz, | |
76 AudioProcessing::kSampleRate32kHz, | |
77 AudioProcessing::kSampleRate48kHz}; | |
78 const size_t AudioProcessing::kNumNativeSampleRates = | |
79 arraysize(AudioProcessing::kNativeSampleRatesHz); | |
80 const int AudioProcessing::kMaxNativeSampleRateHz = AudioProcessing:: | |
81 kNativeSampleRatesHz[AudioProcessing::kNumNativeSampleRates - 1]; | |
82 | 74 |
83 namespace { | 75 namespace { |
84 | 76 |
85 static bool LayoutHasKeyboard(AudioProcessing::ChannelLayout layout) { | 77 static bool LayoutHasKeyboard(AudioProcessing::ChannelLayout layout) { |
86 switch (layout) { | 78 switch (layout) { |
87 case AudioProcessing::kMono: | 79 case AudioProcessing::kMono: |
88 case AudioProcessing::kStereo: | 80 case AudioProcessing::kStereo: |
89 return false; | 81 return false; |
90 case AudioProcessing::kMonoAndKeyboard: | 82 case AudioProcessing::kMonoAndKeyboard: |
91 case AudioProcessing::kStereoAndKeyboard: | 83 case AudioProcessing::kStereoAndKeyboard: |
92 return true; | 84 return true; |
93 } | 85 } |
94 | 86 |
95 assert(false); | 87 assert(false); |
96 return false; | 88 return false; |
97 } | 89 } |
98 | 90 |
99 bool SampleRateSupportsMultiBand(int sample_rate_hz) { | 91 bool SampleRateSupportsMultiBand(int sample_rate_hz) { |
100 return sample_rate_hz == AudioProcessing::kSampleRate32kHz || | 92 return sample_rate_hz == AudioProcessing::kSampleRate32kHz || |
101 sample_rate_hz == AudioProcessing::kSampleRate48kHz; | 93 sample_rate_hz == AudioProcessing::kSampleRate48kHz; |
102 } | 94 } |
103 | 95 |
104 int FindNativeProcessRateToUse(int minimum_rate, bool band_splitting_required) { | 96 int FindNativeProcessRateToUse(int minimum_rate, bool band_splitting_required) { |
105 #ifdef WEBRTC_ARCH_ARM_FAMILY | 97 #ifdef WEBRTC_ARCH_ARM_FAMILY |
106 const int kMaxSplittingNativeProcessRate = AudioProcessing::kSampleRate32kHz; | 98 constexpr int kMaxSplittingNativeProcessRate = |
99 AudioProcessing::kSampleRate32kHz; | |
107 #else | 100 #else |
108 const int kMaxSplittingNativeProcessRate = AudioProcessing::kSampleRate48kHz; | 101 constexpr int kMaxSplittingNativeProcessRate = |
102 AudioProcessing::kSampleRate48kHz; | |
109 #endif | 103 #endif |
110 RTC_DCHECK_LE(kMaxSplittingNativeProcessRate, | 104 static_assert( |
111 AudioProcessing::kMaxNativeSampleRateHz); | 105 kMaxSplittingNativeProcessRate <= AudioProcessing::kMaxNativeSampleRateHz, |
106 ""); | |
peah-webrtc
2016/09/13 12:50:12
Don't we want a message for the assert?
kwiberg-webrtc
2016/09/13 13:11:17
No. If the assert fails, there'll be a compilation
| |
112 const int uppermost_native_rate = band_splitting_required | 107 const int uppermost_native_rate = band_splitting_required |
113 ? kMaxSplittingNativeProcessRate | 108 ? kMaxSplittingNativeProcessRate |
114 : AudioProcessing::kSampleRate48kHz; | 109 : AudioProcessing::kSampleRate48kHz; |
115 | 110 |
116 for (auto rate : AudioProcessing::kNativeSampleRatesHz) { | 111 for (auto rate : AudioProcessing::kNativeSampleRatesHz) { |
117 if (rate >= uppermost_native_rate) { | 112 if (rate >= uppermost_native_rate) { |
118 return uppermost_native_rate; | 113 return uppermost_native_rate; |
119 } | 114 } |
120 if (rate >= minimum_rate) { | 115 if (rate >= minimum_rate) { |
121 return rate; | 116 return rate; |
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1598 fwd_proc_format(kSampleRate16kHz), | 1593 fwd_proc_format(kSampleRate16kHz), |
1599 split_rate(kSampleRate16kHz) {} | 1594 split_rate(kSampleRate16kHz) {} |
1600 | 1595 |
1601 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; | 1596 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; |
1602 | 1597 |
1603 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; | 1598 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; |
1604 | 1599 |
1605 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; | 1600 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; |
1606 | 1601 |
1607 } // namespace webrtc | 1602 } // namespace webrtc |
OLD | NEW |