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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 data[i] = (int16_t)(tmp_int32 >> 12); | 93 data[i] = (int16_t)(tmp_int32 >> 12); |
94 } | 94 } |
95 | 95 |
96 return AudioProcessing::kNoError; | 96 return AudioProcessing::kNoError; |
97 } | 97 } |
98 } // namespace | 98 } // namespace |
99 | 99 |
100 typedef FilterState Handle; | 100 typedef FilterState Handle; |
101 | 101 |
102 HighPassFilterImpl::HighPassFilterImpl(const AudioProcessing* apm, | 102 HighPassFilterImpl::HighPassFilterImpl(const AudioProcessing* apm, |
103 CriticalSectionWrapper* crit) | 103 rtc::CriticalSection* crit) |
104 : ProcessingComponent(), | 104 : ProcessingComponent(), apm_(apm), crit_(crit) { |
105 apm_(apm), | 105 RTC_DCHECK(apm); |
106 crit_(crit) {} | 106 RTC_DCHECK(crit); |
| 107 } |
107 | 108 |
108 HighPassFilterImpl::~HighPassFilterImpl() {} | 109 HighPassFilterImpl::~HighPassFilterImpl() {} |
109 | 110 |
110 int HighPassFilterImpl::ProcessCaptureAudio(AudioBuffer* audio) { | 111 int HighPassFilterImpl::ProcessCaptureAudio(AudioBuffer* audio) { |
111 int err = apm_->kNoError; | 112 rtc::CritScope cs(crit_); |
| 113 int err = AudioProcessing::kNoError; |
112 | 114 |
113 if (!is_component_enabled()) { | 115 if (!is_component_enabled()) { |
114 return apm_->kNoError; | 116 return AudioProcessing::kNoError; |
115 } | 117 } |
116 | 118 |
117 assert(audio->num_frames_per_band() <= 160); | 119 assert(audio->num_frames_per_band() <= 160); |
118 | 120 |
119 for (int i = 0; i < num_handles(); i++) { | 121 for (int i = 0; i < num_handles(); i++) { |
120 Handle* my_handle = static_cast<Handle*>(handle(i)); | 122 Handle* my_handle = static_cast<Handle*>(handle(i)); |
121 err = Filter(my_handle, | 123 err = Filter(my_handle, |
122 audio->split_bands(i)[kBand0To8kHz], | 124 audio->split_bands(i)[kBand0To8kHz], |
123 audio->num_frames_per_band()); | 125 audio->num_frames_per_band()); |
124 | 126 |
125 if (err != apm_->kNoError) { | 127 if (err != AudioProcessing::kNoError) { |
126 return GetHandleError(my_handle); | 128 return GetHandleError(my_handle); |
127 } | 129 } |
128 } | 130 } |
129 | 131 |
130 return apm_->kNoError; | 132 return AudioProcessing::kNoError; |
131 } | 133 } |
132 | 134 |
133 int HighPassFilterImpl::Enable(bool enable) { | 135 int HighPassFilterImpl::Enable(bool enable) { |
134 CriticalSectionScoped crit_scoped(crit_); | 136 rtc::CritScope cs(crit_); |
135 return EnableComponent(enable); | 137 return EnableComponent(enable); |
136 } | 138 } |
137 | 139 |
138 bool HighPassFilterImpl::is_enabled() const { | 140 bool HighPassFilterImpl::is_enabled() const { |
| 141 rtc::CritScope cs(crit_); |
139 return is_component_enabled(); | 142 return is_component_enabled(); |
140 } | 143 } |
141 | 144 |
142 void* HighPassFilterImpl::CreateHandle() const { | 145 void* HighPassFilterImpl::CreateHandle() const { |
143 return new FilterState; | 146 return new FilterState; |
144 } | 147 } |
145 | 148 |
146 void HighPassFilterImpl::DestroyHandle(void* handle) const { | 149 void HighPassFilterImpl::DestroyHandle(void* handle) const { |
147 delete static_cast<Handle*>(handle); | 150 delete static_cast<Handle*>(handle); |
148 } | 151 } |
149 | 152 |
150 int HighPassFilterImpl::InitializeHandle(void* handle) const { | 153 int HighPassFilterImpl::InitializeHandle(void* handle) const { |
| 154 // TODO(peah): Remove dependency on apm for the |
| 155 // capture side sample rate. |
| 156 rtc::CritScope cs(crit_); |
151 return InitializeFilter(static_cast<Handle*>(handle), | 157 return InitializeFilter(static_cast<Handle*>(handle), |
152 apm_->proc_sample_rate_hz()); | 158 apm_->proc_sample_rate_hz()); |
153 } | 159 } |
154 | 160 |
155 int HighPassFilterImpl::ConfigureHandle(void* /*handle*/) const { | 161 int HighPassFilterImpl::ConfigureHandle(void* /*handle*/) const { |
156 return apm_->kNoError; // Not configurable. | 162 return AudioProcessing::kNoError; // Not configurable. |
157 } | 163 } |
158 | 164 |
159 int HighPassFilterImpl::num_handles_required() const { | 165 int HighPassFilterImpl::num_handles_required() const { |
160 return apm_->num_output_channels(); | 166 return apm_->num_output_channels(); |
161 } | 167 } |
162 | 168 |
163 int HighPassFilterImpl::GetHandleError(void* handle) const { | 169 int HighPassFilterImpl::GetHandleError(void* handle) const { |
164 // The component has no detailed errors. | 170 // The component has no detailed errors. |
165 assert(handle != NULL); | 171 assert(handle != NULL); |
166 return apm_->kUnspecifiedError; | 172 return AudioProcessing::kUnspecifiedError; |
167 } | 173 } |
168 } // namespace webrtc | 174 } // namespace webrtc |
OLD | NEW |