Index: webrtc/modules/audio_processing/gain_control_impl.h |
diff --git a/webrtc/modules/audio_processing/gain_control_impl.h b/webrtc/modules/audio_processing/gain_control_impl.h |
index f24d200cf2216a05d4c162a655bcf8170d5bea37..1573aea3d1bfbbca7291408b4b40739e2bc06d64 100644 |
--- a/webrtc/modules/audio_processing/gain_control_impl.h |
+++ b/webrtc/modules/audio_processing/gain_control_impl.h |
@@ -13,11 +13,34 @@ |
#include <vector> |
+#include "webrtc/base/scoped_ptr.h" |
+#include "webrtc/common_audio/swap_queue.h" |
#include "webrtc/modules/audio_processing/include/audio_processing.h" |
#include "webrtc/modules/audio_processing/processing_component.h" |
namespace webrtc { |
+namespace { |
+// Functor to use when supplying a verifier function for the queue item |
+// verifcation. |
+class AgcRenderQueueItemVerifier { |
+ public: |
+ explicit AgcRenderQueueItemVerifier(size_t allowed_size_1, |
+ size_t allowed_size_2) |
+ : allowed_size_1_(allowed_size_1), allowed_size_2_(allowed_size_2) {} |
+ |
+ bool operator()(const std::vector<int16_t>& v) const { |
+ return (((v.size() == allowed_size_1_) || (v.size() == allowed_size_2_)) && |
the sun
2015/10/27 16:42:49
Like said in another review: you only need to asse
peah-webrtc
2015/10/29 14:05:23
Good find! This has now been refactored.
Done.
|
+ (v.capacity() >= std::max(allowed_size_1_, allowed_size_2_))); |
+ } |
+ |
+ private: |
+ size_t allowed_size_1_; |
+ size_t allowed_size_2_; |
+}; |
+ |
+} // namespace anonymous |
+ |
class AudioBuffer; |
class CriticalSectionWrapper; |
@@ -41,7 +64,16 @@ class GainControlImpl : public GainControl, |
bool is_limiter_enabled() const override; |
Mode mode() const override; |
+ // Reads render side data that has been queued on the render call. |
+ void ReadQueuedRenderData(); |
+ |
private: |
+ static const size_t kAllowedValuesOfSamplesPerFrame1 = 80; |
+ static const size_t kAllowedValuesOfSamplesPerFrame2 = 160; |
+ // TODO(peah): Decrease this once we properly handle hugely unbalanced |
+ // reverse and forward call numbers. |
+ static const size_t kMaxNumFramesToBuffer = 100; |
+ |
// GainControl implementation. |
int Enable(bool enable) override; |
int set_stream_analog_level(int level) override; |
@@ -64,6 +96,8 @@ class GainControlImpl : public GainControl, |
int num_handles_required() const override; |
int GetHandleError(void* handle) const override; |
+ void AllocateRenderQueue(); |
+ |
const AudioProcessing* apm_; |
CriticalSectionWrapper* crit_; |
Mode mode_; |
@@ -76,6 +110,12 @@ class GainControlImpl : public GainControl, |
int analog_capture_level_; |
bool was_analog_level_set_; |
bool stream_is_saturated_; |
+ |
+ size_t render_queue_element_max_size_; |
+ std::vector<int16_t> render_queue_buffer_; |
+ std::vector<int16_t> capture_queue_buffer_; |
+ rtc::scoped_ptr<SwapQueue<std::vector<int16_t>, AgcRenderQueueItemVerifier> > |
+ render_signal_queue_; |
}; |
} // namespace webrtc |