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

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

Issue 1410833002: Lock scheme #4: Introduced the render sample queue for the aec and aecm (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@aec_error_report_CL
Patch Set: Changes in response to latest reviewer comments 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_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/scoped_ptr.h"
15 #include "webrtc/common_audio/swap_queue.h"
14 #include "webrtc/modules/audio_processing/include/audio_processing.h" 16 #include "webrtc/modules/audio_processing/include/audio_processing.h"
15 #include "webrtc/modules/audio_processing/processing_component.h" 17 #include "webrtc/modules/audio_processing/processing_component.h"
16 18
17 namespace webrtc { 19 namespace webrtc {
18 20
19 class AudioBuffer; 21 class AudioBuffer;
20 class CriticalSectionWrapper; 22 class CriticalSectionWrapper;
21 23
24 // Functor to use when supplying a verifier function for the queue item
25 // verifcation.
26 class AecmRenderQueueItemVerifier {
hlundin-webrtc 2015/11/06 07:05:13 Oh, they have different names. Then I guess you'll
peah-webrtc 2015/11/06 10:44:20 Good point! It works as it is, but I instead creat
27 public:
28 explicit AecmRenderQueueItemVerifier(size_t minimum_capacity)
29 : minimum_capacity_(minimum_capacity) {}
30
31 bool operator()(const std::vector<int16_t>& v) const {
32 return v.capacity() >= minimum_capacity_;
33 }
34
35 private:
36 size_t minimum_capacity_;
37 };
38
22 class EchoControlMobileImpl : public EchoControlMobile, 39 class EchoControlMobileImpl : public EchoControlMobile,
23 public ProcessingComponent { 40 public ProcessingComponent {
24 public: 41 public:
25 EchoControlMobileImpl(const AudioProcessing* apm, 42 EchoControlMobileImpl(const AudioProcessing* apm,
26 CriticalSectionWrapper* crit); 43 CriticalSectionWrapper* crit);
27 virtual ~EchoControlMobileImpl(); 44 virtual ~EchoControlMobileImpl();
28 45
29 int ProcessRenderAudio(const AudioBuffer* audio); 46 int ProcessRenderAudio(const AudioBuffer* audio);
30 int ProcessCaptureAudio(AudioBuffer* audio); 47 int ProcessCaptureAudio(AudioBuffer* audio);
31 48
32 // EchoControlMobile implementation. 49 // EchoControlMobile implementation.
33 bool is_enabled() const override; 50 bool is_enabled() const override;
34 RoutingMode routing_mode() const override; 51 RoutingMode routing_mode() const override;
35 bool is_comfort_noise_enabled() const override; 52 bool is_comfort_noise_enabled() const override;
36 53
37 // ProcessingComponent implementation. 54 // ProcessingComponent implementation.
38 int Initialize() override; 55 int Initialize() override;
39 56
57 // Reads render side data that has been queued on the render call.
58 void ReadQueuedRenderData();
59
40 private: 60 private:
61 static const size_t kAllowedValuesOfSamplesPerFrame1 = 80;
62 static const size_t kAllowedValuesOfSamplesPerFrame2 = 160;
63 // TODO(peah): Decrease this once we properly handle hugely unbalanced
64 // reverse and forward call numbers.
65 static const size_t kMaxNumFramesToBuffer = 100;
66
41 // EchoControlMobile implementation. 67 // EchoControlMobile implementation.
42 int Enable(bool enable) override; 68 int Enable(bool enable) override;
43 int set_routing_mode(RoutingMode mode) override; 69 int set_routing_mode(RoutingMode mode) override;
44 int enable_comfort_noise(bool enable) override; 70 int enable_comfort_noise(bool enable) override;
45 int SetEchoPath(const void* echo_path, size_t size_bytes) override; 71 int SetEchoPath(const void* echo_path, size_t size_bytes) override;
46 int GetEchoPath(void* echo_path, size_t size_bytes) const override; 72 int GetEchoPath(void* echo_path, size_t size_bytes) const override;
47 73
48 // ProcessingComponent implementation. 74 // ProcessingComponent implementation.
49 void* CreateHandle() const override; 75 void* CreateHandle() const override;
50 int InitializeHandle(void* handle) const override; 76 int InitializeHandle(void* handle) const override;
51 int ConfigureHandle(void* handle) const override; 77 int ConfigureHandle(void* handle) const override;
52 void DestroyHandle(void* handle) const override; 78 void DestroyHandle(void* handle) const override;
53 int num_handles_required() const override; 79 int num_handles_required() const override;
54 int GetHandleError(void* handle) const override; 80 int GetHandleError(void* handle) const override;
55 81
82 void AllocateRenderQueue();
83
56 const AudioProcessing* apm_; 84 const AudioProcessing* apm_;
57 CriticalSectionWrapper* crit_; 85 CriticalSectionWrapper* crit_;
58 RoutingMode routing_mode_; 86 RoutingMode routing_mode_;
59 bool comfort_noise_enabled_; 87 bool comfort_noise_enabled_;
60 unsigned char* external_echo_path_; 88 unsigned char* external_echo_path_;
89
90 size_t render_queue_element_max_size_;
91 std::vector<int16_t> render_queue_buffer_;
92 std::vector<int16_t> capture_queue_buffer_;
93 rtc::scoped_ptr<SwapQueue<std::vector<int16_t>, AecmRenderQueueItemVerifier>>
94 render_signal_queue_;
61 }; 95 };
62 } // namespace webrtc 96 } // namespace webrtc
63 97
64 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_ 98 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698