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 |
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ |
13 | 13 |
14 #include <list> | 14 #include <list> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "webrtc/base/criticalsection.h" | |
18 #include "webrtc/base/scoped_ptr.h" | 19 #include "webrtc/base/scoped_ptr.h" |
19 #include "webrtc/base/thread_annotations.h" | 20 #include "webrtc/base/thread_annotations.h" |
21 #include "webrtc/modules/audio_processing/audio_buffer.h" | |
20 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 22 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
23 #include "webrtc/system_wrappers/include/file_wrapper.h" | |
24 | |
25 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | |
26 // Files generated at build-time by the protobuf compiler. | |
27 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | |
28 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" | |
29 #else | |
30 #include "webrtc/audio_processing/debug.pb.h" | |
31 #endif | |
32 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | |
21 | 33 |
22 namespace webrtc { | 34 namespace webrtc { |
23 | 35 |
24 class AgcManagerDirect; | 36 class AgcManagerDirect; |
25 class AudioBuffer; | |
26 class AudioConverter; | 37 class AudioConverter; |
27 | 38 |
28 template<typename T> | 39 template<typename T> |
29 class Beamformer; | 40 class Beamformer; |
30 | 41 |
31 class CriticalSectionWrapper; | |
32 class EchoCancellationImpl; | 42 class EchoCancellationImpl; |
33 class EchoControlMobileImpl; | 43 class EchoControlMobileImpl; |
34 class FileWrapper; | |
35 class GainControlImpl; | 44 class GainControlImpl; |
36 class GainControlForNewAgc; | 45 class GainControlForNewAgc; |
37 class HighPassFilterImpl; | 46 class HighPassFilterImpl; |
38 class LevelEstimatorImpl; | 47 class LevelEstimatorImpl; |
39 class NoiseSuppressionImpl; | 48 class NoiseSuppressionImpl; |
40 class ProcessingComponent; | 49 class ProcessingComponent; |
41 class TransientSuppressor; | 50 class TransientSuppressor; |
42 class VoiceDetectionImpl; | 51 class VoiceDetectionImpl; |
43 class IntelligibilityEnhancer; | 52 class IntelligibilityEnhancer; |
44 | 53 |
45 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 54 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
46 namespace audioproc { | 55 // State for the debug dump. |
the sun
2015/11/27 13:32:28
You could move these two also into the private sec
peah-webrtc
2015/11/27 13:50:22
Great point as usual!
Will do!
Done.
| |
56 struct ApmDebugDumpThreadState { | |
57 ApmDebugDumpThreadState() : event_msg(new audioproc::Event()) {} | |
58 rtc::scoped_ptr<audioproc::Event> event_msg; // Protobuf message. | |
59 std::string event_str; // Memory for protobuf serialization. | |
47 | 60 |
48 class Event; | 61 // Serialized string of last saved APM configuration. |
62 std::string last_serialized_config; | |
63 }; | |
49 | 64 |
50 } // namespace audioproc | 65 struct ApmDebugDumpState { |
66 ApmDebugDumpState() : debug_file(FileWrapper::Create()) {} | |
67 rtc::scoped_ptr<FileWrapper> debug_file; | |
68 ApmDebugDumpThreadState render; | |
69 ApmDebugDumpThreadState capture; | |
70 }; | |
71 | |
51 #endif | 72 #endif |
52 | 73 |
53 class AudioProcessingImpl : public AudioProcessing { | 74 class AudioProcessingImpl : public AudioProcessing { |
54 public: | 75 public: |
76 // Methods forcing APM to run in a single-threaded manner. | |
77 // Acquires both the render and capture locks. | |
55 explicit AudioProcessingImpl(const Config& config); | 78 explicit AudioProcessingImpl(const Config& config); |
56 | |
57 // AudioProcessingImpl takes ownership of beamformer. | 79 // AudioProcessingImpl takes ownership of beamformer. |
58 AudioProcessingImpl(const Config& config, Beamformer<float>* beamformer); | 80 AudioProcessingImpl(const Config& config, Beamformer<float>* beamformer); |
59 virtual ~AudioProcessingImpl(); | 81 virtual ~AudioProcessingImpl(); |
60 | |
61 // AudioProcessing methods. | |
62 int Initialize() override; | 82 int Initialize() override; |
63 int Initialize(int input_sample_rate_hz, | 83 int Initialize(int input_sample_rate_hz, |
64 int output_sample_rate_hz, | 84 int output_sample_rate_hz, |
65 int reverse_sample_rate_hz, | 85 int reverse_sample_rate_hz, |
66 ChannelLayout input_layout, | 86 ChannelLayout input_layout, |
67 ChannelLayout output_layout, | 87 ChannelLayout output_layout, |
68 ChannelLayout reverse_layout) override; | 88 ChannelLayout reverse_layout) override; |
69 int Initialize(const ProcessingConfig& processing_config) override; | 89 int Initialize(const ProcessingConfig& processing_config) override; |
70 void SetExtraOptions(const Config& config) override; | 90 void SetExtraOptions(const Config& config) override; |
71 int proc_sample_rate_hz() const override; | 91 void UpdateHistogramsOnCallEnd() override; |
72 int proc_split_sample_rate_hz() const override; | 92 int StartDebugRecording(const char filename[kMaxFilenameSize]) override; |
73 int num_input_channels() const override; | 93 int StartDebugRecording(FILE* handle) override; |
74 int num_output_channels() const override; | 94 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override; |
75 int num_reverse_channels() const override; | 95 int StopDebugRecording() override; |
76 void set_output_will_be_muted(bool muted) override; | 96 |
97 // Capture-side exclusive methods possibly running APM in a | |
98 // multi-threaded manner. Acquire the capture lock. | |
77 int ProcessStream(AudioFrame* frame) override; | 99 int ProcessStream(AudioFrame* frame) override; |
78 int ProcessStream(const float* const* src, | 100 int ProcessStream(const float* const* src, |
79 size_t samples_per_channel, | 101 size_t samples_per_channel, |
80 int input_sample_rate_hz, | 102 int input_sample_rate_hz, |
81 ChannelLayout input_layout, | 103 ChannelLayout input_layout, |
82 int output_sample_rate_hz, | 104 int output_sample_rate_hz, |
83 ChannelLayout output_layout, | 105 ChannelLayout output_layout, |
84 float* const* dest) override; | 106 float* const* dest) override; |
85 int ProcessStream(const float* const* src, | 107 int ProcessStream(const float* const* src, |
86 const StreamConfig& input_config, | 108 const StreamConfig& input_config, |
87 const StreamConfig& output_config, | 109 const StreamConfig& output_config, |
88 float* const* dest) override; | 110 float* const* dest) override; |
111 void set_output_will_be_muted(bool muted) override; | |
112 int set_stream_delay_ms(int delay) override; | |
113 void set_delay_offset_ms(int offset) override; | |
114 int delay_offset_ms() const override; | |
115 void set_stream_key_pressed(bool key_pressed) override; | |
116 | |
117 // Render-side exclusive methods possibly running APM in a | |
118 // multi-threaded manner. Acquire the render lock. | |
89 int AnalyzeReverseStream(AudioFrame* frame) override; | 119 int AnalyzeReverseStream(AudioFrame* frame) override; |
90 int ProcessReverseStream(AudioFrame* frame) override; | 120 int ProcessReverseStream(AudioFrame* frame) override; |
91 int AnalyzeReverseStream(const float* const* data, | 121 int AnalyzeReverseStream(const float* const* data, |
92 size_t samples_per_channel, | 122 size_t samples_per_channel, |
93 int sample_rate_hz, | 123 int sample_rate_hz, |
94 ChannelLayout layout) override; | 124 ChannelLayout layout) override; |
95 int ProcessReverseStream(const float* const* src, | 125 int ProcessReverseStream(const float* const* src, |
96 const StreamConfig& reverse_input_config, | 126 const StreamConfig& reverse_input_config, |
97 const StreamConfig& reverse_output_config, | 127 const StreamConfig& reverse_output_config, |
98 float* const* dest) override; | 128 float* const* dest) override; |
99 int set_stream_delay_ms(int delay) override; | 129 |
130 // Methods only accessed from APM submodules or | |
131 // from AudioProcessing tests in a single-threaded manner. | |
132 // Hence there is no need for locks in these. | |
133 int proc_sample_rate_hz() const override; | |
134 int proc_split_sample_rate_hz() const override; | |
135 int num_input_channels() const override; | |
136 int num_output_channels() const override; | |
137 int num_reverse_channels() const override; | |
100 int stream_delay_ms() const override; | 138 int stream_delay_ms() const override; |
101 bool was_stream_delay_set() const override; | 139 bool was_stream_delay_set() const override |
102 void set_delay_offset_ms(int offset) override; | 140 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
103 int delay_offset_ms() const override; | 141 |
104 void set_stream_key_pressed(bool key_pressed) override; | 142 // Methods returning pointers to APM submodules. |
105 int StartDebugRecording(const char filename[kMaxFilenameSize]) override; | 143 // No locks are aquired in those, as those locks |
106 int StartDebugRecording(FILE* handle) override; | 144 // would offer no protection (the submodules are |
107 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override; | 145 // created only once in a single-treaded manner |
108 int StopDebugRecording() override; | 146 // during APM creation). |
109 void UpdateHistogramsOnCallEnd() override; | |
110 EchoCancellation* echo_cancellation() const override; | 147 EchoCancellation* echo_cancellation() const override; |
111 EchoControlMobile* echo_control_mobile() const override; | 148 EchoControlMobile* echo_control_mobile() const override; |
112 GainControl* gain_control() const override; | 149 GainControl* gain_control() const override; |
113 HighPassFilter* high_pass_filter() const override; | 150 HighPassFilter* high_pass_filter() const override; |
114 LevelEstimator* level_estimator() const override; | 151 LevelEstimator* level_estimator() const override; |
115 NoiseSuppression* noise_suppression() const override; | 152 NoiseSuppression* noise_suppression() const override; |
116 VoiceDetection* voice_detection() const override; | 153 VoiceDetection* voice_detection() const override; |
117 | 154 |
118 protected: | 155 protected: |
119 // Overridden in a mock. | 156 // Overridden in a mock. |
120 virtual int InitializeLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 157 virtual int InitializeLocked() |
158 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | |
121 | 159 |
122 private: | 160 private: |
161 struct ApmPublicSubmodules; | |
162 struct ApmPrivateSubmodules; | |
163 | |
164 // Method for modifying the formats struct that are called from both | |
165 // the render and capture threads. The check for whether modifications | |
166 // are needed is done while holding the render lock only, thereby avoiding | |
167 // that the capture thread blocks the render thread. | |
168 // The struct is modified in a single-threaded manner by holding both the | |
169 // render and capture locks. | |
170 int MaybeInitialize(const ProcessingConfig& config) | |
171 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); | |
172 | |
173 int MaybeInitializeRender(const ProcessingConfig& processing_config) | |
174 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); | |
175 | |
176 int MaybeInitializeCapture(const ProcessingConfig& processing_config) | |
177 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); | |
178 | |
179 // Method for checking for the need of conversion. Accesses the formats | |
180 // structs in a read manner but the requirement for the render lock to be held | |
181 // was added as it currently anyway is always called in that manner. | |
182 bool rev_conversion_needed() const EXCLUSIVE_LOCKS_REQUIRED(crit_render_); | |
183 bool render_check_rev_conversion_needed() const | |
184 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); | |
185 | |
186 // Methods requiring APM running in a single-threaded manner. | |
187 // Are called with both the render and capture locks already | |
188 // acquired. | |
189 void InitializeExperimentalAgc() | |
190 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | |
191 void InitializeTransient() | |
192 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | |
193 void InitializeBeamformer() | |
194 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | |
195 void InitializeIntelligibility() | |
196 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | |
123 int InitializeLocked(const ProcessingConfig& config) | 197 int InitializeLocked(const ProcessingConfig& config) |
124 EXCLUSIVE_LOCKS_REQUIRED(crit_); | 198 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
125 int MaybeInitializeLockedRender(const ProcessingConfig& config) | 199 |
126 EXCLUSIVE_LOCKS_REQUIRED(crit_); | 200 // Capture-side exclusive methods possibly running APM in a multi-threaded |
127 int MaybeInitializeLockedCapture(const ProcessingConfig& config) | 201 // manner that are called with the render lock already acquired. |
128 EXCLUSIVE_LOCKS_REQUIRED(crit_); | 202 int ProcessStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
129 int MaybeInitializeLocked(const ProcessingConfig& config) | 203 bool output_copy_needed(bool is_data_processed) const |
130 EXCLUSIVE_LOCKS_REQUIRED(crit_); | 204 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
205 bool is_data_processed() const EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); | |
206 bool synthesis_needed(bool is_data_processed) const | |
207 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); | |
208 bool analysis_needed(bool is_data_processed) const | |
209 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); | |
210 void MaybeUpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); | |
211 | |
212 // Render-side exclusive methods possibly running APM in a multi-threaded | |
213 // manner that are called with the render lock already acquired. | |
131 // TODO(ekm): Remove once all clients updated to new interface. | 214 // TODO(ekm): Remove once all clients updated to new interface. |
132 int AnalyzeReverseStream(const float* const* src, | 215 int AnalyzeReverseStreamLocked(const float* const* src, |
133 const StreamConfig& input_config, | 216 const StreamConfig& input_config, |
134 const StreamConfig& output_config); | 217 const StreamConfig& output_config) |
135 int ProcessStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 218 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
136 int ProcessReverseStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 219 bool is_rev_processed() const EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
220 int ProcessReverseStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_render_); | |
137 | 221 |
138 bool is_data_processed() const; | 222 // Debug dump methods that are internal and called without locks. |
139 bool output_copy_needed(bool is_data_processed) const; | 223 // TODO(peah): Make thread safe. |
140 bool synthesis_needed(bool is_data_processed) const; | |
141 bool analysis_needed(bool is_data_processed) const; | |
142 bool is_rev_processed() const; | |
143 bool rev_conversion_needed() const; | |
144 // TODO(peah): Add EXCLUSIVE_LOCKS_REQUIRED for the method below. | |
145 bool render_check_rev_conversion_needed() const; | |
146 void InitializeExperimentalAgc() EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
147 void InitializeTransient() EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
148 void InitializeBeamformer() EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
149 void InitializeIntelligibility() EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
150 void MaybeUpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
151 | |
152 EchoCancellationImpl* echo_cancellation_; | |
153 EchoControlMobileImpl* echo_control_mobile_; | |
154 GainControlImpl* gain_control_; | |
155 HighPassFilterImpl* high_pass_filter_; | |
156 LevelEstimatorImpl* level_estimator_; | |
157 NoiseSuppressionImpl* noise_suppression_; | |
158 VoiceDetectionImpl* voice_detection_; | |
159 rtc::scoped_ptr<GainControlForNewAgc> gain_control_for_new_agc_; | |
160 | |
161 std::list<ProcessingComponent*> component_list_; | |
162 CriticalSectionWrapper* crit_; | |
163 rtc::scoped_ptr<AudioBuffer> render_audio_; | |
164 rtc::scoped_ptr<AudioBuffer> capture_audio_; | |
165 rtc::scoped_ptr<AudioConverter> render_converter_; | |
166 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 224 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
167 // TODO(andrew): make this more graceful. Ideally we would split this stuff | 225 // TODO(andrew): make this more graceful. Ideally we would split this stuff |
168 // out into a separate class with an "enabled" and "disabled" implementation. | 226 // out into a separate class with an "enabled" and "disabled" implementation. |
169 int WriteMessageToDebugFile(); | 227 static int WriteMessageToDebugFile(FileWrapper* debug_file, |
170 int WriteInitMessage(); | 228 rtc::CriticalSection* crit_debug, |
229 ApmDebugDumpThreadState* debug_state); | |
230 int WriteInitMessage() EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | |
171 | 231 |
172 // Writes Config message. If not |forced|, only writes the current config if | 232 // Writes Config message. If not |forced|, only writes the current config if |
173 // it is different from the last saved one; if |forced|, writes the config | 233 // it is different from the last saved one; if |forced|, writes the config |
174 // regardless of the last saved. | 234 // regardless of the last saved. |
175 int WriteConfigMessage(bool forced); | 235 int WriteConfigMessage(bool forced) EXCLUSIVE_LOCKS_REQUIRED(crit_capture_) |
236 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); | |
176 | 237 |
177 rtc::scoped_ptr<FileWrapper> debug_file_; | 238 // Critical section. |
178 rtc::scoped_ptr<audioproc::Event> event_msg_; // Protobuf message. | 239 mutable rtc::CriticalSection crit_debug_; |
179 std::string event_str_; // Memory for protobuf serialization. | |
180 | 240 |
181 // Serialized string of last saved APM configuration. | 241 // Debug dump state. |
182 std::string last_serialized_config_; | 242 ApmDebugDumpState debug_dump_; |
183 #endif | 243 #endif |
184 | 244 |
245 // Critical sections. | |
246 mutable rtc::CriticalSection crit_render_ ACQUIRED_BEFORE(crit_capture_); | |
247 mutable rtc::CriticalSection crit_capture_; | |
248 | |
249 // Structs containing the pointers to the submodules. | |
250 rtc::scoped_ptr<ApmPublicSubmodules> public_submodules_; | |
251 rtc::scoped_ptr<ApmPrivateSubmodules> private_submodules_ | |
252 GUARDED_BY(crit_capture_); | |
253 | |
185 // State that is written to while holding both the render and capture locks | 254 // State that is written to while holding both the render and capture locks |
186 // but can be read while holding only one of the locks. | 255 // but can be read without any lock being held. |
187 struct SharedState { | 256 // As this is only accessed internally of APM, and all internal methods in APM |
188 SharedState() | 257 // either are holding the render or capture locks, this construct is safe as |
258 // it is not possible to read the variables while writing them. | |
259 struct ApmFormatState { | |
260 ApmFormatState() | |
189 : // Format of processing streams at input/output call sites. | 261 : // Format of processing streams at input/output call sites. |
190 api_format_({{{kSampleRate16kHz, 1, false}, | 262 api_format({{{kSampleRate16kHz, 1, false}, |
191 {kSampleRate16kHz, 1, false}, | 263 {kSampleRate16kHz, 1, false}, |
192 {kSampleRate16kHz, 1, false}, | 264 {kSampleRate16kHz, 1, false}, |
193 {kSampleRate16kHz, 1, false}}}) {} | 265 {kSampleRate16kHz, 1, false}}}), |
194 ProcessingConfig api_format_; | 266 rev_proc_format(kSampleRate16kHz, 1) {} |
195 } shared_state_; | 267 ProcessingConfig api_format; |
268 StreamConfig rev_proc_format; | |
269 } formats_; | |
196 | 270 |
197 // Only the rate and samples fields of fwd_proc_format_ are used because the | 271 // APM constants. |
198 // forward processing number of channels is mutable and is tracked by the | 272 const struct ApmConstants { |
199 // capture_audio_. | 273 ApmConstants(int agc_startup_min_volume, |
200 StreamConfig fwd_proc_format_; | 274 const std::vector<Point> array_geometry, |
201 StreamConfig rev_proc_format_; | 275 SphericalPointf target_direction, |
202 int split_rate_; | 276 bool use_new_agc, |
277 bool intelligibility_enabled, | |
278 bool beamformer_enabled) | |
279 : // Format of processing streams at input/output call sites. | |
280 agc_startup_min_volume(agc_startup_min_volume), | |
281 array_geometry(array_geometry), | |
282 target_direction(target_direction), | |
283 use_new_agc(use_new_agc), | |
284 intelligibility_enabled(intelligibility_enabled), | |
285 beamformer_enabled(beamformer_enabled) {} | |
286 int agc_startup_min_volume; | |
287 std::vector<Point> array_geometry; | |
288 SphericalPointf target_direction; | |
289 bool use_new_agc; | |
290 bool intelligibility_enabled; | |
291 bool beamformer_enabled; | |
292 } constants_; | |
203 | 293 |
204 int stream_delay_ms_; | 294 struct ApmCaptureState { |
205 int delay_offset_ms_; | 295 ApmCaptureState(bool transient_suppressor_enabled) |
206 bool was_stream_delay_set_; | 296 : aec_system_delay_jumps(-1), |
207 int last_stream_delay_ms_; | 297 delay_offset_ms(0), |
208 int last_aec_system_delay_ms_; | 298 was_stream_delay_set(false), |
209 int stream_delay_jumps_; | 299 last_stream_delay_ms(0), |
210 int aec_system_delay_jumps_; | 300 last_aec_system_delay_ms(0), |
301 stream_delay_jumps(-1), | |
302 output_will_be_muted(false), | |
303 key_pressed(false), | |
304 transient_suppressor_enabled(transient_suppressor_enabled), | |
305 fwd_proc_format(kSampleRate16kHz), | |
306 split_rate(kSampleRate16kHz) {} | |
307 int aec_system_delay_jumps; | |
308 int delay_offset_ms; | |
309 bool was_stream_delay_set; | |
310 int last_stream_delay_ms; | |
311 int last_aec_system_delay_ms; | |
312 int stream_delay_jumps; | |
313 bool output_will_be_muted; | |
314 bool key_pressed; | |
315 bool transient_suppressor_enabled; | |
316 rtc::scoped_ptr<AudioBuffer> capture_audio; | |
317 // Only the rate and samples fields of fwd_proc_format_ are used because the | |
318 // forward processing number of channels is mutable and is tracked by the | |
319 // capture_audio_. | |
320 StreamConfig fwd_proc_format; | |
321 int split_rate; | |
322 } capture_ GUARDED_BY(crit_capture_); | |
211 | 323 |
212 bool output_will_be_muted_ GUARDED_BY(crit_); | 324 struct ApmCaptureNonLockedState { |
325 ApmCaptureNonLockedState() | |
326 : fwd_proc_format(kSampleRate16kHz), | |
327 split_rate(kSampleRate16kHz), | |
328 stream_delay_ms(0) {} | |
329 // Only the rate and samples fields of fwd_proc_format_ are used because the | |
330 // forward processing number of channels is mutable and is tracked by the | |
331 // capture_audio_. | |
332 StreamConfig fwd_proc_format; | |
333 int split_rate; | |
334 int stream_delay_ms; | |
335 } capture_nonlocked_; | |
213 | 336 |
214 bool key_pressed_; | 337 struct ApmRenderState { |
215 | 338 rtc::scoped_ptr<AudioConverter> render_converter; |
216 // Only set through the constructor's Config parameter. | 339 rtc::scoped_ptr<AudioBuffer> render_audio; |
217 const bool use_new_agc_; | 340 } render_ GUARDED_BY(crit_render_); |
218 rtc::scoped_ptr<AgcManagerDirect> agc_manager_ GUARDED_BY(crit_); | |
219 int agc_startup_min_volume_; | |
220 | |
221 bool transient_suppressor_enabled_; | |
222 rtc::scoped_ptr<TransientSuppressor> transient_suppressor_; | |
223 const bool beamformer_enabled_; | |
224 rtc::scoped_ptr<Beamformer<float>> beamformer_; | |
225 const std::vector<Point> array_geometry_; | |
226 const SphericalPointf target_direction_; | |
227 | |
228 bool intelligibility_enabled_; | |
229 rtc::scoped_ptr<IntelligibilityEnhancer> intelligibility_enhancer_; | |
230 }; | 341 }; |
231 | 342 |
232 } // namespace webrtc | 343 } // namespace webrtc |
233 | 344 |
234 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ | 345 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ |
OLD | NEW |