Send runtime settings to the Audio Processing Module (APM)
This CL includes the following changes:
- APM runtime setting (ID + float payload) and unit tests
- Swap queue of APM runtime settings used in AudioProcessingImpl
- runtime settings handler that forwards the settings to APM
sub-modules when a message is retrieved from the queue
- Unit test placeholder to check that the pre-gain update message
is correctly delivered
Bug: webrtc:9138
Change-Id: Id22704af15fde2b87a4431f5ce64ad1aeafc5280
Reviewed-on: https://webrtc-review.googlesource.com/69320
Reviewed-by: Per Ã…hgren <peah@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22873}
diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h
index 05eef5e..027010b 100644
--- a/modules/audio_processing/include/audio_processing.h
+++ b/modules/audio_processing/include/audio_processing.h
@@ -302,6 +302,32 @@
kStereoAndKeyboard
};
+ // Specifies the properties of a setting to be passed to AudioProcessing at
+ // runtime.
+ class RuntimeSetting {
+ public:
+ enum class Type { kNotSpecified, kCapturePreGain };
+
+ RuntimeSetting() : type_(Type::kNotSpecified), value_(0.f) {}
+ ~RuntimeSetting() = default;
+
+ static RuntimeSetting CreateCapturePreGain(float gain) {
+ RTC_DCHECK_GE(gain, 1.f) << "Attenuation is not allowed.";
+ return {Type::kCapturePreGain, gain};
+ }
+
+ Type type() const { return type_; }
+ void GetFloat(float* value) const {
+ RTC_DCHECK(value);
+ *value = value_;
+ }
+
+ private:
+ RuntimeSetting(Type id, float value) : type_(id), value_(value) {}
+ Type type_;
+ float value_;
+ };
+
~AudioProcessing() override {}
// Initializes internal states, while retaining all user settings. This
@@ -359,6 +385,9 @@
// Default false.
virtual void set_output_will_be_muted(bool muted) = 0;
+ // Enqueue a runtime setting.
+ virtual void SetRuntimeSetting(RuntimeSetting setting) = 0;
+
// Processes a 10 ms |frame| of the primary audio stream. On the client-side,
// this is the near-end (or captured) audio.
//