Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: webrtc/modules/audio_processing/audio_processing_impl.h

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

Powered by Google App Engine
This is Rietveld 408576698