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}
This commit is contained in:
Alessio Bazzica
2019-11-07 13:22:00 +01:00
committed by Commit Bot
parent 1cd6fbc2a4
commit 7c19a706b0
6 changed files with 62 additions and 4 deletions

View File

@ -414,7 +414,14 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
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 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
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 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
}
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 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
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_;
};