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

Side by Side Diff: webrtc/modules/audio_processing/echo_control_mobile_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_CONTROL_MOBILE_IMPL_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_ 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_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 EchoControlMobileImpl : public EchoControlMobile, 24 class EchoControlMobileImpl : public EchoControlMobile,
25 public ProcessingComponent { 25 public ProcessingComponent {
26 public: 26 public:
27 EchoControlMobileImpl(const AudioProcessing* apm, 27 EchoControlMobileImpl(const AudioProcessing* apm,
28 CriticalSectionWrapper* crit); 28 rtc::CriticalSection* crit_render,
29 rtc::CriticalSection* crit_capture);
30
29 virtual ~EchoControlMobileImpl(); 31 virtual ~EchoControlMobileImpl();
30 32
31 int ProcessRenderAudio(const AudioBuffer* audio); 33 int ProcessRenderAudio(const AudioBuffer* audio);
32 int ProcessCaptureAudio(AudioBuffer* audio); 34 int ProcessCaptureAudio(AudioBuffer* audio);
33 35
34 // EchoControlMobile implementation. 36 // EchoControlMobile implementation.
35 bool is_enabled() const override; 37 bool is_enabled() const override;
36 RoutingMode routing_mode() const override; 38 RoutingMode routing_mode() const override;
37 bool is_comfort_noise_enabled() const override; 39 bool is_comfort_noise_enabled() const override;
38 40
39 // ProcessingComponent implementation. 41 // ProcessingComponent implementation.
40 int Initialize() override; 42 int Initialize() override;
41 43
42 // Reads render side data that has been queued on the render call. 44 // Reads render side data that has been queued on the render call.
43 void ReadQueuedRenderData(); 45 void ReadQueuedRenderData();
44 46
45 private: 47 private:
46 // EchoControlMobile implementation. 48 // EchoControlMobile implementation.
47 int Enable(bool enable) override; 49 int Enable(bool enable) override;
48 int set_routing_mode(RoutingMode mode) override; 50 int set_routing_mode(RoutingMode mode) override;
49 int enable_comfort_noise(bool enable) override; 51 int enable_comfort_noise(bool enable) override;
50 int SetEchoPath(const void* echo_path, size_t size_bytes) override; 52 int SetEchoPath(const void* echo_path, size_t size_bytes) override;
51 int GetEchoPath(void* echo_path, size_t size_bytes) const override; 53 int GetEchoPath(void* echo_path, size_t size_bytes) const override;
52 54
53 // ProcessingComponent implementation. 55 // ProcessingComponent implementation.
56 // Called holding both the render and capture locks.
54 void* CreateHandle() const override; 57 void* CreateHandle() const override;
55 int InitializeHandle(void* handle) const override; 58 int InitializeHandle(void* handle) const override;
56 int ConfigureHandle(void* handle) const override; 59 int ConfigureHandle(void* handle) const override;
57 void DestroyHandle(void* handle) const override; 60 void DestroyHandle(void* handle) const override;
58 int num_handles_required() const override; 61 int num_handles_required() const override;
59 int GetHandleError(void* handle) const override; 62 int GetHandleError(void* handle) const override;
60 63
61 void AllocateRenderQueue(); 64 void AllocateRenderQueue();
62 65
66 // Not guarded as its public API is thread safe.
63 const AudioProcessing* apm_; 67 const AudioProcessing* apm_;
64 CriticalSectionWrapper* crit_;
65 RoutingMode routing_mode_;
66 bool comfort_noise_enabled_;
67 unsigned char* external_echo_path_;
68 68
69 size_t render_queue_element_max_size_; 69 rtc::CriticalSection* const crit_render_ ACQUIRED_BEFORE(crit_capture_);
70 std::vector<int16_t> render_queue_buffer_; 70 rtc::CriticalSection* const crit_capture_;
71 std::vector<int16_t> capture_queue_buffer_; 71
72 RoutingMode routing_mode_ GUARDED_BY(crit_capture_);
73 bool comfort_noise_enabled_ GUARDED_BY(crit_capture_);
74 unsigned char* external_echo_path_ GUARDED_BY(crit_render_)
75 GUARDED_BY(crit_capture_);
76
77 size_t render_queue_element_max_size_ GUARDED_BY(crit_render_)
78 GUARDED_BY(crit_capture_);
79
80 std::vector<int16_t> render_queue_buffer_ GUARDED_BY(crit_render_);
81 std::vector<int16_t> capture_queue_buffer_ GUARDED_BY(crit_capture_);
82
83 // Lock protection not needed.
72 rtc::scoped_ptr< 84 rtc::scoped_ptr<
73 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>> 85 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>>
74 render_signal_queue_; 86 render_signal_queue_;
75 }; 87 };
76 } // namespace webrtc 88 } // namespace webrtc
77 89
78 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_ 90 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/echo_cancellation_impl.cc ('k') | webrtc/modules/audio_processing/echo_control_mobile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698