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

Side by Side Diff: webrtc/modules/audio_processing/echo_cancellation_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: Fixed a bad merge error for the beamformer settings and updated with the latest merge from master 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 /* 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_ECHO_CANCELLATION_IMPL_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_
13 13
14 #include "webrtc/base/criticalsection.h"
14 #include "webrtc/base/scoped_ptr.h" 15 #include "webrtc/base/scoped_ptr.h"
15 #include "webrtc/base/thread_checker.h" 16 #include "webrtc/base/thread_checker.h"
16 #include "webrtc/common_audio/swap_queue.h" 17 #include "webrtc/common_audio/swap_queue.h"
17 #include "webrtc/modules/audio_processing/include/audio_processing.h" 18 #include "webrtc/modules/audio_processing/include/audio_processing.h"
18 #include "webrtc/modules/audio_processing/processing_component.h" 19 #include "webrtc/modules/audio_processing/processing_component.h"
19 20
20 namespace webrtc { 21 namespace webrtc {
21 22
22 class AudioBuffer; 23 class AudioBuffer;
23 class CriticalSectionWrapper;
24 24
25 class EchoCancellationImpl : public EchoCancellation, 25 class EchoCancellationImpl : public EchoCancellation,
26 public ProcessingComponent { 26 public ProcessingComponent {
27 public: 27 public:
28 EchoCancellationImpl(const AudioProcessing* apm, 28 EchoCancellationImpl(const AudioProcessing* apm,
29 CriticalSectionWrapper* crit, 29 rtc::CriticalSection* crit_render,
30 rtc::CriticalSection* crit_capture,
30 const rtc::ThreadChecker* render_thread_checker); 31 const rtc::ThreadChecker* render_thread_checker);
31 virtual ~EchoCancellationImpl(); 32 virtual ~EchoCancellationImpl();
32 33
34 // Called holding the render lock.
the sun 2015/11/23 21:36:05 These comments just add noise. Remove. Document yo
peah-webrtc 2015/11/24 21:42:24 After today's discussion, I think this work will m
33 int ProcessRenderAudio(const AudioBuffer* audio); 35 int ProcessRenderAudio(const AudioBuffer* audio);
36 // Called holding the capture lock.
34 int ProcessCaptureAudio(AudioBuffer* audio); 37 int ProcessCaptureAudio(AudioBuffer* audio);
35 38
36 // EchoCancellation implementation. 39 // EchoCancellation implementation.
40 // Aquires both the render and capture locks.
37 bool is_enabled() const override; 41 bool is_enabled() const override;
42 // Aquires the capture loc.k
kwiberg-webrtc 2015/11/23 22:15:11 Swap the last two characters.
peah-webrtc 2015/11/24 21:42:24 Done.
38 int stream_drift_samples() const override; 43 int stream_drift_samples() const override;
44 // Aquires the capture lock.
39 SuppressionLevel suppression_level() const override; 45 SuppressionLevel suppression_level() const override;
46 // Aquires the capture lock.
40 bool is_drift_compensation_enabled() const override; 47 bool is_drift_compensation_enabled() const override;
41 48
42 // ProcessingComponent implementation. 49 // ProcessingComponent implementation.
50 // Called holding both the capture and render locks.
43 int Initialize() override; 51 int Initialize() override;
52 // Conditionally acquires the capture lock.
44 void SetExtraOptions(const Config& config) override; 53 void SetExtraOptions(const Config& config) override;
45 54 // Only called from APM. No lock required.
46 bool is_delay_agnostic_enabled() const; 55 bool is_delay_agnostic_enabled() const;
56 // Only called from APM. No lock required.
47 bool is_extended_filter_enabled() const; 57 bool is_extended_filter_enabled() const;
48 58
49 // Reads render side data that has been queued on the render call. 59 // Reads render side data that has been queued on the render call.
60 // Called holding the capture lock.
50 void ReadQueuedRenderData(); 61 void ReadQueuedRenderData();
51 62
52 private: 63 private:
53 // EchoCancellation implementation. 64 // EchoCancellation implementation.
65 // Aquires both the render and capture locks.
54 int Enable(bool enable) override; 66 int Enable(bool enable) override;
67 // Aquires the capture lock.
55 int enable_drift_compensation(bool enable) override; 68 int enable_drift_compensation(bool enable) override;
69 // Aquires the capture lock.
56 void set_stream_drift_samples(int drift) override; 70 void set_stream_drift_samples(int drift) override;
71 // Aquires the capture lock.
57 int set_suppression_level(SuppressionLevel level) override; 72 int set_suppression_level(SuppressionLevel level) override;
73 // Aquires the capture lock.
58 int enable_metrics(bool enable) override; 74 int enable_metrics(bool enable) override;
75 // Aquires the capture lock.
59 bool are_metrics_enabled() const override; 76 bool are_metrics_enabled() const override;
77 // Conditionally acquires the capture lock.
60 bool stream_has_echo() const override; 78 bool stream_has_echo() const override;
79 // Aquires the capture lock.
61 int GetMetrics(Metrics* metrics) override; 80 int GetMetrics(Metrics* metrics) override;
81 // Aquires the capture lock.
62 int enable_delay_logging(bool enable) override; 82 int enable_delay_logging(bool enable) override;
83 // Only called from APM. No lock required.
63 bool is_delay_logging_enabled() const override; 84 bool is_delay_logging_enabled() const override;
85 // Aquires the capture lock.
64 int GetDelayMetrics(int* median, int* std) override; 86 int GetDelayMetrics(int* median, int* std) override;
87 // Aquires the capture lock.
65 int GetDelayMetrics(int* median, 88 int GetDelayMetrics(int* median,
66 int* std, 89 int* std,
67 float* fraction_poor_delays) override; 90 float* fraction_poor_delays) override;
91 // Only called from APM. No lock required.
68 struct AecCore* aec_core() const override; 92 struct AecCore* aec_core() const override;
69 93
70 // ProcessingComponent implementation. 94 // ProcessingComponent implementation.
95 // Called holding both the render and capture locks.
71 void* CreateHandle() const override; 96 void* CreateHandle() const override;
97 // Called holding both the render and capture locks.
72 int InitializeHandle(void* handle) const override; 98 int InitializeHandle(void* handle) const override;
99 // Called holding both the render and capture locks.
73 int ConfigureHandle(void* handle) const override; 100 int ConfigureHandle(void* handle) const override;
101 // Called holding both the render and capture locks.
74 void DestroyHandle(void* handle) const override; 102 void DestroyHandle(void* handle) const override;
103 // Called holding both the render and capture locks.
75 int num_handles_required() const override; 104 int num_handles_required() const override;
105 // Called holding both the render and capture locks.
76 int GetHandleError(void* handle) const override; 106 int GetHandleError(void* handle) const override;
77 107
108 // Called holding both the render and capture locks.
78 void AllocateRenderQueue(); 109 void AllocateRenderQueue();
79 110
80 const AudioProcessing* apm_; 111 const AudioProcessing* apm_;
81 CriticalSectionWrapper* crit_; 112 rtc::CriticalSection* const crit_render_;
113 rtc::CriticalSection* const crit_capture_;
82 const rtc::ThreadChecker* const render_thread_checker_; 114 const rtc::ThreadChecker* const render_thread_checker_;
83 115
84 bool drift_compensation_enabled_; 116 bool drift_compensation_enabled_;
85 bool metrics_enabled_; 117 bool metrics_enabled_;
86 SuppressionLevel suppression_level_; 118 SuppressionLevel suppression_level_;
87 int stream_drift_samples_; 119 int stream_drift_samples_;
88 bool was_stream_drift_set_; 120 bool was_stream_drift_set_;
89 bool stream_has_echo_; 121 bool stream_has_echo_;
90 bool delay_logging_enabled_; 122 bool delay_logging_enabled_;
91 bool extended_filter_enabled_; 123 bool extended_filter_enabled_;
92 bool delay_agnostic_enabled_; 124 bool delay_agnostic_enabled_;
93 125
94 size_t render_queue_element_max_size_; 126 size_t render_queue_element_max_size_;
95 std::vector<float> render_queue_buffer_; 127 std::vector<float> render_queue_buffer_;
96 std::vector<float> capture_queue_buffer_; 128 std::vector<float> capture_queue_buffer_;
129
130 // Lock protection not needed.
97 rtc::scoped_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>> 131 rtc::scoped_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>>
98 render_signal_queue_; 132 render_signal_queue_;
99 }; 133 };
100 134
101 } // namespace webrtc 135 } // namespace webrtc
102 136
103 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ 137 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_
kwiberg-webrtc 2015/11/23 22:15:11 It's a serious problem that you aren't able to use
peah-webrtc 2015/11/24 21:42:24 Agree! I'm not sure how far the lock annotation re
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698