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

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

Issue 2444283002: Moved the AGC render sample queue into the audio processing module (Closed)
Patch Set: Rebase Created 4 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
(...skipping 13 matching lines...) Expand all
24 namespace webrtc { 24 namespace webrtc {
25 25
26 class AudioBuffer; 26 class AudioBuffer;
27 27
28 class GainControlImpl : public GainControl { 28 class GainControlImpl : public GainControl {
29 public: 29 public:
30 GainControlImpl(rtc::CriticalSection* crit_render, 30 GainControlImpl(rtc::CriticalSection* crit_render,
31 rtc::CriticalSection* crit_capture); 31 rtc::CriticalSection* crit_capture);
32 ~GainControlImpl() override; 32 ~GainControlImpl() override;
33 33
34 int ProcessRenderAudio(AudioBuffer* audio); 34 void ProcessRenderAudio(rtc::ArrayView<const int16_t> packed_render_audio);
35 int AnalyzeCaptureAudio(AudioBuffer* audio); 35 int AnalyzeCaptureAudio(AudioBuffer* audio);
36 int ProcessCaptureAudio(AudioBuffer* audio, bool stream_has_echo); 36 int ProcessCaptureAudio(AudioBuffer* audio, bool stream_has_echo);
37 37
38 void Initialize(size_t num_proc_channels, int sample_rate_hz); 38 void Initialize(size_t num_proc_channels, int sample_rate_hz);
39 39
40 static void PackRenderAudioBuffer(AudioBuffer* audio,
41 std::vector<int16_t>* packed_buffer);
42
40 // GainControl implementation. 43 // GainControl implementation.
41 bool is_enabled() const override; 44 bool is_enabled() const override;
42 int stream_analog_level() override; 45 int stream_analog_level() override;
43 bool is_limiter_enabled() const override; 46 bool is_limiter_enabled() const override;
44 Mode mode() const override; 47 Mode mode() const override;
45 48
46 // Reads render side data that has been queued on the render call.
47 void ReadQueuedRenderData();
48
49 int compression_gain_db() const override; 49 int compression_gain_db() const override;
50 50
51 private: 51 private:
52 class GainController; 52 class GainController;
53 53
54 // GainControl implementation. 54 // GainControl implementation.
55 int Enable(bool enable) override; 55 int Enable(bool enable) override;
56 int set_stream_analog_level(int level) override; 56 int set_stream_analog_level(int level) override;
57 int set_mode(Mode mode) override; 57 int set_mode(Mode mode) override;
58 int set_target_level_dbfs(int level) override; 58 int set_target_level_dbfs(int level) override;
59 int target_level_dbfs() const override; 59 int target_level_dbfs() const override;
60 int set_compression_gain_db(int gain) override; 60 int set_compression_gain_db(int gain) override;
61 int enable_limiter(bool enable) override; 61 int enable_limiter(bool enable) override;
62 int set_analog_level_limits(int minimum, int maximum) override; 62 int set_analog_level_limits(int minimum, int maximum) override;
63 int analog_level_minimum() const override; 63 int analog_level_minimum() const override;
64 int analog_level_maximum() const override; 64 int analog_level_maximum() const override;
65 bool stream_is_saturated() const override; 65 bool stream_is_saturated() const override;
66 66
67 void AllocateRenderQueue();
68 int Configure(); 67 int Configure();
69 68
70 rtc::CriticalSection* const crit_render_ ACQUIRED_BEFORE(crit_capture_); 69 rtc::CriticalSection* const crit_render_ ACQUIRED_BEFORE(crit_capture_);
71 rtc::CriticalSection* const crit_capture_; 70 rtc::CriticalSection* const crit_capture_;
72 71
73 bool enabled_ = false; 72 bool enabled_ = false;
74 73
75 Mode mode_ GUARDED_BY(crit_capture_); 74 Mode mode_ GUARDED_BY(crit_capture_);
76 int minimum_capture_level_ GUARDED_BY(crit_capture_); 75 int minimum_capture_level_ GUARDED_BY(crit_capture_);
77 int maximum_capture_level_ GUARDED_BY(crit_capture_); 76 int maximum_capture_level_ GUARDED_BY(crit_capture_);
78 bool limiter_enabled_ GUARDED_BY(crit_capture_); 77 bool limiter_enabled_ GUARDED_BY(crit_capture_);
79 int target_level_dbfs_ GUARDED_BY(crit_capture_); 78 int target_level_dbfs_ GUARDED_BY(crit_capture_);
80 int compression_gain_db_ GUARDED_BY(crit_capture_); 79 int compression_gain_db_ GUARDED_BY(crit_capture_);
81 int analog_capture_level_ GUARDED_BY(crit_capture_); 80 int analog_capture_level_ GUARDED_BY(crit_capture_);
82 bool was_analog_level_set_ GUARDED_BY(crit_capture_); 81 bool was_analog_level_set_ GUARDED_BY(crit_capture_);
83 bool stream_is_saturated_ GUARDED_BY(crit_capture_); 82 bool stream_is_saturated_ GUARDED_BY(crit_capture_);
84 83
85 size_t render_queue_element_max_size_ GUARDED_BY(crit_render_)
86 GUARDED_BY(crit_capture_);
87 std::vector<int16_t> render_queue_buffer_ GUARDED_BY(crit_render_);
88 std::vector<int16_t> capture_queue_buffer_ GUARDED_BY(crit_capture_);
89
90 // Lock protection not needed.
91 std::unique_ptr<
92 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>>
93 render_signal_queue_;
94
95 std::vector<std::unique_ptr<GainController>> gain_controllers_; 84 std::vector<std::unique_ptr<GainController>> gain_controllers_;
96 85
97 rtc::Optional<size_t> num_proc_channels_ GUARDED_BY(crit_capture_); 86 rtc::Optional<size_t> num_proc_channels_ GUARDED_BY(crit_capture_);
98 rtc::Optional<int> sample_rate_hz_ GUARDED_BY(crit_capture_); 87 rtc::Optional<int> sample_rate_hz_ GUARDED_BY(crit_capture_);
99 88
100 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(GainControlImpl); 89 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(GainControlImpl);
101 }; 90 };
102 } // namespace webrtc 91 } // namespace webrtc
103 92
104 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_ 93 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/audio_processing_impl.cc ('k') | webrtc/modules/audio_processing/gain_control_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698