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

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

Issue 1422013002: Preparational work for an upcoming addition of a threadchecking scheme for APM (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@bundling_of_state_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_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" 16 #include "webrtc/base/scoped_ptr.h"
17 #include "webrtc/base/thread_checker.h"
17 #include "webrtc/common_audio/swap_queue.h" 18 #include "webrtc/common_audio/swap_queue.h"
18 #include "webrtc/modules/audio_processing/include/audio_processing.h" 19 #include "webrtc/modules/audio_processing/include/audio_processing.h"
19 #include "webrtc/modules/audio_processing/processing_component.h" 20 #include "webrtc/modules/audio_processing/processing_component.h"
20 21
21 namespace webrtc { 22 namespace webrtc {
22 23
23 class AudioBuffer; 24 class AudioBuffer;
24 class CriticalSectionWrapper; 25 class CriticalSectionWrapper;
25 26
26 // Functor to use when supplying a verifier function for the queue item 27 // Functor to use when supplying a verifier function for the queue item
27 // verifcation. 28 // verifcation.
28 class AgcRenderQueueItemVerifier { 29 class AgcRenderQueueItemVerifier {
29 public: 30 public:
30 explicit AgcRenderQueueItemVerifier(size_t minimum_capacity) 31 explicit AgcRenderQueueItemVerifier(size_t minimum_capacity)
31 : minimum_capacity_(minimum_capacity) {} 32 : minimum_capacity_(minimum_capacity) {}
32 33
33 bool operator()(const std::vector<int16_t>& v) const { 34 bool operator()(const std::vector<int16_t>& v) const {
34 return v.capacity() >= minimum_capacity_; 35 return v.capacity() >= minimum_capacity_;
35 } 36 }
36 37
37 private: 38 private:
38 size_t minimum_capacity_; 39 size_t minimum_capacity_;
39 }; 40 };
40 41
41 class GainControlImpl : public GainControl, 42 class GainControlImpl : public GainControl,
42 public ProcessingComponent { 43 public ProcessingComponent {
43 public: 44 public:
44 GainControlImpl(const AudioProcessing* apm, 45 GainControlImpl(const AudioProcessing* apm,
45 CriticalSectionWrapper* crit); 46 CriticalSectionWrapper* crit,
47 const rtc::ThreadChecker* render_thread_checker,
48 const rtc::ThreadChecker* capture_thread_checker);
46 virtual ~GainControlImpl(); 49 virtual ~GainControlImpl();
47 50
48 int ProcessRenderAudio(AudioBuffer* audio); 51 int ProcessRenderAudio(AudioBuffer* audio);
49 int AnalyzeCaptureAudio(AudioBuffer* audio); 52 int AnalyzeCaptureAudio(AudioBuffer* audio);
50 int ProcessCaptureAudio(AudioBuffer* audio); 53 int ProcessCaptureAudio(AudioBuffer* audio);
51 54
52 // ProcessingComponent implementation. 55 // ProcessingComponent implementation.
53 int Initialize() override; 56 int Initialize() override;
54 57
55 // GainControl implementation. 58 // GainControl implementation.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 int InitializeHandle(void* handle) const override; 90 int InitializeHandle(void* handle) const override;
88 int ConfigureHandle(void* handle) const override; 91 int ConfigureHandle(void* handle) const override;
89 void DestroyHandle(void* handle) const override; 92 void DestroyHandle(void* handle) const override;
90 int num_handles_required() const override; 93 int num_handles_required() const override;
91 int GetHandleError(void* handle) const override; 94 int GetHandleError(void* handle) const override;
92 95
93 void AllocateRenderQueue(); 96 void AllocateRenderQueue();
94 97
95 const AudioProcessing* apm_; 98 const AudioProcessing* apm_;
96 CriticalSectionWrapper* crit_; 99 CriticalSectionWrapper* crit_;
100 const rtc::ThreadChecker* const render_thread_checker_;
101 const rtc::ThreadChecker* const capture_thread_checker_;
97 Mode mode_; 102 Mode mode_;
98 int minimum_capture_level_; 103 int minimum_capture_level_;
99 int maximum_capture_level_; 104 int maximum_capture_level_;
100 bool limiter_enabled_; 105 bool limiter_enabled_;
101 int target_level_dbfs_; 106 int target_level_dbfs_;
102 int compression_gain_db_; 107 int compression_gain_db_;
103 std::vector<int> capture_levels_; 108 std::vector<int> capture_levels_;
104 int analog_capture_level_; 109 int analog_capture_level_;
105 bool was_analog_level_set_; 110 bool was_analog_level_set_;
106 bool stream_is_saturated_; 111 bool stream_is_saturated_;
107 112
108 size_t render_queue_element_max_size_; 113 size_t render_queue_element_max_size_;
109 std::vector<int16_t> render_queue_buffer_; 114 std::vector<int16_t> render_queue_buffer_;
110 std::vector<int16_t> capture_queue_buffer_; 115 std::vector<int16_t> capture_queue_buffer_;
111 rtc::scoped_ptr<SwapQueue<std::vector<int16_t>, AgcRenderQueueItemVerifier> > 116 rtc::scoped_ptr<SwapQueue<std::vector<int16_t>, AgcRenderQueueItemVerifier> >
112 render_signal_queue_; 117 render_signal_queue_;
113 }; 118 };
114 } // namespace webrtc 119 } // namespace webrtc
115 120
116 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_ 121 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698