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

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

Issue 1416583003: Lock scheme #5: Applied the render queueing to the agc (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@introduce_queue_CL
Patch Set: Merge from other Cls in the list 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_GAIN_CONTROL_IMPL_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_ 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_
13 13
14 #include <vector> 14 #include <vector>
15 15
16 #include "webrtc/base/scoped_ptr.h"
17 #include "webrtc/common_audio/swap_queue.h"
16 #include "webrtc/modules/audio_processing/include/audio_processing.h" 18 #include "webrtc/modules/audio_processing/include/audio_processing.h"
17 #include "webrtc/modules/audio_processing/processing_component.h" 19 #include "webrtc/modules/audio_processing/processing_component.h"
18 20
19 namespace webrtc { 21 namespace webrtc {
20 22
23 namespace {
hlundin-webrtc 2015/11/05 13:01:09 "Do not use unnamed namespaces in .h files." https
peah-webrtc 2015/11/06 07:10:58 Done.
24 // Functor to use when supplying a verifier function for the queue item
25 // verifcation.
26 class AgcRenderQueueItemVerifier {
27 public:
28 explicit AgcRenderQueueItemVerifier(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
39 } // namespace anonymous
40
21 class AudioBuffer; 41 class AudioBuffer;
22 class CriticalSectionWrapper; 42 class CriticalSectionWrapper;
23 43
24 class GainControlImpl : public GainControl, 44 class GainControlImpl : public GainControl,
25 public ProcessingComponent { 45 public ProcessingComponent {
26 public: 46 public:
27 GainControlImpl(const AudioProcessing* apm, 47 GainControlImpl(const AudioProcessing* apm,
28 CriticalSectionWrapper* crit); 48 CriticalSectionWrapper* crit);
29 virtual ~GainControlImpl(); 49 virtual ~GainControlImpl();
30 50
31 int ProcessRenderAudio(AudioBuffer* audio); 51 int ProcessRenderAudio(AudioBuffer* audio);
32 int AnalyzeCaptureAudio(AudioBuffer* audio); 52 int AnalyzeCaptureAudio(AudioBuffer* audio);
33 int ProcessCaptureAudio(AudioBuffer* audio); 53 int ProcessCaptureAudio(AudioBuffer* audio);
34 54
35 // ProcessingComponent implementation. 55 // ProcessingComponent implementation.
36 int Initialize() override; 56 int Initialize() override;
37 57
38 // GainControl implementation. 58 // GainControl implementation.
39 bool is_enabled() const override; 59 bool is_enabled() const override;
40 int stream_analog_level() override; 60 int stream_analog_level() override;
41 bool is_limiter_enabled() const override; 61 bool is_limiter_enabled() const override;
42 Mode mode() const override; 62 Mode mode() const override;
43 63
64 // Reads render side data that has been queued on the render call.
65 void ReadQueuedRenderData();
66
44 private: 67 private:
68 static const size_t kAllowedValuesOfSamplesPerFrame1 = 80;
69 static const size_t kAllowedValuesOfSamplesPerFrame2 = 160;
70 // TODO(peah): Decrease this once we properly handle hugely unbalanced
71 // reverse and forward call numbers.
72 static const size_t kMaxNumFramesToBuffer = 100;
73
45 // GainControl implementation. 74 // GainControl implementation.
46 int Enable(bool enable) override; 75 int Enable(bool enable) override;
47 int set_stream_analog_level(int level) override; 76 int set_stream_analog_level(int level) override;
48 int set_mode(Mode mode) override; 77 int set_mode(Mode mode) override;
49 int set_target_level_dbfs(int level) override; 78 int set_target_level_dbfs(int level) override;
50 int target_level_dbfs() const override; 79 int target_level_dbfs() const override;
51 int set_compression_gain_db(int gain) override; 80 int set_compression_gain_db(int gain) override;
52 int compression_gain_db() const override; 81 int compression_gain_db() const override;
53 int enable_limiter(bool enable) override; 82 int enable_limiter(bool enable) override;
54 int set_analog_level_limits(int minimum, int maximum) override; 83 int set_analog_level_limits(int minimum, int maximum) override;
55 int analog_level_minimum() const override; 84 int analog_level_minimum() const override;
56 int analog_level_maximum() const override; 85 int analog_level_maximum() const override;
57 bool stream_is_saturated() const override; 86 bool stream_is_saturated() const override;
58 87
59 // ProcessingComponent implementation. 88 // ProcessingComponent implementation.
60 void* CreateHandle() const override; 89 void* CreateHandle() const override;
61 int InitializeHandle(void* handle) const override; 90 int InitializeHandle(void* handle) const override;
62 int ConfigureHandle(void* handle) const override; 91 int ConfigureHandle(void* handle) const override;
63 void DestroyHandle(void* handle) const override; 92 void DestroyHandle(void* handle) const override;
64 int num_handles_required() const override; 93 int num_handles_required() const override;
65 int GetHandleError(void* handle) const override; 94 int GetHandleError(void* handle) const override;
66 95
96 void AllocateRenderQueue();
97
67 const AudioProcessing* apm_; 98 const AudioProcessing* apm_;
68 CriticalSectionWrapper* crit_; 99 CriticalSectionWrapper* crit_;
69 Mode mode_; 100 Mode mode_;
70 int minimum_capture_level_; 101 int minimum_capture_level_;
71 int maximum_capture_level_; 102 int maximum_capture_level_;
72 bool limiter_enabled_; 103 bool limiter_enabled_;
73 int target_level_dbfs_; 104 int target_level_dbfs_;
74 int compression_gain_db_; 105 int compression_gain_db_;
75 std::vector<int> capture_levels_; 106 std::vector<int> capture_levels_;
76 int analog_capture_level_; 107 int analog_capture_level_;
77 bool was_analog_level_set_; 108 bool was_analog_level_set_;
78 bool stream_is_saturated_; 109 bool stream_is_saturated_;
110
111 size_t render_queue_element_max_size_;
112 std::vector<int16_t> render_queue_buffer_;
113 std::vector<int16_t> capture_queue_buffer_;
114 rtc::scoped_ptr<SwapQueue<std::vector<int16_t>, AgcRenderQueueItemVerifier> >
115 render_signal_queue_;
79 }; 116 };
80 } // namespace webrtc 117 } // namespace webrtc
81 118
82 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_ 119 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698