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

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: Created a threadsafe wrapper for the random generator in the locktest. Fixed an unprotected variabl… Created 5 years 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/common_audio/swap_queue.h" 16 #include "webrtc/common_audio/swap_queue.h"
16 #include "webrtc/modules/audio_processing/include/audio_processing.h" 17 #include "webrtc/modules/audio_processing/include/audio_processing.h"
17 #include "webrtc/modules/audio_processing/processing_component.h" 18 #include "webrtc/modules/audio_processing/processing_component.h"
18 19
19 namespace webrtc { 20 namespace webrtc {
20 21
21 class AudioBuffer; 22 class AudioBuffer;
22 class CriticalSectionWrapper;
23 23
24 class EchoCancellationImpl : public EchoCancellation, 24 class EchoCancellationImpl : public EchoCancellation,
25 public ProcessingComponent { 25 public ProcessingComponent {
26 public: 26 public:
27 EchoCancellationImpl(const AudioProcessing* apm, 27 EchoCancellationImpl(const AudioProcessing* apm,
28 CriticalSectionWrapper* crit); 28 rtc::CriticalSection* crit_render,
29 rtc::CriticalSection* crit_capture);
29 virtual ~EchoCancellationImpl(); 30 virtual ~EchoCancellationImpl();
30 31
31 int ProcessRenderAudio(const AudioBuffer* audio); 32 int ProcessRenderAudio(const AudioBuffer* audio);
32 int ProcessCaptureAudio(AudioBuffer* audio); 33 int ProcessCaptureAudio(AudioBuffer* audio);
33 34
34 // EchoCancellation implementation. 35 // EchoCancellation implementation.
35 bool is_enabled() const override; 36 bool is_enabled() const override;
36 int stream_drift_samples() const override; 37 int stream_drift_samples() const override;
37 SuppressionLevel suppression_level() const override; 38 SuppressionLevel suppression_level() const override;
38 bool is_drift_compensation_enabled() const override; 39 bool is_drift_compensation_enabled() const override;
39 40
40 // ProcessingComponent implementation. 41 // ProcessingComponent implementation.
41 int Initialize() override; 42 int Initialize() override;
42 void SetExtraOptions(const Config& config) override; 43 void SetExtraOptions(const Config& config) override;
43
44 bool is_delay_agnostic_enabled() const; 44 bool is_delay_agnostic_enabled() const;
45 bool is_extended_filter_enabled() const; 45 bool is_extended_filter_enabled() const;
46 46
47 // Reads render side data that has been queued on the render call. 47 // Reads render side data that has been queued on the render call.
48 // Called holding the capture lock.
48 void ReadQueuedRenderData(); 49 void ReadQueuedRenderData();
49 50
50 private: 51 private:
51 // EchoCancellation implementation. 52 // EchoCancellation implementation.
52 int Enable(bool enable) override; 53 int Enable(bool enable) override;
53 int enable_drift_compensation(bool enable) override; 54 int enable_drift_compensation(bool enable) override;
54 void set_stream_drift_samples(int drift) override; 55 void set_stream_drift_samples(int drift) override;
55 int set_suppression_level(SuppressionLevel level) override; 56 int set_suppression_level(SuppressionLevel level) override;
56 int enable_metrics(bool enable) override; 57 int enable_metrics(bool enable) override;
57 bool are_metrics_enabled() const override; 58 bool are_metrics_enabled() const override;
58 bool stream_has_echo() const override; 59 bool stream_has_echo() const override;
59 int GetMetrics(Metrics* metrics) override; 60 int GetMetrics(Metrics* metrics) override;
60 int enable_delay_logging(bool enable) override; 61 int enable_delay_logging(bool enable) override;
61 bool is_delay_logging_enabled() const override; 62 bool is_delay_logging_enabled() const override;
62 int GetDelayMetrics(int* median, int* std) override; 63 int GetDelayMetrics(int* median, int* std) override;
63 int GetDelayMetrics(int* median, 64 int GetDelayMetrics(int* median,
64 int* std, 65 int* std,
65 float* fraction_poor_delays) override; 66 float* fraction_poor_delays) override;
67
66 struct AecCore* aec_core() const override; 68 struct AecCore* aec_core() const override;
67 69
68 // ProcessingComponent implementation. 70 // ProcessingComponent implementation.
69 void* CreateHandle() const override; 71 void* CreateHandle() const override;
70 int InitializeHandle(void* handle) const override; 72 int InitializeHandle(void* handle) const override;
71 int ConfigureHandle(void* handle) const override; 73 int ConfigureHandle(void* handle) const override;
72 void DestroyHandle(void* handle) const override; 74 void DestroyHandle(void* handle) const override;
73 int num_handles_required() const override; 75 int num_handles_required() const override;
74 int GetHandleError(void* handle) const override; 76 int GetHandleError(void* handle) const override;
75 77
76 void AllocateRenderQueue(); 78 void AllocateRenderQueue();
77 79
80 // Not guarded as its public API is thread safe.
78 const AudioProcessing* apm_; 81 const AudioProcessing* apm_;
79 CriticalSectionWrapper* crit_;
80 82
81 bool drift_compensation_enabled_; 83 rtc::CriticalSection* const crit_render_ ACQUIRED_BEFORE(crit_capture_);
82 bool metrics_enabled_; 84 rtc::CriticalSection* const crit_capture_;
83 SuppressionLevel suppression_level_;
84 int stream_drift_samples_;
85 bool was_stream_drift_set_;
86 bool stream_has_echo_;
87 bool delay_logging_enabled_;
88 bool extended_filter_enabled_;
89 bool delay_agnostic_enabled_;
90 85
91 size_t render_queue_element_max_size_; 86 bool drift_compensation_enabled_ GUARDED_BY(crit_capture_);
92 std::vector<float> render_queue_buffer_; 87 bool metrics_enabled_ GUARDED_BY(crit_capture_);
93 std::vector<float> capture_queue_buffer_; 88 SuppressionLevel suppression_level_ GUARDED_BY(crit_capture_);
89 int stream_drift_samples_ GUARDED_BY(crit_capture_);
90 bool was_stream_drift_set_ GUARDED_BY(crit_capture_);
91 bool stream_has_echo_ GUARDED_BY(crit_capture_);
92 bool delay_logging_enabled_ GUARDED_BY(crit_capture_);
93 bool extended_filter_enabled_ GUARDED_BY(crit_capture_);
94 bool delay_agnostic_enabled_ GUARDED_BY(crit_capture_);
95
96 size_t render_queue_element_max_size_ GUARDED_BY(crit_render_)
97 GUARDED_BY(crit_capture_);
98 std::vector<float> render_queue_buffer_ GUARDED_BY(crit_render_);
99 std::vector<float> capture_queue_buffer_ GUARDED_BY(crit_capture_);
100
101 // Lock protection not needed.
94 rtc::scoped_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>> 102 rtc::scoped_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>>
95 render_signal_queue_; 103 render_signal_queue_;
96 }; 104 };
97 105
98 } // namespace webrtc 106 } // namespace webrtc
99 107
100 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ 108 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698