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

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

Issue 2335633002: This CL renames variables and method and removes some one-line methods inside the APM (Closed)
Patch Set: Re-adding missing initialization Created 4 years, 3 months 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
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/audio_processing_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 30 matching lines...) Expand all
41 class AudioProcessingImpl : public AudioProcessing { 41 class AudioProcessingImpl : public AudioProcessing {
42 public: 42 public:
43 // Methods forcing APM to run in a single-threaded manner. 43 // Methods forcing APM to run in a single-threaded manner.
44 // Acquires both the render and capture locks. 44 // Acquires both the render and capture locks.
45 explicit AudioProcessingImpl(const webrtc::Config& config); 45 explicit AudioProcessingImpl(const webrtc::Config& config);
46 // AudioProcessingImpl takes ownership of beamformer. 46 // AudioProcessingImpl takes ownership of beamformer.
47 AudioProcessingImpl(const webrtc::Config& config, 47 AudioProcessingImpl(const webrtc::Config& config,
48 NonlinearBeamformer* beamformer); 48 NonlinearBeamformer* beamformer);
49 ~AudioProcessingImpl() override; 49 ~AudioProcessingImpl() override;
50 int Initialize() override; 50 int Initialize() override;
51 int Initialize(int input_sample_rate_hz, 51 int Initialize(int capture_input_sample_rate_hz,
52 int output_sample_rate_hz, 52 int capture_output_sample_rate_hz,
53 int reverse_sample_rate_hz, 53 int render_sample_rate_hz,
54 ChannelLayout input_layout, 54 ChannelLayout capture_input_layout,
55 ChannelLayout output_layout, 55 ChannelLayout capture_output_layout,
56 ChannelLayout reverse_layout) override; 56 ChannelLayout render_input_layout) override;
57 int Initialize(const ProcessingConfig& processing_config) override; 57 int Initialize(const ProcessingConfig& processing_config) override;
58 void ApplyConfig(const AudioProcessing::Config& config) override; 58 void ApplyConfig(const AudioProcessing::Config& config) override;
59 void SetExtraOptions(const webrtc::Config& config) override; 59 void SetExtraOptions(const webrtc::Config& config) override;
60 void UpdateHistogramsOnCallEnd() override; 60 void UpdateHistogramsOnCallEnd() override;
61 int StartDebugRecording(const char filename[kMaxFilenameSize], 61 int StartDebugRecording(const char filename[kMaxFilenameSize],
62 int64_t max_log_size_bytes) override; 62 int64_t max_log_size_bytes) override;
63 int StartDebugRecording(FILE* handle, int64_t max_log_size_bytes) override; 63 int StartDebugRecording(FILE* handle, int64_t max_log_size_bytes) override;
64 64
65 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override; 65 int StartDebugRecordingForPlatformFile(rtc::PlatformFile handle) override;
66 int StopDebugRecording() override; 66 int StopDebugRecording() override;
(...skipping 19 matching lines...) Expand all
86 void set_stream_key_pressed(bool key_pressed) override; 86 void set_stream_key_pressed(bool key_pressed) override;
87 87
88 // Render-side exclusive methods possibly running APM in a 88 // Render-side exclusive methods possibly running APM in a
89 // multi-threaded manner. Acquire the render lock. 89 // multi-threaded manner. Acquire the render lock.
90 int ProcessReverseStream(AudioFrame* frame) override; 90 int ProcessReverseStream(AudioFrame* frame) override;
91 int AnalyzeReverseStream(const float* const* data, 91 int AnalyzeReverseStream(const float* const* data,
92 size_t samples_per_channel, 92 size_t samples_per_channel,
93 int sample_rate_hz, 93 int sample_rate_hz,
94 ChannelLayout layout) override; 94 ChannelLayout layout) override;
95 int ProcessReverseStream(const float* const* src, 95 int ProcessReverseStream(const float* const* src,
96 const StreamConfig& reverse_input_config, 96 const StreamConfig& input_config,
97 const StreamConfig& reverse_output_config, 97 const StreamConfig& output_config,
98 float* const* dest) override; 98 float* const* dest) override;
99 99
100 // Methods only accessed from APM submodules or 100 // Methods only accessed from APM submodules or
101 // from AudioProcessing tests in a single-threaded manner. 101 // from AudioProcessing tests in a single-threaded manner.
102 // Hence there is no need for locks in these. 102 // Hence there is no need for locks in these.
103 int proc_sample_rate_hz() const override; 103 int proc_sample_rate_hz() const override;
104 int proc_split_sample_rate_hz() const override; 104 int proc_split_sample_rate_hz() const override;
105 size_t num_input_channels() const override; 105 size_t num_input_channels() const override;
106 size_t num_proc_channels() const override; 106 size_t num_proc_channels() const override;
107 size_t num_output_channels() const override; 107 size_t num_output_channels() const override;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 bool force_initialization) 207 bool force_initialization)
208 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); 208 EXCLUSIVE_LOCKS_REQUIRED(crit_render_);
209 209
210 // Method for updating the state keeping track of the active submodules. 210 // Method for updating the state keeping track of the active submodules.
211 // Returns a bool indicating whether the state has changed. 211 // Returns a bool indicating whether the state has changed.
212 bool UpdateActiveSubmoduleStates() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); 212 bool UpdateActiveSubmoduleStates() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
213 213
214 // Methods requiring APM running in a single-threaded manner. 214 // Methods requiring APM running in a single-threaded manner.
215 // Are called with both the render and capture locks already 215 // Are called with both the render and capture locks already
216 // acquired. 216 // acquired.
217 void InitializeExperimentalAgc()
218 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
219 void InitializeTransient() 217 void InitializeTransient()
220 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); 218 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
221 void InitializeBeamformer() 219 void InitializeBeamformer()
222 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); 220 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
223 void InitializeIntelligibility() 221 void InitializeIntelligibility()
224 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); 222 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
225 void InitializeHighPassFilter()
226 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
227 void InitializeNoiseSuppression()
228 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
229 void InitializeLevelEstimator()
230 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
231 void InitializeVoiceDetection()
232 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
233 void InitializeEchoCanceller()
234 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
235 void InitializeGainController()
236 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
237 void InitializeEchoControlMobile()
238 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
239 int InitializeLocked(const ProcessingConfig& config) 223 int InitializeLocked(const ProcessingConfig& config)
240 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); 224 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
241 void InitializeLevelController() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); 225 void InitializeLevelController() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
242 226
243 // Capture-side exclusive methods possibly running APM in a multi-threaded 227 // Capture-side exclusive methods possibly running APM in a multi-threaded
244 // manner that are called with the render lock already acquired. 228 // manner that are called with the render lock already acquired.
245 int ProcessStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); 229 int ProcessCaptureStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
246 void MaybeUpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); 230 void MaybeUpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
247 231
248 // Render-side exclusive methods possibly running APM in a multi-threaded 232 // Render-side exclusive methods possibly running APM in a multi-threaded
249 // manner that are called with the render lock already acquired. 233 // manner that are called with the render lock already acquired.
250 // TODO(ekm): Remove once all clients updated to new interface. 234 // TODO(ekm): Remove once all clients updated to new interface.
251 int AnalyzeReverseStreamLocked(const float* const* src, 235 int AnalyzeReverseStreamLocked(const float* const* src,
252 const StreamConfig& input_config, 236 const StreamConfig& input_config,
253 const StreamConfig& output_config) 237 const StreamConfig& output_config)
254 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); 238 EXCLUSIVE_LOCKS_REQUIRED(crit_render_);
255 int ProcessReverseStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_render_); 239 int ProcessRenderStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_render_);
256 240
257 // Debug dump methods that are internal and called without locks. 241 // Debug dump methods that are internal and called without locks.
258 // TODO(peah): Make thread safe. 242 // TODO(peah): Make thread safe.
259 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 243 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
260 // TODO(andrew): make this more graceful. Ideally we would split this stuff 244 // TODO(andrew): make this more graceful. Ideally we would split this stuff
261 // out into a separate class with an "enabled" and "disabled" implementation. 245 // out into a separate class with an "enabled" and "disabled" implementation.
262 static int WriteMessageToDebugFile(FileWrapper* debug_file, 246 static int WriteMessageToDebugFile(FileWrapper* debug_file,
263 int64_t* filesize_limit_bytes, 247 int64_t* filesize_limit_bytes,
264 rtc::CriticalSection* crit_debug, 248 rtc::CriticalSection* crit_debug,
265 ApmDebugDumpThreadState* debug_state); 249 ApmDebugDumpThreadState* debug_state);
(...skipping 29 matching lines...) Expand all
295 // As this is only accessed internally of APM, and all internal methods in APM 279 // As this is only accessed internally of APM, and all internal methods in APM
296 // either are holding the render or capture locks, this construct is safe as 280 // either are holding the render or capture locks, this construct is safe as
297 // it is not possible to read the variables while writing them. 281 // it is not possible to read the variables while writing them.
298 struct ApmFormatState { 282 struct ApmFormatState {
299 ApmFormatState() 283 ApmFormatState()
300 : // Format of processing streams at input/output call sites. 284 : // Format of processing streams at input/output call sites.
301 api_format({{{kSampleRate16kHz, 1, false}, 285 api_format({{{kSampleRate16kHz, 1, false},
302 {kSampleRate16kHz, 1, false}, 286 {kSampleRate16kHz, 1, false},
303 {kSampleRate16kHz, 1, false}, 287 {kSampleRate16kHz, 1, false},
304 {kSampleRate16kHz, 1, false}}}), 288 {kSampleRate16kHz, 1, false}}}),
305 rev_proc_format(kSampleRate16kHz, 1) {} 289 render_processing_format(kSampleRate16kHz, 1) {}
306 ProcessingConfig api_format; 290 ProcessingConfig api_format;
307 StreamConfig rev_proc_format; 291 StreamConfig render_processing_format;
308 } formats_; 292 } formats_;
309 293
310 // APM constants. 294 // APM constants.
311 const struct ApmConstants { 295 const struct ApmConstants {
312 ApmConstants(int agc_startup_min_volume, bool use_experimental_agc) 296 ApmConstants(int agc_startup_min_volume, bool use_experimental_agc)
313 : // Format of processing streams at input/output call sites. 297 : // Format of processing streams at input/output call sites.
314 agc_startup_min_volume(agc_startup_min_volume), 298 agc_startup_min_volume(agc_startup_min_volume),
315 use_experimental_agc(use_experimental_agc) {} 299 use_experimental_agc(use_experimental_agc) {}
316 int agc_startup_min_volume; 300 int agc_startup_min_volume;
317 bool use_experimental_agc; 301 bool use_experimental_agc;
318 } constants_; 302 } constants_;
319 303
320 struct ApmCaptureState { 304 struct ApmCaptureState {
321 ApmCaptureState(bool transient_suppressor_enabled, 305 ApmCaptureState(bool transient_suppressor_enabled,
322 const std::vector<Point>& array_geometry, 306 const std::vector<Point>& array_geometry,
323 SphericalPointf target_direction); 307 SphericalPointf target_direction);
324 ~ApmCaptureState(); 308 ~ApmCaptureState();
325 int aec_system_delay_jumps; 309 int aec_system_delay_jumps;
326 int delay_offset_ms; 310 int delay_offset_ms;
327 bool was_stream_delay_set; 311 bool was_stream_delay_set;
328 int last_stream_delay_ms; 312 int last_stream_delay_ms;
329 int last_aec_system_delay_ms; 313 int last_aec_system_delay_ms;
330 int stream_delay_jumps; 314 int stream_delay_jumps;
331 bool output_will_be_muted; 315 bool output_will_be_muted;
332 bool key_pressed; 316 bool key_pressed;
333 bool transient_suppressor_enabled; 317 bool transient_suppressor_enabled;
334 std::vector<Point> array_geometry; 318 std::vector<Point> array_geometry;
335 SphericalPointf target_direction; 319 SphericalPointf target_direction;
336 std::unique_ptr<AudioBuffer> capture_audio; 320 std::unique_ptr<AudioBuffer> capture_audio;
337 // Only the rate and samples fields of fwd_proc_format_ are used because the 321 // Only the rate and samples fields of capture_processing_format_ are used
338 // forward processing number of channels is mutable and is tracked by the 322 // because the capture processing number of channels is mutable and is
339 // capture_audio_. 323 // tracked by the capture_audio_.
340 StreamConfig fwd_proc_format; 324 StreamConfig capture_processing_format;
341 int split_rate; 325 int split_rate;
342 } capture_ GUARDED_BY(crit_capture_); 326 } capture_ GUARDED_BY(crit_capture_);
343 327
344 struct ApmCaptureNonLockedState { 328 struct ApmCaptureNonLockedState {
345 ApmCaptureNonLockedState(bool beamformer_enabled, 329 ApmCaptureNonLockedState(bool beamformer_enabled,
346 bool intelligibility_enabled) 330 bool intelligibility_enabled)
347 : fwd_proc_format(kSampleRate16kHz), 331 : capture_processing_format(kSampleRate16kHz),
348 split_rate(kSampleRate16kHz), 332 split_rate(kSampleRate16kHz),
349 stream_delay_ms(0), 333 stream_delay_ms(0),
350 beamformer_enabled(beamformer_enabled), 334 beamformer_enabled(beamformer_enabled),
351 intelligibility_enabled(intelligibility_enabled) {} 335 intelligibility_enabled(intelligibility_enabled) {}
352 // Only the rate and samples fields of fwd_proc_format_ are used because the 336 // Only the rate and samples fields of capture_processing_format_ are used
353 // forward processing number of channels is mutable and is tracked by the 337 // because the forward processing number of channels is mutable and is
354 // capture_audio_. 338 // tracked by the capture_audio_.
355 StreamConfig fwd_proc_format; 339 StreamConfig capture_processing_format;
356 int split_rate; 340 int split_rate;
357 int stream_delay_ms; 341 int stream_delay_ms;
358 bool beamformer_enabled; 342 bool beamformer_enabled;
359 bool intelligibility_enabled; 343 bool intelligibility_enabled;
360 bool level_controller_enabled = false; 344 bool level_controller_enabled = false;
361 } capture_nonlocked_; 345 } capture_nonlocked_;
362 346
363 struct ApmRenderState { 347 struct ApmRenderState {
364 ApmRenderState(); 348 ApmRenderState();
365 ~ApmRenderState(); 349 ~ApmRenderState();
366 std::unique_ptr<AudioConverter> render_converter; 350 std::unique_ptr<AudioConverter> render_converter;
367 std::unique_ptr<AudioBuffer> render_audio; 351 std::unique_ptr<AudioBuffer> render_audio;
368 } render_ GUARDED_BY(crit_render_); 352 } render_ GUARDED_BY(crit_render_);
369 }; 353 };
370 354
371 } // namespace webrtc 355 } // namespace webrtc
372 356
373 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ 357 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/audio_processing_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698