Audio Processing Module: add play-out audio device runtime information
Add a runtime setting that notifies play-out audio device changes.
The payload is a pair indicating a device id and its maximum play-out
volume.
kPlayoutVolumeChange is now forwarded not only to capture, but also
render (required by render_pre_processor).
Bug: webrtc:10608
Change-Id: I8997c207422c1dcd1d53775397d6290939ef3db8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/159002
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Per Ã…hgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29725}
diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h
index 8c46155..52fbaba 100644
--- a/modules/audio_processing/include/audio_processing.h
+++ b/modules/audio_processing/include/audio_processing.h
@@ -414,7 +414,14 @@
kCaptureCompressionGain,
kCaptureFixedPostGain,
kPlayoutVolumeChange,
- kCustomRenderProcessingRuntimeSetting
+ kCustomRenderProcessingRuntimeSetting,
+ kPlayoutAudioDeviceChange
+ };
+
+ // Play-out audio device properties.
+ struct PlayoutAudioDeviceInfo {
+ int id; // Identifies the audio device.
+ int max_volume; // Maximum play-out volume.
};
RuntimeSetting() : type_(Type::kNotSpecified), value_(0.f) {}
@@ -441,6 +448,15 @@
return {Type::kCaptureFixedPostGain, gain_db};
}
+ // Creates a runtime setting to notify play-out (aka render) audio device
+ // changes.
+ static RuntimeSetting CreatePlayoutAudioDeviceChange(
+ PlayoutAudioDeviceInfo audio_device) {
+ return {Type::kPlayoutAudioDeviceChange, audio_device};
+ }
+
+ // Creates a runtime setting to notify play-out (aka render) volume changes.
+ // |volume| is the unnormalized volume, the maximum of which
static RuntimeSetting CreatePlayoutVolumeChange(int volume) {
return {Type::kPlayoutVolumeChange, volume};
}
@@ -450,6 +466,8 @@
}
Type type() const { return type_; }
+ // Getters do not return a value but instead modify the argument to protect
+ // from implicit casting.
void GetFloat(float* value) const {
RTC_DCHECK(value);
*value = value_.float_value;
@@ -458,17 +476,25 @@
RTC_DCHECK(value);
*value = value_.int_value;
}
+ void GetPlayoutAudioDeviceInfo(PlayoutAudioDeviceInfo* value) const {
+ RTC_DCHECK(value);
+ *value = value_.playout_audio_device_info;
+ }
private:
RuntimeSetting(Type id, float value) : type_(id), value_(value) {}
RuntimeSetting(Type id, int value) : type_(id), value_(value) {}
+ RuntimeSetting(Type id, PlayoutAudioDeviceInfo value)
+ : type_(id), value_(value) {}
Type type_;
union U {
U() {}
U(int value) : int_value(value) {}
U(float value) : float_value(value) {}
+ U(PlayoutAudioDeviceInfo value) : playout_audio_device_info(value) {}
float float_value;
int int_value;
+ PlayoutAudioDeviceInfo playout_audio_device_info;
} value_;
};