OLD | NEW |
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/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 EchoControlMobileImpl : public EchoControlMobile, | 25 class EchoControlMobileImpl : public EchoControlMobile, |
26 public ProcessingComponent { | 26 public ProcessingComponent { |
27 public: | 27 public: |
28 EchoControlMobileImpl(const AudioProcessing* apm, | 28 EchoControlMobileImpl(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); |
| 32 |
31 virtual ~EchoControlMobileImpl(); | 33 virtual ~EchoControlMobileImpl(); |
32 | 34 |
| 35 // Called holding the render lock. |
33 int ProcessRenderAudio(const AudioBuffer* audio); | 36 int ProcessRenderAudio(const AudioBuffer* audio); |
| 37 // Called holding the capture lock. |
34 int ProcessCaptureAudio(AudioBuffer* audio); | 38 int ProcessCaptureAudio(AudioBuffer* audio); |
35 | 39 |
36 // EchoControlMobile implementation. | 40 // EchoControlMobile implementation. |
| 41 // Aquires the capture lock. |
37 bool is_enabled() const override; | 42 bool is_enabled() const override; |
| 43 // Aquires the capture lock. |
38 RoutingMode routing_mode() const override; | 44 RoutingMode routing_mode() const override; |
| 45 // Aquires the capture lock. |
39 bool is_comfort_noise_enabled() const override; | 46 bool is_comfort_noise_enabled() const override; |
40 | 47 |
41 // ProcessingComponent implementation. | 48 // ProcessingComponent implementation. |
| 49 // Called holding both the render and capture locks. |
42 int Initialize() override; | 50 int Initialize() override; |
43 | 51 |
44 // Reads render side data that has been queued on the render call. | 52 // Reads render side data that has been queued on the render call. |
| 53 // Called holding the capture lock. |
45 void ReadQueuedRenderData(); | 54 void ReadQueuedRenderData(); |
46 | 55 |
47 private: | 56 private: |
48 // EchoControlMobile implementation. | 57 // EchoControlMobile implementation. |
| 58 // Aquires both the render and capture locks. |
49 int Enable(bool enable) override; | 59 int Enable(bool enable) override; |
| 60 // Aquires the capture lock. |
50 int set_routing_mode(RoutingMode mode) override; | 61 int set_routing_mode(RoutingMode mode) override; |
| 62 // Aquires the capture lock. |
51 int enable_comfort_noise(bool enable) override; | 63 int enable_comfort_noise(bool enable) override; |
| 64 // Aquires both the capture and render locks. |
52 int SetEchoPath(const void* echo_path, size_t size_bytes) override; | 65 int SetEchoPath(const void* echo_path, size_t size_bytes) override; |
| 66 // Aquires the capture lock. |
53 int GetEchoPath(void* echo_path, size_t size_bytes) const override; | 67 int GetEchoPath(void* echo_path, size_t size_bytes) const override; |
54 | 68 |
55 // ProcessingComponent implementation. | 69 // ProcessingComponent implementation. |
| 70 // Called holding both the render and capture locks. |
56 void* CreateHandle() const override; | 71 void* CreateHandle() const override; |
| 72 // Called holding both the render and capture locks. |
57 int InitializeHandle(void* handle) const override; | 73 int InitializeHandle(void* handle) const override; |
| 74 // Called holding both the render and capture locks. |
58 int ConfigureHandle(void* handle) const override; | 75 int ConfigureHandle(void* handle) const override; |
| 76 // Called holding both the render and capture locks. |
59 void DestroyHandle(void* handle) const override; | 77 void DestroyHandle(void* handle) const override; |
| 78 // Called holding both the render and capture locks. |
60 int num_handles_required() const override; | 79 int num_handles_required() const override; |
| 80 // Called holding both the render and capture locks. |
61 int GetHandleError(void* handle) const override; | 81 int GetHandleError(void* handle) const override; |
62 | 82 |
| 83 // Called holding both the render and capture locks. |
63 void AllocateRenderQueue(); | 84 void AllocateRenderQueue(); |
64 | 85 |
65 const AudioProcessing* apm_; | 86 const AudioProcessing* apm_; |
66 CriticalSectionWrapper* crit_; | 87 rtc::CriticalSection* const crit_render_; |
| 88 rtc::CriticalSection* const crit_capture_; |
67 const rtc::ThreadChecker* const render_thread_checker_; | 89 const rtc::ThreadChecker* const render_thread_checker_; |
68 RoutingMode routing_mode_; | 90 RoutingMode routing_mode_; |
69 bool comfort_noise_enabled_; | 91 bool comfort_noise_enabled_; |
70 unsigned char* external_echo_path_; | 92 unsigned char* external_echo_path_; |
71 | 93 |
72 size_t render_queue_element_max_size_; | 94 size_t render_queue_element_max_size_; |
73 std::vector<int16_t> render_queue_buffer_; | 95 std::vector<int16_t> render_queue_buffer_; |
74 std::vector<int16_t> capture_queue_buffer_; | 96 std::vector<int16_t> capture_queue_buffer_; |
| 97 |
| 98 // Lock protection not needed. |
75 rtc::scoped_ptr< | 99 rtc::scoped_ptr< |
76 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>> | 100 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>> |
77 render_signal_queue_; | 101 render_signal_queue_; |
78 }; | 102 }; |
79 } // namespace webrtc | 103 } // namespace webrtc |
80 | 104 |
81 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_ | 105 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_ |
OLD | NEW |