Merge "audio: save vndbinder threads"
diff --git a/audio/aidl/Android.bp b/audio/aidl/Android.bp
index 01af940..d141514 100644
--- a/audio/aidl/Android.bp
+++ b/audio/aidl/Android.bp
@@ -225,8 +225,8 @@
],
srcs: [
"android/hardware/audio/effect/AcousticEchoCanceler.aidl",
- "android/hardware/audio/effect/AutomaticGainControl.aidl",
"android/hardware/audio/effect/AutomaticGainControlV1.aidl",
+ "android/hardware/audio/effect/AutomaticGainControlV2.aidl",
"android/hardware/audio/effect/BassBoost.aidl",
"android/hardware/audio/effect/Capability.aidl",
"android/hardware/audio/effect/CommandId.aidl",
diff --git a/audio/aidl/TEST_MAPPING b/audio/aidl/TEST_MAPPING
index 6a545c1..3e06595 100644
--- a/audio/aidl/TEST_MAPPING
+++ b/audio/aidl/TEST_MAPPING
@@ -13,9 +13,6 @@
"name": "VtsHalDownmixTargetTest"
},
{
- "name": "VtsHalDynamicsProcessingTargetTest"
- },
- {
"name": "VtsHalEnvironmentalReverbTargetTest"
},
{
@@ -43,7 +40,10 @@
"name": "VtsHalAECTargetTest"
},
{
- "name": "VtsHalAGCTargetTest"
+ "name": "VtsHalAGC1TargetTest"
+ },
+ {
+ "name": "VtsHalAGC2TargetTest"
},
{
"name": "VtsHalNSTargetTest"
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AcousticEchoCanceler.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AcousticEchoCanceler.aidl
index 1d51ade..1ec7dad 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AcousticEchoCanceler.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AcousticEchoCanceler.aidl
@@ -42,10 +42,4 @@
int vendorExtensionTag;
android.hardware.audio.effect.AcousticEchoCanceler.Tag commonTag;
}
- @VintfStability
- parcelable Capability {
- ParcelableHolder extension;
- int maxEchoDelayUs;
- boolean supportMobileMode;
- }
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControlV1.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControlV1.aidl
index ff010c6..57d4418 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControlV1.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControlV1.aidl
@@ -43,9 +43,4 @@
int vendorExtensionTag;
android.hardware.audio.effect.AutomaticGainControlV1.Tag commonTag;
}
- @VintfStability
- parcelable Capability {
- ParcelableHolder extension;
- android.hardware.audio.effect.Range[] ranges;
- }
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControl.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControlV2.aidl
similarity index 85%
rename from audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControl.aidl
rename to audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControlV2.aidl
index 39068d5..bdb481c 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControl.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/AutomaticGainControlV2.aidl
@@ -33,21 +33,15 @@
package android.hardware.audio.effect;
@VintfStability
-union AutomaticGainControl {
+union AutomaticGainControlV2 {
android.hardware.audio.effect.VendorExtension vendor;
int fixedDigitalGainMb;
- android.hardware.audio.effect.AutomaticGainControl.LevelEstimator levelEstimator;
+ android.hardware.audio.effect.AutomaticGainControlV2.LevelEstimator levelEstimator;
int saturationMarginMb;
@VintfStability
union Id {
int vendorExtensionTag;
- android.hardware.audio.effect.AutomaticGainControl.Tag commonTag;
- }
- @VintfStability
- parcelable Capability {
- ParcelableHolder extension;
- int maxFixedDigitalGainMb;
- int maxSaturationMarginMb;
+ android.hardware.audio.effect.AutomaticGainControlV2.Tag commonTag;
}
@Backing(type="int") @VintfStability
enum LevelEstimator {
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/BassBoost.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/BassBoost.aidl
index f8baa2a..d09fe54 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/BassBoost.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/BassBoost.aidl
@@ -41,10 +41,4 @@
int vendorExtensionTag;
android.hardware.audio.effect.BassBoost.Tag commonTag;
}
- @VintfStability
- parcelable Capability {
- ParcelableHolder extension;
- int maxStrengthPm;
- boolean strengthSupported;
- }
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Capability.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Capability.aidl
index 28f77b3..c9df073 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Capability.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Capability.aidl
@@ -33,20 +33,7 @@
package android.hardware.audio.effect;
@VintfStability
-union Capability {
+parcelable Capability {
android.hardware.audio.effect.VendorExtension vendorExtension;
- android.hardware.audio.effect.AcousticEchoCanceler.Capability acousticEchoCanceler;
- android.hardware.audio.effect.AutomaticGainControl.Capability automaticGainControl;
- android.hardware.audio.effect.BassBoost.Capability bassBoost;
- android.hardware.audio.effect.Downmix.Capability downmix;
- android.hardware.audio.effect.DynamicsProcessing.Capability dynamicsProcessing;
- android.hardware.audio.effect.EnvironmentalReverb.Capability environmentalReverb;
- android.hardware.audio.effect.Equalizer.Capability equalizer;
- android.hardware.audio.effect.HapticGenerator.Capability hapticGenerator;
- android.hardware.audio.effect.LoudnessEnhancer.Capability loudnessEnhancer;
- android.hardware.audio.effect.NoiseSuppression.Capability noiseSuppression;
- android.hardware.audio.effect.PresetReverb.Capability presetReverb;
- android.hardware.audio.effect.Virtualizer.Capability virtualizer;
- android.hardware.audio.effect.Visualizer.Capability visualizer;
- android.hardware.audio.effect.Volume.Capability volume;
+ android.hardware.audio.effect.Range range;
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Descriptor.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Descriptor.aidl
index 990d369..0baac3d 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Descriptor.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Descriptor.aidl
@@ -41,7 +41,8 @@
const String EFFECT_TYPE_UUID_EQUALIZER = "0bed4300-ddd6-11db-8f34-0002a5d5c51b";
const String EFFECT_TYPE_UUID_BASS_BOOST = "0634f220-ddd4-11db-a0fc-0002a5d5c51b";
const String EFFECT_TYPE_UUID_VIRTUALIZER = "37cc2c00-dddd-11db-8577-0002a5d5c51b";
- const String EFFECT_TYPE_UUID_AGC = "0a8abfe0-654c-11e0-ba26-0002a5d5c51b";
+ const String EFFECT_TYPE_UUID_AGC1 = "0a8abfe0-654c-11e0-ba26-0002a5d5c51b";
+ const String EFFECT_TYPE_UUID_AGC2 = "ae3c653b-be18-4ab8-8938-418f0a7f06ac";
const String EFFECT_TYPE_UUID_AEC = "7b491460-8d4d-11e0-bd61-0002a5d5c51b";
const String EFFECT_TYPE_UUID_NS = "58b4b260-8e06-11e0-aa8e-0002a5d5c51b";
const String EFFECT_TYPE_UUID_LOUDNESS_ENHANCER = "fe3199be-aed0-413f-87bb-11260eb63cf1";
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Downmix.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Downmix.aidl
index 402441d..45a1f28 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Downmix.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Downmix.aidl
@@ -42,10 +42,6 @@
android.hardware.audio.effect.Downmix.Tag commonTag;
}
@VintfStability
- parcelable Capability {
- ParcelableHolder extension;
- }
- @VintfStability
enum Type {
STRIP,
FOLD,
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/DynamicsProcessing.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/DynamicsProcessing.aidl
index 8e5b719..3e20e33 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/DynamicsProcessing.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/DynamicsProcessing.aidl
@@ -49,12 +49,6 @@
int vendorExtensionTag;
android.hardware.audio.effect.DynamicsProcessing.Tag commonTag;
}
- @VintfStability
- parcelable Capability {
- ParcelableHolder extension;
- float minCutOffFreq;
- float maxCutOffFreq;
- }
enum ResolutionPreference {
FAVOR_FREQUENCY_RESOLUTION,
FAVOR_TIME_RESOLUTION,
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl
index 9edad09..a193102 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl
@@ -49,20 +49,4 @@
int vendorExtensionTag;
android.hardware.audio.effect.EnvironmentalReverb.Tag commonTag;
}
- @VintfStability
- parcelable Capability {
- android.hardware.audio.effect.VendorExtension extension;
- int minRoomLevelMb;
- int maxRoomLevelMb;
- int minRoomHfLevelMb;
- int maxRoomHfLevelMb;
- int maxDecayTimeMs;
- int minDecayHfRatioPm;
- int maxDecayHfRatioPm;
- int minLevelMb;
- int maxLevelMb;
- int maxDelayMs;
- int maxDiffusionPm;
- int maxDensityPm;
- }
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Equalizer.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Equalizer.aidl
index d825eac..3e3539f 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Equalizer.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Equalizer.aidl
@@ -37,18 +37,15 @@
android.hardware.audio.effect.VendorExtension vendorExtension;
android.hardware.audio.effect.Equalizer.BandLevel[] bandLevels;
int preset;
+ int[] centerFreqMh;
+ android.hardware.audio.effect.Equalizer.BandFrequency[] bandFrequencies;
+ android.hardware.audio.effect.Equalizer.Preset[] presets;
@VintfStability
union Id {
int vendorExtensionTag;
android.hardware.audio.effect.Equalizer.Tag commonTag;
}
@VintfStability
- parcelable Capability {
- ParcelableHolder extension;
- android.hardware.audio.effect.Equalizer.BandFrequency[] bandFrequencies;
- android.hardware.audio.effect.Equalizer.Preset[] presets;
- }
- @VintfStability
parcelable BandLevel {
int index;
int levelMb;
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/HapticGenerator.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/HapticGenerator.aidl
index 20f7e02..a7dc265 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/HapticGenerator.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/HapticGenerator.aidl
@@ -42,15 +42,11 @@
int vendorExtensionTag;
android.hardware.audio.effect.HapticGenerator.Tag commonTag;
}
- @VintfStability
- parcelable Capability {
- android.hardware.audio.effect.VendorExtension extension;
- }
@Backing(type="int") @VintfStability
enum VibratorScale {
- MUTE = (-100),
- VERY_LOW = (-2),
- LOW = (-1),
+ MUTE = (-100) /* -100 */,
+ VERY_LOW = (-2) /* -2 */,
+ LOW = (-1) /* -1 */,
NONE = 0,
HIGH = 1,
VERY_HIGH = 2,
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/LoudnessEnhancer.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/LoudnessEnhancer.aidl
index 5c6ca16..774f45f 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/LoudnessEnhancer.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/LoudnessEnhancer.aidl
@@ -41,8 +41,4 @@
int vendorExtensionTag;
android.hardware.audio.effect.LoudnessEnhancer.Tag commonTag;
}
- @VintfStability
- parcelable Capability {
- android.hardware.audio.effect.VendorExtension extension;
- }
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/NoiseSuppression.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/NoiseSuppression.aidl
index 1cf92ef..f1a3449 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/NoiseSuppression.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/NoiseSuppression.aidl
@@ -36,15 +36,12 @@
union NoiseSuppression {
android.hardware.audio.effect.VendorExtension vendor;
android.hardware.audio.effect.NoiseSuppression.Level level;
+ android.hardware.audio.effect.NoiseSuppression.Type type;
@VintfStability
union Id {
int vendorExtensionTag;
android.hardware.audio.effect.NoiseSuppression.Tag commonTag;
}
- @VintfStability
- parcelable Capability {
- ParcelableHolder extension;
- }
@Backing(type="int") @VintfStability
enum Level {
LOW,
@@ -52,4 +49,9 @@
HIGH,
VERY_HIGH,
}
+ @Backing(type="int") @VintfStability
+ enum Type {
+ SINGLE_CHANNEL,
+ MULTI_CHANNEL,
+ }
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Parameter.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Parameter.aidl
index 3ba44a0..14aa1e8 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Parameter.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Parameter.aidl
@@ -44,7 +44,8 @@
union Id {
int vendorEffectTag;
android.hardware.audio.effect.AcousticEchoCanceler.Id acousticEchoCancelerTag;
- android.hardware.audio.effect.AutomaticGainControl.Id automaticGainControlTag;
+ android.hardware.audio.effect.AutomaticGainControlV1.Id automaticGainControlV1Tag;
+ android.hardware.audio.effect.AutomaticGainControlV2.Id automaticGainControlV2Tag;
android.hardware.audio.effect.BassBoost.Id bassBoostTag;
android.hardware.audio.effect.Downmix.Id downmixTag;
android.hardware.audio.effect.DynamicsProcessing.Id dynamicsProcessingTag;
@@ -75,7 +76,8 @@
union Specific {
android.hardware.audio.effect.VendorExtension vendorEffect;
android.hardware.audio.effect.AcousticEchoCanceler acousticEchoCanceler;
- android.hardware.audio.effect.AutomaticGainControl automaticGainControl;
+ android.hardware.audio.effect.AutomaticGainControlV1 automaticGainControlV1;
+ android.hardware.audio.effect.AutomaticGainControlV2 automaticGainControlV2;
android.hardware.audio.effect.BassBoost bassBoost;
android.hardware.audio.effect.Downmix downmix;
android.hardware.audio.effect.DynamicsProcessing dynamicsProcessing;
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/PresetReverb.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/PresetReverb.aidl
index 4651742..148f79d 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/PresetReverb.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/PresetReverb.aidl
@@ -35,6 +35,7 @@
@VintfStability
union PresetReverb {
android.hardware.audio.effect.VendorExtension vendor;
+ android.hardware.audio.effect.PresetReverb.Presets[] supportedPresets;
android.hardware.audio.effect.PresetReverb.Presets preset;
@Backing(type="int") @VintfStability
enum Presets {
@@ -51,9 +52,4 @@
int vendorExtensionTag;
android.hardware.audio.effect.PresetReverb.Tag commonTag;
}
- @VintfStability
- parcelable Capability {
- android.hardware.audio.effect.VendorExtension extension;
- android.hardware.audio.effect.PresetReverb.Presets[] supportedPresets;
- }
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Range.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Range.aidl
index 531d3a1..93edc5e 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Range.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Range.aidl
@@ -33,34 +33,101 @@
package android.hardware.audio.effect;
@VintfStability
-parcelable Range {
- int tag;
- android.hardware.audio.effect.Range.Types types;
+union Range {
+ android.hardware.audio.effect.Range.VendorExtensionRange[] vendorExtension = {};
+ android.hardware.audio.effect.Range.AcousticEchoCancelerRange[] acousticEchoCanceler;
+ android.hardware.audio.effect.Range.AutomaticGainControlV1Range[] automaticGainControlV1;
+ android.hardware.audio.effect.Range.AutomaticGainControlV2Range[] automaticGainControlV2;
+ android.hardware.audio.effect.Range.BassBoostRange[] bassBoost;
+ android.hardware.audio.effect.Range.DownmixRange[] downmix;
+ android.hardware.audio.effect.Range.DynamicsProcessingRange[] dynamicsProcessing;
+ android.hardware.audio.effect.Range.EnvironmentalReverbRange[] environmentalReverb;
+ android.hardware.audio.effect.Range.EqualizerRange[] equalizer;
+ android.hardware.audio.effect.Range.HapticGeneratorRange[] hapticGenerator;
+ android.hardware.audio.effect.Range.LoudnessEnhancerRange[] loudnessEnhancer;
+ android.hardware.audio.effect.Range.NoiseSuppressionRange[] noiseSuppression;
+ android.hardware.audio.effect.Range.PresetReverbRange[] presetReverb;
+ android.hardware.audio.effect.Range.VirtualizerRange[] virtualizer;
+ android.hardware.audio.effect.Range.VisualizerRange[] visualizer;
+ android.hardware.audio.effect.Range.VolumeRange[] volume;
@VintfStability
- parcelable Int {
- int min;
- int max;
+ parcelable AcousticEchoCancelerRange {
+ android.hardware.audio.effect.AcousticEchoCanceler min;
+ android.hardware.audio.effect.AcousticEchoCanceler max;
}
@VintfStability
- parcelable Float {
- float min;
- float max;
+ parcelable AutomaticGainControlV1Range {
+ android.hardware.audio.effect.AutomaticGainControlV1 min;
+ android.hardware.audio.effect.AutomaticGainControlV1 max;
}
@VintfStability
- parcelable Long {
- long min;
- long max;
+ parcelable AutomaticGainControlV2Range {
+ android.hardware.audio.effect.AutomaticGainControlV2 min;
+ android.hardware.audio.effect.AutomaticGainControlV2 max;
}
@VintfStability
- parcelable Byte {
- byte min;
- byte max;
+ parcelable BassBoostRange {
+ android.hardware.audio.effect.BassBoost min;
+ android.hardware.audio.effect.BassBoost max;
}
@VintfStability
- union Types {
- android.hardware.audio.effect.Range.Int rangeInt;
- android.hardware.audio.effect.Range.Float rangeFloat;
- android.hardware.audio.effect.Range.Long rangeLong;
- android.hardware.audio.effect.Range.Byte rangeByte;
+ parcelable DownmixRange {
+ android.hardware.audio.effect.Downmix min;
+ android.hardware.audio.effect.Downmix max;
+ }
+ @VintfStability
+ parcelable DynamicsProcessingRange {
+ android.hardware.audio.effect.DynamicsProcessing min;
+ android.hardware.audio.effect.DynamicsProcessing max;
+ }
+ @VintfStability
+ parcelable EnvironmentalReverbRange {
+ android.hardware.audio.effect.EnvironmentalReverb min;
+ android.hardware.audio.effect.EnvironmentalReverb max;
+ }
+ @VintfStability
+ parcelable EqualizerRange {
+ android.hardware.audio.effect.Equalizer min;
+ android.hardware.audio.effect.Equalizer max;
+ }
+ @VintfStability
+ parcelable HapticGeneratorRange {
+ android.hardware.audio.effect.HapticGenerator min;
+ android.hardware.audio.effect.HapticGenerator max;
+ }
+ @VintfStability
+ parcelable LoudnessEnhancerRange {
+ android.hardware.audio.effect.LoudnessEnhancer min;
+ android.hardware.audio.effect.LoudnessEnhancer max;
+ }
+ @VintfStability
+ parcelable NoiseSuppressionRange {
+ android.hardware.audio.effect.NoiseSuppression min;
+ android.hardware.audio.effect.NoiseSuppression max;
+ }
+ @VintfStability
+ parcelable PresetReverbRange {
+ android.hardware.audio.effect.PresetReverb min;
+ android.hardware.audio.effect.PresetReverb max;
+ }
+ @VintfStability
+ parcelable VendorExtensionRange {
+ android.hardware.audio.effect.VendorExtension min;
+ android.hardware.audio.effect.VendorExtension max;
+ }
+ @VintfStability
+ parcelable VirtualizerRange {
+ android.hardware.audio.effect.Virtualizer min;
+ android.hardware.audio.effect.Virtualizer max;
+ }
+ @VintfStability
+ parcelable VisualizerRange {
+ android.hardware.audio.effect.Visualizer min;
+ android.hardware.audio.effect.Visualizer max;
+ }
+ @VintfStability
+ parcelable VolumeRange {
+ android.hardware.audio.effect.Volume min;
+ android.hardware.audio.effect.Volume max;
}
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Virtualizer.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Virtualizer.aidl
index 9fdd692..e9611e4 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Virtualizer.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Virtualizer.aidl
@@ -36,15 +36,23 @@
union Virtualizer {
android.hardware.audio.effect.VendorExtension vendor;
int strengthPm;
+ android.hardware.audio.effect.Virtualizer.ChannelAngle[] speakerAngles;
+ android.media.audio.common.AudioDeviceDescription device;
@VintfStability
union Id {
int vendorExtensionTag;
android.hardware.audio.effect.Virtualizer.Tag commonTag;
+ android.hardware.audio.effect.Virtualizer.SpeakerAnglesPayload speakerAnglesPayload;
}
@VintfStability
- parcelable Capability {
- android.hardware.audio.effect.VendorExtension extension;
- int maxStrengthPm;
- boolean strengthSupported;
+ parcelable SpeakerAnglesPayload {
+ android.media.audio.common.AudioChannelLayout layout;
+ android.media.audio.common.AudioDeviceDescription device;
+ }
+ @VintfStability
+ parcelable ChannelAngle {
+ int channel;
+ int azimuthDegree;
+ int elevationDegree;
}
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Visualizer.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Visualizer.aidl
index c8cb551..d1b1b3e 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Visualizer.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Visualizer.aidl
@@ -36,30 +36,18 @@
union Visualizer {
android.hardware.audio.effect.Visualizer.Id id;
android.hardware.audio.effect.VendorExtension vendor;
- android.hardware.audio.effect.Visualizer.GetOnlyParameters getOnlyParameters;
- android.hardware.audio.effect.Visualizer.SetOnlyParameters setOnlyParameters;
+ android.hardware.audio.effect.Visualizer.Measurement measurement;
+ byte[] captureSampleBuffer;
+ int latencyMs;
int captureSamples;
android.hardware.audio.effect.Visualizer.ScalingMode scalingMode;
android.hardware.audio.effect.Visualizer.MeasurementMode measurementMode;
@VintfStability
union Id {
int vendorExtensionTag;
- android.hardware.audio.effect.Visualizer.GetOnlyParameters.Tag getOnlyParamTag;
- android.hardware.audio.effect.Visualizer.SetOnlyParameters.Tag setOnlyParamTag;
android.hardware.audio.effect.Visualizer.Tag commonTag;
}
@VintfStability
- parcelable Capability {
- android.hardware.audio.effect.VendorExtension extension;
- int maxLatencyMs;
- android.hardware.audio.effect.Visualizer.CaptureSamplesRange captureSampleRange;
- }
- @VintfStability
- parcelable CaptureSamplesRange {
- int min;
- int max;
- }
- @VintfStability
enum ScalingMode {
NORMALIZED = 0,
AS_PLAYED,
@@ -70,17 +58,8 @@
PEAK_RMS,
}
@VintfStability
- union GetOnlyParameters {
- android.hardware.audio.effect.Visualizer.GetOnlyParameters.Measurement measurement;
- byte[] captureSampleBuffer;
- @VintfStability
- parcelable Measurement {
- int rms;
- int peak;
- }
- }
- @VintfStability
- union SetOnlyParameters {
- int latencyMs;
+ parcelable Measurement {
+ int rms;
+ int peak;
}
}
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Volume.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Volume.aidl
index 6259cfb..c2b2df7 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Volume.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Volume.aidl
@@ -42,10 +42,4 @@
int vendorExtensionTag;
android.hardware.audio.effect.Volume.Tag commonTag;
}
- @VintfStability
- parcelable Capability {
- android.hardware.audio.effect.VendorExtension extension;
- int minLevelDb;
- int maxLevelDb;
- }
}
diff --git a/audio/aidl/android/hardware/audio/effect/AcousticEchoCanceler.aidl b/audio/aidl/android/hardware/audio/effect/AcousticEchoCanceler.aidl
index 19d60b6..49377d6 100644
--- a/audio/aidl/android/hardware/audio/effect/AcousticEchoCanceler.aidl
+++ b/audio/aidl/android/hardware/audio/effect/AcousticEchoCanceler.aidl
@@ -22,9 +22,9 @@
* Acoustic Echo Canceler (AEC) is an audio pre-processor which removes the contribution of the
* signal received from the remote party from the captured audio signal.
*
- * All parameters defined in union AcousticEchoCanceler must be gettable and settable. The
- * capabilities defined in AcousticEchoCanceler.Capability can only acquired with
- * IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.acousticEchoCanceler
+ * definition if the definition for the corresponding parameter tag exist. See more detals about
+ * Range in Range.aidl.
*/
@VintfStability
union AcousticEchoCanceler {
@@ -43,35 +43,20 @@
VendorExtension vendor;
/**
- * Capability supported by AEC implementation.
- */
- @VintfStability
- parcelable Capability {
- /**
- * AEC capability extension, vendor can use this extension in case existing capability
- * definition not enough.
- */
- ParcelableHolder extension;
-
- /**
- * Maximum AEC echo delay in microseconds supported.
- */
- int maxEchoDelayUs;
- /**
- * If AEC mobile mode was supported by the AEC implementation.
- */
- boolean supportMobileMode;
- }
-
- /**
* The AEC echo delay in microseconds.
- * Must never be negative, and not larger than maxEchoDelayUs in capability.
*/
int echoDelayUs;
/**
- * If AEC mobile mode enabled.
- * Can only be false if AEC implementation indicate not support mobile mode by set
- * supportMobileMode to false in capability.
+ * Indicate if the AEC mobile mode is enabled or not.
+ * If an effect implementation supports enabling and disabling mobileMode at runtime, it does
+ * not need to set the min and max range for mobileMode, or report the mobileMode min/max range
+ * as [false, true] in Range.AcousticEchoCancelerRange. If the effect implementation doesn't
+ * support mobileMode, it must report the mobileMode range as [false, false]. If the effect
+ * implementation supports mobileMode and cannot be disabled, it must report the mobileMode
+ * range as [true, true].
+ * If the effect implementation sets the range as invalid: [true, false], it indicates that
+ * mobileMode setParameter is not supported, and clients can only use getParameter to check if
+ * it's enabled or not.
*/
boolean mobileMode;
}
diff --git a/audio/aidl/android/hardware/audio/effect/AutomaticGainControl.aidl b/audio/aidl/android/hardware/audio/effect/AutomaticGainControl.aidl
deleted file mode 100644
index e82a564..0000000
--- a/audio/aidl/android/hardware/audio/effect/AutomaticGainControl.aidl
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.hardware.audio.effect;
-
-import android.hardware.audio.effect.VendorExtension;
-
-/**
- * Automatic Gain Control (AGC) is an audio pre-processor which automatically normalizes the output
- * of the captured signal by boosting or lowering input from the microphone to match a preset level
- * so that the output signal level is virtually constant. AGC can be used by applications where the
- * input signal dynamic range is not important but where a constant strong capture level is desired.
- *
- * All parameters defined in union AutomaticGainControl must be gettable and settable. The
- * capabilities defined in AutomaticGainControl.Capability can only acquired with
- * IEffect.getDescriptor() and not settable.
- */
-@VintfStability
-union AutomaticGainControl {
- /**
- * Effect parameter tag to identify the parameters for getParameter().
- */
- @VintfStability
- union Id {
- int vendorExtensionTag;
- AutomaticGainControl.Tag commonTag;
- }
-
- /**
- * Vendor AutomaticGainControl implementation definition for additional parameters.
- */
- VendorExtension vendor;
-
- /**
- * Capability supported by AutomaticGainControl implementation.
- */
- @VintfStability
- parcelable Capability {
- /**
- * AutomaticGainControl capability extension, vendor can use this extension in case existing
- * capability definition not enough.
- */
- ParcelableHolder extension;
- /**
- * Max fixed digital gain supported by AGC implementation in millibel.
- */
- int maxFixedDigitalGainMb;
- /**
- * Max fixed saturation margin supported by AGC implementation in millibel.
- */
- int maxSaturationMarginMb;
- }
-
- @VintfStability
- @Backing(type="int")
- enum LevelEstimator {
- /* Use Root Mean Square level estimator*/
- RMS = 0,
- /* Use Peak level estimator*/
- PEAK = 1,
- }
-
- /**
- * The AGC fixed digital gain in millibel.
- * Must never be negative, and not larger than maxFixedDigitalGainMb in capability.
- */
- int fixedDigitalGainMb;
- /*
- * Adaptive digital level estimator.
- */
- LevelEstimator levelEstimator;
- /**
- * The AGC saturation margin in millibel.
- * Must never be negative, and not larger than maxSaturationMarginMb in capability.
- */
- int saturationMarginMb;
-}
diff --git a/audio/aidl/android/hardware/audio/effect/AutomaticGainControlV1.aidl b/audio/aidl/android/hardware/audio/effect/AutomaticGainControlV1.aidl
index d6e0648..9b2feff 100644
--- a/audio/aidl/android/hardware/audio/effect/AutomaticGainControlV1.aidl
+++ b/audio/aidl/android/hardware/audio/effect/AutomaticGainControlV1.aidl
@@ -16,7 +16,6 @@
package android.hardware.audio.effect;
-import android.hardware.audio.effect.Range;
import android.hardware.audio.effect.VendorExtension;
/**
@@ -25,9 +24,9 @@
* so that the output signal level is virtually constant. AGC can be used by applications where the
* input signal dynamic range is not important but where a constant strong capture level is desired.
*
- * All parameters defined in union AutomaticGainControlV1 must be gettable and settable. The
- * capabilities defined in AutomaticGainControlV1.Capability can only acquired with
- * IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.automaticGainControlV1
+ * definition if the definition for the corresponding parameter tag exist. See more detals about
+ * Range in Range.aidl.
*/
@VintfStability
union AutomaticGainControlV1 {
@@ -46,31 +45,13 @@
VendorExtension vendor;
/**
- * Capability supported by AutomaticGainControlV1 implementation.
- */
- @VintfStability
- parcelable Capability {
- /**
- * AutomaticGainControlV1 capability extension, vendor can use this extension in case
- * existing capability definition not enough.
- */
- ParcelableHolder extension;
- /**
- * Supported range for parameters.
- */
- Range[] ranges;
- }
-
- /**
* Target peak level (or envelope) of the AGC implementation in dBFs (dB relative to full
* scale).
- * Must be in range of AutomaticGainControlV1.Capability.ranges with targetPeakLevelDbFs tag.
*/
int targetPeakLevelDbFs;
/*
* Sets the maximum gain the digital compression stage may apply, in dB. A higher number
* corresponds to greater compression, while a value of 0 will leave the signal uncompressed.
- * Must be in range of AutomaticGainControlV1.Capability.ranges with maxCompressionGainDb tag.
*/
int maxCompressionGainDb;
/**
diff --git a/audio/aidl/android/hardware/audio/effect/AutomaticGainControlV2.aidl b/audio/aidl/android/hardware/audio/effect/AutomaticGainControlV2.aidl
new file mode 100644
index 0000000..836d6b8
--- /dev/null
+++ b/audio/aidl/android/hardware/audio/effect/AutomaticGainControlV2.aidl
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.audio.effect;
+
+import android.hardware.audio.effect.VendorExtension;
+
+/**
+ * Automatic Gain Control V2 (AGC2) is an audio pre-processor which automatically normalizes the
+ * output of the captured signal by boosting or lowering input from the microphone to match a preset
+ * level so that the output signal level is virtually constant. AGC can be used by applications
+ * where the input signal dynamic range is not important but where a constant strong capture level
+ * is desired.
+ *
+ * All parameter settings must be inside the range of Capability.Range.automaticGainControlV2
+ * definition if the definition for the corresponding parameter tag exist. See more detals about
+ * Range in Range.aidl.
+ */
+@VintfStability
+union AutomaticGainControlV2 {
+ /**
+ * Effect parameter tag to identify the parameters for getParameter().
+ */
+ @VintfStability
+ union Id {
+ int vendorExtensionTag;
+ AutomaticGainControlV2.Tag commonTag;
+ }
+
+ /**
+ * Vendor AutomaticGainControlV2 implementation definition for additional parameters.
+ */
+ VendorExtension vendor;
+
+ @VintfStability
+ @Backing(type="int")
+ enum LevelEstimator {
+ /* Use Root Mean Square level estimator*/
+ RMS = 0,
+ /* Use Peak level estimator*/
+ PEAK = 1,
+ }
+
+ /**
+ * The AGC fixed digital gain in millibel.
+ */
+ int fixedDigitalGainMb;
+ /*
+ * Adaptive digital level estimator.
+ */
+ LevelEstimator levelEstimator;
+ /**
+ * The AGC saturation margin in millibel.
+ */
+ int saturationMarginMb;
+}
diff --git a/audio/aidl/android/hardware/audio/effect/BassBoost.aidl b/audio/aidl/android/hardware/audio/effect/BassBoost.aidl
index 6a94242..d734825 100644
--- a/audio/aidl/android/hardware/audio/effect/BassBoost.aidl
+++ b/audio/aidl/android/hardware/audio/effect/BassBoost.aidl
@@ -22,8 +22,8 @@
* Bass boost is an audio effect to boost or amplify low frequencies of the sound. It is comparable
* to a simple equalizer but limited to one band amplification in the low frequency range.
*
- * All parameters defined in union BassBoost must be gettable and settable. The capabilities defined
- * in BassBoost.Capability can only acquired with IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.bassBoost definition if the
+ * definition for the corresponding parameter tag exist. See more detals about Range in Range.aidl.
*/
@VintfStability
union BassBoost {
@@ -42,35 +42,11 @@
VendorExtension vendor;
/**
- * Capability supported by BassBoost implementation.
- */
- @VintfStability
- parcelable Capability {
- /**
- * BassBoost capability extension, vendor can use this extension in case existing capability
- * definition not enough.
- */
- ParcelableHolder extension;
- /**
- * Maximum possible per mille strength.
- */
- int maxStrengthPm;
- /**
- * Indicates whether setting strength is supported. False value indicates only one strength
- * is supported and setParameter() method will return EX_ILLEGAL_ARGUMENT.
- */
- boolean strengthSupported;
- }
-
- /**
* The per mille strength of the bass boost effect.
*
* If the implementation does not support per mille accuracy for setting the strength, it is
* allowed to round the given strength to the nearest supported value. In this case {@link
* #IEffect.getParameter()} method should return the rounded value that was actually set.
- *
- * The value of the strength must be non-negative and not exceed the value specified by
- * the 'maxStrengthPm' capability.
*/
int strengthPm;
}
diff --git a/audio/aidl/android/hardware/audio/effect/Capability.aidl b/audio/aidl/android/hardware/audio/effect/Capability.aidl
index 30780e6..06c2024 100644
--- a/audio/aidl/android/hardware/audio/effect/Capability.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Capability.aidl
@@ -16,21 +16,8 @@
package android.hardware.audio.effect;
-import android.hardware.audio.effect.AcousticEchoCanceler;
-import android.hardware.audio.effect.AutomaticGainControl;
-import android.hardware.audio.effect.BassBoost;
-import android.hardware.audio.effect.Downmix;
-import android.hardware.audio.effect.DynamicsProcessing;
-import android.hardware.audio.effect.EnvironmentalReverb;
-import android.hardware.audio.effect.Equalizer;
-import android.hardware.audio.effect.HapticGenerator;
-import android.hardware.audio.effect.LoudnessEnhancer;
-import android.hardware.audio.effect.NoiseSuppression;
-import android.hardware.audio.effect.PresetReverb;
+import android.hardware.audio.effect.Range;
import android.hardware.audio.effect.VendorExtension;
-import android.hardware.audio.effect.Virtualizer;
-import android.hardware.audio.effect.Visualizer;
-import android.hardware.audio.effect.Volume;
/**
* Effect capability definitions.
@@ -38,32 +25,19 @@
* not meant to change at runtime.
*/
@VintfStability
-union Capability {
+parcelable Capability {
/**
* Vendor defined effect capability.
- * This extension can be used when vendor have a new effect implementated and need
+ * This extension can be used when vendor has a new effect implementation and needs
* capability definition for this new type of effect.
- * If vendor want to extend existing effect capabilities, it is recommended to expose though
- * the ParcelableHolder in each effect capability definition. For example:
- * Equalizer.Capability.extension.
+ * If vendor want to extend existing effect capabilities, it is recommended to expose through
+ * the ParcelableHolder in each effect definition. For example: Equalizer.vendorExtension. And
+ * define an appropriate Range for the extension.
*/
VendorExtension vendorExtension;
/**
- * Effect capabilities.
+ * Supported range for parameters. See Range.aidl.
*/
- AcousticEchoCanceler.Capability acousticEchoCanceler;
- AutomaticGainControl.Capability automaticGainControl;
- BassBoost.Capability bassBoost;
- Downmix.Capability downmix;
- DynamicsProcessing.Capability dynamicsProcessing;
- EnvironmentalReverb.Capability environmentalReverb;
- Equalizer.Capability equalizer;
- HapticGenerator.Capability hapticGenerator;
- LoudnessEnhancer.Capability loudnessEnhancer;
- NoiseSuppression.Capability noiseSuppression;
- PresetReverb.Capability presetReverb;
- Virtualizer.Capability virtualizer;
- Visualizer.Capability visualizer;
- Volume.Capability volume;
+ Range range;
}
diff --git a/audio/aidl/android/hardware/audio/effect/Descriptor.aidl b/audio/aidl/android/hardware/audio/effect/Descriptor.aidl
index 47c88dc..01ca1c6 100644
--- a/audio/aidl/android/hardware/audio/effect/Descriptor.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Descriptor.aidl
@@ -57,9 +57,13 @@
*/
const String EFFECT_TYPE_UUID_VIRTUALIZER = "37cc2c00-dddd-11db-8577-0002a5d5c51b";
/**
- * UUID for Automatic Gain Control (AGC) type.
+ * UUID for Automatic Gain Control V1 (AGC1) type.
*/
- const String EFFECT_TYPE_UUID_AGC = "0a8abfe0-654c-11e0-ba26-0002a5d5c51b";
+ const String EFFECT_TYPE_UUID_AGC1 = "0a8abfe0-654c-11e0-ba26-0002a5d5c51b";
+ /**
+ * UUID for Automatic Gain Control V2 (AGC2) type.
+ */
+ const String EFFECT_TYPE_UUID_AGC2 = "ae3c653b-be18-4ab8-8938-418f0a7f06ac";
/**
* UUID for Acoustic Echo Canceler (AEC) type.
*/
diff --git a/audio/aidl/android/hardware/audio/effect/Downmix.aidl b/audio/aidl/android/hardware/audio/effect/Downmix.aidl
index ee57baf..f90e339 100644
--- a/audio/aidl/android/hardware/audio/effect/Downmix.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Downmix.aidl
@@ -21,8 +21,8 @@
/**
* Downmix specific definitions.
*
- * All parameters defined in union Downmix must be gettable and settable. The capabilities defined
- * in Downmix.Capability can only acquired with IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.downmix definition if the
+ * definition for the corresponding parameter tag exist. See more detals about Range in Range.aidl.
*/
@VintfStability
union Downmix {
@@ -40,18 +40,6 @@
*/
VendorExtension vendor;
- /**
- * Capability supported by Downmix implementation.
- */
- @VintfStability
- parcelable Capability {
- /**
- * Downmix capability extension, vendor can use this extension in case existing capability
- * definition not enough.
- */
- ParcelableHolder extension;
- }
-
@VintfStability
enum Type {
/**
diff --git a/audio/aidl/android/hardware/audio/effect/DynamicsProcessing.aidl b/audio/aidl/android/hardware/audio/effect/DynamicsProcessing.aidl
index 6db3338..486d4f4 100644
--- a/audio/aidl/android/hardware/audio/effect/DynamicsProcessing.aidl
+++ b/audio/aidl/android/hardware/audio/effect/DynamicsProcessing.aidl
@@ -21,9 +21,9 @@
/**
* DynamicsProcessing specific definitions.
*
- * All parameters defined in union DynamicsProcessing must be gettable and settable. The
- * capabilities defined in DynamicsProcessing.Capability can only acquired with
- * IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.dynamicsProcessing definition
+ * if the definition for the corresponding parameter tag exist. See more detals about Range in
+ * Range.aidl.
*/
@VintfStability
union DynamicsProcessing {
@@ -42,26 +42,6 @@
VendorExtension vendorExtension;
/**
- * Capability supported by DynamicsProcessing implementation.
- */
- @VintfStability
- parcelable Capability {
- /**
- * DynamicsProcessing capability extension, vendor can use this extension in case existing
- * capability definition not enough.
- */
- ParcelableHolder extension;
- /**
- * Min Cut off frequency (in Hz) for all Bands.
- */
- float minCutOffFreq;
- /**
- * Max Cut off frequency (in Hz) for all Bands.
- */
- float maxCutOffFreq;
- }
-
- /**
* Resolution preference definition.
*/
enum ResolutionPreference {
@@ -159,8 +139,7 @@
*/
boolean enable;
/**
- * Topmost frequency number (in Hz) this band will process. Must be in the range of
- * [minCutOffFreq, maxCutOffFreq] defined in Capability.
+ * Topmost frequency number (in Hz) this band will process.
*/
float cutoffFrequencyHz;
/**
@@ -190,8 +169,7 @@
*/
boolean enable;
/**
- * Topmost frequency number (in Hz) this band will process. Must be in the range of
- * [minCutOffFreq, maxCutOffFreq] defined in Capability.
+ * Topmost frequency number (in Hz) this band will process.
*/
float cutoffFrequencyHz;
/**
diff --git a/audio/aidl/android/hardware/audio/effect/EnvironmentalReverb.aidl b/audio/aidl/android/hardware/audio/effect/EnvironmentalReverb.aidl
index fc98fe6..a158dca 100644
--- a/audio/aidl/android/hardware/audio/effect/EnvironmentalReverb.aidl
+++ b/audio/aidl/android/hardware/audio/effect/EnvironmentalReverb.aidl
@@ -21,9 +21,9 @@
/**
* Environmental Reverb specific definitions.
*
- * All parameters defined in union Environmental must be gettable and settable. The capabilities
- * * defined in EnvironmentalReverb.Capability can only acquired with IEffect.getDescriptor() and
- * not * settable.
+ * All parameter settings must be inside the range of Capability.Range.environmentalReverb
+ * definition if the definition for the corresponding parameter tag exist. See more detals about
+ * Range in Range.aidl.
*/
@VintfStability
@@ -43,103 +43,35 @@
VendorExtension vendor;
/**
- * Capability supported by effect implementation.
- */
- @VintfStability
- parcelable Capability {
- VendorExtension extension;
-
- /**
- * Minimal possible room level in millibels.
- */
- int minRoomLevelMb;
- /**
- * Maximum possible room level in millibels.
- */
- int maxRoomLevelMb;
- /**
- * Minimal possible room hf level in millibels.
- */
- int minRoomHfLevelMb;
- /**
- * Maximum possible room hf level in millibels.
- */
- int maxRoomHfLevelMb;
- /**
- * Max decay time supported in millisecond.
- */
- int maxDecayTimeMs;
- /**
- * Minimal possible per mille decay hf ratio.
- */
- int minDecayHfRatioPm;
- /**
- * Maximum possible per mille decay hf ratio.
- */
- int maxDecayHfRatioPm;
- /**
- * Minimal possible room level in millibels.
- */
- int minLevelMb;
- /**
- * Maximum possible room level in millibels.
- */
- int maxLevelMb;
- /**
- * Maximum possible delay time in milliseconds.
- */
- int maxDelayMs;
- /**
- * Maximum possible per mille diffusion.
- */
- int maxDiffusionPm;
- /**
- * Maximum possible per mille density.
- */
- int maxDensityPm;
- }
-
- /**
- * Room level apply to the reverb effect in millibels. The value of the roomLevelMb must be in
- * range of the value specified by the 'minRoomLevelMb' capability and the 'maxRoomLevelMb'
- * capability.
+ * Room level apply to the reverb effect in millibels.
*/
int roomLevelMb;
/**
- * Room HF level apply to the reverb effect in millibels. The value of the roomHfLevelMb must be
- * in range of the value specified by the 'minRoomHfLevelMb' capability and the
- * 'maxRoomHfLevelMb' capability.
+ * Room HF level apply to the reverb effect in millibels.
*/
int roomHfLevelMb;
/**
- * Delay time apply to the reverb effect in milliseconds.The value of the decayTimeMs must
- * be non-negative and not exceed the value specified by the 'maxDecayTimeMs' capability.
+ * Delay time apply to the reverb effect in milliseconds.
*/
int decayTimeMs;
/**
- * HF decay ratio in permilles. The value of the decayHfRatioPm must be in range
- * of the value specified by the 'minDecayHfRatioPm' capability and the 'maxDecayHfRatioPm'
- * capability.
+ * HF decay ratio in permilles.
*/
int decayHfRatioPm;
/**
- * Reverb level in millibels. The value of the levelMb must be in range
- * of the value specified by the 'minLevelMb' capability and the 'maxLevelMb' capability.
+ * Reverb level in millibels.
*/
int levelMb;
/**
- * Reverb delay in milliseconds. The value of the delayMs must be non-negative and not
- * exceed the value specified by the 'maxDelayMs' capability.
+ * Reverb delay in milliseconds.
*/
int delayMs;
/**
- * Diffusion in permilles. The value of the diffusionPm must be non-negative and not
- * exceed the value specified by the 'maxDiffusionPm' capability.
+ * Diffusion in permilles.
*/
int diffusionPm;
/**
- * Density in permilles. The value of the densityPm must be non-negative and not
- * exceed the value specified by the 'maxDensityPm' capability.
+ * Density in permilles.
*/
int densityPm;
diff --git a/audio/aidl/android/hardware/audio/effect/Equalizer.aidl b/audio/aidl/android/hardware/audio/effect/Equalizer.aidl
index 79a1c4f..2bce151 100644
--- a/audio/aidl/android/hardware/audio/effect/Equalizer.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Equalizer.aidl
@@ -21,8 +21,8 @@
/**
* Equalizer specific definitions.
*
- * All parameters defined in union Equalizer must be gettable and settable. The capabilities defined
- * in Equalizer.Capability can only acquired with IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.equalizer definition if the
+ * definition for the corresponding parameter tag exist. See more detals about Range in Range.aidl.
*/
@VintfStability
union Equalizer {
@@ -41,28 +41,6 @@
VendorExtension vendorExtension;
/**
- * Capability MUST be supported by Equalizer implementation.
- */
- @VintfStability
- parcelable Capability {
- /**
- * Equalizer capability extension, vendor can use this extension in case existing capability
- * definition not enough.
- */
- ParcelableHolder extension;
-
- /**
- * Bands frequency ranges supported.
- */
- BandFrequency[] bandFrequencies;
-
- /**
- * Presets name and index.
- */
- Preset[] presets;
- }
-
- /**
* Level setting for each band in millibels.
*/
@VintfStability
@@ -72,7 +50,7 @@
}
/**
- * Supported minimal and maximal frequency for each band in millihertz.
+ * Supported minimal and maximal frequency for each band in milliHertz.
*/
@VintfStability
parcelable BandFrequency {
@@ -97,8 +75,24 @@
* Level for each band.
*/
BandLevel[] bandLevels;
+
/**
* Index of current preset.
*/
int preset;
+
+ /**
+ * Get only parameter, get the center frequency for all bands in milliHertz.
+ */
+ int[] centerFreqMh;
+
+ /**
+ * Get only parameter, indicating bands frequency ranges supported by implementation.
+ */
+ BandFrequency[] bandFrequencies;
+
+ /**
+ * Get only parameter, indicating presets name and index supported by implementation.
+ */
+ Preset[] presets;
}
diff --git a/audio/aidl/android/hardware/audio/effect/HapticGenerator.aidl b/audio/aidl/android/hardware/audio/effect/HapticGenerator.aidl
index 3063ee3..a8e4564 100644
--- a/audio/aidl/android/hardware/audio/effect/HapticGenerator.aidl
+++ b/audio/aidl/android/hardware/audio/effect/HapticGenerator.aidl
@@ -22,9 +22,9 @@
* HapticGenerator specific definitions. HapticGenerator effect provide HapticGenerator control and
* mute/unmute functionality.
*
- * All parameters defined in union HapticGenerator must be gettable and settable. The capabilities
- * defined in HapticGenerator.Capability can only acquired with IEffect.getDescriptor() and not
- * settable.
+ * All parameter settings must be inside the range of Capability.Range.hapticGenerator definition if
+ * the definition for the corresponding parameter tag exist. See more detals about Range in
+ * Range.aidl.
*/
@VintfStability
union HapticGenerator {
@@ -42,18 +42,6 @@
*/
VendorExtension vendorExtension;
- /**
- * Capability supported by HapticGenerator implementation.
- */
- @VintfStability
- parcelable Capability {
- /**
- * HapticGenerator capability extension, vendor can use this extension in case existing
- * capability definition not enough.
- */
- VendorExtension extension;
- }
-
@VintfStability
@Backing(type="int")
enum VibratorScale {
diff --git a/audio/aidl/android/hardware/audio/effect/LoudnessEnhancer.aidl b/audio/aidl/android/hardware/audio/effect/LoudnessEnhancer.aidl
index 0441f10..a7cbe8d 100644
--- a/audio/aidl/android/hardware/audio/effect/LoudnessEnhancer.aidl
+++ b/audio/aidl/android/hardware/audio/effect/LoudnessEnhancer.aidl
@@ -21,9 +21,9 @@
/**
* LoudnessEnhancer specific definitions.
*
- * All parameters defined in union LoudnessEnhancer must be gettable and settable. The capabilities
- * defined in LoudnessEnhancer.Capability can only acquired with IEffect.getDescriptor() and not
- * settable.
+ * All parameter settings must be inside the range of Capability.Range.loudnessEnhancer definition
+ * if the definition for the corresponding parameter tag exist. See more detals about Range in
+ * Range.aidl.
*/
@VintfStability
union LoudnessEnhancer {
@@ -42,18 +42,6 @@
VendorExtension vendor;
/**
- * Capability supported by LoudnessEnhancer implementation.
- */
- @VintfStability
- parcelable Capability {
- /**
- * LoudnessEnhancer capability extension, vendor can use this extension in case existing
- * capability definition not enough.
- */
- VendorExtension extension;
- }
-
- /**
* The maximum gain in millibels (mB) applied to the signal to process, default value is 0 which
* corresponds to no amplification.
*/
diff --git a/audio/aidl/android/hardware/audio/effect/NoiseSuppression.aidl b/audio/aidl/android/hardware/audio/effect/NoiseSuppression.aidl
index 9969a0b..6c2fb5f 100644
--- a/audio/aidl/android/hardware/audio/effect/NoiseSuppression.aidl
+++ b/audio/aidl/android/hardware/audio/effect/NoiseSuppression.aidl
@@ -24,9 +24,9 @@
* engine, AC system) or non-stationary (other peoples conversations, car horn) for more advanced
* implementations.
*
- * All parameters defined in union NoiseSuppression must be gettable and settable. The capabilities
- * defined in NoiseSuppression.Capability can only acquired with IEffect.getDescriptor() and not
- * settable.
+ * All parameter settings must be inside the range of Capability.Range.noiseSuppression definition
+ * if the definition for the corresponding parameter tag exist. See more detals about Range in
+ * Range.aidl.
*/
@VintfStability
union NoiseSuppression {
@@ -45,18 +45,6 @@
VendorExtension vendor;
/**
- * Capability supported by NoiseSuppression implementation.
- */
- @VintfStability
- parcelable Capability {
- /**
- * NoiseSuppression capability extension, vendor can use this extension in case existing
- * capability definition not enough.
- */
- ParcelableHolder extension;
- }
-
- /**
* Different level of Noise Suppression to set.
* As an example, webrtc have NsConfig::SuppressionLevel::k6dB applied for LOW level noise
* suppression, NsConfig::SuppressionLevel::k12dB for MEDIUM, and
@@ -68,4 +56,11 @@
* The NS level.
*/
Level level;
+
+ /**
+ * Noise suppression type.
+ */
+ @VintfStability @Backing(type="int") enum Type { SINGLE_CHANNEL, MULTI_CHANNEL }
+
+ Type type;
}
diff --git a/audio/aidl/android/hardware/audio/effect/Parameter.aidl b/audio/aidl/android/hardware/audio/effect/Parameter.aidl
index 473dfb5..9f8874b 100644
--- a/audio/aidl/android/hardware/audio/effect/Parameter.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Parameter.aidl
@@ -17,7 +17,8 @@
package android.hardware.audio.effect;
import android.hardware.audio.effect.AcousticEchoCanceler;
-import android.hardware.audio.effect.AutomaticGainControl;
+import android.hardware.audio.effect.AutomaticGainControlV1;
+import android.hardware.audio.effect.AutomaticGainControlV2;
import android.hardware.audio.effect.BassBoost;
import android.hardware.audio.effect.Downmix;
import android.hardware.audio.effect.DynamicsProcessing;
@@ -44,6 +45,14 @@
* 2. Parameters defined for a specific effect type.
* 3. Extension parameters ParcelableHolder can be used for vendor effect definition.
*
+ * All parameter settings must be inside the range of Capability.Range.$EffectType$ definition. If
+ * an effect implementation doesn't have limitation for a parameter, then don't define any effect
+ * range.
+ *
+ * All parameters are get-able, if any parameter doesn't support set, effect implementation should
+ * report the supported range for this parameter as range.min > range.max. If no support range is
+ * defined for a parameter, it means this parameter doesn't have any limitation.
+ *
*/
@VintfStability
union Parameter {
@@ -75,7 +84,8 @@
*
*/
AcousticEchoCanceler.Id acousticEchoCancelerTag;
- AutomaticGainControl.Id automaticGainControlTag;
+ AutomaticGainControlV1.Id automaticGainControlV1Tag;
+ AutomaticGainControlV2.Id automaticGainControlV2Tag;
BassBoost.Id bassBoostTag;
Downmix.Id downmixTag;
DynamicsProcessing.Id dynamicsProcessingTag;
@@ -157,7 +167,8 @@
union Specific {
VendorExtension vendorEffect;
AcousticEchoCanceler acousticEchoCanceler;
- AutomaticGainControl automaticGainControl;
+ AutomaticGainControlV1 automaticGainControlV1;
+ AutomaticGainControlV2 automaticGainControlV2;
BassBoost bassBoost;
Downmix downmix;
DynamicsProcessing dynamicsProcessing;
diff --git a/audio/aidl/android/hardware/audio/effect/PresetReverb.aidl b/audio/aidl/android/hardware/audio/effect/PresetReverb.aidl
index 6048eea..87c78b0 100644
--- a/audio/aidl/android/hardware/audio/effect/PresetReverb.aidl
+++ b/audio/aidl/android/hardware/audio/effect/PresetReverb.aidl
@@ -21,9 +21,9 @@
/**
* PresetReverb specific definitions.
*
- * All parameters defined in union PresetReverb must be gettable and settable. The capabilities
- * defined in PresetReverb.Capability can only acquired with IEffect.getDescriptor() and not
- * settable.
+ * All parameter settings must be inside the range of Capability.Range.presetReverb definition if
+ * the definition for the corresponding parameter tag exist. See more detals about Range in
+ * Range.aidl.
*/
@VintfStability
union PresetReverb {
@@ -78,21 +78,24 @@
VendorExtension vendor;
/**
- * Capability supported by effect implementation.
+ * The list of presets supported by implementation, effect implementation must declare the
+ * support of Presets with Capability.Range.presetReverb definition. For example, if an effect
+ * implementation supports all Presets in PresetReverb.Presets, then the capability will be:
+ * const std::vector<PresetReverb::Presets> kSupportedPresets{
+ * ndk::enum_range<PresetReverb::Presets>().begin(),
+ * ndk::enum_range<PresetReverb::Presets>().end()};
+ * const std::vector<Range::PresetReverbRange> kRanges = {
+ * MAKE_RANGE(PresetReverb, supportedPresets, kSupportedPresets, kSupportedPresets)};
*/
- @VintfStability
- parcelable Capability {
- VendorExtension extension;
-
- /**
- * List of presets supported.
- */
- Presets[] supportedPresets;
- }
+ Presets[] supportedPresets;
/**
* Get current reverb preset when used in getParameter.
* Enable a preset reverb when used in setParameter.
+ * With the current Range definition, there is no good way to define enum capability, so the
+ * Presets vector supportedPresets is used to defined the capability. Client must check the
+ * capability in PresetReverb.supportedPresets, and make sure to get the list of supported
+ * presets before setting.
*/
Presets preset;
}
diff --git a/audio/aidl/android/hardware/audio/effect/Range.aidl b/audio/aidl/android/hardware/audio/effect/Range.aidl
index c052502..567320a 100644
--- a/audio/aidl/android/hardware/audio/effect/Range.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Range.aidl
@@ -16,50 +16,205 @@
package android.hardware.audio.effect;
+import android.hardware.audio.effect.AcousticEchoCanceler;
+import android.hardware.audio.effect.AutomaticGainControlV1;
+import android.hardware.audio.effect.AutomaticGainControlV2;
+import android.hardware.audio.effect.BassBoost;
+import android.hardware.audio.effect.Downmix;
+import android.hardware.audio.effect.DynamicsProcessing;
+import android.hardware.audio.effect.EnvironmentalReverb;
+import android.hardware.audio.effect.Equalizer;
+import android.hardware.audio.effect.HapticGenerator;
+import android.hardware.audio.effect.LoudnessEnhancer;
+import android.hardware.audio.effect.NoiseSuppression;
+import android.hardware.audio.effect.PresetReverb;
+import android.hardware.audio.effect.VendorExtension;
+import android.hardware.audio.effect.Virtualizer;
+import android.hardware.audio.effect.Visualizer;
+import android.hardware.audio.effect.Volume;
+
/**
- * Define the range (min and max) of a certain field, identified by tag.
- * Can be used by effect capabilities to define supported value ranges.
+ * Define the supported range of effect parameters.
+ * Effect implementation must report the supported range of parameter/capability if there is any
+ * limitation.
+ * Range of each effect type is defined with a vector, because each $EffectType$Range can only
+ * describe the range of one parameter. For example, Range::AcousticEchoCancelerRange can only
+ * describe one of vendor, echoDelayUs, and mobileMode.
+ *
+ * If an effect implementation needs to define the valid range for a certain parameter, it can
+ * write the minimum/maximum supported value to the corresponding effect range, and add the range
+ * to vector of this effect type.
+ * Say if an AcousticEchoCanceler implementation wants to define the supported range of echoDelayUs
+ * to [0, 500], then the Capability range should include an item in acousticEchoCanceler list:
+ * std::vector<Range::AcousticEchoCancelerRange> kRanges = {
+ * MAKE_RANGE(AcousticEchoCanceler, echoDelayUs, 0, 500)};
+ *
+ * For a more complex example, if a DynamicsProcessing implementation wants to define the
+ * supported range of preEqBand channel to [0, 1], band index to [0, 5], and cutoffFrequencyHz to
+ * [220, 20000]:
+ * Range::DynamicsProcessingRange kRange = {
+ * .min = DynamicsProcessing::make<DynamicsProcessing::preEqBand>(
+ * {EqBandConfig({.channel = 0,
+ * .band = 0,
+ * .enable = false,
+ * .cutoffFrequencyHz = 220,
+ * .gainDb = std::numeric_limits<float>::min()})}),
+ * .max = DynamicsProcessing::make<DynamicsProcessing::preEqBand>(
+ * {EqBandConfig({.channel = 1,
+ * .band = 5,
+ * .enable = true,
+ * .cutoffFrequencyHz = 20000,
+ * .gainDb = std::numeric_limits<float>::max()})})};
+ *
+ * For get only parameters, the effect implementation must define an invalid range (min > max), to
+ * indicate no parameter from the effect client can be accepted for setting. The effect
+ * implementation must return EX_ILLEGAL_ARGUMENT if it receives any setParameter call for a get
+ * only parameter.
+ * As an example, the get-only parameter Virtualizer.speakerAngles can be defined with:
+ * Range::VirtualizerRange kRanges = {
+ * MAKE_RANGE(Virtualizer, speakerAngles,
+ * {Virtualizer::ChannelAngle({.channel = 1},
+ * {Virtualizer::ChannelAngle({.channel = 0})};
+ *
+ * For a capability definition (which is also get only), the effect implementation must define a
+ * range with min == max, to indicate this is a fixed capability which shouldn't set by client.
+ * As an example, the Equalizer presets capability can be defined with:
+ * std::vector<Equalizer::Preset> kPresets = {
+ * {0, "Normal"}, {1, "Classical"}, {2, "Dance"}, {3, "Flat"}, {4, "Folk"},
+ * {5, "Heavy Metal"}, {6, "Hip Hop"}, {7, "Jazz"}, {8, "Pop"}, {9, "Rock"}};
+ * Range::EqualizerRange kRanges =
+ * MAKE_RANGE(Equalizer, presets, EqualizerSw::kPresets, EqualizerSw::kPresets);
+ *
+ * For enum capability, it's necessary to either list a range, or explicitly list out all enums in
+ * the Range definition, see PresetReverb.supportedPresets as example.
+ *
+ * The effect implementation must return EX_ILLEGAL_ARGUMENT if:
+ * 1. receive any setParameter call for get only parameter (min > max).
+ * 2. receive any setParameter call for capability parameter definition (min == max).
+ * 3. receive any setParameter call for parameters not in the range of [min, max].
+ *
*/
@VintfStability
-parcelable Range {
+union Range {
+ @VintfStability
+ parcelable AcousticEchoCancelerRange {
+ AcousticEchoCanceler min;
+ AcousticEchoCanceler max;
+ }
+
+ @VintfStability
+ parcelable AutomaticGainControlV1Range {
+ AutomaticGainControlV1 min;
+ AutomaticGainControlV1 max;
+ }
+
+ @VintfStability
+ parcelable AutomaticGainControlV2Range {
+ AutomaticGainControlV2 min;
+ AutomaticGainControlV2 max;
+ }
+
+ @VintfStability
+ parcelable BassBoostRange {
+ BassBoost min;
+ BassBoost max;
+ }
+
+ @VintfStability
+ parcelable DownmixRange {
+ Downmix min;
+ Downmix max;
+ }
+
+ @VintfStability
+ parcelable DynamicsProcessingRange {
+ DynamicsProcessing min;
+ DynamicsProcessing max;
+ }
+
+ @VintfStability
+ parcelable EnvironmentalReverbRange {
+ EnvironmentalReverb min;
+ EnvironmentalReverb max;
+ }
+
+ @VintfStability
+ parcelable EqualizerRange {
+ Equalizer min;
+ Equalizer max;
+ }
+
+ @VintfStability
+ parcelable HapticGeneratorRange {
+ HapticGenerator min;
+ HapticGenerator max;
+ }
+
+ @VintfStability
+ parcelable LoudnessEnhancerRange {
+ LoudnessEnhancer min;
+ LoudnessEnhancer max;
+ }
+
+ @VintfStability
+ parcelable NoiseSuppressionRange {
+ NoiseSuppression min;
+ NoiseSuppression max;
+ }
+
+ @VintfStability
+ parcelable PresetReverbRange {
+ PresetReverb min;
+ PresetReverb max;
+ }
+
+ @VintfStability
+ parcelable VendorExtensionRange {
+ VendorExtension min;
+ VendorExtension max;
+ }
+
+ @VintfStability
+ parcelable VirtualizerRange {
+ Virtualizer min;
+ Virtualizer max;
+ }
+
+ @VintfStability
+ parcelable VisualizerRange {
+ Visualizer min;
+ Visualizer max;
+ }
+
+ @VintfStability
+ parcelable VolumeRange {
+ Volume min;
+ Volume max;
+ }
+
/**
- * The union tag name which the range is defined for.
- * For example: if used in AutomaticGainControlV1.Capability, value of Range.tag could be
- * targetLevelDbFs or compressionGainDb.
+ * The vector of range defined for parameters of each effect implementation.
+ * Each element of the vector represents the min and max range of a parameter, so the size of
+ * vector is the number of parameter ranges defined for this effect implementation.
+ *
+ * The effect implementation must not have duplicated parameter range definition in the vector.
+ * Client side must go though the vector and make sure the parameter setting to effect
+ * implementation is in valid range.
*/
- int tag;
-
- @VintfStability
- parcelable Int {
- int min;
- int max;
- }
-
- @VintfStability
- parcelable Float {
- float min;
- float max;
- }
-
- @VintfStability
- parcelable Long {
- long min;
- long max;
- }
-
- @VintfStability
- parcelable Byte {
- byte min;
- byte max;
- }
-
- @VintfStability
- union Types {
- Int rangeInt;
- Float rangeFloat;
- Long rangeLong;
- Byte rangeByte;
- }
-
- Types types;
+ VendorExtensionRange[] vendorExtension = {};
+ AcousticEchoCancelerRange[] acousticEchoCanceler;
+ AutomaticGainControlV1Range[] automaticGainControlV1;
+ AutomaticGainControlV2Range[] automaticGainControlV2;
+ BassBoostRange[] bassBoost;
+ DownmixRange[] downmix;
+ DynamicsProcessingRange[] dynamicsProcessing;
+ EnvironmentalReverbRange[] environmentalReverb;
+ EqualizerRange[] equalizer;
+ HapticGeneratorRange[] hapticGenerator;
+ LoudnessEnhancerRange[] loudnessEnhancer;
+ NoiseSuppressionRange[] noiseSuppression;
+ PresetReverbRange[] presetReverb;
+ VirtualizerRange[] virtualizer;
+ VisualizerRange[] visualizer;
+ VolumeRange[] volume;
}
diff --git a/audio/aidl/android/hardware/audio/effect/Virtualizer.aidl b/audio/aidl/android/hardware/audio/effect/Virtualizer.aidl
index 5f385a6..37ea2a4 100644
--- a/audio/aidl/android/hardware/audio/effect/Virtualizer.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Virtualizer.aidl
@@ -17,14 +17,15 @@
package android.hardware.audio.effect;
import android.hardware.audio.effect.VendorExtension;
+import android.media.audio.common.AudioChannelLayout;
+import android.media.audio.common.AudioDeviceDescription;
/**
* Virtualizer specific definitions. An audio virtualizer is a general name for an effect to
* spatialize audio channels.
*
- * All parameters defined in union Virtualizer must be gettable and settable. The capabilities
- * defined in Virtualizer.Capability can only acquired with IEffect.getDescriptor() and not
- * settable.
+ * All parameter settings must be inside the range of Capability.Range.virtualizer definition if the
+ * definition for the corresponding parameter tag exist. See more detals about Range in Range.aidl.
*/
@VintfStability
union Virtualizer {
@@ -35,6 +36,7 @@
union Id {
int vendorExtensionTag;
Virtualizer.Tag commonTag;
+ SpeakerAnglesPayload speakerAnglesPayload;
}
/**
@@ -43,24 +45,22 @@
VendorExtension vendor;
/**
- * Capability supported by Virtualizer implementation.
+ * Payload to query speaker angles for the given channel position mask and device.
+ * The Virtualizer implementation must return EX_ILLEGAL_ARGUMENT if the given payload not
+ * supported.
*/
@VintfStability
- parcelable Capability {
+ parcelable SpeakerAnglesPayload {
/**
- * Virtualizer capability extension, vendor can use this extension in case existing
- * capability definition not enough.
+ * Audio channel position definition. See
+ * android.media.audio.common.AudioChannelLayout.aidl. Only the channel position "CHANNEL_*"
+ * in AudioChannelLayout be used.
*/
- VendorExtension extension;
+ AudioChannelLayout layout;
/**
- * Maximum possible per mille strength.
+ * Audio device type. See android.media.audio.common.AudioDeviceDescription.aidl.
*/
- int maxStrengthPm;
- /**
- * Indicates whether setting strength is supported. False value indicates only one strength
- * is supported and setParameter() method will always return EX_ILLEGAL_ARGUMENT.
- */
- boolean strengthSupported;
+ AudioDeviceDescription device;
}
/**
@@ -70,8 +70,42 @@
* allowed to round the given strength to the nearest supported value. In this case {@link
* #IEffect.getParameter()} method should return the rounded value that was actually set.
*
- * The value of the strength must be non-negative and not exceed the value specified by
- * the 'maxStrengthPm' capability.
*/
int strengthPm;
+
+ /**
+ * All angles are expressed in degrees and are relative to the listener.
+ */
+ @VintfStability
+ parcelable ChannelAngle {
+ /**
+ * Audio channel layout, CHANNEL_* constants defined in
+ * android.media.audio.common.AudioChannelLayout.
+ */
+ int channel;
+
+ /**
+ * 0 is the direction the listener faces, 180 is behind the listener, and -90 is left of
+ * the listener.
+ */
+ int azimuthDegree;
+
+ /**
+ * 0 is the horizontal plane, +90 is above the listener, -90 is below.
+ */
+ int elevationDegree;
+ }
+
+ /**
+ * Get only parameter.
+ * A vector of angles per channel represented by azimuth and elevation (in degrees), client must
+ * set Parameter.Id to SpeakerAnglesPayload to get speakerAngles.
+ */
+ ChannelAngle[] speakerAngles;
+
+ /**
+ * Get only parameter.
+ * The audio device on which virtualzation mode is forced.
+ */
+ AudioDeviceDescription device;
}
diff --git a/audio/aidl/android/hardware/audio/effect/Visualizer.aidl b/audio/aidl/android/hardware/audio/effect/Visualizer.aidl
index dfe29c8..8f2faaa 100644
--- a/audio/aidl/android/hardware/audio/effect/Visualizer.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Visualizer.aidl
@@ -22,9 +22,8 @@
* Visualizer specific definitions. Visualizer enables application to retrieve part of the currently
* playing audio for visualization purpose
*
- * All parameters defined in union Visualizer other than these in GetOnlyParameters and
- * SetOnlyParameters must be gettable and settable. The capabilities defined in
- * Visualizer.Capability can only acquired with IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.visualizer definition if the
+ * definition for the corresponding parameter tag exist. See more detals about Range in Range.aidl.
*
*/
@VintfStability
@@ -35,8 +34,6 @@
@VintfStability
union Id {
int vendorExtensionTag;
- GetOnlyParameters.Tag getOnlyParamTag;
- SetOnlyParameters.Tag setOnlyParamTag;
Visualizer.Tag commonTag;
}
Id id;
@@ -47,35 +44,6 @@
VendorExtension vendor;
/**
- * Capability supported by Visualizer implementation.
- */
- @VintfStability
- parcelable Capability {
- /**
- * Visualizer capability extension, vendor can use this extension in case existing
- * capability definition not enough.
- */
- VendorExtension extension;
- /**
- * Max latency supported in millseconds.
- */
- int maxLatencyMs;
- /**
- * Capture size range.
- */
- CaptureSamplesRange captureSampleRange;
- }
-
- /**
- * Supported capture size range in samples.
- */
- @VintfStability
- parcelable CaptureSamplesRange {
- int min;
- int max;
- }
-
- /**
* Type of scaling applied on the captured visualization data.
*/
@VintfStability
@@ -115,51 +83,42 @@
}
/**
- * Any parameter defined in this union must be gettable via getParameter(), but must not
- * settable.
+ * Get only parameter to get the current measurements.
*/
@VintfStability
- union GetOnlyParameters {
- /**
- * Get the current measurements.
- */
- @VintfStability
- parcelable Measurement {
- int rms;
- int peak;
- }
- Measurement measurement;
-
- /**
- * Get the latest captureSamples of PCM samples (8 bits per sample).
- */
- byte[] captureSampleBuffer;
+ parcelable Measurement {
+ int rms;
+ int peak;
}
- GetOnlyParameters getOnlyParameters;
+ Measurement measurement;
/**
- * Any parameter defined in this union must be settable via setParameter(), but must not
- * gettable.
+ * Get only parameter to get the latest captured samples of PCM samples (8 bits per sample).
*/
- @VintfStability
- union SetOnlyParameters {
- /**
- * Used by framework to inform the visualizer about the downstream latency (audio hardware
- * driver estimated latency in milliseconds).
- */
- int latencyMs;
- }
- SetOnlyParameters setOnlyParameters;
+ byte[] captureSampleBuffer;
/**
- * Current capture size in number of samples. The capture size must be inside
- * Capability.captureSizeRange.
+ * Used by framework to inform the visualizer about the downstream latency (audio hardware
+ * driver estimated latency in milliseconds).
+ *
+ * Visualizer implementation must use Range.VisualizerRange to define the range of supported
+ * latency.
+ */
+ int latencyMs;
+
+ /**
+ * Current capture size in number of samples.
+ *
+ * Visualizer implementation must use Range.VisualizerRange to define the range of supported
+ * capture size.
*/
int captureSamples;
+
/**
* Visualizer capture mode
*/
ScalingMode scalingMode;
+
/**
* Visualizer measurement mode.
*/
diff --git a/audio/aidl/android/hardware/audio/effect/Volume.aidl b/audio/aidl/android/hardware/audio/effect/Volume.aidl
index 5033881..4a76703 100644
--- a/audio/aidl/android/hardware/audio/effect/Volume.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Volume.aidl
@@ -21,8 +21,8 @@
/**
* Volume specific definitions. Volume effect provide volume control and mute/unmute functionality.
*
- * All parameters defined in union Volume must be gettable and settable. The capabilities defined in
- * Volume.Capability can only acquired with IEffect.getDescriptor() and not settable.
+ * All parameter settings must be inside the range of Capability.Range.volume definition if the
+ * definition for the corresponding parameter tag exist. See more detals about Range in Range.aidl.
*/
@VintfStability
union Volume {
@@ -41,29 +41,7 @@
VendorExtension vendor;
/**
- * Capability supported by Volume implementation.
- */
- @VintfStability
- parcelable Capability {
- /**
- * Volume capability extension, vendor can use this extension in case existing capability
- * definition not enough.
- */
- VendorExtension extension;
-
- /**
- * Minimum Volume level supported in dB.
- */
- int minLevelDb;
-
- /**
- * Maximum Volume level supported in dB.
- */
- int maxLevelDb;
- }
-
- /**
- * Current level in dB with supported minimum and maximum level specified in capability.
+ * Current level in dB.
*/
int levelDb;
/**
diff --git a/audio/aidl/default/EffectImpl.cpp b/audio/aidl/default/EffectImpl.cpp
index 403a4b9..fa9eb95 100644
--- a/audio/aidl/default/EffectImpl.cpp
+++ b/audio/aidl/default/EffectImpl.cpp
@@ -78,7 +78,7 @@
ndk::ScopedAStatus EffectImpl::setParameter(const Parameter& param) {
LOG(DEBUG) << __func__ << " with: " << param.toString();
- auto tag = param.getTag();
+ const auto tag = param.getTag();
switch (tag) {
case Parameter::common:
case Parameter::deviceDescription:
diff --git a/audio/aidl/default/EffectThread.cpp b/audio/aidl/default/EffectThread.cpp
index 2b3513d..024c0ea 100644
--- a/audio/aidl/default/EffectThread.cpp
+++ b/audio/aidl/default/EffectThread.cpp
@@ -70,26 +70,14 @@
}
RetCode EffectThread::startThread() {
- if (!mThread.joinable()) {
- LOG(ERROR) << __func__ << " thread already destroyed";
- return RetCode::ERROR_THREAD;
- }
-
- {
- std::lock_guard lg(mThreadMutex);
- if (!mStop) {
- LOG(WARNING) << __func__ << " already start";
- return RetCode::SUCCESS;
- }
- mStop = false;
- }
-
- mCv.notify_one();
- LOG(DEBUG) << __func__ << " done";
- return RetCode::SUCCESS;
+ return handleStartStop(false /* stop */);
}
RetCode EffectThread::stopThread() {
+ return handleStartStop(true /* stop */);
+}
+
+RetCode EffectThread::handleStartStop(bool stop) {
if (!mThread.joinable()) {
LOG(ERROR) << __func__ << " thread already destroyed";
return RetCode::ERROR_THREAD;
@@ -97,13 +85,15 @@
{
std::lock_guard lg(mThreadMutex);
- if (mStop) {
- LOG(WARNING) << __func__ << " already stop";
+ if (stop == mStop) {
+ LOG(WARNING) << __func__ << " already " << (stop ? "stop" : "start");
return RetCode::SUCCESS;
}
- mStop = true;
+ mStop = stop;
}
- LOG(DEBUG) << __func__ << " done";
+
+ mCv.notify_one();
+ LOG(DEBUG) << (stop ? "stop done" : "start done");
return RetCode::SUCCESS;
}
@@ -111,34 +101,23 @@
pthread_setname_np(pthread_self(), mName.substr(0, kMaxTaskNameLen - 1).c_str());
setpriority(PRIO_PROCESS, 0, mPriority);
while (true) {
- bool needExit = false;
- {
- std::unique_lock l(mThreadMutex);
- mCv.wait(l, [&]() REQUIRES(mThreadMutex) {
- needExit = mExit;
- return mExit || !mStop;
- });
- }
- if (needExit) {
+ std::unique_lock l(mThreadMutex);
+ ::android::base::ScopedLockAssertion lock_assertion(mThreadMutex);
+ mCv.wait(l, [&]() REQUIRES(mThreadMutex) { return mExit || !mStop; });
+ if (mExit) {
LOG(WARNING) << __func__ << " EXIT!";
return;
}
-
- process();
+ process_l();
}
}
-void EffectThread::process() {
- std::shared_ptr<EffectContext> context;
- {
- std::lock_guard lg(mThreadMutex);
- context = mThreadContext;
- RETURN_VALUE_IF(!context, void(), "nullContext");
- }
- std::shared_ptr<EffectContext::StatusMQ> statusMQ = context->getStatusFmq();
- std::shared_ptr<EffectContext::DataMQ> inputMQ = context->getInputDataFmq();
- std::shared_ptr<EffectContext::DataMQ> outputMQ = context->getOutputDataFmq();
- auto buffer = context->getWorkBuffer();
+void EffectThread::process_l() {
+ RETURN_VALUE_IF(!mThreadContext, void(), "nullContext");
+ std::shared_ptr<EffectContext::StatusMQ> statusMQ = mThreadContext->getStatusFmq();
+ std::shared_ptr<EffectContext::DataMQ> inputMQ = mThreadContext->getInputDataFmq();
+ std::shared_ptr<EffectContext::DataMQ> outputMQ = mThreadContext->getOutputDataFmq();
+ auto buffer = mThreadContext->getWorkBuffer();
// Only this worker will read from input data MQ and write to output data MQ.
auto readSamples = inputMQ->availableToRead(), writeSamples = outputMQ->availableToWrite();
@@ -149,7 +128,6 @@
inputMQ->read(buffer, processSamples);
- // call effectProcessImpl without lock
IEffect::Status status = effectProcessImpl(buffer, buffer, processSamples);
outputMQ->write(buffer, status.fmqProduced);
statusMQ->writeBlocking(&status, 1);
diff --git a/audio/aidl/default/acousticEchoCanceler/AcousticEchoCancelerSw.cpp b/audio/aidl/default/acousticEchoCanceler/AcousticEchoCancelerSw.cpp
index 40b46e0..f5af81e 100644
--- a/audio/aidl/default/acousticEchoCanceler/AcousticEchoCancelerSw.cpp
+++ b/audio/aidl/default/acousticEchoCanceler/AcousticEchoCancelerSw.cpp
@@ -30,6 +30,7 @@
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::kAcousticEchoCancelerSwImplUUID;
+using aidl::android::hardware::audio::effect::Range;
using aidl::android::media::audio::common::AudioUuid;
extern "C" binder_exception_t createEffect(const AudioUuid* in_impl_uuid,
@@ -60,8 +61,14 @@
namespace aidl::android::hardware::audio::effect {
const std::string AcousticEchoCancelerSw::kEffectName = "AcousticEchoCancelerSw";
-const AcousticEchoCanceler::Capability AcousticEchoCancelerSw::kCapability = {
- .maxEchoDelayUs = 500, .supportMobileMode = false};
+
+const std::vector<Range::AcousticEchoCancelerRange> AcousticEchoCancelerSw::kRanges = {
+ MAKE_RANGE(AcousticEchoCanceler, echoDelayUs, 0, 500),
+ /* mobile mode not supported, and not settable */
+ MAKE_RANGE(AcousticEchoCanceler, mobileMode, false, false)};
+
+const Capability AcousticEchoCancelerSw::kCapability = {.range = AcousticEchoCancelerSw::kRanges};
+
const Descriptor AcousticEchoCancelerSw::kDescriptor = {
.common = {.id = {.type = kAcousticEchoCancelerTypeUUID,
.uuid = kAcousticEchoCancelerSwImplUUID,
@@ -71,8 +78,7 @@
.volume = Flags::Volume::CTRL},
.name = AcousticEchoCancelerSw::kEffectName,
.implementor = "The Android Open Source Project"},
- .capability = Capability::make<Capability::acousticEchoCanceler>(
- AcousticEchoCancelerSw::kCapability)};
+ .capability = AcousticEchoCancelerSw::kCapability};
ndk::ScopedAStatus AcousticEchoCancelerSw::getDescriptor(Descriptor* _aidl_return) {
LOG(DEBUG) << __func__ << kDescriptor.toString();
@@ -87,8 +93,9 @@
RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
auto& param = specific.get<Parameter::Specific::acousticEchoCanceler>();
- auto tag = param.getTag();
+ RETURN_IF(!inRange(param, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
+ auto tag = param.getTag();
switch (tag) {
case AcousticEchoCanceler::echoDelayUs: {
RETURN_IF(mContext->setEchoDelay(param.get<AcousticEchoCanceler::echoDelayUs>()) !=
@@ -182,10 +189,6 @@
}
RetCode AcousticEchoCancelerSwContext::setEchoDelay(int echoDelayUs) {
- if (echoDelayUs < 0 || echoDelayUs > AcousticEchoCancelerSw::kCapability.maxEchoDelayUs) {
- LOG(DEBUG) << __func__ << " illegal delay " << echoDelayUs;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
mEchoDelayUs = echoDelayUs;
return RetCode::SUCCESS;
}
diff --git a/audio/aidl/default/acousticEchoCanceler/AcousticEchoCancelerSw.h b/audio/aidl/default/acousticEchoCanceler/AcousticEchoCancelerSw.h
index 5f1bc46..753207d 100644
--- a/audio/aidl/default/acousticEchoCanceler/AcousticEchoCancelerSw.h
+++ b/audio/aidl/default/acousticEchoCanceler/AcousticEchoCancelerSw.h
@@ -17,6 +17,7 @@
#pragma once
#include <aidl/android/hardware/audio/effect/BnEffect.h>
+#include <aidl/android/hardware/audio/effect/Range.h>
#include <fmq/AidlMessageQueue.h>
#include <cstdlib>
#include <memory>
@@ -43,8 +44,7 @@
class AcousticEchoCancelerSw final : public EffectImpl {
public:
static const std::string kEffectName;
- static const bool kStrengthSupported;
- static const AcousticEchoCanceler::Capability kCapability;
+ static const Capability kCapability;
static const Descriptor kDescriptor;
AcousticEchoCancelerSw() { LOG(DEBUG) << __func__; }
~AcousticEchoCancelerSw() {
@@ -65,6 +65,7 @@
IEffect::Status effectProcessImpl(float* in, float* out, int samples) override;
private:
+ static const std::vector<Range::AcousticEchoCancelerRange> kRanges;
std::shared_ptr<AcousticEchoCancelerSwContext> mContext;
ndk::ScopedAStatus getParameterAcousticEchoCanceler(const AcousticEchoCanceler::Tag& tag,
Parameter::Specific* specific);
diff --git a/audio/aidl/default/audio_effects_config.xml b/audio/aidl/default/audio_effects_config.xml
index 6714a7e..6785539 100644
--- a/audio/aidl/default/audio_effects_config.xml
+++ b/audio/aidl/default/audio_effects_config.xml
@@ -29,7 +29,8 @@
-->
<libraries>
<library name="aecsw" path="libaecsw.so"/>
- <library name="agcsw" path="libagcsw.so"/>
+ <library name="agc1sw" path="libagc1sw.so"/>
+ <library name="agc2sw" path="libagc2sw.so"/>
<library name="bassboostsw" path="libbassboostsw.so"/>
<library name="bundle" path="libbundleaidl.so"/>
<library name="downmix" path="libdownmixaidl.so"/>
@@ -67,7 +68,8 @@
<effects>
<effect name="acoustic_echo_canceler" library="aecsw" uuid="bb392ec0-8d4d-11e0-a896-0002a5d5c51b"/>
- <effect name="automatic_gain_control" library="agcsw" uuid="89f38e65-d4d2-4d64-ad0e-2b3e799ea886"/>
+ <effect name="automatic_gain_control_v1" library="agc1sw" uuid="aa8130e0-66fc-11e0-bad0-0002a5d5c51b"/>
+ <effect name="automatic_gain_control_v2" library="agc2sw" uuid="89f38e65-d4d2-4d64-ad0e-2b3e799ea886"/>
<effectProxy name="bassboost" uuid="14804144-a5ee-4d24-aa88-0002a5d5c51b">
<libsw library="bassboostsw" uuid="fa8181f2-588b-11ed-9b6a-0242ac120002"/>
<libsw library="bundle" uuid="8631f300-72e2-11df-b57e-0002a5d5c51b"/>
diff --git a/audio/aidl/default/automaticGainControl/AutomaticGainControlSw.cpp b/audio/aidl/default/automaticGainControl/AutomaticGainControlSw.cpp
deleted file mode 100644
index 8c706ef..0000000
--- a/audio/aidl/default/automaticGainControl/AutomaticGainControlSw.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <algorithm>
-#include <cstddef>
-#include <memory>
-#define LOG_TAG "AHAL_AutomaticGainControlSw"
-#include <Utils.h>
-#include <unordered_set>
-
-#include <android-base/logging.h>
-#include <fmq/AidlMessageQueue.h>
-
-#include "AutomaticGainControlSw.h"
-
-using aidl::android::hardware::audio::effect::AutomaticGainControlSw;
-using aidl::android::hardware::audio::effect::Descriptor;
-using aidl::android::hardware::audio::effect::IEffect;
-using aidl::android::hardware::audio::effect::kAutomaticGainControlSwImplUUID;
-using aidl::android::media::audio::common::AudioUuid;
-
-extern "C" binder_exception_t createEffect(const AudioUuid* in_impl_uuid,
- std::shared_ptr<IEffect>* instanceSpp) {
- if (!in_impl_uuid || *in_impl_uuid != kAutomaticGainControlSwImplUUID) {
- LOG(ERROR) << __func__ << "uuid not supported";
- return EX_ILLEGAL_ARGUMENT;
- }
- if (instanceSpp) {
- *instanceSpp = ndk::SharedRefBase::make<AutomaticGainControlSw>();
- LOG(DEBUG) << __func__ << " instance " << instanceSpp->get() << " created";
- return EX_NONE;
- } else {
- LOG(ERROR) << __func__ << " invalid input parameter!";
- return EX_ILLEGAL_ARGUMENT;
- }
-}
-
-extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descriptor* _aidl_return) {
- if (!in_impl_uuid || *in_impl_uuid != kAutomaticGainControlSwImplUUID) {
- LOG(ERROR) << __func__ << "uuid not supported";
- return EX_ILLEGAL_ARGUMENT;
- }
- *_aidl_return = AutomaticGainControlSw::kDescriptor;
- return EX_NONE;
-}
-
-namespace aidl::android::hardware::audio::effect {
-
-const std::string AutomaticGainControlSw::kEffectName = "AutomaticGainControlSw";
-const AutomaticGainControl::Capability AutomaticGainControlSw::kCapability = {
- .maxFixedDigitalGainMb = 50000, .maxSaturationMarginMb = 10000};
-const Descriptor AutomaticGainControlSw::kDescriptor = {
- .common = {.id = {.type = kAutomaticGainControlTypeUUID,
- .uuid = kAutomaticGainControlSwImplUUID,
- .proxy = std::nullopt},
- .flags = {.type = Flags::Type::INSERT,
- .insert = Flags::Insert::FIRST,
- .volume = Flags::Volume::CTRL},
- .name = AutomaticGainControlSw::kEffectName,
- .implementor = "The Android Open Source Project"},
- .capability = Capability::make<Capability::automaticGainControl>(
- AutomaticGainControlSw::kCapability)};
-
-ndk::ScopedAStatus AutomaticGainControlSw::getDescriptor(Descriptor* _aidl_return) {
- LOG(DEBUG) << __func__ << kDescriptor.toString();
- *_aidl_return = kDescriptor;
- return ndk::ScopedAStatus::ok();
-}
-
-ndk::ScopedAStatus AutomaticGainControlSw::setParameterSpecific(
- const Parameter::Specific& specific) {
- RETURN_IF(Parameter::Specific::automaticGainControl != specific.getTag(), EX_ILLEGAL_ARGUMENT,
- "EffectNotSupported");
- RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
-
- auto& param = specific.get<Parameter::Specific::automaticGainControl>();
- auto tag = param.getTag();
-
- switch (tag) {
- case AutomaticGainControl::fixedDigitalGainMb: {
- RETURN_IF(mContext->setDigitalGain(
- param.get<AutomaticGainControl::fixedDigitalGainMb>()) !=
- RetCode::SUCCESS,
- EX_ILLEGAL_ARGUMENT, "digitalGainNotSupported");
- return ndk::ScopedAStatus::ok();
- }
- case AutomaticGainControl::levelEstimator: {
- RETURN_IF(
- mContext->setLevelEstimator(
- param.get<AutomaticGainControl::levelEstimator>()) != RetCode::SUCCESS,
- EX_ILLEGAL_ARGUMENT, "levelEstimatorNotSupported");
- return ndk::ScopedAStatus::ok();
- }
- case AutomaticGainControl::saturationMarginMb: {
- RETURN_IF(mContext->setSaturationMargin(
- param.get<AutomaticGainControl::saturationMarginMb>()) !=
- RetCode::SUCCESS,
- EX_ILLEGAL_ARGUMENT, "saturationMarginNotSupported");
- return ndk::ScopedAStatus::ok();
- }
- default: {
- LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
- return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
- EX_ILLEGAL_ARGUMENT, "AutomaticGainControlTagNotSupported");
- }
- }
-}
-
-ndk::ScopedAStatus AutomaticGainControlSw::getParameterSpecific(const Parameter::Id& id,
- Parameter::Specific* specific) {
- auto tag = id.getTag();
- RETURN_IF(Parameter::Id::automaticGainControlTag != tag, EX_ILLEGAL_ARGUMENT, "wrongIdTag");
- auto specificId = id.get<Parameter::Id::automaticGainControlTag>();
- auto specificIdTag = specificId.getTag();
- switch (specificIdTag) {
- case AutomaticGainControl::Id::commonTag:
- return getParameterAutomaticGainControl(
- specificId.get<AutomaticGainControl::Id::commonTag>(), specific);
- default:
- LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
- return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
- EX_ILLEGAL_ARGUMENT, "AutomaticGainControlTagNotSupported");
- }
-}
-
-ndk::ScopedAStatus AutomaticGainControlSw::getParameterAutomaticGainControl(
- const AutomaticGainControl::Tag& tag, Parameter::Specific* specific) {
- RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
- AutomaticGainControl param;
- switch (tag) {
- case AutomaticGainControl::fixedDigitalGainMb: {
- param.set<AutomaticGainControl::fixedDigitalGainMb>(mContext->getDigitalGain());
- break;
- }
- case AutomaticGainControl::levelEstimator: {
- param.set<AutomaticGainControl::levelEstimator>(mContext->getLevelEstimator());
- break;
- }
- case AutomaticGainControl::saturationMarginMb: {
- param.set<AutomaticGainControl::saturationMarginMb>(mContext->getSaturationMargin());
- break;
- }
- default: {
- LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
- return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
- EX_ILLEGAL_ARGUMENT, "AutomaticGainControlTagNotSupported");
- }
- }
-
- specific->set<Parameter::Specific::automaticGainControl>(param);
- return ndk::ScopedAStatus::ok();
-}
-
-std::shared_ptr<EffectContext> AutomaticGainControlSw::createContext(
- const Parameter::Common& common) {
- if (mContext) {
- LOG(DEBUG) << __func__ << " context already exist";
- } else {
- mContext = std::make_shared<AutomaticGainControlSwContext>(1 /* statusFmqDepth */, common);
- }
- return mContext;
-}
-
-std::shared_ptr<EffectContext> AutomaticGainControlSw::getContext() {
- return mContext;
-}
-
-RetCode AutomaticGainControlSw::releaseContext() {
- if (mContext) {
- mContext.reset();
- }
- return RetCode::SUCCESS;
-}
-
-// Processing method running in EffectWorker thread.
-IEffect::Status AutomaticGainControlSw::effectProcessImpl(float* in, float* out, int samples) {
- // TODO: get data buffer and process.
- LOG(DEBUG) << __func__ << " in " << in << " out " << out << " samples " << samples;
- for (int i = 0; i < samples; i++) {
- *out++ = *in++;
- }
- return {STATUS_OK, samples, samples};
-}
-
-RetCode AutomaticGainControlSwContext::setDigitalGain(int gain) {
- if (gain < 0 || gain > AutomaticGainControlSw::kCapability.maxFixedDigitalGainMb) {
- LOG(DEBUG) << __func__ << " illegal digital gain " << gain;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
- mDigitalGain = gain;
- return RetCode::SUCCESS;
-}
-
-int AutomaticGainControlSwContext::getDigitalGain() {
- return mDigitalGain;
-}
-
-RetCode AutomaticGainControlSwContext::setLevelEstimator(
- AutomaticGainControl::LevelEstimator levelEstimator) {
- mLevelEstimator = levelEstimator;
- return RetCode::SUCCESS;
-}
-
-AutomaticGainControl::LevelEstimator AutomaticGainControlSwContext::getLevelEstimator() {
- return mLevelEstimator;
-}
-
-RetCode AutomaticGainControlSwContext::setSaturationMargin(int margin) {
- if (margin < 0 || margin > AutomaticGainControlSw::kCapability.maxSaturationMarginMb) {
- LOG(DEBUG) << __func__ << " illegal saturationMargin " << margin;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
- mSaturationMargin = margin;
- return RetCode::SUCCESS;
-}
-
-int AutomaticGainControlSwContext::getSaturationMargin() {
- return mSaturationMargin;
-}
-
-} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/automaticGainControl/Android.bp b/audio/aidl/default/automaticGainControlV1/Android.bp
similarity index 91%
copy from audio/aidl/default/automaticGainControl/Android.bp
copy to audio/aidl/default/automaticGainControlV1/Android.bp
index 17d6416..4ae8e63 100644
--- a/audio/aidl/default/automaticGainControl/Android.bp
+++ b/audio/aidl/default/automaticGainControlV1/Android.bp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 The Android Open Source Project
+ * Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,14 +24,14 @@
}
cc_library_shared {
- name: "libagcsw",
+ name: "libagc1sw",
defaults: [
"aidlaudioeffectservice_defaults",
"latest_android_media_audio_common_types_ndk_shared",
"latest_android_hardware_audio_effect_ndk_shared",
],
srcs: [
- "AutomaticGainControlSw.cpp",
+ "AutomaticGainControlV1Sw.cpp",
":effectCommonFile",
],
relative_install_path: "soundfx",
diff --git a/audio/aidl/default/automaticGainControlV1/AutomaticGainControlV1Sw.cpp b/audio/aidl/default/automaticGainControlV1/AutomaticGainControlV1Sw.cpp
new file mode 100644
index 0000000..39290b4
--- /dev/null
+++ b/audio/aidl/default/automaticGainControlV1/AutomaticGainControlV1Sw.cpp
@@ -0,0 +1,226 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "AHAL_AutomaticGainControlV1Sw"
+
+#include <android-base/logging.h>
+
+#include "AutomaticGainControlV1Sw.h"
+
+using aidl::android::hardware::audio::effect::AutomaticGainControlV1Sw;
+using aidl::android::hardware::audio::effect::Descriptor;
+using aidl::android::hardware::audio::effect::IEffect;
+using aidl::android::hardware::audio::effect::kAutomaticGainControlV1SwImplUUID;
+using aidl::android::media::audio::common::AudioUuid;
+
+extern "C" binder_exception_t createEffect(const AudioUuid* in_impl_uuid,
+ std::shared_ptr<IEffect>* instanceSpp) {
+ if (!in_impl_uuid || *in_impl_uuid != kAutomaticGainControlV1SwImplUUID) {
+ LOG(ERROR) << __func__ << "uuid not supported";
+ return EX_ILLEGAL_ARGUMENT;
+ }
+ if (instanceSpp) {
+ *instanceSpp = ndk::SharedRefBase::make<AutomaticGainControlV1Sw>();
+ LOG(DEBUG) << __func__ << " instance " << instanceSpp->get() << " created";
+ return EX_NONE;
+ } else {
+ LOG(ERROR) << __func__ << " invalid input parameter!";
+ return EX_ILLEGAL_ARGUMENT;
+ }
+}
+
+extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descriptor* _aidl_return) {
+ if (!in_impl_uuid || *in_impl_uuid != kAutomaticGainControlV1SwImplUUID) {
+ LOG(ERROR) << __func__ << "uuid not supported";
+ return EX_ILLEGAL_ARGUMENT;
+ }
+ *_aidl_return = AutomaticGainControlV1Sw::kDescriptor;
+ return EX_NONE;
+}
+
+namespace aidl::android::hardware::audio::effect {
+
+const std::string AutomaticGainControlV1Sw::kEffectName = "AutomaticGainControlV1Sw";
+
+const std::vector<Range::AutomaticGainControlV1Range> AutomaticGainControlV1Sw::kRanges = {
+ MAKE_RANGE(AutomaticGainControlV1, targetPeakLevelDbFs, -3100, 0),
+ MAKE_RANGE(AutomaticGainControlV1, maxCompressionGainDb, 0, 9000)};
+
+const Capability AutomaticGainControlV1Sw::kCapability = {
+ .range = AutomaticGainControlV1Sw::kRanges};
+
+const Descriptor AutomaticGainControlV1Sw::kDescriptor = {
+ .common = {.id = {.type = kAutomaticGainControlV1TypeUUID,
+ .uuid = kAutomaticGainControlV1SwImplUUID,
+ .proxy = std::nullopt},
+ .flags = {.type = Flags::Type::INSERT,
+ .insert = Flags::Insert::FIRST,
+ .volume = Flags::Volume::CTRL},
+ .name = AutomaticGainControlV1Sw::kEffectName,
+ .implementor = "The Android Open Source Project"},
+ .capability = AutomaticGainControlV1Sw::kCapability};
+
+ndk::ScopedAStatus AutomaticGainControlV1Sw::getDescriptor(Descriptor* _aidl_return) {
+ LOG(DEBUG) << __func__ << kDescriptor.toString();
+ *_aidl_return = kDescriptor;
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus AutomaticGainControlV1Sw::setParameterSpecific(
+ const Parameter::Specific& specific) {
+ RETURN_IF(Parameter::Specific::automaticGainControlV1 != specific.getTag(), EX_ILLEGAL_ARGUMENT,
+ "EffectNotSupported");
+ RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
+
+ auto& param = specific.get<Parameter::Specific::automaticGainControlV1>();
+ RETURN_IF(!inRange(param, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
+ auto tag = param.getTag();
+ switch (tag) {
+ case AutomaticGainControlV1::targetPeakLevelDbFs: {
+ RETURN_IF(mContext->setTargetPeakLevel(
+ param.get<AutomaticGainControlV1::targetPeakLevelDbFs>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "targetPeakLevelNotSupported");
+ return ndk::ScopedAStatus::ok();
+ }
+ case AutomaticGainControlV1::maxCompressionGainDb: {
+ RETURN_IF(mContext->setMaxCompressionGain(
+ param.get<AutomaticGainControlV1::maxCompressionGainDb>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "maxCompressionGainNotSupported");
+ return ndk::ScopedAStatus::ok();
+ }
+ case AutomaticGainControlV1::enableLimiter: {
+ RETURN_IF(
+ mContext->setEnableLimiter(
+ param.get<AutomaticGainControlV1::enableLimiter>()) != RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "enableLimiterNotSupported");
+ return ndk::ScopedAStatus::ok();
+ }
+ default: {
+ LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
+ EX_ILLEGAL_ARGUMENT, "AutomaticGainControlV1TagNotSupported");
+ }
+ }
+}
+
+ndk::ScopedAStatus AutomaticGainControlV1Sw::getParameterSpecific(const Parameter::Id& id,
+ Parameter::Specific* specific) {
+ auto tag = id.getTag();
+ RETURN_IF(Parameter::Id::automaticGainControlV1Tag != tag, EX_ILLEGAL_ARGUMENT, "wrongIdTag");
+ auto specificId = id.get<Parameter::Id::automaticGainControlV1Tag>();
+ auto specificIdTag = specificId.getTag();
+ switch (specificIdTag) {
+ case AutomaticGainControlV1::Id::commonTag:
+ return getParameterAutomaticGainControlV1(
+ specificId.get<AutomaticGainControlV1::Id::commonTag>(), specific);
+ default:
+ LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
+ EX_ILLEGAL_ARGUMENT, "AutomaticGainControlV1TagNotSupported");
+ }
+}
+
+ndk::ScopedAStatus AutomaticGainControlV1Sw::getParameterAutomaticGainControlV1(
+ const AutomaticGainControlV1::Tag& tag, Parameter::Specific* specific) {
+ RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
+ AutomaticGainControlV1 param;
+ switch (tag) {
+ case AutomaticGainControlV1::targetPeakLevelDbFs: {
+ param.set<AutomaticGainControlV1::targetPeakLevelDbFs>(mContext->getTargetPeakLevel());
+ break;
+ }
+ case AutomaticGainControlV1::maxCompressionGainDb: {
+ param.set<AutomaticGainControlV1::maxCompressionGainDb>(
+ mContext->getMaxCompressionGain());
+ break;
+ }
+ case AutomaticGainControlV1::enableLimiter: {
+ param.set<AutomaticGainControlV1::enableLimiter>(mContext->getEnableLimiter());
+ break;
+ }
+ default: {
+ LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
+ EX_ILLEGAL_ARGUMENT, "AutomaticGainControlV1TagNotSupported");
+ }
+ }
+
+ specific->set<Parameter::Specific::automaticGainControlV1>(param);
+ return ndk::ScopedAStatus::ok();
+}
+
+std::shared_ptr<EffectContext> AutomaticGainControlV1Sw::createContext(
+ const Parameter::Common& common) {
+ if (mContext) {
+ LOG(DEBUG) << __func__ << " context already exist";
+ } else {
+ mContext =
+ std::make_shared<AutomaticGainControlV1SwContext>(1 /* statusFmqDepth */, common);
+ }
+ return mContext;
+}
+
+std::shared_ptr<EffectContext> AutomaticGainControlV1Sw::getContext() {
+ return mContext;
+}
+
+RetCode AutomaticGainControlV1Sw::releaseContext() {
+ if (mContext) {
+ mContext.reset();
+ }
+ return RetCode::SUCCESS;
+}
+
+// Processing method running in EffectWorker thread.
+IEffect::Status AutomaticGainControlV1Sw::effectProcessImpl(float* in, float* out, int samples) {
+ // TODO: get data buffer and process.
+ LOG(DEBUG) << __func__ << " in " << in << " out " << out << " samples " << samples;
+ for (int i = 0; i < samples; i++) {
+ *out++ = *in++;
+ }
+ return {STATUS_OK, samples, samples};
+}
+
+RetCode AutomaticGainControlV1SwContext::setTargetPeakLevel(int targetPeakLevel) {
+ mTargetPeakLevel = targetPeakLevel;
+ return RetCode::SUCCESS;
+}
+
+int AutomaticGainControlV1SwContext::getTargetPeakLevel() {
+ return mTargetPeakLevel;
+}
+
+RetCode AutomaticGainControlV1SwContext::setMaxCompressionGain(int maxCompressionGain) {
+ mMaxCompressionGain = maxCompressionGain;
+ return RetCode::SUCCESS;
+}
+
+int AutomaticGainControlV1SwContext::getMaxCompressionGain() {
+ return mMaxCompressionGain;
+}
+
+RetCode AutomaticGainControlV1SwContext::setEnableLimiter(bool enableLimiter) {
+ mEnableLimiter = enableLimiter;
+ return RetCode::SUCCESS;
+}
+
+bool AutomaticGainControlV1SwContext::getEnableLimiter() {
+ return mEnableLimiter;
+}
+
+} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/automaticGainControlV1/AutomaticGainControlV1Sw.h b/audio/aidl/default/automaticGainControlV1/AutomaticGainControlV1Sw.h
new file mode 100644
index 0000000..6ba7328
--- /dev/null
+++ b/audio/aidl/default/automaticGainControlV1/AutomaticGainControlV1Sw.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include "effect-impl/EffectImpl.h"
+#include "effect-impl/EffectUUID.h"
+
+namespace aidl::android::hardware::audio::effect {
+
+class AutomaticGainControlV1SwContext final : public EffectContext {
+ public:
+ AutomaticGainControlV1SwContext(int statusDepth, const Parameter::Common& common)
+ : EffectContext(statusDepth, common) {
+ LOG(DEBUG) << __func__;
+ }
+
+ RetCode setTargetPeakLevel(int targetPeakLevel);
+ int getTargetPeakLevel();
+ RetCode setMaxCompressionGain(int maxCompressionGainDb);
+ int getMaxCompressionGain();
+ RetCode setEnableLimiter(bool enableLimiter);
+ bool getEnableLimiter();
+
+ private:
+ int mTargetPeakLevel = 0;
+ int mMaxCompressionGain = 0;
+ bool mEnableLimiter = false;
+};
+
+class AutomaticGainControlV1Sw final : public EffectImpl {
+ public:
+ static const std::string kEffectName;
+ static const bool kStrengthSupported;
+ static const Capability kCapability;
+ static const Descriptor kDescriptor;
+ AutomaticGainControlV1Sw() { LOG(DEBUG) << __func__; }
+ ~AutomaticGainControlV1Sw() {
+ cleanUp();
+ LOG(DEBUG) << __func__;
+ }
+
+ ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override;
+ ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific) override;
+ ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id,
+ Parameter::Specific* specific) override;
+
+ std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) override;
+ std::shared_ptr<EffectContext> getContext() override;
+ RetCode releaseContext() override;
+
+ std::string getEffectName() override { return kEffectName; };
+ IEffect::Status effectProcessImpl(float* in, float* out, int samples) override;
+
+ private:
+ static const std::vector<Range::AutomaticGainControlV1Range> kRanges;
+ std::shared_ptr<AutomaticGainControlV1SwContext> mContext;
+ ndk::ScopedAStatus getParameterAutomaticGainControlV1(const AutomaticGainControlV1::Tag& tag,
+ Parameter::Specific* specific);
+};
+} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/automaticGainControl/Android.bp b/audio/aidl/default/automaticGainControlV2/Android.bp
similarity index 95%
rename from audio/aidl/default/automaticGainControl/Android.bp
rename to audio/aidl/default/automaticGainControlV2/Android.bp
index 17d6416..631cf58 100644
--- a/audio/aidl/default/automaticGainControl/Android.bp
+++ b/audio/aidl/default/automaticGainControlV2/Android.bp
@@ -24,14 +24,14 @@
}
cc_library_shared {
- name: "libagcsw",
+ name: "libagc2sw",
defaults: [
"aidlaudioeffectservice_defaults",
"latest_android_media_audio_common_types_ndk_shared",
"latest_android_hardware_audio_effect_ndk_shared",
],
srcs: [
- "AutomaticGainControlSw.cpp",
+ "AutomaticGainControlV2Sw.cpp",
":effectCommonFile",
],
relative_install_path: "soundfx",
diff --git a/audio/aidl/default/automaticGainControlV2/AutomaticGainControlV2Sw.cpp b/audio/aidl/default/automaticGainControlV2/AutomaticGainControlV2Sw.cpp
new file mode 100644
index 0000000..8441f22
--- /dev/null
+++ b/audio/aidl/default/automaticGainControlV2/AutomaticGainControlV2Sw.cpp
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <algorithm>
+#include <cstddef>
+#include <memory>
+#define LOG_TAG "AHAL_AutomaticGainControlV2Sw"
+#include <Utils.h>
+#include <unordered_set>
+
+#include <android-base/logging.h>
+#include <fmq/AidlMessageQueue.h>
+
+#include "AutomaticGainControlV2Sw.h"
+
+using aidl::android::hardware::audio::effect::AutomaticGainControlV2Sw;
+using aidl::android::hardware::audio::effect::Descriptor;
+using aidl::android::hardware::audio::effect::IEffect;
+using aidl::android::hardware::audio::effect::kAutomaticGainControlV2SwImplUUID;
+using aidl::android::media::audio::common::AudioUuid;
+
+extern "C" binder_exception_t createEffect(const AudioUuid* in_impl_uuid,
+ std::shared_ptr<IEffect>* instanceSpp) {
+ if (!in_impl_uuid || *in_impl_uuid != kAutomaticGainControlV2SwImplUUID) {
+ LOG(ERROR) << __func__ << "uuid not supported";
+ return EX_ILLEGAL_ARGUMENT;
+ }
+ if (instanceSpp) {
+ *instanceSpp = ndk::SharedRefBase::make<AutomaticGainControlV2Sw>();
+ LOG(DEBUG) << __func__ << " instance " << instanceSpp->get() << " created";
+ return EX_NONE;
+ } else {
+ LOG(ERROR) << __func__ << " invalid input parameter!";
+ return EX_ILLEGAL_ARGUMENT;
+ }
+}
+
+extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descriptor* _aidl_return) {
+ if (!in_impl_uuid || *in_impl_uuid != kAutomaticGainControlV2SwImplUUID) {
+ LOG(ERROR) << __func__ << "uuid not supported";
+ return EX_ILLEGAL_ARGUMENT;
+ }
+ *_aidl_return = AutomaticGainControlV2Sw::kDescriptor;
+ return EX_NONE;
+}
+
+namespace aidl::android::hardware::audio::effect {
+
+const std::string AutomaticGainControlV2Sw::kEffectName = "AutomaticGainControlV2Sw";
+
+const std::vector<Range::AutomaticGainControlV2Range> AutomaticGainControlV2Sw::kRanges = {
+ MAKE_RANGE(AutomaticGainControlV2, fixedDigitalGainMb, 0, 50000),
+ MAKE_RANGE(AutomaticGainControlV2, saturationMarginMb, 0, 10000)};
+
+const Capability AutomaticGainControlV2Sw::kCapability = {
+ .range = AutomaticGainControlV2Sw::kRanges};
+
+const Descriptor AutomaticGainControlV2Sw::kDescriptor = {
+ .common = {.id = {.type = kAutomaticGainControlV2TypeUUID,
+ .uuid = kAutomaticGainControlV2SwImplUUID,
+ .proxy = std::nullopt},
+ .flags = {.type = Flags::Type::INSERT,
+ .insert = Flags::Insert::FIRST,
+ .volume = Flags::Volume::CTRL},
+ .name = AutomaticGainControlV2Sw::kEffectName,
+ .implementor = "The Android Open Source Project"},
+ .capability = AutomaticGainControlV2Sw::kCapability};
+
+ndk::ScopedAStatus AutomaticGainControlV2Sw::getDescriptor(Descriptor* _aidl_return) {
+ LOG(DEBUG) << __func__ << kDescriptor.toString();
+ *_aidl_return = kDescriptor;
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus AutomaticGainControlV2Sw::setParameterSpecific(
+ const Parameter::Specific& specific) {
+ RETURN_IF(Parameter::Specific::automaticGainControlV2 != specific.getTag(), EX_ILLEGAL_ARGUMENT,
+ "EffectNotSupported");
+ RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
+
+ auto& param = specific.get<Parameter::Specific::automaticGainControlV2>();
+ RETURN_IF(!inRange(param, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
+ auto tag = param.getTag();
+ switch (tag) {
+ case AutomaticGainControlV2::fixedDigitalGainMb: {
+ RETURN_IF(mContext->setDigitalGain(
+ param.get<AutomaticGainControlV2::fixedDigitalGainMb>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "digitalGainNotSupported");
+ return ndk::ScopedAStatus::ok();
+ }
+ case AutomaticGainControlV2::levelEstimator: {
+ RETURN_IF(mContext->setLevelEstimator(
+ param.get<AutomaticGainControlV2::levelEstimator>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "levelEstimatorNotSupported");
+ return ndk::ScopedAStatus::ok();
+ }
+ case AutomaticGainControlV2::saturationMarginMb: {
+ RETURN_IF(mContext->setSaturationMargin(
+ param.get<AutomaticGainControlV2::saturationMarginMb>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "saturationMarginNotSupported");
+ return ndk::ScopedAStatus::ok();
+ }
+ default: {
+ LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
+ EX_ILLEGAL_ARGUMENT, "AutomaticGainControlV2TagNotSupported");
+ }
+ }
+}
+
+ndk::ScopedAStatus AutomaticGainControlV2Sw::getParameterSpecific(const Parameter::Id& id,
+ Parameter::Specific* specific) {
+ auto tag = id.getTag();
+ RETURN_IF(Parameter::Id::automaticGainControlV2Tag != tag, EX_ILLEGAL_ARGUMENT, "wrongIdTag");
+ auto specificId = id.get<Parameter::Id::automaticGainControlV2Tag>();
+ auto specificIdTag = specificId.getTag();
+ switch (specificIdTag) {
+ case AutomaticGainControlV2::Id::commonTag:
+ return getParameterAutomaticGainControlV2(
+ specificId.get<AutomaticGainControlV2::Id::commonTag>(), specific);
+ default:
+ LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
+ EX_ILLEGAL_ARGUMENT, "AutomaticGainControlV2TagNotSupported");
+ }
+}
+
+ndk::ScopedAStatus AutomaticGainControlV2Sw::getParameterAutomaticGainControlV2(
+ const AutomaticGainControlV2::Tag& tag, Parameter::Specific* specific) {
+ RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
+ AutomaticGainControlV2 param;
+ switch (tag) {
+ case AutomaticGainControlV2::fixedDigitalGainMb: {
+ param.set<AutomaticGainControlV2::fixedDigitalGainMb>(mContext->getDigitalGain());
+ break;
+ }
+ case AutomaticGainControlV2::levelEstimator: {
+ param.set<AutomaticGainControlV2::levelEstimator>(mContext->getLevelEstimator());
+ break;
+ }
+ case AutomaticGainControlV2::saturationMarginMb: {
+ param.set<AutomaticGainControlV2::saturationMarginMb>(mContext->getSaturationMargin());
+ break;
+ }
+ default: {
+ LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
+ EX_ILLEGAL_ARGUMENT, "AutomaticGainControlV2TagNotSupported");
+ }
+ }
+
+ specific->set<Parameter::Specific::automaticGainControlV2>(param);
+ return ndk::ScopedAStatus::ok();
+}
+
+std::shared_ptr<EffectContext> AutomaticGainControlV2Sw::createContext(
+ const Parameter::Common& common) {
+ if (mContext) {
+ LOG(DEBUG) << __func__ << " context already exist";
+ } else {
+ mContext =
+ std::make_shared<AutomaticGainControlV2SwContext>(1 /* statusFmqDepth */, common);
+ }
+ return mContext;
+}
+
+std::shared_ptr<EffectContext> AutomaticGainControlV2Sw::getContext() {
+ return mContext;
+}
+
+RetCode AutomaticGainControlV2Sw::releaseContext() {
+ if (mContext) {
+ mContext.reset();
+ }
+ return RetCode::SUCCESS;
+}
+
+// Processing method running in EffectWorker thread.
+IEffect::Status AutomaticGainControlV2Sw::effectProcessImpl(float* in, float* out, int samples) {
+ // TODO: get data buffer and process.
+ LOG(DEBUG) << __func__ << " in " << in << " out " << out << " samples " << samples;
+ for (int i = 0; i < samples; i++) {
+ *out++ = *in++;
+ }
+ return {STATUS_OK, samples, samples};
+}
+
+RetCode AutomaticGainControlV2SwContext::setDigitalGain(int gain) {
+ mDigitalGain = gain;
+ return RetCode::SUCCESS;
+}
+
+int AutomaticGainControlV2SwContext::getDigitalGain() {
+ return mDigitalGain;
+}
+
+RetCode AutomaticGainControlV2SwContext::setLevelEstimator(
+ AutomaticGainControlV2::LevelEstimator levelEstimator) {
+ mLevelEstimator = levelEstimator;
+ return RetCode::SUCCESS;
+}
+
+AutomaticGainControlV2::LevelEstimator AutomaticGainControlV2SwContext::getLevelEstimator() {
+ return mLevelEstimator;
+}
+
+RetCode AutomaticGainControlV2SwContext::setSaturationMargin(int margin) {
+ mSaturationMargin = margin;
+ return RetCode::SUCCESS;
+}
+
+int AutomaticGainControlV2SwContext::getSaturationMargin() {
+ return mSaturationMargin;
+}
+
+} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/automaticGainControl/AutomaticGainControlSw.h b/audio/aidl/default/automaticGainControlV2/AutomaticGainControlV2Sw.h
similarity index 68%
rename from audio/aidl/default/automaticGainControl/AutomaticGainControlSw.h
rename to audio/aidl/default/automaticGainControlV2/AutomaticGainControlV2Sw.h
index 2724835..0b50f4d 100644
--- a/audio/aidl/default/automaticGainControl/AutomaticGainControlSw.h
+++ b/audio/aidl/default/automaticGainControlV2/AutomaticGainControlV2Sw.h
@@ -26,35 +26,35 @@
namespace aidl::android::hardware::audio::effect {
-class AutomaticGainControlSwContext final : public EffectContext {
+class AutomaticGainControlV2SwContext final : public EffectContext {
public:
- AutomaticGainControlSwContext(int statusDepth, const Parameter::Common& common)
+ AutomaticGainControlV2SwContext(int statusDepth, const Parameter::Common& common)
: EffectContext(statusDepth, common) {
LOG(DEBUG) << __func__;
}
RetCode setDigitalGain(int gain);
int getDigitalGain();
- RetCode setLevelEstimator(AutomaticGainControl::LevelEstimator levelEstimator);
- AutomaticGainControl::LevelEstimator getLevelEstimator();
+ RetCode setLevelEstimator(AutomaticGainControlV2::LevelEstimator levelEstimator);
+ AutomaticGainControlV2::LevelEstimator getLevelEstimator();
RetCode setSaturationMargin(int margin);
int getSaturationMargin();
private:
int mDigitalGain = 0;
- AutomaticGainControl::LevelEstimator mLevelEstimator =
- AutomaticGainControl::LevelEstimator::RMS;
+ AutomaticGainControlV2::LevelEstimator mLevelEstimator =
+ AutomaticGainControlV2::LevelEstimator::RMS;
int mSaturationMargin = 0;
};
-class AutomaticGainControlSw final : public EffectImpl {
+class AutomaticGainControlV2Sw final : public EffectImpl {
public:
static const std::string kEffectName;
static const bool kStrengthSupported;
- static const AutomaticGainControl::Capability kCapability;
+ static const Capability kCapability;
static const Descriptor kDescriptor;
- AutomaticGainControlSw() { LOG(DEBUG) << __func__; }
- ~AutomaticGainControlSw() {
+ AutomaticGainControlV2Sw() { LOG(DEBUG) << __func__; }
+ ~AutomaticGainControlV2Sw() {
cleanUp();
LOG(DEBUG) << __func__;
}
@@ -72,8 +72,9 @@
IEffect::Status effectProcessImpl(float* in, float* out, int samples) override;
private:
- std::shared_ptr<AutomaticGainControlSwContext> mContext;
- ndk::ScopedAStatus getParameterAutomaticGainControl(const AutomaticGainControl::Tag& tag,
- Parameter::Specific* specific);
+ static const std::vector<Range::AutomaticGainControlV2Range> kRanges;
+ std::shared_ptr<AutomaticGainControlV2SwContext> mContext;
+ ndk::ScopedAStatus getParameterAutomaticGainControlV2(const AutomaticGainControlV2::Tag& tag,
+ Parameter::Specific* specific);
};
} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/bassboost/BassBoostSw.cpp b/audio/aidl/default/bassboost/BassBoostSw.cpp
index 0c7ebe1..e50f0a2 100644
--- a/audio/aidl/default/bassboost/BassBoostSw.cpp
+++ b/audio/aidl/default/bassboost/BassBoostSw.cpp
@@ -61,9 +61,10 @@
namespace aidl::android::hardware::audio::effect {
const std::string BassBoostSw::kEffectName = "BassBoostSw";
-const bool BassBoostSw::kStrengthSupported = true;
-const BassBoost::Capability BassBoostSw::kCapability = {.maxStrengthPm = 1000,
- .strengthSupported = kStrengthSupported};
+
+const std::vector<Range::BassBoostRange> BassBoostSw::kRanges = {
+ MAKE_RANGE(BassBoost, strengthPm, 0, 1000)};
+const Capability BassBoostSw::kCapability = {.range = {BassBoostSw::kRanges}};
const Descriptor BassBoostSw::kDescriptor = {
.common = {.id = {.type = kBassBoostTypeUUID,
.uuid = kBassBoostSwImplUUID,
@@ -73,7 +74,7 @@
.volume = Flags::Volume::CTRL},
.name = BassBoostSw::kEffectName,
.implementor = "The Android Open Source Project"},
- .capability = Capability::make<Capability::bassBoost>(BassBoostSw::kCapability)};
+ .capability = BassBoostSw::kCapability};
ndk::ScopedAStatus BassBoostSw::getDescriptor(Descriptor* _aidl_return) {
LOG(DEBUG) << __func__ << kDescriptor.toString();
@@ -87,15 +88,14 @@
RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
auto& bbParam = specific.get<Parameter::Specific::bassBoost>();
+ RETURN_IF(!inRange(bbParam, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
auto tag = bbParam.getTag();
switch (tag) {
case BassBoost::strengthPm: {
- RETURN_IF(!kStrengthSupported, EX_ILLEGAL_ARGUMENT, "SettingStrengthNotSupported");
-
- RETURN_IF(mContext->setBbStrengthPm(bbParam.get<BassBoost::strengthPm>()) !=
- RetCode::SUCCESS,
- EX_ILLEGAL_ARGUMENT, "strengthPmNotSupported");
+ const auto strength = bbParam.get<BassBoost::strengthPm>();
+ RETURN_IF(mContext->setBbStrengthPm(strength) != RetCode::SUCCESS, EX_ILLEGAL_ARGUMENT,
+ "strengthPmNotSupported");
return ndk::ScopedAStatus::ok();
}
default: {
@@ -173,11 +173,6 @@
}
RetCode BassBoostSwContext::setBbStrengthPm(int strength) {
- if (strength < 0 || strength > BassBoostSw::kCapability.maxStrengthPm) {
- LOG(ERROR) << __func__ << " invalid strength: " << strength;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
- // TODO : Add implementation to apply new strength
mStrength = strength;
return RetCode::SUCCESS;
}
diff --git a/audio/aidl/default/bassboost/BassBoostSw.h b/audio/aidl/default/bassboost/BassBoostSw.h
index 65c01c8..8d183dd 100644
--- a/audio/aidl/default/bassboost/BassBoostSw.h
+++ b/audio/aidl/default/bassboost/BassBoostSw.h
@@ -43,8 +43,7 @@
class BassBoostSw final : public EffectImpl {
public:
static const std::string kEffectName;
- static const bool kStrengthSupported;
- static const BassBoost::Capability kCapability;
+ static const Capability kCapability;
static const Descriptor kDescriptor;
BassBoostSw() { LOG(DEBUG) << __func__; }
~BassBoostSw() {
@@ -65,6 +64,7 @@
IEffect::Status effectProcessImpl(float* in, float* out, int samples) override;
private:
+ static const std::vector<Range::BassBoostRange> kRanges;
std::shared_ptr<BassBoostSwContext> mContext;
ndk::ScopedAStatus getParameterBassBoost(const BassBoost::Tag& tag,
Parameter::Specific* specific);
diff --git a/audio/aidl/default/downmix/DownmixSw.cpp b/audio/aidl/default/downmix/DownmixSw.cpp
index 7bb958d..0af95d0 100644
--- a/audio/aidl/default/downmix/DownmixSw.cpp
+++ b/audio/aidl/default/downmix/DownmixSw.cpp
@@ -60,17 +60,14 @@
namespace aidl::android::hardware::audio::effect {
const std::string DownmixSw::kEffectName = "DownmixSw";
-const Downmix::Capability DownmixSw::kCapability;
const Descriptor DownmixSw::kDescriptor = {
- .common = {.id = {.type = kDownmixTypeUUID,
- .uuid = kDownmixSwImplUUID,
- .proxy = std::nullopt},
- .flags = {.type = Flags::Type::INSERT,
- .insert = Flags::Insert::FIRST,
- .volume = Flags::Volume::CTRL},
- .name = kEffectName,
- .implementor = "The Android Open Source Project"},
- .capability = Capability::make<Capability::downmix>(kCapability)};
+ .common = {
+ .id = {.type = kDownmixTypeUUID, .uuid = kDownmixSwImplUUID, .proxy = std::nullopt},
+ .flags = {.type = Flags::Type::INSERT,
+ .insert = Flags::Insert::FIRST,
+ .volume = Flags::Volume::CTRL},
+ .name = kEffectName,
+ .implementor = "The Android Open Source Project"}};
ndk::ScopedAStatus DownmixSw::getDescriptor(Descriptor* _aidl_return) {
LOG(DEBUG) << __func__ << kDescriptor.toString();
diff --git a/audio/aidl/default/downmix/DownmixSw.h b/audio/aidl/default/downmix/DownmixSw.h
index 51546c1..37c978b 100644
--- a/audio/aidl/default/downmix/DownmixSw.h
+++ b/audio/aidl/default/downmix/DownmixSw.h
@@ -47,7 +47,7 @@
class DownmixSw final : public EffectImpl {
public:
static const std::string kEffectName;
- static const Downmix::Capability kCapability;
+ static const Capability kCapability;
static const Descriptor kDescriptor;
DownmixSw() { LOG(DEBUG) << __func__; }
~DownmixSw() {
diff --git a/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.cpp b/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.cpp
index 0ffbaa1..da6d0c6 100644
--- a/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.cpp
+++ b/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.cpp
@@ -61,8 +61,33 @@
namespace aidl::android::hardware::audio::effect {
const std::string DynamicsProcessingSw::kEffectName = "DynamicsProcessingSw";
-const DynamicsProcessing::Capability DynamicsProcessingSw::kCapability = {.minCutOffFreq = 220,
- .maxCutOffFreq = 20000};
+const DynamicsProcessing::EqBandConfig DynamicsProcessingSw::kEqBandConfigMin =
+ DynamicsProcessing::EqBandConfig({.channel = 0,
+ .band = 0,
+ .enable = false,
+ .cutoffFrequencyHz = 220,
+ .gainDb = std::numeric_limits<float>::min()});
+const DynamicsProcessing::EqBandConfig DynamicsProcessingSw::kEqBandConfigMax =
+ DynamicsProcessing::EqBandConfig({.channel = std::numeric_limits<int>::max(),
+ .band = std::numeric_limits<int>::max(),
+ .enable = true,
+ .cutoffFrequencyHz = 20000,
+ .gainDb = std::numeric_limits<float>::max()});
+const Range::DynamicsProcessingRange DynamicsProcessingSw::kPreEqBandRange = {
+ .min = DynamicsProcessing::make<DynamicsProcessing::preEqBand>(
+ {DynamicsProcessingSw::kEqBandConfigMin}),
+ .max = DynamicsProcessing::make<DynamicsProcessing::preEqBand>(
+ {DynamicsProcessingSw::kEqBandConfigMax})};
+const Range::DynamicsProcessingRange DynamicsProcessingSw::kPostEqBandRange = {
+ .min = DynamicsProcessing::make<DynamicsProcessing::postEqBand>(
+ {DynamicsProcessingSw::kEqBandConfigMin}),
+ .max = DynamicsProcessing::make<DynamicsProcessing::postEqBand>(
+ {DynamicsProcessingSw::kEqBandConfigMax})};
+
+const std::vector<Range::DynamicsProcessingRange> DynamicsProcessingSw::kRanges = {
+ DynamicsProcessingSw::kPreEqBandRange, DynamicsProcessingSw::kPostEqBandRange};
+const Capability DynamicsProcessingSw::kCapability = {.range = DynamicsProcessingSw::kRanges};
+
const Descriptor DynamicsProcessingSw::kDescriptor = {
.common = {.id = {.type = kDynamicsProcessingTypeUUID,
.uuid = kDynamicsProcessingSwImplUUID,
@@ -72,8 +97,7 @@
.volume = Flags::Volume::CTRL},
.name = DynamicsProcessingSw::kEffectName,
.implementor = "The Android Open Source Project"},
- .capability = Capability::make<Capability::dynamicsProcessing>(
- DynamicsProcessingSw::kCapability)};
+ .capability = DynamicsProcessingSw::kCapability};
ndk::ScopedAStatus DynamicsProcessingSw::getDescriptor(Descriptor* _aidl_return) {
LOG(DEBUG) << __func__ << kDescriptor.toString();
@@ -341,7 +365,6 @@
LOG(WARNING) << __func__ << " skip invalid band " << cfg.toString();
ret = RetCode::ERROR_ILLEGAL_PARAMETER;
continue;
- ;
}
targetCfgs[cfg.channel * stage.bandCount + cfg.band] = cfg;
}
@@ -380,7 +403,6 @@
LOG(WARNING) << __func__ << " skip invalid band " << it.toString();
ret = RetCode::ERROR_ILLEGAL_PARAMETER;
continue;
- ;
}
mMbcChBands[it.channel * bandCount + it.band] = it;
}
@@ -462,11 +484,6 @@
return ret;
}
-bool DynamicsProcessingSwContext::validateCutoffFrequency(float freq) {
- return freq >= DynamicsProcessingSw::kCapability.minCutOffFreq &&
- freq <= DynamicsProcessingSw::kCapability.maxCutOffFreq;
-}
-
bool DynamicsProcessingSwContext::validateStageEnablement(
const DynamicsProcessing::StageEnablement& enablement) {
return !enablement.inUse || (enablement.inUse && enablement.bandCount > 0);
@@ -484,7 +501,7 @@
const std::vector<DynamicsProcessing::ChannelConfig>& channelConfig) {
return band.channel >= 0 && band.channel < maxChannel &&
(size_t)band.channel < channelConfig.size() && channelConfig[band.channel].enable &&
- band.band >= 0 && band.band < maxBand && validateCutoffFrequency(band.cutoffFrequencyHz);
+ band.band >= 0 && band.band < maxBand;
}
bool DynamicsProcessingSwContext::validateMbcBandConfig(
@@ -492,8 +509,7 @@
const std::vector<DynamicsProcessing::ChannelConfig>& channelConfig) {
return band.channel >= 0 && band.channel < maxChannel &&
(size_t)band.channel < channelConfig.size() && channelConfig[band.channel].enable &&
- band.band >= 0 && band.band < maxBand &&
- validateCutoffFrequency(band.cutoffFrequencyHz) && band.attackTimeMs >= 0 &&
+ band.band >= 0 && band.band < maxBand && band.attackTimeMs >= 0 &&
band.releaseTimeMs >= 0 && band.ratio >= 0 && band.thresholdDb <= 0 &&
band.kneeWidthDb <= 0 && band.noiseGateThresholdDb <= 0 && band.expanderRatio >= 0;
}
diff --git a/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.h b/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.h
index e336df7..3e14cce 100644
--- a/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.h
+++ b/audio/aidl/default/dynamicProcessing/DynamicsProcessingSw.h
@@ -86,8 +86,6 @@
std::vector<DynamicsProcessing::EqBandConfig> mPreEqChBands;
std::vector<DynamicsProcessing::EqBandConfig> mPostEqChBands;
std::vector<DynamicsProcessing::MbcBandConfig> mMbcChBands;
-
- bool validateCutoffFrequency(float freq);
bool validateStageEnablement(const DynamicsProcessing::StageEnablement& enablement);
bool validateEngineConfig(const DynamicsProcessing::EngineArchitecture& engine);
bool validateEqBandConfig(const DynamicsProcessing::EqBandConfig& band, int maxChannel,
@@ -104,7 +102,7 @@
class DynamicsProcessingSw final : public EffectImpl {
public:
static const std::string kEffectName;
- static const DynamicsProcessing::Capability kCapability;
+ static const Capability kCapability;
static const Descriptor kDescriptor;
DynamicsProcessingSw() { LOG(DEBUG) << __func__; }
~DynamicsProcessingSw() {
@@ -125,6 +123,11 @@
std::string getEffectName() override { return kEffectName; };
private:
+ static const DynamicsProcessing::EqBandConfig kEqBandConfigMin;
+ static const DynamicsProcessing::EqBandConfig kEqBandConfigMax;
+ static const Range::DynamicsProcessingRange kPreEqBandRange;
+ static const Range::DynamicsProcessingRange kPostEqBandRange;
+ static const std::vector<Range::DynamicsProcessingRange> kRanges;
std::shared_ptr<DynamicsProcessingSwContext> mContext;
ndk::ScopedAStatus getParameterDynamicsProcessing(const DynamicsProcessing::Tag& tag,
Parameter::Specific* specific);
diff --git a/audio/aidl/default/envReverb/EnvReverbSw.cpp b/audio/aidl/default/envReverb/EnvReverbSw.cpp
index 905dba4..46d9016 100644
--- a/audio/aidl/default/envReverb/EnvReverbSw.cpp
+++ b/audio/aidl/default/envReverb/EnvReverbSw.cpp
@@ -60,18 +60,20 @@
namespace aidl::android::hardware::audio::effect {
const std::string EnvReverbSw::kEffectName = "EnvReverbSw";
-const EnvironmentalReverb::Capability EnvReverbSw::kCapability = {.minRoomLevelMb = -6000,
- .maxRoomLevelMb = 0,
- .minRoomHfLevelMb = -4000,
- .maxRoomHfLevelMb = 0,
- .maxDecayTimeMs = 7000,
- .minDecayHfRatioPm = 100,
- .maxDecayHfRatioPm = 2000,
- .minLevelMb = -6000,
- .maxLevelMb = 0,
- .maxDelayMs = 65,
- .maxDiffusionPm = 1000,
- .maxDensityPm = 1000};
+
+const std::vector<Range::EnvironmentalReverbRange> EnvReverbSw::kRanges = {
+ MAKE_RANGE(EnvironmentalReverb, roomLevelMb, -6000, 0),
+ MAKE_RANGE(EnvironmentalReverb, roomHfLevelMb, -4000, 0),
+ MAKE_RANGE(EnvironmentalReverb, decayTimeMs, 0, 7000),
+ MAKE_RANGE(EnvironmentalReverb, decayHfRatioPm, 100, 2000),
+ MAKE_RANGE(EnvironmentalReverb, levelMb, -6000, 0),
+ MAKE_RANGE(EnvironmentalReverb, delayMs, 0, 65),
+ MAKE_RANGE(EnvironmentalReverb, diffusionPm, 0, 1000),
+ MAKE_RANGE(EnvironmentalReverb, densityPm, 0, 1000)};
+
+const Capability EnvReverbSw::kCapability = {
+ .range = Range::make<Range::environmentalReverb>(EnvReverbSw::kRanges)};
+
const Descriptor EnvReverbSw::kDescriptor = {
.common = {.id = {.type = kEnvReverbTypeUUID,
.uuid = kEnvReverbSwImplUUID,
@@ -81,7 +83,7 @@
.volume = Flags::Volume::CTRL},
.name = EnvReverbSw::kEffectName,
.implementor = "The Android Open Source Project"},
- .capability = Capability::make<Capability::environmentalReverb>(EnvReverbSw::kCapability)};
+ .capability = EnvReverbSw::kCapability};
ndk::ScopedAStatus EnvReverbSw::getDescriptor(Descriptor* _aidl_return) {
LOG(DEBUG) << __func__ << kDescriptor.toString();
@@ -94,8 +96,8 @@
"EffectNotSupported");
auto& erParam = specific.get<Parameter::Specific::environmentalReverb>();
+ RETURN_IF(!inRange(erParam, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
auto tag = erParam.getTag();
-
switch (tag) {
case EnvironmentalReverb::roomLevelMb: {
RETURN_IF(mContext->setErRoomLevel(erParam.get<EnvironmentalReverb::roomLevelMb>()) !=
@@ -262,85 +264,41 @@
}
RetCode EnvReverbSwContext::setErRoomLevel(int roomLevel) {
- if (roomLevel < EnvReverbSw::kCapability.minRoomLevelMb ||
- roomLevel > EnvReverbSw::kCapability.maxRoomLevelMb) {
- LOG(ERROR) << __func__ << " invalid roomLevel: " << roomLevel;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
- // TODO : Add implementation to apply new room level
mRoomLevel = roomLevel;
return RetCode::SUCCESS;
}
RetCode EnvReverbSwContext::setErRoomHfLevel(int roomHfLevel) {
- if (roomHfLevel < EnvReverbSw::kCapability.minRoomHfLevelMb ||
- roomHfLevel > EnvReverbSw::kCapability.maxRoomHfLevelMb) {
- LOG(ERROR) << __func__ << " invalid roomHfLevel: " << roomHfLevel;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
- // TODO : Add implementation to apply new room HF level
mRoomHfLevel = roomHfLevel;
return RetCode::SUCCESS;
}
RetCode EnvReverbSwContext::setErDecayTime(int decayTime) {
- if (decayTime < 0 || decayTime > EnvReverbSw::kCapability.maxDecayTimeMs) {
- LOG(ERROR) << __func__ << " invalid decayTime: " << decayTime;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
- // TODO : Add implementation to apply new decay time
mDecayTime = decayTime;
return RetCode::SUCCESS;
}
RetCode EnvReverbSwContext::setErDecayHfRatio(int decayHfRatio) {
- if (decayHfRatio < EnvReverbSw::kCapability.minDecayHfRatioPm ||
- decayHfRatio > EnvReverbSw::kCapability.maxDecayHfRatioPm) {
- LOG(ERROR) << __func__ << " invalid decayHfRatio: " << decayHfRatio;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
- // TODO : Add implementation to apply new decay HF ratio
mDecayHfRatio = decayHfRatio;
return RetCode::SUCCESS;
}
RetCode EnvReverbSwContext::setErLevel(int level) {
- if (level < EnvReverbSw::kCapability.minLevelMb ||
- level > EnvReverbSw::kCapability.maxLevelMb) {
- LOG(ERROR) << __func__ << " invalid level: " << level;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
- // TODO : Add implementation to apply new level
mLevel = level;
return RetCode::SUCCESS;
}
RetCode EnvReverbSwContext::setErDelay(int delay) {
- if (delay < 0 || delay > EnvReverbSw::kCapability.maxDelayMs) {
- LOG(ERROR) << __func__ << " invalid delay: " << delay;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
- // TODO : Add implementation to apply new delay
mDelay = delay;
return RetCode::SUCCESS;
}
RetCode EnvReverbSwContext::setErDiffusion(int diffusion) {
- if (diffusion < 0 || diffusion > EnvReverbSw::kCapability.maxDiffusionPm) {
- LOG(ERROR) << __func__ << " invalid diffusion: " << diffusion;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
- // TODO : Add implementation to apply new diffusion
mDiffusion = diffusion;
return RetCode::SUCCESS;
}
RetCode EnvReverbSwContext::setErDensity(int density) {
- if (density < 0 || density > EnvReverbSw::kCapability.maxDensityPm) {
- LOG(ERROR) << __func__ << " invalid density: " << density;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
- // TODO : Add implementation to apply new density
mDensity = density;
return RetCode::SUCCESS;
}
diff --git a/audio/aidl/default/envReverb/EnvReverbSw.h b/audio/aidl/default/envReverb/EnvReverbSw.h
index 77f384e..4f11a5c 100644
--- a/audio/aidl/default/envReverb/EnvReverbSw.h
+++ b/audio/aidl/default/envReverb/EnvReverbSw.h
@@ -79,7 +79,7 @@
class EnvReverbSw final : public EffectImpl {
public:
static const std::string kEffectName;
- static const EnvironmentalReverb::Capability kCapability;
+ static const Capability kCapability;
static const Descriptor kDescriptor;
EnvReverbSw() { LOG(DEBUG) << __func__; }
~EnvReverbSw() {
@@ -100,6 +100,7 @@
std::string getEffectName() override { return kEffectName; }
private:
+ static const std::vector<Range::EnvironmentalReverbRange> kRanges;
std::shared_ptr<EnvReverbSwContext> mContext;
ndk::ScopedAStatus getParameterEnvironmentalReverb(const EnvironmentalReverb::Tag& tag,
Parameter::Specific* specific);
diff --git a/audio/aidl/default/equalizer/EqualizerSw.cpp b/audio/aidl/default/equalizer/EqualizerSw.cpp
index 984b943..2814322 100644
--- a/audio/aidl/default/equalizer/EqualizerSw.cpp
+++ b/audio/aidl/default/equalizer/EqualizerSw.cpp
@@ -60,6 +60,7 @@
namespace aidl::android::hardware::audio::effect {
const std::string EqualizerSw::kEffectName = "EqualizerSw";
+
const std::vector<Equalizer::BandFrequency> EqualizerSw::kBandFrequency = {{0, 30000, 120000},
{1, 120001, 460000},
{2, 460001, 1800000},
@@ -69,19 +70,34 @@
{0, "Normal"}, {1, "Classical"}, {2, "Dance"}, {3, "Flat"}, {4, "Folk"},
{5, "Heavy Metal"}, {6, "Hip Hop"}, {7, "Jazz"}, {8, "Pop"}, {9, "Rock"}};
-const Equalizer::Capability EqualizerSw::kEqCap = {.bandFrequencies = kBandFrequency,
- .presets = kPresets};
+/**
+ * Use the same min and max to build a capability represented by Range.
+ */
+const std::vector<Range::EqualizerRange> EqualizerSw::kRanges = {
+ MAKE_RANGE(Equalizer, preset, 0, EqualizerSw::kPresets.size() - 1),
+ MAKE_RANGE(Equalizer, bandLevels,
+ std::vector<Equalizer::BandLevel>{Equalizer::BandLevel(
+ {.index = 0, .levelMb = std::numeric_limits<int>::min()})},
+ std::vector<Equalizer::BandLevel>{
+ Equalizer::BandLevel({.index = EqualizerSwContext::kMaxBandNumber - 1,
+ .levelMb = std::numeric_limits<int>::max()})}),
+ /* capability definition */
+ MAKE_RANGE(Equalizer, bandFrequencies, EqualizerSw::kBandFrequency,
+ EqualizerSw::kBandFrequency),
+ MAKE_RANGE(Equalizer, presets, EqualizerSw::kPresets, EqualizerSw::kPresets),
+ /* centerFreqMh is get only, set invalid range min > max */
+ MAKE_RANGE(Equalizer, centerFreqMh, std::vector<int>({1}), std::vector<int>({0}))};
-const Descriptor EqualizerSw::kDesc = {
- .common = {.id = {.type = kEqualizerTypeUUID,
- .uuid = kEqualizerSwImplUUID,
- .proxy = kEqualizerProxyUUID},
- .flags = {.type = Flags::Type::INSERT,
- .insert = Flags::Insert::FIRST,
- .volume = Flags::Volume::CTRL},
- .name = EqualizerSw::kEffectName,
- .implementor = "The Android Open Source Project"},
- .capability = Capability::make<Capability::equalizer>(EqualizerSw::kEqCap)};
+const Capability EqualizerSw::kEqCap = {.range = EqualizerSw::kRanges};
+const Descriptor EqualizerSw::kDesc = {.common = {.id = {.type = kEqualizerTypeUUID,
+ .uuid = kEqualizerSwImplUUID,
+ .proxy = kEqualizerProxyUUID},
+ .flags = {.type = Flags::Type::INSERT,
+ .insert = Flags::Insert::FIRST,
+ .volume = Flags::Volume::CTRL},
+ .name = EqualizerSw::kEffectName,
+ .implementor = "The Android Open Source Project"},
+ .capability = EqualizerSw::kEqCap};
ndk::ScopedAStatus EqualizerSw::getDescriptor(Descriptor* _aidl_return) {
LOG(DEBUG) << __func__ << kDesc.toString();
@@ -95,6 +111,7 @@
RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
auto& eqParam = specific.get<Parameter::Specific::equalizer>();
+ RETURN_IF(!inRange(eqParam, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
auto tag = eqParam.getTag();
switch (tag) {
case Equalizer::preset: {
@@ -150,6 +167,10 @@
eqParam.set<Equalizer::preset>(mContext->getEqPreset());
break;
}
+ case Equalizer::centerFreqMh: {
+ eqParam.set<Equalizer::centerFreqMh>(mContext->getCenterFreqs());
+ break;
+ }
default: {
LOG(ERROR) << __func__ << " not handled tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
diff --git a/audio/aidl/default/equalizer/EqualizerSw.h b/audio/aidl/default/equalizer/EqualizerSw.h
index 65a8002..f8987c7 100644
--- a/audio/aidl/default/equalizer/EqualizerSw.h
+++ b/audio/aidl/default/equalizer/EqualizerSw.h
@@ -34,7 +34,7 @@
}
RetCode setEqPreset(const int& presetIdx) {
- if (presetIdx < 0 || presetIdx >= NUM_OF_PRESETS) {
+ if (presetIdx < 0 || presetIdx >= kMaxPresetNumber) {
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
mPreset = presetIdx;
@@ -43,13 +43,13 @@
int getEqPreset() { return mPreset; }
RetCode setEqBandLevels(const std::vector<Equalizer::BandLevel>& bandLevels) {
- if (bandLevels.size() > NUM_OF_BANDS) {
- LOG(ERROR) << __func__ << " return because size exceed " << NUM_OF_BANDS;
+ if (bandLevels.size() > kMaxBandNumber) {
+ LOG(ERROR) << __func__ << " return because size exceed " << kMaxBandNumber;
return RetCode::ERROR_ILLEGAL_PARAMETER;
}
RetCode ret = RetCode::SUCCESS;
for (auto& it : bandLevels) {
- if (it.index >= NUM_OF_BANDS || it.index < 0) {
+ if (it.index >= kMaxBandNumber || it.index < 0) {
LOG(ERROR) << __func__ << " index illegal, skip: " << it.index << " - "
<< it.levelMb;
ret = RetCode::ERROR_ILLEGAL_PARAMETER;
@@ -62,19 +62,25 @@
std::vector<Equalizer::BandLevel> getEqBandLevels() {
std::vector<Equalizer::BandLevel> bandLevels;
- for (int i = 0; i < NUM_OF_BANDS; i++) {
+ for (int i = 0; i < kMaxBandNumber; i++) {
bandLevels.push_back({i, mBandLevels[i]});
}
return bandLevels;
}
+ std::vector<int> getCenterFreqs() {
+ return {std::begin(kPresetsFrequencies), std::end(kPresetsFrequencies)};
+ }
+ static const int kMaxBandNumber = 5;
+ static const int kMaxPresetNumber = 10;
+ static const int kCustomPreset = -1;
+
private:
- static const int NUM_OF_BANDS = 5;
- static const int NUM_OF_PRESETS = 10;
- static const int PRESET_CUSTOM = -1;
+ static constexpr std::array<uint16_t, kMaxBandNumber> kPresetsFrequencies = {60, 230, 910, 3600,
+ 14000};
// preset band level
- int mPreset = PRESET_CUSTOM;
- int32_t mBandLevels[NUM_OF_BANDS] = {3, 0, 0, 0, 3};
+ int mPreset = kCustomPreset;
+ int32_t mBandLevels[kMaxBandNumber] = {3, 0, 0, 0, 3};
// Add equalizer specific context for processing here
};
@@ -82,9 +88,7 @@
class EqualizerSw final : public EffectImpl {
public:
static const std::string kEffectName;
- static const std::vector<Equalizer::BandFrequency> kBandFrequency;
- static const std::vector<Equalizer::Preset> kPresets;
- static const Equalizer::Capability kEqCap;
+ static const Capability kEqCap;
static const Descriptor kDesc;
EqualizerSw() { LOG(DEBUG) << __func__; }
@@ -106,6 +110,9 @@
std::string getEffectName() override { return kEffectName; }
private:
+ static const std::vector<Equalizer::BandFrequency> kBandFrequency;
+ static const std::vector<Equalizer::Preset> kPresets;
+ static const std::vector<Range::EqualizerRange> kRanges;
ndk::ScopedAStatus getParameterEqualizer(const Equalizer::Tag& tag,
Parameter::Specific* specific);
std::shared_ptr<EqualizerSwContext> mContext;
diff --git a/audio/aidl/default/hapticGenerator/HapticGeneratorSw.cpp b/audio/aidl/default/hapticGenerator/HapticGeneratorSw.cpp
index 3c3b66f..6037ad2 100644
--- a/audio/aidl/default/hapticGenerator/HapticGeneratorSw.cpp
+++ b/audio/aidl/default/hapticGenerator/HapticGeneratorSw.cpp
@@ -60,8 +60,6 @@
namespace aidl::android::hardware::audio::effect {
const std::string HapticGeneratorSw::kEffectName = "HapticGeneratorSw";
-/* capabilities */
-const HapticGenerator::Capability HapticGeneratorSw::kCapability;
/* Effect descriptor */
const Descriptor HapticGeneratorSw::kDescriptor = {
.common = {.id = {.type = kHapticGeneratorTypeUUID,
@@ -71,9 +69,7 @@
.insert = Flags::Insert::FIRST,
.volume = Flags::Volume::CTRL},
.name = HapticGeneratorSw::kEffectName,
- .implementor = "The Android Open Source Project"},
- .capability =
- Capability::make<Capability::hapticGenerator>(HapticGeneratorSw::kCapability)};
+ .implementor = "The Android Open Source Project"}};
ndk::ScopedAStatus HapticGeneratorSw::getDescriptor(Descriptor* _aidl_return) {
LOG(DEBUG) << __func__ << kDescriptor.toString();
diff --git a/audio/aidl/default/hapticGenerator/HapticGeneratorSw.h b/audio/aidl/default/hapticGenerator/HapticGeneratorSw.h
index 7159501..428f460 100644
--- a/audio/aidl/default/hapticGenerator/HapticGeneratorSw.h
+++ b/audio/aidl/default/hapticGenerator/HapticGeneratorSw.h
@@ -58,7 +58,6 @@
class HapticGeneratorSw final : public EffectImpl {
public:
static const std::string kEffectName;
- static const HapticGenerator::Capability kCapability;
static const Descriptor kDescriptor;
HapticGeneratorSw() { LOG(DEBUG) << __func__; }
~HapticGeneratorSw() {
diff --git a/audio/aidl/default/include/effect-impl/EffectThread.h b/audio/aidl/default/include/effect-impl/EffectThread.h
index 4b6cecd..9b1a75b 100644
--- a/audio/aidl/default/include/effect-impl/EffectThread.h
+++ b/audio/aidl/default/include/effect-impl/EffectThread.h
@@ -54,6 +54,9 @@
* EffectThread will make sure effectProcessImpl only be called after startThread() successful
* and before stopThread() successful.
*
+ * effectProcessImpl implementation must not call any EffectThread interface, otherwise it will
+ * cause deadlock.
+ *
* @param in address of input float buffer.
* @param out address of output float buffer.
* @param samples number of samples to process.
@@ -62,16 +65,11 @@
virtual IEffect::Status effectProcessImpl(float* in, float* out, int samples) = 0;
/**
- * The default EffectThread::process() implementation doesn't need to lock. It will only
- * access the FMQ and mWorkBuffer in EffectContext, since they will only be changed in
- * EffectImpl IEffect::open() (in this case EffectThread just created and not running yet) and
- * IEffect::command(CommandId::RESET) (in this case EffectThread already stopped).
- *
- * process() call effectProcessImpl for effect processing, and because effectProcessImpl is
- * implemented by effects, process() must not hold lock before call into effectProcessImpl to
- * avoid deadlock.
+ * process() call effectProcessImpl() for effect data processing, it is necessary for the
+ * processing to be called under Effect thread mutex mThreadMutex, to avoid the effect state
+ * change before/during data processing, and keep the thread and effect state consistent.
*/
- virtual void process();
+ virtual void process_l() REQUIRES(mThreadMutex);
private:
const int kMaxTaskNameLen = 15;
@@ -83,5 +81,7 @@
std::thread mThread;
int mPriority;
std::string mName;
+
+ RetCode handleStartStop(bool stop);
};
} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/include/effect-impl/EffectTypes.h b/audio/aidl/default/include/effect-impl/EffectTypes.h
index b100a2e..fe534d7 100644
--- a/audio/aidl/default/include/effect-impl/EffectTypes.h
+++ b/audio/aidl/default/include/effect-impl/EffectTypes.h
@@ -19,16 +19,18 @@
#include <string>
#include <aidl/android/hardware/audio/effect/BnEffect.h>
+#include <aidl/android/hardware/audio/effect/Range.h>
#include <android-base/logging.h>
+#include <system/audio_effects/aidl_effects_utils.h>
typedef binder_exception_t (*EffectCreateFunctor)(
const ::aidl::android::media::audio::common::AudioUuid*,
- std::shared_ptr<aidl::android::hardware::audio::effect::IEffect>*);
+ std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>*);
typedef binder_exception_t (*EffectDestroyFunctor)(
- const std::shared_ptr<aidl::android::hardware::audio::effect::IEffect>&);
+ const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>&);
typedef binder_exception_t (*EffectQueryFunctor)(
const ::aidl::android::media::audio::common::AudioUuid*,
- aidl::android::hardware::audio::effect::Descriptor*);
+ ::aidl::android::hardware::audio::effect::Descriptor*);
struct effect_dl_interface_s {
EffectCreateFunctor createEffectFunc;
@@ -116,6 +118,16 @@
} \
}
+/**
+ * Make a Range::$EffectType$Range.
+ * T: The $EffectType$, Visualizer for example.
+ * Tag: The union tag name in $EffectType$ definition, latencyMs for example.
+ * l: The value of Range::$EffectType$Range.min.
+ * r: The value of Range::$EffectType$Range.max.
+ */
+#define MAKE_RANGE(T, Tag, l, r) \
+ { .min = T::make<T::Tag>(l), .max = T::make<T::Tag>(r) }
+
static inline bool stringToUuid(const char* str,
::aidl::android::media::audio::common::AudioUuid* uuid) {
RETURN_VALUE_IF(!uuid || !str, false, "nullPtr");
diff --git a/audio/aidl/default/include/effect-impl/EffectUUID.h b/audio/aidl/default/include/effect-impl/EffectUUID.h
index 7703091..30a6581 100644
--- a/audio/aidl/default/include/effect-impl/EffectUUID.h
+++ b/audio/aidl/default/include/effect-impl/EffectUUID.h
@@ -45,18 +45,30 @@
0x11e0,
0xa896,
{0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
-// 0xae3c653b-be18-4ab8-8938-418f0a7f06ac
-static const AudioUuid kAutomaticGainControlTypeUUID = {static_cast<int32_t>(0xae3c653b),
- 0xbe18,
- 0x4ab8,
- 0x8938,
- {0x41, 0x8f, 0x0a, 0x7f, 0x06, 0xac}};
+// 0a8abfe0-654c-11e0-ba26-0002a5d5c51b
+static const AudioUuid kAutomaticGainControlV1TypeUUID = {static_cast<int32_t>(0x0a8abfe0),
+ 0x654c,
+ 0x11e0,
+ 0xba26,
+ {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+// aa8130e0-66fc-11e0-bad0-0002a5d5c51b
+static const AudioUuid kAutomaticGainControlV1SwImplUUID = {static_cast<int32_t>(0xaa8130e0),
+ 0x66fc,
+ 0x11e0,
+ 0xbad0,
+ {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+// ae3c653b-be18-4ab8-8938-418f0a7f06ac
+static const AudioUuid kAutomaticGainControlV2TypeUUID = {static_cast<int32_t>(0xae3c653b),
+ 0xbe18,
+ 0x4ab8,
+ 0x8938,
+ {0x41, 0x8f, 0x0a, 0x7f, 0x06, 0xac}};
// 89f38e65-d4d2-4d64-ad0e-2b3e799ea886
-static const AudioUuid kAutomaticGainControlSwImplUUID = {static_cast<int32_t>(0x89f38e65),
- 0xd4d2,
- 0x4d64,
- 0xad0e,
- {0x2b, 0x3e, 0x79, 0x9e, 0xa8, 0x86}};
+static const AudioUuid kAutomaticGainControlV2SwImplUUID = {static_cast<int32_t>(0x89f38e65),
+ 0xd4d2,
+ 0x4d64,
+ 0xad0e,
+ {0x2b, 0x3e, 0x79, 0x9e, 0xa8, 0x86}};
// 0634f220-ddd4-11db-a0fc-0002a5d5c51b
static const AudioUuid kBassBoostTypeUUID = {static_cast<int32_t>(0x0634f220),
0xddd4,
@@ -306,7 +318,8 @@
*/
static const std::map<const std::string /* effect type */, const AudioUuid&> kUuidNameTypeMap = {
{"acoustic_echo_canceler", kAcousticEchoCancelerTypeUUID},
- {"automatic_gain_control", kAutomaticGainControlTypeUUID},
+ {"automatic_gain_control_v1", kAutomaticGainControlV1TypeUUID},
+ {"automatic_gain_control_v2", kAutomaticGainControlV2TypeUUID},
{"bassboost", kBassBoostTypeUUID},
{"downmix", kDownmixTypeUUID},
{"dynamics_processing", kDynamicsProcessingTypeUUID},
diff --git a/audio/aidl/default/loudnessEnhancer/LoudnessEnhancerSw.h b/audio/aidl/default/loudnessEnhancer/LoudnessEnhancerSw.h
index 5da70c7..e252f4a 100644
--- a/audio/aidl/default/loudnessEnhancer/LoudnessEnhancerSw.h
+++ b/audio/aidl/default/loudnessEnhancer/LoudnessEnhancerSw.h
@@ -47,7 +47,6 @@
class LoudnessEnhancerSw final : public EffectImpl {
public:
static const std::string kEffectName;
- static const LoudnessEnhancer::Capability kCapability;
static const Descriptor kDescriptor;
LoudnessEnhancerSw() { LOG(DEBUG) << __func__; }
~LoudnessEnhancerSw() {
diff --git a/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.cpp b/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.cpp
index a36cfe0..0ea31ea 100644
--- a/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.cpp
+++ b/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.cpp
@@ -60,7 +60,6 @@
namespace aidl::android::hardware::audio::effect {
const std::string NoiseSuppressionSw::kEffectName = "NoiseSuppressionSw";
-const NoiseSuppression::Capability NoiseSuppressionSw::kCapability;
const Descriptor NoiseSuppressionSw::kDescriptor = {
.common = {.id = {.type = kNoiseSuppressionTypeUUID,
.uuid = kNoiseSuppressionSwImplUUID,
@@ -69,9 +68,7 @@
.insert = Flags::Insert::FIRST,
.volume = Flags::Volume::CTRL},
.name = NoiseSuppressionSw::kEffectName,
- .implementor = "The Android Open Source Project"},
- .capability =
- Capability::make<Capability::noiseSuppression>(NoiseSuppressionSw::kCapability)};
+ .implementor = "The Android Open Source Project"}};
ndk::ScopedAStatus NoiseSuppressionSw::getDescriptor(Descriptor* _aidl_return) {
LOG(DEBUG) << __func__ << kDescriptor.toString();
@@ -90,10 +87,15 @@
switch (tag) {
case NoiseSuppression::level: {
RETURN_IF(mContext->setLevel(param.get<NoiseSuppression::level>()) != RetCode::SUCCESS,
- EX_ILLEGAL_ARGUMENT, "levelSupported");
+ EX_ILLEGAL_ARGUMENT, "levelNotSupported");
return ndk::ScopedAStatus::ok();
}
- default: {
+ case NoiseSuppression::type: {
+ RETURN_IF(mContext->setType(param.get<NoiseSuppression::type>()) != RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "typeNotSupported");
+ return ndk::ScopedAStatus::ok();
+ }
+ case NoiseSuppression::vendor: {
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
EX_ILLEGAL_ARGUMENT, "NoiseSuppressionTagNotSupported");
@@ -111,10 +113,11 @@
case NoiseSuppression::Id::commonTag:
return getParameterNoiseSuppression(specificId.get<NoiseSuppression::Id::commonTag>(),
specific);
- default:
+ case NoiseSuppression::Id::vendorExtensionTag: {
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
EX_ILLEGAL_ARGUMENT, "NoiseSuppressionTagNotSupported");
+ }
}
}
@@ -127,7 +130,11 @@
param.set<NoiseSuppression::level>(mContext->getLevel());
break;
}
- default: {
+ case NoiseSuppression::type: {
+ param.set<NoiseSuppression::type>(mContext->getType());
+ break;
+ }
+ case NoiseSuppression::vendor: {
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
EX_ILLEGAL_ARGUMENT, "NoiseSuppressionTagNotSupported");
@@ -177,4 +184,9 @@
return mLevel;
}
+RetCode NoiseSuppressionSwContext::setType(NoiseSuppression::Type type) {
+ mType = type;
+ return RetCode::SUCCESS;
+}
+
} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.h b/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.h
index f39d8e5..22bf066 100644
--- a/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.h
+++ b/audio/aidl/default/noiseSuppression/NoiseSuppressionSw.h
@@ -35,16 +35,18 @@
RetCode setLevel(NoiseSuppression::Level level);
NoiseSuppression::Level getLevel();
+ RetCode setType(NoiseSuppression::Type type);
+ NoiseSuppression::Type getType() { return mType; }
private:
NoiseSuppression::Level mLevel = NoiseSuppression::Level::LOW;
+ NoiseSuppression::Type mType = NoiseSuppression::Type::SINGLE_CHANNEL;
};
class NoiseSuppressionSw final : public EffectImpl {
public:
static const std::string kEffectName;
static const bool kStrengthSupported;
- static const NoiseSuppression::Capability kCapability;
static const Descriptor kDescriptor;
NoiseSuppressionSw() { LOG(DEBUG) << __func__; }
~NoiseSuppressionSw() {
diff --git a/audio/aidl/default/presetReverb/PresetReverbSw.cpp b/audio/aidl/default/presetReverb/PresetReverbSw.cpp
index d038596..2da3ff6 100644
--- a/audio/aidl/default/presetReverb/PresetReverbSw.cpp
+++ b/audio/aidl/default/presetReverb/PresetReverbSw.cpp
@@ -62,12 +62,17 @@
const std::string PresetReverbSw::kEffectName = "PresetReverbSw";
-const std::vector<PresetReverb::Presets> kSupportedPresets{
+const std::vector<PresetReverb::Presets> PresetReverbSw::kSupportedPresets{
ndk::enum_range<PresetReverb::Presets>().begin(),
ndk::enum_range<PresetReverb::Presets>().end()};
-const PresetReverb::Capability PresetReverbSw::kCapability = {.supportedPresets =
- kSupportedPresets};
+const std::vector<Range::PresetReverbRange> PresetReverbSw::kRanges = {
+ MAKE_RANGE(PresetReverb, supportedPresets, PresetReverbSw::kSupportedPresets,
+ PresetReverbSw::kSupportedPresets)};
+
+const Capability PresetReverbSw::kCapability = {
+ .range = Range::make<Range::presetReverb>(PresetReverbSw::kRanges)};
+
const Descriptor PresetReverbSw::kDescriptor = {
.common = {.id = {.type = kPresetReverbTypeUUID,
.uuid = kPresetReverbSwImplUUID,
@@ -77,7 +82,7 @@
.volume = Flags::Volume::CTRL},
.name = PresetReverbSw::kEffectName,
.implementor = "The Android Open Source Project"},
- .capability = Capability::make<Capability::presetReverb>(PresetReverbSw::kCapability)};
+ .capability = PresetReverbSw::kCapability};
ndk::ScopedAStatus PresetReverbSw::getDescriptor(Descriptor* _aidl_return) {
LOG(DEBUG) << __func__ << kDescriptor.toString();
@@ -92,6 +97,7 @@
RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
auto& prParam = specific.get<Parameter::Specific::presetReverb>();
+ RETURN_IF(!inRange(prParam, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
auto tag = prParam.getTag();
switch (tag) {
diff --git a/audio/aidl/default/presetReverb/PresetReverbSw.h b/audio/aidl/default/presetReverb/PresetReverbSw.h
index eb1d80a..5061475 100644
--- a/audio/aidl/default/presetReverb/PresetReverbSw.h
+++ b/audio/aidl/default/presetReverb/PresetReverbSw.h
@@ -46,7 +46,9 @@
class PresetReverbSw final : public EffectImpl {
public:
static const std::string kEffectName;
- static const PresetReverb::Capability kCapability;
+ static const std::vector<PresetReverb::Presets> kSupportedPresets;
+ static const std::vector<Range::PresetReverbRange> kRanges;
+ static const Capability kCapability;
static const Descriptor kDescriptor;
PresetReverbSw() { LOG(DEBUG) << __func__; }
~PresetReverbSw() {
diff --git a/audio/aidl/default/virtualizer/VirtualizerSw.cpp b/audio/aidl/default/virtualizer/VirtualizerSw.cpp
index cc51937..5e99cba2 100644
--- a/audio/aidl/default/virtualizer/VirtualizerSw.cpp
+++ b/audio/aidl/default/virtualizer/VirtualizerSw.cpp
@@ -30,6 +30,9 @@
using aidl::android::hardware::audio::effect::kVirtualizerSwImplUUID;
using aidl::android::hardware::audio::effect::State;
using aidl::android::hardware::audio::effect::VirtualizerSw;
+using aidl::android::media::audio::common::AudioChannelLayout;
+using aidl::android::media::audio::common::AudioDeviceDescription;
+using aidl::android::media::audio::common::AudioDeviceType;
using aidl::android::media::audio::common::AudioUuid;
extern "C" binder_exception_t createEffect(const AudioUuid* in_impl_uuid,
@@ -60,9 +63,20 @@
namespace aidl::android::hardware::audio::effect {
const std::string VirtualizerSw::kEffectName = "VirtualizerSw";
-const bool VirtualizerSw::kStrengthSupported = true;
-const Virtualizer::Capability VirtualizerSw::kCapability = {
- .maxStrengthPm = 1000, .strengthSupported = kStrengthSupported};
+
+const std::vector<Range::VirtualizerRange> VirtualizerSw::kRanges = {
+ MAKE_RANGE(Virtualizer, strengthPm, 0, 1000),
+ /* speakerAngle is get-only, set min > max */
+ MAKE_RANGE(Virtualizer, speakerAngles, {Virtualizer::ChannelAngle({.channel = 1})},
+ {Virtualizer::ChannelAngle({.channel = 0})}),
+ /* device is get-only */
+ MAKE_RANGE(Virtualizer, device,
+ AudioDeviceDescription({.type = AudioDeviceType::IN_DEFAULT}),
+ AudioDeviceDescription({.type = AudioDeviceType::NONE}))};
+
+const Capability VirtualizerSw::kCapability = {
+ .range = Range::make<Range::virtualizer>(VirtualizerSw::kRanges)};
+
const Descriptor VirtualizerSw::kDescriptor = {
.common = {.id = {.type = kVirtualizerTypeUUID,
.uuid = kVirtualizerSwImplUUID,
@@ -72,7 +86,7 @@
.volume = Flags::Volume::CTRL},
.name = VirtualizerSw::kEffectName,
.implementor = "The Android Open Source Project"},
- .capability = Capability::make<Capability::virtualizer>(VirtualizerSw::kCapability)};
+ .capability = VirtualizerSw::kCapability};
ndk::ScopedAStatus VirtualizerSw::getDescriptor(Descriptor* _aidl_return) {
LOG(DEBUG) << __func__ << kDescriptor.toString();
@@ -85,18 +99,25 @@
"EffectNotSupported");
auto& vrParam = specific.get<Parameter::Specific::virtualizer>();
+ RETURN_IF(!inRange(vrParam, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
auto tag = vrParam.getTag();
switch (tag) {
case Virtualizer::strengthPm: {
- RETURN_IF(!kStrengthSupported, EX_ILLEGAL_ARGUMENT, "SettingStrengthNotSupported");
-
RETURN_IF(mContext->setVrStrength(vrParam.get<Virtualizer::strengthPm>()) !=
RetCode::SUCCESS,
- EX_ILLEGAL_ARGUMENT, "strengthPmNotSupported");
+ EX_ILLEGAL_ARGUMENT, "setStrengthPmFailed");
return ndk::ScopedAStatus::ok();
}
- default: {
+ case Virtualizer::device: {
+ RETURN_IF(mContext->setForcedDevice(vrParam.get<Virtualizer::device>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "setDeviceFailed");
+ return ndk::ScopedAStatus::ok();
+ }
+ case Virtualizer::speakerAngles:
+ FALLTHROUGH_INTENDED;
+ case Virtualizer::vendor: {
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
"VirtualizerTagNotSupported");
@@ -113,10 +134,13 @@
switch (vrIdTag) {
case Virtualizer::Id::commonTag:
return getParameterVirtualizer(vrId.get<Virtualizer::Id::commonTag>(), specific);
- default:
+ case Virtualizer::Id::speakerAnglesPayload:
+ return getSpeakerAngles(vrId.get<Virtualizer::Id::speakerAnglesPayload>(), specific);
+ case Virtualizer::Id::vendorExtensionTag: {
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
"VirtualizerTagNotSupported");
+ }
}
}
@@ -130,7 +154,13 @@
vrParam.set<Virtualizer::strengthPm>(mContext->getVrStrength());
break;
}
- default: {
+ case Virtualizer::device: {
+ vrParam.set<Virtualizer::device>(mContext->getForcedDevice());
+ break;
+ }
+ case Virtualizer::speakerAngles:
+ FALLTHROUGH_INTENDED;
+ case Virtualizer::vendor: {
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
"VirtualizerTagNotSupported");
@@ -141,6 +171,27 @@
return ndk::ScopedAStatus::ok();
}
+ndk::ScopedAStatus VirtualizerSw::getSpeakerAngles(const Virtualizer::SpeakerAnglesPayload payload,
+ Parameter::Specific* specific) {
+ std::vector<Virtualizer::ChannelAngle> angles;
+ if (::android::hardware::audio::common::getChannelCount(payload.layout) == 1) {
+ angles = {{.channel = (int32_t)AudioChannelLayout::CHANNEL_FRONT_LEFT,
+ .azimuthDegree = 0,
+ .elevationDegree = 0}};
+ } else {
+ angles = {{.channel = (int32_t)AudioChannelLayout::CHANNEL_FRONT_LEFT,
+ .azimuthDegree = -90,
+ .elevationDegree = 0},
+ {.channel = (int32_t)AudioChannelLayout::CHANNEL_FRONT_RIGHT,
+ .azimuthDegree = 90,
+ .elevationDegree = 0}};
+ }
+
+ Virtualizer param = Virtualizer::make<Virtualizer::speakerAngles>(angles);
+ specific->set<Parameter::Specific::virtualizer>(param);
+ return ndk::ScopedAStatus::ok();
+}
+
std::shared_ptr<EffectContext> VirtualizerSw::createContext(const Parameter::Common& common) {
if (mContext) {
LOG(DEBUG) << __func__ << " context already exist";
@@ -173,11 +224,6 @@
}
RetCode VirtualizerSwContext::setVrStrength(int strength) {
- if (strength < 0 || strength > VirtualizerSw::kCapability.maxStrengthPm) {
- LOG(ERROR) << __func__ << " invalid strength: " << strength;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
- // TODO : Add implementation to apply new strength
mStrength = strength;
return RetCode::SUCCESS;
}
diff --git a/audio/aidl/default/virtualizer/VirtualizerSw.h b/audio/aidl/default/virtualizer/VirtualizerSw.h
index 0f294cd..5c5b616 100644
--- a/audio/aidl/default/virtualizer/VirtualizerSw.h
+++ b/audio/aidl/default/virtualizer/VirtualizerSw.h
@@ -34,16 +34,24 @@
}
RetCode setVrStrength(int strength);
int getVrStrength() const { return mStrength; }
+ RetCode setForcedDevice(
+ const ::aidl::android::media::audio::common::AudioDeviceDescription& device) {
+ mForceDevice = device;
+ return RetCode::SUCCESS;
+ }
+ aidl::android::media::audio::common::AudioDeviceDescription getForcedDevice() const {
+ return mForceDevice;
+ }
private:
int mStrength = 0;
+ ::aidl::android::media::audio::common::AudioDeviceDescription mForceDevice;
};
class VirtualizerSw final : public EffectImpl {
public:
static const std::string kEffectName;
- static const bool kStrengthSupported;
- static const Virtualizer::Capability kCapability;
+ static const Capability kCapability;
static const Descriptor kDescriptor;
VirtualizerSw() { LOG(DEBUG) << __func__; }
~VirtualizerSw() {
@@ -64,9 +72,12 @@
std::string getEffectName() override { return kEffectName; }
private:
+ static const std::vector<Range::VirtualizerRange> kRanges;
std::shared_ptr<VirtualizerSwContext> mContext;
ndk::ScopedAStatus getParameterVirtualizer(const Virtualizer::Tag& tag,
Parameter::Specific* specific);
+ ndk::ScopedAStatus getSpeakerAngles(const Virtualizer::SpeakerAnglesPayload payload,
+ Parameter::Specific* specific);
};
} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/visualizer/VisualizerSw.cpp b/audio/aidl/default/visualizer/VisualizerSw.cpp
index 614988c..deb3204 100644
--- a/audio/aidl/default/visualizer/VisualizerSw.cpp
+++ b/audio/aidl/default/visualizer/VisualizerSw.cpp
@@ -55,12 +55,15 @@
namespace aidl::android::hardware::audio::effect {
const std::string VisualizerSw::kEffectName = "VisualizerSw";
+
/* capabilities */
-const Visualizer::CaptureSamplesRange VisualizerSwContext::kCaptureSamplesRange = {
- VisualizerSwContext::kMinCaptureSize, VisualizerSwContext::kMaxCaptureSize};
-const Visualizer::Capability VisualizerSw::kCapability = {
- .maxLatencyMs = VisualizerSwContext::kMaxLatencyMs,
- .captureSampleRange = VisualizerSwContext::kCaptureSamplesRange};
+const std::vector<Range::VisualizerRange> VisualizerSw::kRanges = {
+ MAKE_RANGE(Visualizer, latencyMs, 0, VisualizerSwContext::kMaxLatencyMs),
+ MAKE_RANGE(Visualizer, captureSamples, VisualizerSwContext::kMinCaptureSize,
+ VisualizerSwContext::kMaxCaptureSize)};
+
+const Capability VisualizerSw::kCapability = {
+ .range = Range::make<Range::visualizer>(VisualizerSw::kRanges)};
const Descriptor VisualizerSw::kDescriptor = {
.common = {.id = {.type = kVisualizerTypeUUID,
@@ -71,7 +74,7 @@
.volume = Flags::Volume::CTRL},
.name = VisualizerSw::kEffectName,
.implementor = "The Android Open Source Project"},
- .capability = Capability::make<Capability::visualizer>(VisualizerSw::kCapability)};
+ .capability = VisualizerSw::kCapability};
ndk::ScopedAStatus VisualizerSw::getDescriptor(Descriptor* _aidl_return) {
LOG(DEBUG) << __func__ << kDescriptor.toString();
@@ -84,34 +87,33 @@
"EffectNotSupported");
auto& vsParam = specific.get<Parameter::Specific::visualizer>();
+ RETURN_IF(!inRange(vsParam, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
auto tag = vsParam.getTag();
switch (tag) {
case Visualizer::captureSamples: {
RETURN_IF(mContext->setVsCaptureSize(vsParam.get<Visualizer::captureSamples>()) !=
RetCode::SUCCESS,
- EX_ILLEGAL_ARGUMENT, "captureSizeNotSupported");
+ EX_ILLEGAL_ARGUMENT, "setCaptureSizeFailed");
return ndk::ScopedAStatus::ok();
}
case Visualizer::scalingMode: {
RETURN_IF(mContext->setVsScalingMode(vsParam.get<Visualizer::scalingMode>()) !=
RetCode::SUCCESS,
- EX_ILLEGAL_ARGUMENT, "scalingModeNotSupported");
+ EX_ILLEGAL_ARGUMENT, "setScalingModeFailed");
return ndk::ScopedAStatus::ok();
}
case Visualizer::measurementMode: {
RETURN_IF(mContext->setVsMeasurementMode(vsParam.get<Visualizer::measurementMode>()) !=
RetCode::SUCCESS,
- EX_ILLEGAL_ARGUMENT, "measurementModeNotSupported");
+ EX_ILLEGAL_ARGUMENT, "setMeasurementModeFailed");
return ndk::ScopedAStatus::ok();
}
- case Visualizer::setOnlyParameters: {
- return setSetOnlyParameterVisualizer(vsParam.get<Visualizer::setOnlyParameters>());
- }
- case Visualizer::getOnlyParameters: {
- LOG(ERROR) << __func__ << " unsupported settable getOnlyParam";
- return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
- EX_ILLEGAL_ARGUMENT, "SetofGetOnlyParamsNotSupported");
+ case Visualizer::latencyMs: {
+ RETURN_IF(mContext->setVsLatency(vsParam.get<Visualizer::latencyMs>()) !=
+ RetCode::SUCCESS,
+ EX_ILLEGAL_ARGUMENT, "setLatencyFailed");
+ return ndk::ScopedAStatus::ok();
}
default: {
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
@@ -121,18 +123,6 @@
}
}
-ndk::ScopedAStatus VisualizerSw::setSetOnlyParameterVisualizer(
- Visualizer::SetOnlyParameters setOnlyParam) {
- auto tag = setOnlyParam.getTag();
- RETURN_IF(Visualizer::SetOnlyParameters::latencyMs != tag, EX_ILLEGAL_ARGUMENT,
- "SetOnlyParametersTagNotSupported");
- RETURN_IF(
- mContext->setVsLatency(setOnlyParam.get<Visualizer::SetOnlyParameters::latencyMs>()) !=
- RetCode::SUCCESS,
- EX_ILLEGAL_ARGUMENT, "latencyNotSupported");
- return ndk::ScopedAStatus::ok();
-}
-
ndk::ScopedAStatus VisualizerSw::getParameterSpecific(const Parameter::Id& id,
Parameter::Specific* specific) {
auto tag = id.getTag();
@@ -142,14 +132,6 @@
switch (vsIdTag) {
case Visualizer::Id::commonTag:
return getParameterVisualizer(vsId.get<Visualizer::Id::commonTag>(), specific);
- case Visualizer::Id::getOnlyParamTag:
- return getGetOnlyParameterVisualizer(vsId.get<Visualizer::Id::getOnlyParamTag>(),
- specific);
- case Visualizer::Id::setOnlyParamTag: {
- LOG(ERROR) << __func__ << " unsupported gettable setOnlyParam";
- return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
- EX_ILLEGAL_ARGUMENT, "GetofSetOnlyParamsNotSupported");
- }
default:
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
@@ -174,6 +156,18 @@
vsParam.set<Visualizer::measurementMode>(mContext->getVsMeasurementMode());
break;
}
+ case Visualizer::measurement: {
+ vsParam.set<Visualizer::measurement>(mContext->getVsMeasurement());
+ break;
+ }
+ case Visualizer::captureSampleBuffer: {
+ vsParam.set<Visualizer::captureSampleBuffer>(mContext->getVsCaptureSampleBuffer());
+ break;
+ }
+ case Visualizer::latencyMs: {
+ vsParam.set<Visualizer::latencyMs>(mContext->getVsLatency());
+ break;
+ }
default: {
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
@@ -184,32 +178,6 @@
return ndk::ScopedAStatus::ok();
}
-ndk::ScopedAStatus VisualizerSw::getGetOnlyParameterVisualizer(
- const Visualizer::GetOnlyParameters::Tag& tag, Parameter::Specific* specific) {
- Visualizer::GetOnlyParameters getOnlyParam;
- switch (tag) {
- case Visualizer::GetOnlyParameters::measurement: {
- getOnlyParam.set<Visualizer::GetOnlyParameters::measurement>(
- mContext->getVsMeasurement());
- break;
- }
- case Visualizer::GetOnlyParameters::captureSampleBuffer: {
- getOnlyParam.set<Visualizer::GetOnlyParameters::captureSampleBuffer>(
- mContext->getVsCaptureSampleBuffer());
- break;
- }
- default: {
- LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
- return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
- EX_ILLEGAL_ARGUMENT, "GetOnlyParameterTagNotSupported");
- }
- }
- Visualizer vsParam;
- vsParam.set<Visualizer::getOnlyParameters>(getOnlyParam);
- specific->set<Parameter::Specific::visualizer>(vsParam);
- return ndk::ScopedAStatus::ok();
-}
-
std::shared_ptr<EffectContext> VisualizerSw::createContext(const Parameter::Common& common) {
if (mContext) {
LOG(DEBUG) << __func__ << " context already exist";
@@ -242,34 +210,21 @@
}
RetCode VisualizerSwContext::setVsCaptureSize(int captureSize) {
- if (captureSize < VisualizerSw::kCapability.captureSampleRange.min ||
- captureSize > VisualizerSw::kCapability.captureSampleRange.max) {
- LOG(ERROR) << __func__ << " invalid captureSize " << captureSize;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
- // TODO : Add implementation to apply new captureSize
mCaptureSize = captureSize;
return RetCode::SUCCESS;
}
RetCode VisualizerSwContext::setVsScalingMode(Visualizer::ScalingMode scalingMode) {
- // TODO : Add implementation to apply new scalingMode
mScalingMode = scalingMode;
return RetCode::SUCCESS;
}
RetCode VisualizerSwContext::setVsMeasurementMode(Visualizer::MeasurementMode measurementMode) {
- // TODO : Add implementation to apply new measurementMode
mMeasurementMode = measurementMode;
return RetCode::SUCCESS;
}
RetCode VisualizerSwContext::setVsLatency(int latency) {
- if (latency < 0 || latency > VisualizerSw::kCapability.maxLatencyMs) {
- LOG(ERROR) << __func__ << " invalid latency " << latency;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
- // TODO : Add implementation to modify latency
mLatency = latency;
return RetCode::SUCCESS;
}
diff --git a/audio/aidl/default/visualizer/VisualizerSw.h b/audio/aidl/default/visualizer/VisualizerSw.h
index e9d46d7..ee7276a 100644
--- a/audio/aidl/default/visualizer/VisualizerSw.h
+++ b/audio/aidl/default/visualizer/VisualizerSw.h
@@ -30,7 +30,6 @@
static const int kMaxCaptureSize = 0x400;
static const int kMaxLatencyMs = 3000;
static const int kMaxCaptureBufSize = 0xffff;
- static const Visualizer::CaptureSamplesRange kCaptureSamplesRange;
VisualizerSwContext(int statusDepth, const Parameter::Common& common)
: EffectContext(statusDepth, common) {
LOG(DEBUG) << __func__;
@@ -48,8 +47,9 @@
Visualizer::MeasurementMode getVsMeasurementMode() const { return mMeasurementMode; }
RetCode setVsLatency(int latency);
+ int getVsLatency() const { return mLatency; }
- Visualizer::GetOnlyParameters::Measurement getVsMeasurement() const { return mMeasurement; }
+ Visualizer::Measurement getVsMeasurement() const { return mMeasurement; }
std::vector<uint8_t> getVsCaptureSampleBuffer() const { return mCaptureSampleBuffer; }
private:
@@ -57,14 +57,14 @@
Visualizer::ScalingMode mScalingMode = Visualizer::ScalingMode::NORMALIZED;
Visualizer::MeasurementMode mMeasurementMode = Visualizer::MeasurementMode::NONE;
int mLatency = 0;
- const Visualizer::GetOnlyParameters::Measurement mMeasurement = {0, 0};
+ const Visualizer::Measurement mMeasurement = {0, 0};
std::vector<uint8_t> mCaptureSampleBuffer;
};
class VisualizerSw final : public EffectImpl {
public:
static const std::string kEffectName;
- static const Visualizer::Capability kCapability;
+ static const Capability kCapability;
static const Descriptor kDescriptor;
VisualizerSw() { LOG(DEBUG) << __func__; }
~VisualizerSw() {
@@ -85,12 +85,9 @@
std::string getEffectName() override { return kEffectName; }
private:
+ static const std::vector<Range::VisualizerRange> kRanges;
std::shared_ptr<VisualizerSwContext> mContext;
-
- ndk::ScopedAStatus setSetOnlyParameterVisualizer(Visualizer::SetOnlyParameters setOnlyParam);
ndk::ScopedAStatus getParameterVisualizer(const Visualizer::Tag& tag,
Parameter::Specific* specific);
- ndk::ScopedAStatus getGetOnlyParameterVisualizer(const Visualizer::GetOnlyParameters::Tag& tag,
- Parameter::Specific* specific);
};
} // namespace aidl::android::hardware::audio::effect
diff --git a/audio/aidl/default/volume/VolumeSw.cpp b/audio/aidl/default/volume/VolumeSw.cpp
index 64301dc..796c332 100644
--- a/audio/aidl/default/volume/VolumeSw.cpp
+++ b/audio/aidl/default/volume/VolumeSw.cpp
@@ -60,7 +60,11 @@
namespace aidl::android::hardware::audio::effect {
const std::string VolumeSw::kEffectName = "VolumeSw";
-const Volume::Capability VolumeSw::kCapability = {.minLevelDb = -9600, .maxLevelDb = 0};
+
+const std::vector<Range::VolumeRange> VolumeSw::kRanges = {MAKE_RANGE(Volume, levelDb, -9600, 0)};
+
+const Capability VolumeSw::kCapability = {.range = Range::make<Range::volume>(VolumeSw::kRanges)};
+
const Descriptor VolumeSw::kDescriptor = {
.common = {.id = {.type = kVolumeTypeUUID,
.uuid = kVolumeSwImplUUID,
@@ -70,7 +74,7 @@
.volume = Flags::Volume::CTRL},
.name = VolumeSw::kEffectName,
.implementor = "The Android Open Source Project"},
- .capability = Capability::make<Capability::volume>(VolumeSw::kCapability)};
+ .capability = VolumeSw::kCapability};
ndk::ScopedAStatus VolumeSw::getDescriptor(Descriptor* _aidl_return) {
LOG(DEBUG) << __func__ << kDescriptor.toString();
@@ -83,6 +87,7 @@
"EffectNotSupported");
auto& volParam = specific.get<Parameter::Specific::volume>();
+ RETURN_IF(!inRange(volParam, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
auto tag = volParam.getTag();
switch (tag) {
@@ -177,11 +182,6 @@
}
RetCode VolumeSwContext::setVolLevel(int level) {
- if (level < VolumeSw::kCapability.minLevelDb || level > VolumeSw::kCapability.maxLevelDb) {
- LOG(ERROR) << __func__ << " invalid level " << level;
- return RetCode::ERROR_ILLEGAL_PARAMETER;
- }
- // TODO : Add implementation to apply new level
mLevel = level;
return RetCode::SUCCESS;
}
diff --git a/audio/aidl/default/volume/VolumeSw.h b/audio/aidl/default/volume/VolumeSw.h
index b6f6077..2dd4324 100644
--- a/audio/aidl/default/volume/VolumeSw.h
+++ b/audio/aidl/default/volume/VolumeSw.h
@@ -49,7 +49,7 @@
class VolumeSw final : public EffectImpl {
public:
static const std::string kEffectName;
- static const Volume::Capability kCapability;
+ static const Capability kCapability;
static const Descriptor kDescriptor;
VolumeSw() { LOG(DEBUG) << __func__; }
~VolumeSw() {
@@ -70,6 +70,7 @@
std::string getEffectName() override { return kEffectName; }
private:
+ static const std::vector<Range::VolumeRange> kRanges;
std::shared_ptr<VolumeSwContext> mContext;
ndk::ScopedAStatus getParameterVolume(const Volume::Tag& tag, Parameter::Specific* specific);
diff --git a/audio/aidl/vts/Android.bp b/audio/aidl/vts/Android.bp
index f9d12dd..8db8eaf 100644
--- a/audio/aidl/vts/Android.bp
+++ b/audio/aidl/vts/Android.bp
@@ -141,9 +141,15 @@
}
cc_test {
- name: "VtsHalAGCTargetTest",
+ name: "VtsHalAGC1TargetTest",
defaults: ["VtsHalAudioTargetTestDefaults"],
- srcs: ["VtsHalAGCTargetTest.cpp"],
+ srcs: ["VtsHalAGC1TargetTest.cpp"],
+}
+
+cc_test {
+ name: "VtsHalAGC2TargetTest",
+ defaults: ["VtsHalAudioTargetTestDefaults"],
+ srcs: ["VtsHalAGC2TargetTest.cpp"],
}
cc_test {
diff --git a/audio/aidl/vts/EffectHelper.h b/audio/aidl/vts/EffectHelper.h
index 7222d4f..5ed8e1f 100644
--- a/audio/aidl/vts/EffectHelper.h
+++ b/audio/aidl/vts/EffectHelper.h
@@ -19,6 +19,7 @@
#include <algorithm>
#include <memory>
#include <string>
+#include <type_traits>
#include <unordered_map>
#include <vector>
@@ -27,6 +28,7 @@
#include <aidl/android/media/audio/common/AudioChannelLayout.h>
#include <android/binder_auto_utils.h>
#include <fmq/AidlMessageQueue.h>
+#include <system/audio_effects/aidl_effects_utils.h>
#include "AudioHalBinderServiceUtil.h"
#include "EffectFactoryHelper.h"
@@ -37,6 +39,7 @@
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::Parameter;
+using aidl::android::hardware::audio::effect::Range;
using aidl::android::hardware::audio::effect::State;
using aidl::android::hardware::common::fmq::SynchronizedReadWrite;
using aidl::android::media::audio::common::AudioChannelLayout;
@@ -148,16 +151,22 @@
}
static void readFromFmq(std::unique_ptr<StatusMQ>& statusMq, size_t statusNum,
std::unique_ptr<DataMQ>& dataMq, size_t expectFloats,
- std::vector<float>& buffer) {
+ std::vector<float>& buffer,
+ std::optional<int> expectStatus = STATUS_OK) {
+ if (0 == statusNum) {
+ ASSERT_EQ(0ul, statusMq->availableToRead());
+ return;
+ }
IEffect::Status status{};
ASSERT_TRUE(statusMq->readBlocking(&status, statusNum));
- ASSERT_EQ(STATUS_OK, status.status);
- if (statusNum != 0) {
- ASSERT_EQ(expectFloats, (unsigned)status.fmqProduced);
- ASSERT_EQ(expectFloats, dataMq->availableToRead());
- if (expectFloats != 0) {
- ASSERT_TRUE(dataMq->read(buffer.data(), expectFloats));
- }
+ if (expectStatus.has_value()) {
+ ASSERT_EQ(expectStatus.value(), status.status);
+ }
+
+ ASSERT_EQ(expectFloats, (unsigned)status.fmqProduced);
+ ASSERT_EQ(expectFloats, dataMq->availableToRead());
+ if (expectFloats != 0) {
+ ASSERT_TRUE(dataMq->read(buffer.data(), expectFloats));
}
}
static Parameter::Common createParamCommon(
@@ -199,4 +208,58 @@
std::unique_ptr<DataMQ> inputMQ;
std::unique_ptr<DataMQ> outputMQ;
};
+
+ template <typename T, Range::Tag tag>
+ static bool isParameterValid(const T& target, const Descriptor& desc) {
+ if (desc.capability.range.getTag() != tag) {
+ return true;
+ }
+ const auto& ranges = desc.capability.range.get<tag>();
+ return inRange(target, ranges);
+ }
+
+ /**
+ * Add to test value set: (min+max)/2, minimum/maximum numeric limits, and min-1/max+1 if
+ * result still in numeric limits after -1/+1.
+ * Only use this when the type of test value is basic type (std::is_arithmetic return true).
+ */
+ template <typename S, typename = std::enable_if_t<std::is_arithmetic_v<S>>>
+ static std::set<S> expandTestValueBasic(std::set<S>& s) {
+ const auto min = *s.begin(), max = *s.rbegin();
+ const auto minLimit = std::numeric_limits<S>::min(),
+ maxLimit = std::numeric_limits<S>::max();
+ if (s.size()) {
+ s.insert(min + (max - min) / 2);
+ if (min != minLimit) {
+ s.insert(min - 1);
+ }
+ if (max != maxLimit) {
+ s.insert(max + 1);
+ }
+ }
+ s.insert(minLimit);
+ s.insert(maxLimit);
+ return s;
+ }
+
+ template <typename T, typename S, Range::Tag R, typename T::Tag tag, typename Functor>
+ static std::set<S> getTestValueSet(
+ std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kFactoryDescList,
+ Functor functor) {
+ std::set<S> result;
+ for (const auto& [_, desc] : kFactoryDescList) {
+ if (desc.capability.range.getTag() == R) {
+ const auto& ranges = desc.capability.range.get<R>();
+ for (const auto& range : ranges) {
+ if (range.min.getTag() == tag) {
+ result.insert(range.min.template get<tag>());
+ }
+ if (range.max.getTag() == tag) {
+ result.insert(range.max.template get<tag>());
+ }
+ }
+ }
+ }
+ return functor(result);
+ }
};
diff --git a/audio/aidl/vts/VtsHalAECTargetTest.cpp b/audio/aidl/vts/VtsHalAECTargetTest.cpp
index c3427c8..39be191 100644
--- a/audio/aidl/vts/VtsHalAECTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAECTargetTest.cpp
@@ -23,16 +23,17 @@
#define LOG_TAG "VtsHalAECParamTest"
#include "EffectHelper.h"
+#include "effect-impl/EffectTypes.h"
using namespace android;
using aidl::android::hardware::audio::effect::AcousticEchoCanceler;
-using aidl::android::hardware::audio::effect::Capability;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::IFactory;
using aidl::android::hardware::audio::effect::kAcousticEchoCancelerTypeUUID;
using aidl::android::hardware::audio::effect::Parameter;
+using aidl::android::hardware::audio::effect::Range;
enum ParamName { PARAM_INSTANCE_NAME, PARAM_ECHO_DELAY, PARAM_MOBILE_MODE };
using AECParamTestParam = std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>,
@@ -87,7 +88,8 @@
// validate parameter
Descriptor desc;
ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
- const bool valid = isTagInRange(tag, aec, desc);
+ const bool valid =
+ isParameterValid<AcousticEchoCanceler, Range::acousticEchoCanceler>(aec, desc);
const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
// set parameter
@@ -124,54 +126,6 @@
mTags.push_back({AcousticEchoCanceler::mobileMode, aec});
}
- bool isTagInRange(const AcousticEchoCanceler::Tag& tag, const AcousticEchoCanceler& aec,
- const Descriptor& desc) const {
- const AcousticEchoCanceler::Capability& aecCap =
- desc.capability.get<Capability::acousticEchoCanceler>();
- switch (tag) {
- case AcousticEchoCanceler::echoDelayUs: {
- return isEchoDelayInRange(aecCap, aec.get<AcousticEchoCanceler::echoDelayUs>());
- }
- case AcousticEchoCanceler::mobileMode: {
- bool mode = aec.get<AcousticEchoCanceler::mobileMode>();
- return isMobileModeValid(aecCap, mode);
- }
- default:
- return false;
- }
- }
-
- bool isEchoDelayInRange(const AcousticEchoCanceler::Capability& cap, int delay) const {
- return (delay >= 0 && delay <= cap.maxEchoDelayUs);
- }
-
- bool isMobileModeValid(const AcousticEchoCanceler::Capability& cap, bool mode) const {
- if (cap.supportMobileMode) {
- return true;
- } else {
- return mode == false;
- }
- }
-
- static std::unordered_set<int> getEchoDelayTestValues() {
- auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kAcousticEchoCancelerTypeUUID);
- const auto max = std::max_element(
- descList.begin(), descList.end(),
- [](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
- const std::pair<std::shared_ptr<IFactory>, Descriptor>& b) {
- return a.second.capability.get<Capability::acousticEchoCanceler>()
- .maxEchoDelayUs <
- b.second.capability.get<Capability::acousticEchoCanceler>()
- .maxEchoDelayUs;
- });
- if (max == descList.end()) {
- return {0};
- }
- int maxDelay =
- max->second.capability.get<Capability::acousticEchoCanceler>().maxEchoDelayUs;
- return {-1, 0, maxDelay - 1, maxDelay, maxDelay + 1};
- }
static std::unordered_set<bool> getMobileModeValues() { return {true, false}; }
private:
@@ -189,12 +143,20 @@
SetAndGetParameters();
}
+std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kDescPair;
INSTANTIATE_TEST_SUITE_P(
AECParamTest, AECParamTest,
- ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
- IFactory::descriptor, kAcousticEchoCancelerTypeUUID)),
- testing::ValuesIn(AECParamTest::getEchoDelayTestValues()),
- testing::ValuesIn(AECParamTest::getMobileModeValues())),
+ ::testing::Combine(
+ testing::ValuesIn(kDescPair = EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, kAcousticEchoCancelerTypeUUID)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<AcousticEchoCanceler, int,
+ Range::acousticEchoCanceler,
+ AcousticEchoCanceler::echoDelayUs>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<AcousticEchoCanceler, bool,
+ Range::acousticEchoCanceler,
+ AcousticEchoCanceler::mobileMode>(
+ kDescPair, EffectHelper::expandTestValueBasic<bool>))),
[](const testing::TestParamInfo<AECParamTest::ParamType>& info) {
auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
std::string echoDelay = std::to_string(std::get<PARAM_ECHO_DELAY>(info.param));
diff --git a/audio/aidl/vts/VtsHalAGC1TargetTest.cpp b/audio/aidl/vts/VtsHalAGC1TargetTest.cpp
new file mode 100644
index 0000000..a6fc1aa
--- /dev/null
+++ b/audio/aidl/vts/VtsHalAGC1TargetTest.cpp
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <Utils.h>
+#include <aidl/Vintf.h>
+
+#define LOG_TAG "VtsHalAGC1ParamTest"
+
+#include "EffectHelper.h"
+
+using namespace android;
+
+using aidl::android::hardware::audio::effect::AutomaticGainControlV1;
+using aidl::android::hardware::audio::effect::Descriptor;
+using aidl::android::hardware::audio::effect::IEffect;
+using aidl::android::hardware::audio::effect::IFactory;
+using aidl::android::hardware::audio::effect::kAutomaticGainControlV1TypeUUID;
+using aidl::android::hardware::audio::effect::Parameter;
+
+enum ParamName {
+ PARAM_INSTANCE_NAME,
+ PARAM_TARGET_PEAK_LEVEL,
+ PARAM_MAX_COMPRESSION_GAIN,
+ PARAM_ENABLE_LIMITER
+};
+using AGC1ParamTestParam =
+ std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int /* targetPeakLevel */,
+ int /* maxCompressionGain */, bool /* enableLimiter */>;
+
+class AGC1ParamTest : public ::testing::TestWithParam<AGC1ParamTestParam>, public EffectHelper {
+ public:
+ AGC1ParamTest()
+ : mTargetPeakLevel(std::get<PARAM_TARGET_PEAK_LEVEL>(GetParam())),
+ mMaxCompressionGain(std::get<PARAM_MAX_COMPRESSION_GAIN>(GetParam())),
+ mEnableLimiter(std::get<PARAM_ENABLE_LIMITER>(GetParam())) {
+ std::tie(mFactory, mDescriptor) = std::get<PARAM_INSTANCE_NAME>(GetParam());
+ }
+
+ void SetUp() override {
+ ASSERT_NE(nullptr, mFactory);
+ ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
+
+ Parameter::Specific specific = getDefaultParamSpecific();
+ Parameter::Common common = EffectHelper::createParamCommon(
+ 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
+ kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
+ IEffect::OpenEffectReturn ret;
+ ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &ret, EX_NONE));
+ ASSERT_NE(nullptr, mEffect);
+ }
+
+ void TearDown() override {
+ ASSERT_NO_FATAL_FAILURE(close(mEffect));
+ ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
+ }
+
+ Parameter::Specific getDefaultParamSpecific() {
+ AutomaticGainControlV1 AGC1 =
+ AutomaticGainControlV1::make<AutomaticGainControlV1::targetPeakLevelDbFs>(0);
+ Parameter::Specific specific =
+ Parameter::Specific::make<Parameter::Specific::automaticGainControlV1>(AGC1);
+ return specific;
+ }
+
+ static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
+ std::shared_ptr<IFactory> mFactory;
+ std::shared_ptr<IEffect> mEffect;
+ Descriptor mDescriptor;
+ int mTargetPeakLevel;
+ int mMaxCompressionGain;
+ bool mEnableLimiter;
+
+ void SetAndGetParameters() {
+ for (auto& it : mTags) {
+ auto& tag = it.first;
+ auto& AGC1 = it.second;
+
+ // validate parameter
+ Descriptor desc;
+ ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
+ const bool valid =
+ isParameterValid<AutomaticGainControlV1, Range::automaticGainControlV1>(AGC1,
+ desc);
+ const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
+
+ // set parameter
+ Parameter expectParam;
+ Parameter::Specific specific;
+ specific.set<Parameter::Specific::automaticGainControlV1>(AGC1);
+ expectParam.set<Parameter::specific>(specific);
+ EXPECT_STATUS(expected, mEffect->setParameter(expectParam)) << expectParam.toString();
+
+ // only get if parameter in range and set success
+ if (expected == EX_NONE) {
+ Parameter getParam;
+ Parameter::Id id;
+ AutomaticGainControlV1::Id specificId;
+ specificId.set<AutomaticGainControlV1::Id::commonTag>(tag);
+ id.set<Parameter::Id::automaticGainControlV1Tag>(specificId);
+ EXPECT_STATUS(EX_NONE, mEffect->getParameter(id, &getParam));
+
+ EXPECT_EQ(expectParam, getParam) << "\nexpect:" << expectParam.toString()
+ << "\ngetParam:" << getParam.toString();
+ }
+ }
+ }
+
+ void addTargetPeakLevelParam(int targetPeakLevel) {
+ AutomaticGainControlV1 AGC1;
+ AGC1.set<AutomaticGainControlV1::targetPeakLevelDbFs>(targetPeakLevel);
+ mTags.push_back({AutomaticGainControlV1::targetPeakLevelDbFs, AGC1});
+ }
+ void addMaxCompressionGainParam(int maxCompressionGainDb) {
+ AutomaticGainControlV1 AGC1;
+ AGC1.set<AutomaticGainControlV1::maxCompressionGainDb>(maxCompressionGainDb);
+ mTags.push_back({AutomaticGainControlV1::maxCompressionGainDb, AGC1});
+ }
+ void addEnableLimiterParam(bool enableLimiter) {
+ AutomaticGainControlV1 AGC1;
+ AGC1.set<AutomaticGainControlV1::enableLimiter>(enableLimiter);
+ mTags.push_back({AutomaticGainControlV1::enableLimiter, AGC1});
+ }
+
+ private:
+ std::vector<std::pair<AutomaticGainControlV1::Tag, AutomaticGainControlV1>> mTags;
+ void CleanUp() { mTags.clear(); }
+};
+
+TEST_P(AGC1ParamTest, SetAndGetTargetPeakLevelParam) {
+ EXPECT_NO_FATAL_FAILURE(addTargetPeakLevelParam(mTargetPeakLevel));
+ SetAndGetParameters();
+}
+
+TEST_P(AGC1ParamTest, SetAndGetMaxCompressionGain) {
+ EXPECT_NO_FATAL_FAILURE(addMaxCompressionGainParam(mMaxCompressionGain));
+ SetAndGetParameters();
+}
+
+TEST_P(AGC1ParamTest, SetAndGetEnableLimiter) {
+ EXPECT_NO_FATAL_FAILURE(addEnableLimiterParam(mEnableLimiter));
+ SetAndGetParameters();
+}
+
+std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kDescPair;
+INSTANTIATE_TEST_SUITE_P(
+ AGC1ParamTest, AGC1ParamTest,
+ ::testing::Combine(
+ testing::ValuesIn(kDescPair = EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, kAutomaticGainControlV1TypeUUID)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<
+ AutomaticGainControlV1, int, Range::automaticGainControlV1,
+ AutomaticGainControlV1::targetPeakLevelDbFs>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<
+ AutomaticGainControlV1, int, Range::automaticGainControlV1,
+ AutomaticGainControlV1::maxCompressionGainDb>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>)),
+ testing::Bool()),
+ [](const testing::TestParamInfo<AGC1ParamTest::ParamType>& info) {
+ auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
+ std::string targetPeakLevel =
+ std::to_string(std::get<PARAM_TARGET_PEAK_LEVEL>(info.param));
+ std::string maxCompressionGain =
+ std::to_string(std::get<PARAM_MAX_COMPRESSION_GAIN>(info.param));
+ std::string enableLimiter = std::to_string(std::get<PARAM_ENABLE_LIMITER>(info.param));
+
+ std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
+ descriptor.common.name + "_UUID_" +
+ descriptor.common.id.uuid.toString() + "_target_peak_level_" +
+ targetPeakLevel + "_max_compression_gain_" + maxCompressionGain +
+ "_enable_limiter_" + enableLimiter;
+ std::replace_if(
+ name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
+ return name;
+ });
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AGC1ParamTest);
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ABinderProcess_setThreadPoolMaxThreadCount(1);
+ ABinderProcess_startThreadPool();
+ return RUN_ALL_TESTS();
+}
diff --git a/audio/aidl/vts/VtsHalAGC2TargetTest.cpp b/audio/aidl/vts/VtsHalAGC2TargetTest.cpp
new file mode 100644
index 0000000..fd3a866
--- /dev/null
+++ b/audio/aidl/vts/VtsHalAGC2TargetTest.cpp
@@ -0,0 +1,203 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <Utils.h>
+#include <aidl/Vintf.h>
+#include <android/binder_enums.h>
+#include <unordered_set>
+
+#define LOG_TAG "VtsHalAGC2ParamTest"
+
+#include "EffectHelper.h"
+
+using namespace android;
+
+using aidl::android::hardware::audio::effect::AutomaticGainControlV2;
+using aidl::android::hardware::audio::effect::Descriptor;
+using aidl::android::hardware::audio::effect::IEffect;
+using aidl::android::hardware::audio::effect::IFactory;
+using aidl::android::hardware::audio::effect::kAutomaticGainControlV2TypeUUID;
+using aidl::android::hardware::audio::effect::Parameter;
+
+enum ParamName {
+ PARAM_INSTANCE_NAME,
+ PARAM_DIGITAL_GAIN,
+ PARAM_SATURATION_MARGIN,
+ PARAM_LEVEL_ESTIMATOR
+};
+using AGC2ParamTestParam =
+ std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int /* gain */,
+ int /* margin */, AutomaticGainControlV2::LevelEstimator>;
+
+class AGC2ParamTest : public ::testing::TestWithParam<AGC2ParamTestParam>, public EffectHelper {
+ public:
+ AGC2ParamTest()
+ : mGain(std::get<PARAM_DIGITAL_GAIN>(GetParam())),
+ mMargin(std::get<PARAM_SATURATION_MARGIN>(GetParam())),
+ mLevelEstimator(std::get<PARAM_LEVEL_ESTIMATOR>(GetParam())) {
+ std::tie(mFactory, mDescriptor) = std::get<PARAM_INSTANCE_NAME>(GetParam());
+ }
+
+ void SetUp() override {
+ ASSERT_NE(nullptr, mFactory);
+ ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
+
+ Parameter::Specific specific = getDefaultParamSpecific();
+ Parameter::Common common = EffectHelper::createParamCommon(
+ 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
+ kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
+ IEffect::OpenEffectReturn ret;
+ ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &ret, EX_NONE));
+ ASSERT_NE(nullptr, mEffect);
+ }
+
+ void TearDown() override {
+ ASSERT_NO_FATAL_FAILURE(close(mEffect));
+ ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
+ }
+
+ Parameter::Specific getDefaultParamSpecific() {
+ AutomaticGainControlV2 AGC2 =
+ AutomaticGainControlV2::make<AutomaticGainControlV2::fixedDigitalGainMb>(0);
+ Parameter::Specific specific =
+ Parameter::Specific::make<Parameter::Specific::automaticGainControlV2>(AGC2);
+ return specific;
+ }
+
+ static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
+ std::shared_ptr<IFactory> mFactory;
+ std::shared_ptr<IEffect> mEffect;
+ Descriptor mDescriptor;
+ int mGain;
+ int mMargin;
+ AutomaticGainControlV2::LevelEstimator mLevelEstimator;
+
+ void SetAndGetParameters() {
+ for (auto& it : mTags) {
+ auto& tag = it.first;
+ auto& AGC2 = it.second;
+
+ // validate parameter
+ Descriptor desc;
+ ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
+ const bool valid =
+ isParameterValid<AutomaticGainControlV2, Range::automaticGainControlV2>(AGC2,
+ desc);
+ const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
+
+ // set parameter
+ Parameter expectParam;
+ Parameter::Specific specific;
+ specific.set<Parameter::Specific::automaticGainControlV2>(AGC2);
+ expectParam.set<Parameter::specific>(specific);
+ EXPECT_STATUS(expected, mEffect->setParameter(expectParam)) << expectParam.toString();
+
+ // only get if parameter in range and set success
+ if (expected == EX_NONE) {
+ Parameter getParam;
+ Parameter::Id id;
+ AutomaticGainControlV2::Id specificId;
+ specificId.set<AutomaticGainControlV2::Id::commonTag>(tag);
+ id.set<Parameter::Id::automaticGainControlV2Tag>(specificId);
+ EXPECT_STATUS(EX_NONE, mEffect->getParameter(id, &getParam));
+
+ EXPECT_EQ(expectParam, getParam) << "\nexpect:" << expectParam.toString()
+ << "\ngetParam:" << getParam.toString();
+ }
+ }
+ }
+
+ void addDigitalGainParam(int gain) {
+ AutomaticGainControlV2 AGC2;
+ AGC2.set<AutomaticGainControlV2::fixedDigitalGainMb>(gain);
+ mTags.push_back({AutomaticGainControlV2::fixedDigitalGainMb, AGC2});
+ }
+ void addSaturationMarginParam(int margin) {
+ AutomaticGainControlV2 AGC2;
+ AGC2.set<AutomaticGainControlV2::saturationMarginMb>(margin);
+ mTags.push_back({AutomaticGainControlV2::saturationMarginMb, AGC2});
+ }
+ void addLevelEstimatorParam(AutomaticGainControlV2::LevelEstimator levelEstimator) {
+ AutomaticGainControlV2 AGC2;
+ AGC2.set<AutomaticGainControlV2::levelEstimator>(levelEstimator);
+ mTags.push_back({AutomaticGainControlV2::levelEstimator, AGC2});
+ }
+
+ static std::set<AutomaticGainControlV2::LevelEstimator> getLevelEstimatorValues() {
+ return {ndk::enum_range<AutomaticGainControlV2::LevelEstimator>().begin(),
+ ndk::enum_range<AutomaticGainControlV2::LevelEstimator>().end()};
+ }
+
+ private:
+ std::vector<std::pair<AutomaticGainControlV2::Tag, AutomaticGainControlV2>> mTags;
+ void CleanUp() { mTags.clear(); }
+};
+
+TEST_P(AGC2ParamTest, SetAndGetDigitalGainParam) {
+ EXPECT_NO_FATAL_FAILURE(addDigitalGainParam(mGain));
+ SetAndGetParameters();
+}
+
+TEST_P(AGC2ParamTest, SetAndGetSaturationMargin) {
+ EXPECT_NO_FATAL_FAILURE(addSaturationMarginParam(mMargin));
+ SetAndGetParameters();
+}
+
+TEST_P(AGC2ParamTest, SetAndGetLevelEstimator) {
+ EXPECT_NO_FATAL_FAILURE(addLevelEstimatorParam(mLevelEstimator));
+ SetAndGetParameters();
+}
+
+std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kDescPair;
+INSTANTIATE_TEST_SUITE_P(
+ AGC2ParamTest, AGC2ParamTest,
+ ::testing::Combine(
+ testing::ValuesIn(kDescPair = EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, kAutomaticGainControlV2TypeUUID)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<
+ AutomaticGainControlV2, int, Range::automaticGainControlV2,
+ AutomaticGainControlV2::fixedDigitalGainMb>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<
+ AutomaticGainControlV2, int, Range::automaticGainControlV2,
+ AutomaticGainControlV2::saturationMarginMb>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>)),
+ testing::ValuesIn(AGC2ParamTest::getLevelEstimatorValues())),
+ [](const testing::TestParamInfo<AGC2ParamTest::ParamType>& info) {
+ auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
+ std::string gain = std::to_string(std::get<PARAM_DIGITAL_GAIN>(info.param));
+ std::string estimator = aidl::android::hardware::audio::effect::toString(
+ std::get<PARAM_LEVEL_ESTIMATOR>(info.param));
+ std::string margin =
+ std::to_string(static_cast<int>(std::get<PARAM_SATURATION_MARGIN>(info.param)));
+
+ std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
+ descriptor.common.name + "_UUID_" +
+ descriptor.common.id.uuid.toString() + "_digital_gain_" + gain +
+ "_level_estimator_" + estimator + "_margin_" + margin;
+ std::replace_if(
+ name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
+ return name;
+ });
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AGC2ParamTest);
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ABinderProcess_setThreadPoolMaxThreadCount(1);
+ ABinderProcess_startThreadPool();
+ return RUN_ALL_TESTS();
+}
\ No newline at end of file
diff --git a/audio/aidl/vts/VtsHalAGCTargetTest.cpp b/audio/aidl/vts/VtsHalAGCTargetTest.cpp
deleted file mode 100644
index 3448ae2..0000000
--- a/audio/aidl/vts/VtsHalAGCTargetTest.cpp
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Utils.h>
-#include <aidl/Vintf.h>
-#include <android/binder_enums.h>
-#include <unordered_set>
-
-#define LOG_TAG "VtsHalAGCParamTest"
-
-#include "EffectHelper.h"
-
-using namespace android;
-
-using aidl::android::hardware::audio::effect::AutomaticGainControl;
-using aidl::android::hardware::audio::effect::Capability;
-using aidl::android::hardware::audio::effect::Descriptor;
-using aidl::android::hardware::audio::effect::IEffect;
-using aidl::android::hardware::audio::effect::IFactory;
-using aidl::android::hardware::audio::effect::kAutomaticGainControlTypeUUID;
-using aidl::android::hardware::audio::effect::Parameter;
-
-enum ParamName {
- PARAM_INSTANCE_NAME,
- PARAM_DIGITAL_GAIN,
- PARAM_SATURATION_MARGIN,
- PARAM_LEVEL_ESTIMATOR
-};
-using AGCParamTestParam =
- std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int /* gain */,
- int /* margin */, AutomaticGainControl::LevelEstimator>;
-
-class AGCParamTest : public ::testing::TestWithParam<AGCParamTestParam>, public EffectHelper {
- public:
- AGCParamTest()
- : mGain(std::get<PARAM_DIGITAL_GAIN>(GetParam())),
- mMargin(std::get<PARAM_SATURATION_MARGIN>(GetParam())),
- mLevelEstimator(std::get<PARAM_LEVEL_ESTIMATOR>(GetParam())) {
- std::tie(mFactory, mDescriptor) = std::get<PARAM_INSTANCE_NAME>(GetParam());
- }
-
- void SetUp() override {
- ASSERT_NE(nullptr, mFactory);
- ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
-
- Parameter::Specific specific = getDefaultParamSpecific();
- Parameter::Common common = EffectHelper::createParamCommon(
- 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
- kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
- IEffect::OpenEffectReturn ret;
- ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &ret, EX_NONE));
- ASSERT_NE(nullptr, mEffect);
- }
-
- void TearDown() override {
- ASSERT_NO_FATAL_FAILURE(close(mEffect));
- ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
- }
-
- Parameter::Specific getDefaultParamSpecific() {
- AutomaticGainControl AGC =
- AutomaticGainControl::make<AutomaticGainControl::fixedDigitalGainMb>(0);
- Parameter::Specific specific =
- Parameter::Specific::make<Parameter::Specific::automaticGainControl>(AGC);
- return specific;
- }
-
- static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
- std::shared_ptr<IFactory> mFactory;
- std::shared_ptr<IEffect> mEffect;
- Descriptor mDescriptor;
- int mGain;
- int mMargin;
- AutomaticGainControl::LevelEstimator mLevelEstimator;
-
- void SetAndGetParameters() {
- for (auto& it : mTags) {
- auto& tag = it.first;
- auto& AGC = it.second;
-
- // validate parameter
- Descriptor desc;
- ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
- const bool valid = isTagInRange(tag, AGC, desc);
- const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
-
- // set parameter
- Parameter expectParam;
- Parameter::Specific specific;
- specific.set<Parameter::Specific::automaticGainControl>(AGC);
- expectParam.set<Parameter::specific>(specific);
- EXPECT_STATUS(expected, mEffect->setParameter(expectParam)) << expectParam.toString();
-
- // only get if parameter in range and set success
- if (expected == EX_NONE) {
- Parameter getParam;
- Parameter::Id id;
- AutomaticGainControl::Id specificId;
- specificId.set<AutomaticGainControl::Id::commonTag>(tag);
- id.set<Parameter::Id::automaticGainControlTag>(specificId);
- EXPECT_STATUS(EX_NONE, mEffect->getParameter(id, &getParam));
-
- EXPECT_EQ(expectParam, getParam) << "\nexpect:" << expectParam.toString()
- << "\ngetParam:" << getParam.toString();
- }
- }
- }
-
- void addDigitalGainParam(int gain) {
- AutomaticGainControl AGC;
- AGC.set<AutomaticGainControl::fixedDigitalGainMb>(gain);
- mTags.push_back({AutomaticGainControl::fixedDigitalGainMb, AGC});
- }
- void addSaturationMarginParam(int margin) {
- AutomaticGainControl AGC;
- AGC.set<AutomaticGainControl::saturationMarginMb>(margin);
- mTags.push_back({AutomaticGainControl::saturationMarginMb, AGC});
- }
- void addLevelEstimatorParam(AutomaticGainControl::LevelEstimator levelEstimator) {
- AutomaticGainControl AGC;
- AGC.set<AutomaticGainControl::levelEstimator>(levelEstimator);
- mTags.push_back({AutomaticGainControl::levelEstimator, AGC});
- }
-
- bool isTagInRange(const AutomaticGainControl::Tag& tag, const AutomaticGainControl& AGC,
- const Descriptor& desc) const {
- const AutomaticGainControl::Capability& AGCCap =
- desc.capability.get<Capability::automaticGainControl>();
- switch (tag) {
- case AutomaticGainControl::fixedDigitalGainMb: {
- auto gain = AGC.get<AutomaticGainControl::fixedDigitalGainMb>();
- return gain >= 0 && gain <= AGCCap.maxFixedDigitalGainMb;
- }
- case AutomaticGainControl::levelEstimator: {
- return true;
- }
- case AutomaticGainControl::saturationMarginMb: {
- auto margin = AGC.get<AutomaticGainControl::saturationMarginMb>();
- return margin >= 0 && margin <= AGCCap.maxSaturationMarginMb;
- }
- default:
- return false;
- }
- }
- static std::unordered_set<int> getDigitalGainValues() {
- auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kAutomaticGainControlTypeUUID);
- const auto max = std::max_element(
- descList.begin(), descList.end(),
- [](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
- const std::pair<std::shared_ptr<IFactory>, Descriptor>& b) {
- return a.second.capability.get<Capability::automaticGainControl>()
- .maxFixedDigitalGainMb <
- b.second.capability.get<Capability::automaticGainControl>()
- .maxFixedDigitalGainMb;
- });
- if (max == descList.end()) {
- return {0};
- }
- int maxGain = max->second.capability.get<Capability::automaticGainControl>()
- .maxFixedDigitalGainMb;
- return {-1, 0, maxGain - 1, maxGain, maxGain + 1};
- }
- static std::unordered_set<int> getSaturationMarginValues() {
- auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kAutomaticGainControlTypeUUID);
- const auto max = std::max_element(
- descList.begin(), descList.end(),
- [](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
- const std::pair<std::shared_ptr<IFactory>, Descriptor>& b) {
- return a.second.capability.get<Capability::automaticGainControl>()
- .maxSaturationMarginMb <
- b.second.capability.get<Capability::automaticGainControl>()
- .maxSaturationMarginMb;
- });
- if (max == descList.end()) {
- return {0};
- }
- int maxMargin = max->second.capability.get<Capability::automaticGainControl>()
- .maxSaturationMarginMb;
- return {-1, 0, maxMargin - 1, maxMargin, maxMargin + 1};
- }
- static std::unordered_set<AutomaticGainControl::LevelEstimator> getLevelEstimatorValues() {
- return {ndk::enum_range<AutomaticGainControl::LevelEstimator>().begin(),
- ndk::enum_range<AutomaticGainControl::LevelEstimator>().end()};
- }
-
- private:
- std::vector<std::pair<AutomaticGainControl::Tag, AutomaticGainControl>> mTags;
- void CleanUp() { mTags.clear(); }
-};
-
-TEST_P(AGCParamTest, SetAndGetDigitalGainParam) {
- EXPECT_NO_FATAL_FAILURE(addDigitalGainParam(mGain));
- SetAndGetParameters();
-}
-
-TEST_P(AGCParamTest, SetAndGetSaturationMargin) {
- EXPECT_NO_FATAL_FAILURE(addSaturationMarginParam(mMargin));
- SetAndGetParameters();
-}
-
-TEST_P(AGCParamTest, SetAndGetLevelEstimator) {
- EXPECT_NO_FATAL_FAILURE(addLevelEstimatorParam(mLevelEstimator));
- SetAndGetParameters();
-}
-
-INSTANTIATE_TEST_SUITE_P(
- AGCParamTest, AGCParamTest,
- ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
- IFactory::descriptor, kAutomaticGainControlTypeUUID)),
- testing::ValuesIn(AGCParamTest::getDigitalGainValues()),
- testing::ValuesIn(AGCParamTest::getSaturationMarginValues()),
- testing::ValuesIn(AGCParamTest::getLevelEstimatorValues())),
- [](const testing::TestParamInfo<AGCParamTest::ParamType>& info) {
- auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
- std::string gain = std::to_string(std::get<PARAM_DIGITAL_GAIN>(info.param));
- std::string estimator = aidl::android::hardware::audio::effect::toString(
- std::get<PARAM_LEVEL_ESTIMATOR>(info.param));
- std::string margin =
- std::to_string(static_cast<int>(std::get<PARAM_SATURATION_MARGIN>(info.param)));
-
- std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
- descriptor.common.name + "_UUID_" +
- descriptor.common.id.uuid.toString() + "_digital_gain_" + gain +
- "_level_estimator_" + estimator + "_margin_" + margin;
- std::replace_if(
- name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
- return name;
- });
-
-GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AGCParamTest);
-
-int main(int argc, char** argv) {
- ::testing::InitGoogleTest(&argc, argv);
- ABinderProcess_setThreadPoolMaxThreadCount(1);
- ABinderProcess_startThreadPool();
- return RUN_ALL_TESTS();
-}
\ No newline at end of file
diff --git a/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp b/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
index c5a0943..88bdd13 100644
--- a/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
@@ -590,12 +590,14 @@
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
std::vector<float> buffer;
- EffectHelper::allocateInputData(common, inputMQ, buffer);
- EffectHelper::writeToFmq(inputMQ, buffer);
- EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer);
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(inputMQ, buffer));
+ EXPECT_NO_FATAL_FAILURE(
+ EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
@@ -617,20 +619,24 @@
auto outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
ASSERT_TRUE(outputMQ->isValid());
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
-
std::vector<float> buffer;
- EffectHelper::allocateInputData(common, inputMQ, buffer);
- EffectHelper::writeToFmq(inputMQ, buffer);
- EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer);
+ ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
+ ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
+ ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
+ ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
+ EXPECT_NO_FATAL_FAILURE(
+ EffectHelper::readFromFmq(statusMQ, 0, outputMQ, buffer.size(), buffer));
+ ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
+ ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
+
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(inputMQ, buffer));
+ EXPECT_NO_FATAL_FAILURE(
+ EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
@@ -653,14 +659,14 @@
ASSERT_TRUE(outputMQ->isValid());
std::vector<float> buffer;
- EffectHelper::allocateInputData(common, inputMQ, buffer);
- EffectHelper::writeToFmq(inputMQ, buffer);
- EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer);
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(inputMQ, buffer));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
- EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer);
+ EXPECT_NO_FATAL_FAILURE(
+ EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
@@ -686,31 +692,30 @@
ASSERT_TRUE(outputMQ->isValid());
std::vector<float> buffer;
- EffectHelper::allocateInputData(common, inputMQ, buffer);
- EffectHelper::writeToFmq(inputMQ, buffer);
- EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer);
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(inputMQ, buffer));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
- EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer);
- // expect no status and data after consume
- EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer);
+ EXPECT_NO_FATAL_FAILURE(
+ EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
- EffectHelper::writeToFmq(inputMQ, buffer);
- EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer);
- // expect no status and data after consume
- EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer);
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(inputMQ, buffer));
+ EXPECT_NO_FATAL_FAILURE(
+ EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
-// Send data to IDLE state effects and expect it not be consumed.
-TEST_P(AudioEffectTest, NotConsumeDataInIdleState) {
+// Send data to processing state effects, stop, and restart.
+TEST_P(AudioEffectTest, ConsumeDataAndRestart) {
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
Parameter::Common common = EffectHelper::createParamCommon(
@@ -727,17 +732,21 @@
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
+ std::vector<float> buffer;
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(inputMQ, buffer));
+ EXPECT_NO_FATAL_FAILURE(
+ EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
+
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
-
- std::vector<float> buffer;
- EffectHelper::allocateInputData(common, inputMQ, buffer);
- EffectHelper::writeToFmq(inputMQ, buffer);
- EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer);
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(inputMQ, buffer));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
- EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer);
+ EXPECT_NO_FATAL_FAILURE(
+ EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
@@ -765,9 +774,9 @@
ASSERT_TRUE(outputMQ->isValid());
std::vector<float> buffer;
- EffectHelper::allocateInputData(common, inputMQ, buffer);
- EffectHelper::writeToFmq(inputMQ, buffer);
- EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer);
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(inputMQ, buffer));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -800,9 +809,10 @@
ASSERT_TRUE(outputMQ1->isValid());
std::vector<float> buffer1, buffer2;
- EffectHelper::allocateInputData(common1, inputMQ1, buffer1);
- EffectHelper::writeToFmq(inputMQ1, buffer1);
- EffectHelper::readFromFmq(statusMQ1, 1, outputMQ1, buffer1.size(), buffer1);
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common1, inputMQ1, buffer1));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(inputMQ1, buffer1));
+ EXPECT_NO_FATAL_FAILURE(
+ EffectHelper::readFromFmq(statusMQ1, 1, outputMQ1, buffer1.size(), buffer1));
auto statusMQ2 = std::make_unique<EffectHelper::StatusMQ>(ret2.statusMQ);
ASSERT_TRUE(statusMQ2->isValid());
@@ -810,9 +820,10 @@
ASSERT_TRUE(inputMQ2->isValid());
auto outputMQ2 = std::make_unique<EffectHelper::DataMQ>(ret2.outputDataMQ);
ASSERT_TRUE(outputMQ2->isValid());
- EffectHelper::allocateInputData(common2, inputMQ2, buffer2);
- EffectHelper::writeToFmq(inputMQ2, buffer2);
- EffectHelper::readFromFmq(statusMQ2, 1, outputMQ2, buffer2.size(), buffer2);
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common2, inputMQ2, buffer2));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(inputMQ2, buffer2));
+ EXPECT_NO_FATAL_FAILURE(
+ EffectHelper::readFromFmq(statusMQ2, 1, outputMQ2, buffer2.size(), buffer2));
ASSERT_NO_FATAL_FAILURE(command(effect1, CommandId::STOP));
ASSERT_NO_FATAL_FAILURE(expectState(effect1, State::IDLE));
diff --git a/audio/aidl/vts/VtsHalBassBoostTargetTest.cpp b/audio/aidl/vts/VtsHalBassBoostTargetTest.cpp
index d49a865..a1862d2 100644
--- a/audio/aidl/vts/VtsHalBassBoostTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalBassBoostTargetTest.cpp
@@ -31,6 +31,7 @@
using aidl::android::hardware::audio::effect::IFactory;
using aidl::android::hardware::audio::effect::kBassBoostTypeUUID;
using aidl::android::hardware::audio::effect::Parameter;
+using aidl::android::hardware::audio::effect::Range;
/**
* Here we focus on specific parameter checking, general IEffect interfaces testing performed in
@@ -92,7 +93,7 @@
// validate parameter
Descriptor desc;
ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
- const bool valid = isTagInRange(it.first, it.second, desc);
+ const bool valid = isParameterValid<BassBoost, Range::bassBoost>(it.second, desc);
const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
// set parameter
@@ -122,46 +123,6 @@
mTags.push_back({BassBoost::strengthPm, bb});
}
- bool isTagInRange(const BassBoost::Tag& tag, const BassBoost& bb,
- const Descriptor& desc) const {
- const BassBoost::Capability& bbCap = desc.capability.get<Capability::bassBoost>();
- switch (tag) {
- case BassBoost::strengthPm: {
- int strength = bb.get<BassBoost::strengthPm>();
- return isStrengthInRange(bbCap, strength);
- }
- default:
- return false;
- }
- return false;
- }
-
- bool isStrengthInRange(const BassBoost::Capability& cap, int strength) const {
- return cap.strengthSupported && strength >= 0 && strength <= cap.maxStrengthPm;
- }
-
- static std::vector<int> getStrengthTestValues(
- std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kFactoryDescList) {
- const auto max = std::max_element(
- kFactoryDescList.begin(), kFactoryDescList.end(),
- [](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
- const std::pair<std::shared_ptr<IFactory>, Descriptor>& b) {
- return a.second.capability.get<Capability::bassBoost>().maxStrengthPm <
- b.second.capability.get<Capability::bassBoost>().maxStrengthPm;
- });
- if (max == kFactoryDescList.end()) {
- return {0};
- }
- int maxStrength = max->second.capability.get<Capability::bassBoost>().maxStrengthPm;
- return {std::numeric_limits<int>::min(),
- -1,
- 0,
- maxStrength >> 1,
- maxStrength,
- maxStrength + 1,
- std::numeric_limits<int>::max()};
- }
-
private:
std::vector<std::pair<BassBoost::Tag, BassBoost>> mTags;
void CleanUp() { mTags.clear(); }
@@ -172,14 +133,15 @@
SetAndGetBassBoostParameters();
}
+std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kDescPair;
INSTANTIATE_TEST_SUITE_P(
BassBoostTest, BassBoostParamTest,
::testing::Combine(
- testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kBassBoostTypeUUID)),
- testing::ValuesIn(BassBoostParamTest::getStrengthTestValues(
- EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kBassBoostTypeUUID)))),
+ testing::ValuesIn(kDescPair = EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, kBassBoostTypeUUID)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<BassBoost, int, Range::bassBoost,
+ BassBoost::strengthPm>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<BassBoostParamTest::ParamType>& info) {
auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
std::string strength = std::to_string(std::get<PARAM_STRENGTH>(info.param));
diff --git a/audio/aidl/vts/VtsHalDownmixTargetTest.cpp b/audio/aidl/vts/VtsHalDownmixTargetTest.cpp
index 8612660..0601cc4 100644
--- a/audio/aidl/vts/VtsHalDownmixTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalDownmixTargetTest.cpp
@@ -22,7 +22,6 @@
using namespace android;
-using aidl::android::hardware::audio::effect::Capability;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::Downmix;
using aidl::android::hardware::audio::effect::IEffect;
diff --git a/audio/aidl/vts/VtsHalDynamicsProcessingTest.cpp b/audio/aidl/vts/VtsHalDynamicsProcessingTest.cpp
index 9feff91..ece07f0 100644
--- a/audio/aidl/vts/VtsHalDynamicsProcessingTest.cpp
+++ b/audio/aidl/vts/VtsHalDynamicsProcessingTest.cpp
@@ -28,7 +28,6 @@
using namespace android;
-using aidl::android::hardware::audio::effect::Capability;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::DynamicsProcessing;
using aidl::android::hardware::audio::effect::IEffect;
@@ -82,31 +81,8 @@
}
// utils functions for parameter checking
- bool isParamValid(const DynamicsProcessing::Tag& tag, const DynamicsProcessing& dp,
- const Descriptor& desc);
bool isParamEqual(const DynamicsProcessing::Tag& tag, const DynamicsProcessing& dpRef,
const DynamicsProcessing& dpTest);
-
- bool isEnablementValid(const DynamicsProcessing::StageEnablement& enablement);
- bool isEngineConfigValid(const DynamicsProcessing::EngineArchitecture& cfg);
-
- bool isCutoffFrequencyValid(float freq, const DynamicsProcessing::Capability& cap);
- bool isChannelConfigValid(const std::vector<DynamicsProcessing::ChannelConfig>& cfgs,
- bool stageInUse);
-
- bool isPreEqBandConfigValid(const DynamicsProcessing::Capability& cap,
- const std::vector<DynamicsProcessing::EqBandConfig>& cfgs,
- bool stageInUse, int bandCount);
- bool isPostEqBandConfigValid(const DynamicsProcessing::Capability& cap,
- const std::vector<DynamicsProcessing::EqBandConfig>& cfgs,
- bool stageInUse, int bandCount);
- bool isMbcBandConfigValid(const DynamicsProcessing::Capability& cap,
- const std::vector<DynamicsProcessing::MbcBandConfig>& cfgs,
- bool stageInUse, int bandCount);
- bool isLimiterConfigValid(const std::vector<DynamicsProcessing::LimiterConfig>& cfgs,
- bool stageInUse);
- bool isInputGainValid(const std::vector<DynamicsProcessing::InputGain>& cfgs);
-
bool isEngineConfigEqual(const DynamicsProcessing::EngineArchitecture& refCfg,
const DynamicsProcessing::EngineArchitecture& testCfg);
@@ -201,56 +177,6 @@
{{.channel = -1, .gainDb = 10.f}, {.channel = 0, .gainDb = -10.f}}};
-bool DynamicsProcessingTestHelper::isParamValid(const DynamicsProcessing::Tag& tag,
- const DynamicsProcessing& dp,
- const Descriptor& desc) {
- const DynamicsProcessing::Capability& dpCap =
- desc.capability.get<Capability::dynamicsProcessing>();
- switch (tag) {
- case DynamicsProcessing::engineArchitecture: {
- return isEngineConfigValid(dp.get<DynamicsProcessing::engineArchitecture>());
- }
- case DynamicsProcessing::preEq: {
- return isChannelConfigValid(dp.get<DynamicsProcessing::preEq>(),
- mEngineConfigApplied.preEqStage.inUse);
- }
- case DynamicsProcessing::postEq: {
- return isChannelConfigValid(dp.get<DynamicsProcessing::postEq>(),
- mEngineConfigApplied.postEqStage.inUse);
- }
- case DynamicsProcessing::mbc: {
- return isChannelConfigValid(dp.get<DynamicsProcessing::mbc>(),
- mEngineConfigApplied.mbcStage.inUse);
- }
- case DynamicsProcessing::preEqBand: {
- return isPreEqBandConfigValid(dpCap, dp.get<DynamicsProcessing::preEqBand>(),
- mEngineConfigApplied.preEqStage.inUse,
- mEngineConfigApplied.preEqStage.bandCount);
- }
- case DynamicsProcessing::postEqBand: {
- return isPostEqBandConfigValid(dpCap, dp.get<DynamicsProcessing::postEqBand>(),
- mEngineConfigApplied.postEqStage.inUse,
- mEngineConfigApplied.postEqStage.bandCount);
- }
- case DynamicsProcessing::mbcBand: {
- return isMbcBandConfigValid(dpCap, dp.get<DynamicsProcessing::mbcBand>(),
- mEngineConfigApplied.mbcStage.inUse,
- mEngineConfigApplied.mbcStage.bandCount);
- }
- case DynamicsProcessing::limiter: {
- return isLimiterConfigValid(dp.get<DynamicsProcessing::limiter>(),
- mEngineConfigApplied.limiterInUse);
- }
- case DynamicsProcessing::inputGain: {
- return isInputGainValid(dp.get<DynamicsProcessing::inputGain>());
- }
- case DynamicsProcessing::vendorExtension: {
- return true;
- }
- }
- return true;
-}
-
bool DynamicsProcessingTestHelper::isParamEqual(const DynamicsProcessing::Tag& tag,
const DynamicsProcessing& dpRef,
const DynamicsProcessing& dpTest) {
@@ -304,117 +230,6 @@
}
}
-bool DynamicsProcessingTestHelper::isEnablementValid(
- const DynamicsProcessing::StageEnablement& enablement) {
- return !enablement.inUse || (enablement.inUse && enablement.bandCount > 0);
-}
-
-bool DynamicsProcessingTestHelper::isEngineConfigValid(
- const DynamicsProcessing::EngineArchitecture& cfg) {
- return cfg.preferredProcessingDurationMs >= 0 && isEnablementValid(cfg.preEqStage) &&
- isEnablementValid(cfg.postEqStage) && isEnablementValid(cfg.mbcStage);
-}
-
-bool DynamicsProcessingTestHelper::isChannelConfigValid(
- const std::vector<DynamicsProcessing::ChannelConfig>& cfgs, bool stageInUse) {
- std::unordered_set<int> channelSet;
- if (!stageInUse) return false;
- for (auto cfg : cfgs) {
- if (cfg.channel < 0 || cfg.channel >= mChannelCount || 0 != channelSet.count(cfg.channel)) {
- return false;
- }
- channelSet.insert(cfg.channel);
- }
- return true;
-}
-
-bool DynamicsProcessingTestHelper::isCutoffFrequencyValid(
- float freq, const DynamicsProcessing::Capability& cap) {
- return freq >= cap.minCutOffFreq && freq <= cap.maxCutOffFreq;
-}
-
-bool DynamicsProcessingTestHelper::isPreEqBandConfigValid(
- const DynamicsProcessing::Capability& cap,
- const std::vector<DynamicsProcessing::EqBandConfig>& cfgs, bool stageInUse, int bandCount) {
- std::set<std::pair<int /* channelID */, int /* bandID */>> bandSet;
- if (!stageInUse) return false;
- for (auto cfg : cfgs) {
- if (0 == mPreEqChannelEnable.count(cfg.channel) || cfg.channel < 0 ||
- cfg.channel >= mChannelCount || cfg.band < 0 || cfg.band >= bandCount ||
- !isCutoffFrequencyValid(cfg.cutoffFrequencyHz, cap) ||
- 0 != bandSet.count({cfg.channel, cfg.band})) {
- return false;
- }
- bandSet.insert({cfg.channel, cfg.band});
- }
- return true;
-}
-
-bool DynamicsProcessingTestHelper::isPostEqBandConfigValid(
- const DynamicsProcessing::Capability& cap,
- const std::vector<DynamicsProcessing::EqBandConfig>& cfgs, bool stageInUse, int bandCount) {
- std::set<std::pair<int /* channelID */, int /* bandID */>> bandSet;
- // not able to set/get parameter when stage not in use.
- if (!stageInUse) return false;
- for (auto cfg : cfgs) {
- if (0 == mPostEqChannelEnable.count(cfg.channel) || cfg.channel < 0 ||
- cfg.channel >= mChannelCount || cfg.band < 0 || cfg.band >= bandCount ||
- !isCutoffFrequencyValid(cfg.cutoffFrequencyHz, cap) ||
- 0 != bandSet.count({cfg.channel, cfg.band})) {
- return false;
- }
- bandSet.insert({cfg.channel, cfg.band});
- }
- return true;
-}
-
-bool DynamicsProcessingTestHelper::isMbcBandConfigValid(
- const DynamicsProcessing::Capability& cap,
- const std::vector<DynamicsProcessing::MbcBandConfig>& cfgs, bool stageInUse,
- int bandCount) {
- std::set<std::pair<int /* channelID */, int /* bandID */>> bandSet;
- if (!stageInUse) return false;
- for (auto cfg : cfgs) {
- if (0 == mMbcChannelEnable.count(cfg.channel) || cfg.channel < 0 ||
- cfg.channel >= mChannelCount || cfg.band < 0 || cfg.band >= bandCount ||
- (cfg.attackTimeMs < 0) || cfg.releaseTimeMs < 0 || cfg.ratio < 0 ||
- cfg.thresholdDb > 0 || cfg.kneeWidthDb < 0 || cfg.noiseGateThresholdDb > 0 ||
- cfg.expanderRatio < 0 || !isCutoffFrequencyValid(cfg.cutoffFrequencyHz, cap) ||
- 0 != bandSet.count({cfg.channel, cfg.band})) {
- return false;
- }
- bandSet.insert({cfg.channel, cfg.band});
- }
- return true;
-}
-
-bool DynamicsProcessingTestHelper::isLimiterConfigValid(
- const std::vector<DynamicsProcessing::LimiterConfig>& cfgs, bool stageInUse) {
- std::set<int> channelSet;
- if (!stageInUse) return false;
- for (auto cfg : cfgs) {
- if (0 == mLimiterChannelEnable.count(cfg.channel) || cfg.channel < 0 ||
- cfg.channel >= mChannelCount || cfg.attackTimeMs < 0 || cfg.releaseTimeMs < 0 ||
- cfg.ratio < 0 || cfg.thresholdDb > 0 || 0 != channelSet.count(cfg.channel)) {
- return false;
- }
- channelSet.insert(cfg.channel);
- }
- return true;
-}
-
-bool DynamicsProcessingTestHelper::isInputGainValid(
- const std::vector<DynamicsProcessing::InputGain>& cfgs) {
- std::set<int> channelSet;
- for (auto cfg : cfgs) {
- if (cfg.channel < 0 || cfg.channel >= mChannelCount || 0 != channelSet.count(cfg.channel)) {
- return false;
- }
- channelSet.insert(cfg.channel);
- }
- return true;
-}
-
bool DynamicsProcessingTestHelper::isEngineConfigEqual(
const DynamicsProcessing::EngineArchitecture& ref,
const DynamicsProcessing::EngineArchitecture& test) {
@@ -455,7 +270,8 @@
// validate parameter
Descriptor desc;
ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
- const bool valid = isParamValid(tag, dp, desc);
+ const bool valid =
+ isParameterValid<DynamicsProcessing, Range::dynamicsProcessing>(dp, desc);
const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
// set parameter
@@ -463,7 +279,10 @@
Parameter::Specific specific;
specific.set<Parameter::Specific::dynamicsProcessing>(dp);
expectParam.set<Parameter::specific>(specific);
- ASSERT_STATUS(expected, mEffect->setParameter(expectParam)) << expectParam.toString();
+ ASSERT_STATUS(expected, mEffect->setParameter(expectParam))
+ << "\n"
+ << expectParam.toString() << "\n"
+ << desc.toString();
// only get if parameter in range and set success
if (expected == EX_NONE) {
diff --git a/audio/aidl/vts/VtsHalEnvironmentalReverbTargetTest.cpp b/audio/aidl/vts/VtsHalEnvironmentalReverbTargetTest.cpp
index 82c8757..fea41cb 100644
--- a/audio/aidl/vts/VtsHalEnvironmentalReverbTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalEnvironmentalReverbTargetTest.cpp
@@ -23,7 +23,6 @@
using namespace android;
-using aidl::android::hardware::audio::effect::Capability;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::EnvironmentalReverb;
using aidl::android::hardware::audio::effect::IEffect;
@@ -93,7 +92,8 @@
// validate parameter
Descriptor desc;
ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
- const bool valid = isTagInRange(it.first, it.second, desc);
+ const bool valid = isParameterValid<EnvironmentalReverb, Range::environmentalReverb>(
+ it.second, desc);
const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
// set
@@ -171,239 +171,6 @@
mTags.push_back({EnvironmentalReverb::bypass, er});
}
- bool isTagInRange(const EnvironmentalReverb::Tag& tag, const EnvironmentalReverb er,
- const Descriptor& desc) const {
- const EnvironmentalReverb::Capability& erCap =
- desc.capability.get<Capability::environmentalReverb>();
- switch (tag) {
- case EnvironmentalReverb::roomLevelMb: {
- int roomLevel = er.get<EnvironmentalReverb::roomLevelMb>();
- return isRoomLevelInRange(erCap, roomLevel);
- }
- case EnvironmentalReverb::roomHfLevelMb: {
- int roomHfLevel = er.get<EnvironmentalReverb::roomHfLevelMb>();
- return isRoomHfLevelInRange(erCap, roomHfLevel);
- }
- case EnvironmentalReverb::decayTimeMs: {
- int decayTime = er.get<EnvironmentalReverb::decayTimeMs>();
- return isDecayTimeInRange(erCap, decayTime);
- }
- case EnvironmentalReverb::decayHfRatioPm: {
- int decayHfRatio = er.get<EnvironmentalReverb::decayHfRatioPm>();
- return isDecayHfRatioInRange(erCap, decayHfRatio);
- }
- case EnvironmentalReverb::levelMb: {
- int level = er.get<EnvironmentalReverb::levelMb>();
- return isLevelInRange(erCap, level);
- }
- case EnvironmentalReverb::delayMs: {
- int delay = er.get<EnvironmentalReverb::delayMs>();
- return isDelayInRange(erCap, delay);
- }
- case EnvironmentalReverb::diffusionPm: {
- int diffusion = er.get<EnvironmentalReverb::diffusionPm>();
- return isDiffusionInRange(erCap, diffusion);
- }
- case EnvironmentalReverb::densityPm: {
- int density = er.get<EnvironmentalReverb::densityPm>();
- return isDensityInRange(erCap, density);
- }
- case EnvironmentalReverb::bypass: {
- return true;
- }
- default:
- return false;
- }
- return false;
- }
-
- bool isRoomLevelInRange(const EnvironmentalReverb::Capability& cap, int roomLevel) const {
- return roomLevel >= cap.minRoomLevelMb && roomLevel <= cap.maxRoomLevelMb;
- }
-
- bool isRoomHfLevelInRange(const EnvironmentalReverb::Capability& cap, int roomHfLevel) const {
- return roomHfLevel >= cap.minRoomHfLevelMb && roomHfLevel <= cap.maxRoomHfLevelMb;
- }
-
- bool isDecayTimeInRange(const EnvironmentalReverb::Capability& cap, int decayTime) const {
- return decayTime >= 0 && decayTime <= cap.maxDecayTimeMs;
- }
-
- bool isDecayHfRatioInRange(const EnvironmentalReverb::Capability& cap, int decayHfRatio) const {
- return decayHfRatio >= cap.minDecayHfRatioPm && decayHfRatio <= cap.maxDecayHfRatioPm;
- }
-
- bool isLevelInRange(const EnvironmentalReverb::Capability& cap, int level) const {
- return level >= cap.minLevelMb && level <= cap.maxLevelMb;
- }
-
- bool isDelayInRange(const EnvironmentalReverb::Capability& cap, int delay) const {
- return delay >= 0 && delay <= cap.maxDelayMs;
- }
-
- bool isDiffusionInRange(const EnvironmentalReverb::Capability& cap, int diffusion) const {
- return diffusion >= 0 && diffusion <= cap.maxDiffusionPm;
- }
-
- bool isDensityInRange(const EnvironmentalReverb::Capability& cap, int density) const {
- return density >= 0 && density <= cap.maxDensityPm;
- }
-
- static std::unordered_set<int> getRoomLevelValues() {
- auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kEnvReverbTypeUUID);
- int minRoomLevelMb = std::numeric_limits<int>::max();
- int maxRoomLevelMb = std::numeric_limits<int>::min();
- for (const auto& it : descList) {
- maxRoomLevelMb = std::max(
- it.second.capability.get<Capability::environmentalReverb>().maxRoomLevelMb,
- maxRoomLevelMb);
- minRoomLevelMb = std::min(
- it.second.capability.get<Capability::environmentalReverb>().minRoomLevelMb,
- minRoomLevelMb);
- }
- return {std::numeric_limits<int>::min(), minRoomLevelMb - 1, minRoomLevelMb,
- (minRoomLevelMb + maxRoomLevelMb) >> 1, maxRoomLevelMb, maxRoomLevelMb + 1,
- std::numeric_limits<int>::max()};
- }
-
- static std::unordered_set<int> getRoomHfLevelValues() {
- auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kEnvReverbTypeUUID);
- int minRoomHfLevelMb = std::numeric_limits<int>::max();
- int maxRoomHfLevelMb = std::numeric_limits<int>::min();
- for (const auto& it : descList) {
- maxRoomHfLevelMb = std::max(
- it.second.capability.get<Capability::environmentalReverb>().maxRoomHfLevelMb,
- maxRoomHfLevelMb);
- minRoomHfLevelMb = std::min(
- it.second.capability.get<Capability::environmentalReverb>().minRoomHfLevelMb,
- minRoomHfLevelMb);
- }
- return {std::numeric_limits<int>::min(),
- minRoomHfLevelMb - 1,
- minRoomHfLevelMb,
- (minRoomHfLevelMb + maxRoomHfLevelMb) >> 1,
- maxRoomHfLevelMb,
- maxRoomHfLevelMb + 1,
- std::numeric_limits<int>::max()};
- }
-
- static std::unordered_set<int> getDecayTimeValues() {
- auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kEnvReverbTypeUUID);
- const auto max = std::max_element(
- descList.begin(), descList.end(),
- [](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
- const std::pair<std::shared_ptr<IFactory>, Descriptor>& b) {
- return a.second.capability.get<Capability::environmentalReverb>()
- .maxDecayTimeMs <
- b.second.capability.get<Capability::environmentalReverb>()
- .maxDecayTimeMs;
- });
- if (max == descList.end()) {
- return {0};
- }
- int maxDecayTimeMs =
- max->second.capability.get<Capability::environmentalReverb>().maxDecayTimeMs;
- return {-1, 0, maxDecayTimeMs >> 1, maxDecayTimeMs - 1, maxDecayTimeMs, maxDecayTimeMs + 1};
- }
-
- static std::unordered_set<int> getDecayHfRatioValues() {
- auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kEnvReverbTypeUUID);
- int minDecayHfRatioPm = std::numeric_limits<int>::max();
- int maxDecayHfRatioPm = std::numeric_limits<int>::min();
- for (const auto& it : descList) {
- maxDecayHfRatioPm = std::max(
- it.second.capability.get<Capability::environmentalReverb>().maxDecayHfRatioPm,
- maxDecayHfRatioPm);
- minDecayHfRatioPm = std::min(
- it.second.capability.get<Capability::environmentalReverb>().minDecayHfRatioPm,
- minDecayHfRatioPm);
- }
- return {std::numeric_limits<int>::min(),
- minDecayHfRatioPm - 1,
- minDecayHfRatioPm,
- (minDecayHfRatioPm + maxDecayHfRatioPm) >> 1,
- maxDecayHfRatioPm,
- maxDecayHfRatioPm + 1,
- std::numeric_limits<int>::max()};
- }
-
- static std::unordered_set<int> getLevelValues() {
- auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kEnvReverbTypeUUID);
- int minLevelMb = std::numeric_limits<int>::max();
- int maxLevelMb = std::numeric_limits<int>::min();
- for (const auto& it : descList) {
- maxLevelMb =
- std::max(it.second.capability.get<Capability::environmentalReverb>().maxLevelMb,
- maxLevelMb);
- minLevelMb =
- std::min(it.second.capability.get<Capability::environmentalReverb>().minLevelMb,
- minLevelMb);
- }
- return {std::numeric_limits<int>::min(), minLevelMb - 1, minLevelMb,
- (minLevelMb + maxLevelMb) >> 1, maxLevelMb, maxLevelMb + 1,
- std::numeric_limits<int>::max()};
- }
-
- static std::unordered_set<int> getDelayValues() {
- auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kEnvReverbTypeUUID);
- const auto max = std::max_element(
- descList.begin(), descList.end(),
- [](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
- const std::pair<std::shared_ptr<IFactory>, Descriptor>& b) {
- return a.second.capability.get<Capability::environmentalReverb>().maxDelayMs <
- b.second.capability.get<Capability::environmentalReverb>().maxDelayMs;
- });
- if (max == descList.end()) {
- return {0};
- }
- int maxDelayMs = max->second.capability.get<Capability::environmentalReverb>().maxDelayMs;
- return {-1, 0, maxDelayMs >> 1, maxDelayMs - 1, maxDelayMs, maxDelayMs + 1};
- }
-
- static std::unordered_set<int> getDiffusionValues() {
- auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kEnvReverbTypeUUID);
- const auto max = std::max_element(
- descList.begin(), descList.end(),
- [](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
- const std::pair<std::shared_ptr<IFactory>, Descriptor>& b) {
- return a.second.capability.get<Capability::environmentalReverb>()
- .maxDiffusionPm <
- b.second.capability.get<Capability::environmentalReverb>()
- .maxDiffusionPm;
- });
- if (max == descList.end()) {
- return {0};
- }
- int maxDiffusionPm =
- max->second.capability.get<Capability::environmentalReverb>().maxDiffusionPm;
- return {-1, 0, maxDiffusionPm >> 1, maxDiffusionPm - 1, maxDiffusionPm, maxDiffusionPm + 1};
- }
-
- static std::unordered_set<int> getDensityValues() {
- auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kEnvReverbTypeUUID);
- const auto max = std::max_element(
- descList.begin(), descList.end(),
- [](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
- const std::pair<std::shared_ptr<IFactory>, Descriptor>& b) {
- return a.second.capability.get<Capability::environmentalReverb>().maxDensityPm <
- b.second.capability.get<Capability::environmentalReverb>().maxDensityPm;
- });
- if (max == descList.end()) {
- return {0};
- }
- int maxDensityPm =
- max->second.capability.get<Capability::environmentalReverb>().maxDensityPm;
- return {-1, 0, maxDensityPm >> 1, maxDensityPm - 1, maxDensityPm, maxDensityPm + 1};
- }
-
private:
std::vector<std::pair<EnvironmentalReverb::Tag, EnvironmentalReverb>> mTags;
void CleanUp() { mTags.clear(); }
@@ -428,11 +195,17 @@
SetAndGetReverbParameters();
}
+std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kDescPair;
+
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbRoomLevelTest,
- ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
- IFactory::descriptor, kEnvReverbTypeUUID)),
- testing::ValuesIn(EnvironmentalReverbHelper::getRoomLevelValues())),
+ ::testing::Combine(
+ testing::ValuesIn(kDescPair = EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, kEnvReverbTypeUUID)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<EnvironmentalReverb, int,
+ Range::environmentalReverb,
+ EnvironmentalReverb::roomLevelMb>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbRoomLevelTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string roomLevel = std::to_string(std::get<1>(info.param));
@@ -467,9 +240,13 @@
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbRoomHfLevelTest,
- ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
- IFactory::descriptor, kEnvReverbTypeUUID)),
- testing::ValuesIn(EnvironmentalReverbHelper::getRoomHfLevelValues())),
+ ::testing::Combine(
+ testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
+ kEnvReverbTypeUUID)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<EnvironmentalReverb, int,
+ Range::environmentalReverb,
+ EnvironmentalReverb::roomHfLevelMb>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbRoomHfLevelTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string roomHfLevel = std::to_string(std::get<1>(info.param));
@@ -504,9 +281,13 @@
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbDecayTimeTest,
- ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
- IFactory::descriptor, kEnvReverbTypeUUID)),
- testing::ValuesIn(EnvironmentalReverbHelper::getDecayTimeValues())),
+ ::testing::Combine(
+ testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
+ kEnvReverbTypeUUID)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<EnvironmentalReverb, int,
+ Range::environmentalReverb,
+ EnvironmentalReverb::decayTimeMs>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbDecayTimeTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string decayTime = std::to_string(std::get<1>(info.param));
@@ -543,7 +324,10 @@
EnvironmentalReverbTest, EnvironmentalReverbDecayHfRatioTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, kEnvReverbTypeUUID)),
- testing::ValuesIn(EnvironmentalReverbHelper::getDecayHfRatioValues())),
+ testing::ValuesIn(EffectHelper::getTestValueSet<
+ EnvironmentalReverb, int, Range::environmentalReverb,
+ EnvironmentalReverb::decayHfRatioPm>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbDecayHfRatioTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string decayHfRatio = std::to_string(std::get<1>(info.param));
@@ -579,9 +363,13 @@
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbLevelTest,
- ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
- IFactory::descriptor, kEnvReverbTypeUUID)),
- testing::ValuesIn(EnvironmentalReverbHelper::getLevelValues())),
+ ::testing::Combine(
+ testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
+ kEnvReverbTypeUUID)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<EnvironmentalReverb, int,
+ Range::environmentalReverb,
+ EnvironmentalReverb::levelMb>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbDecayHfRatioTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string level = std::to_string(std::get<1>(info.param));
@@ -616,9 +404,13 @@
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbDelayTest,
- ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
- IFactory::descriptor, kEnvReverbTypeUUID)),
- testing::ValuesIn(EnvironmentalReverbHelper::getDelayValues())),
+ ::testing::Combine(
+ testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
+ kEnvReverbTypeUUID)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<EnvironmentalReverb, int,
+ Range::environmentalReverb,
+ EnvironmentalReverb::delayMs>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbDelayTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string delay = std::to_string(std::get<1>(info.param));
@@ -653,9 +445,13 @@
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbDiffusionTest,
- ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
- IFactory::descriptor, kEnvReverbTypeUUID)),
- testing::ValuesIn(EnvironmentalReverbHelper::getDiffusionValues())),
+ ::testing::Combine(
+ testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
+ kEnvReverbTypeUUID)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<EnvironmentalReverb, int,
+ Range::environmentalReverb,
+ EnvironmentalReverb::diffusionPm>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbDiffusionTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string diffusion = std::to_string(std::get<1>(info.param));
@@ -690,9 +486,13 @@
INSTANTIATE_TEST_SUITE_P(
EnvironmentalReverbTest, EnvironmentalReverbDensityTest,
- ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
- IFactory::descriptor, kEnvReverbTypeUUID)),
- testing::ValuesIn(EnvironmentalReverbHelper::getDensityValues())),
+ ::testing::Combine(
+ testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
+ kEnvReverbTypeUUID)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<EnvironmentalReverb, int,
+ Range::environmentalReverb,
+ EnvironmentalReverb::densityPm>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<EnvironmentalReverbDensityTest::ParamType>& info) {
auto descriptor = std::get<0>(info.param).second;
std::string density = std::to_string(std::get<1>(info.param));
diff --git a/audio/aidl/vts/VtsHalEqualizerTargetTest.cpp b/audio/aidl/vts/VtsHalEqualizerTargetTest.cpp
index e11a936..54d00a7 100644
--- a/audio/aidl/vts/VtsHalEqualizerTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalEqualizerTargetTest.cpp
@@ -18,6 +18,7 @@
#include <limits>
#include <map>
#include <memory>
+#include <optional>
#include <string>
#include <vector>
@@ -43,7 +44,6 @@
using namespace android;
-using aidl::android::hardware::audio::effect::Capability;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::Equalizer;
using aidl::android::hardware::audio::effect::IEffect;
@@ -56,8 +56,9 @@
* testing performed in VtsAudioEfectTargetTest.
*/
-enum ParamName { PARAM_INSTANCE_NAME, PARAM_BAND_LEVEL };
-using EqualizerParamTestParam = std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int>;
+enum ParamName { PARAM_INSTANCE_NAME, PARAM_PRESET, PARAM_BAND_LEVEL };
+using EqualizerParamTestParam = std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int,
+ std::vector<Equalizer::BandLevel>>;
/*
Testing parameter range, assuming the parameter supported by effect is in this range.
@@ -69,7 +70,9 @@
class EqualizerTest : public ::testing::TestWithParam<EqualizerParamTestParam>,
public EffectHelper {
public:
- EqualizerTest() : mBandLevel(std::get<PARAM_BAND_LEVEL>(GetParam())) {
+ EqualizerTest()
+ : mPresetIndex(std::get<PARAM_PRESET>(GetParam())),
+ mBandLevel(std::get<PARAM_BAND_LEVEL>(GetParam())) {
std::tie(mFactory, mDescriptor) = std::get<PARAM_INSTANCE_NAME>(GetParam());
}
@@ -77,48 +80,24 @@
ASSERT_NE(nullptr, mFactory);
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
- Parameter::Specific specific = getDefaultParamSpecific();
Parameter::Common common = EffectHelper::createParamCommon(
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
IEffect::OpenEffectReturn ret;
- ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &ret, EX_NONE));
+ ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt, &ret, EX_NONE));
ASSERT_NE(nullptr, mEffect);
- ASSERT_NO_FATAL_FAILURE(setTagRange());
}
void TearDown() override {
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
- std::pair<int, int> setPresetIndexRange(const Equalizer::Capability& cap) const {
- const auto [min, max] =
- std::minmax_element(cap.presets.begin(), cap.presets.end(),
- [](const auto& a, const auto& b) { return a.index < b.index; });
- return {min->index, max->index};
- }
- std::pair<int, int> setBandIndexRange(const Equalizer::Capability& cap) const {
- const auto [min, max] =
- std::minmax_element(cap.bandFrequencies.begin(), cap.bandFrequencies.end(),
- [](const auto& a, const auto& b) { return a.index < b.index; });
- return {min->index, max->index};
- }
- void setTagRange() {
- Descriptor desc;
- ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
- Equalizer::Capability& eqCap = desc.capability.get<Capability::equalizer>();
- mPresetIndex = setPresetIndexRange(eqCap);
- mBandIndex = setBandIndexRange(eqCap);
- }
-
static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
std::shared_ptr<IFactory> mFactory;
std::shared_ptr<IEffect> mEffect;
Descriptor mDescriptor;
- std::pair<int, int> mPresetIndex;
- std::pair<int, int> mBandIndex;
- const int mBandLevel;
- Descriptor mDesc;
+ int mPresetIndex;
+ std::vector<Equalizer::BandLevel> mBandLevel;
void SetAndGetEqualizerParameters() {
ASSERT_NE(nullptr, mEffect);
@@ -127,25 +106,22 @@
auto& eq = it.second;
// validate parameter
- const bool valid = isTagInRange(it.first, it.second);
+ const bool valid = isParameterValid<Equalizer, Range::equalizer>(eq, mDescriptor);
const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
// set
- Parameter expectParam;
- Parameter::Specific specific;
- specific.set<Parameter::Specific::equalizer>(eq);
- expectParam.set<Parameter::specific>(specific);
+ Parameter::Specific specific =
+ Parameter::Specific::make<Parameter::Specific::equalizer>(eq);
+ Parameter expectParam = Parameter::make<Parameter::specific>(specific);
EXPECT_STATUS(expected, mEffect->setParameter(expectParam))
<< expectParam.toString() << "\n"
- << mDesc.toString();
+ << mDescriptor.toString();
// only get if parameter in range and set success
if (expected == EX_NONE) {
Parameter getParam;
- Parameter::Id id;
- Equalizer::Id eqId;
- eqId.set<Equalizer::Id::commonTag>(tag);
- id.set<Parameter::Id::equalizerTag>(eqId);
+ Equalizer::Id eqId = Equalizer::Id::make<Equalizer::Id::commonTag>(tag);
+ Parameter::Id id = Parameter::Id::make<Parameter::Id::equalizerTag>(eqId);
// if set success, then get should match
EXPECT_STATUS(expected, mEffect->getParameter(id, &getParam));
EXPECT_TRUE(isEqParameterExpected(expectParam, getParam))
@@ -197,140 +173,51 @@
}
void addPresetParam(int preset) {
- Equalizer eq;
- eq.set<Equalizer::preset>(preset);
- mTags.push_back({Equalizer::preset, eq});
+ mTags.push_back({Equalizer::preset, Equalizer::make<Equalizer::preset>(preset)});
}
void addBandLevelsParam(std::vector<Equalizer::BandLevel>& bandLevels) {
- Equalizer eq;
- eq.set<Equalizer::bandLevels>(bandLevels);
- mTags.push_back({Equalizer::bandLevels, eq});
- }
-
- bool isTagInRange(const Equalizer::Tag& tag, const Equalizer& eq) const {
- switch (tag) {
- case Equalizer::preset: {
- int index = eq.get<Equalizer::preset>();
- return index >= mPresetIndex.first && index <= mPresetIndex.second;
- }
- case Equalizer::bandLevels: {
- auto& bandLevel = eq.get<Equalizer::bandLevels>();
- return isBandInRange(bandLevel);
- }
- default:
- return false;
- }
- return false;
- }
-
- bool isBandInRange(const std::vector<Equalizer::BandLevel>& bandLevel) const {
- for (auto& it : bandLevel) {
- if (it.index < mBandIndex.first || it.index > mBandIndex.second) return false;
- }
- return true;
- }
-
- Parameter::Specific getDefaultParamSpecific() {
- Equalizer eq = Equalizer::make<Equalizer::preset>(0);
- Parameter::Specific specific =
- Parameter::Specific::make<Parameter::Specific::equalizer>(eq);
- return specific;
+ mTags.push_back(
+ {Equalizer::bandLevels, Equalizer::make<Equalizer::bandLevels>(bandLevels)});
}
private:
std::vector<std::pair<Equalizer::Tag, Equalizer>> mTags;
- bool validCapabilityTag(Capability& cap) { return cap.getTag() == Capability::equalizer; }
-
void CleanUp() { mTags.clear(); }
};
-TEST_P(EqualizerTest, SetAndGetPresetOutOfLowerBound) {
- addPresetParam(mPresetIndex.second - 1);
- ASSERT_NO_FATAL_FAILURE(SetAndGetEqualizerParameters());
-}
-
-TEST_P(EqualizerTest, SetAndGetPresetOutOfUpperBound) {
- addPresetParam(mPresetIndex.second + 1);
+TEST_P(EqualizerTest, SetAndGetParams) {
+ addBandLevelsParam(mBandLevel);
+ addPresetParam(mPresetIndex);
EXPECT_NO_FATAL_FAILURE(SetAndGetEqualizerParameters());
}
-TEST_P(EqualizerTest, SetAndGetPresetAtLowerBound) {
- addPresetParam(mPresetIndex.first);
- EXPECT_NO_FATAL_FAILURE(SetAndGetEqualizerParameters());
-}
-
-TEST_P(EqualizerTest, SetAndGetPresetAtHigherBound) {
- addPresetParam(mPresetIndex.second);
- EXPECT_NO_FATAL_FAILURE(SetAndGetEqualizerParameters());
-}
-
-TEST_P(EqualizerTest, SetAndGetPresetInBound) {
- addPresetParam((mPresetIndex.first + mPresetIndex.second) >> 1);
- EXPECT_NO_FATAL_FAILURE(SetAndGetEqualizerParameters());
-}
-
-TEST_P(EqualizerTest, SetAndGetBandOutOfLowerBound) {
- std::vector<Equalizer::BandLevel> bandLevels{{mBandIndex.first - 1, mBandLevel}};
- addBandLevelsParam(bandLevels);
- EXPECT_NO_FATAL_FAILURE(SetAndGetEqualizerParameters());
-}
-
-TEST_P(EqualizerTest, SetAndGetBandOutOfUpperBound) {
- std::vector<Equalizer::BandLevel> bandLevels{{mBandIndex.second + 1, mBandLevel}};
- addBandLevelsParam(bandLevels);
- EXPECT_NO_FATAL_FAILURE(SetAndGetEqualizerParameters());
-}
-
-TEST_P(EqualizerTest, SetAndGetBandAtLowerBound) {
- std::vector<Equalizer::BandLevel> bandLevels{{mBandIndex.first, mBandLevel}};
- addBandLevelsParam(bandLevels);
- EXPECT_NO_FATAL_FAILURE(SetAndGetEqualizerParameters());
-}
-
-TEST_P(EqualizerTest, SetAndGetBandAtHigherBound) {
- std::vector<Equalizer::BandLevel> bandLevels{{mBandIndex.second, mBandLevel}};
- addBandLevelsParam(bandLevels);
- EXPECT_NO_FATAL_FAILURE(SetAndGetEqualizerParameters());
-}
-
-TEST_P(EqualizerTest, SetAndGetBandInBound) {
- std::vector<Equalizer::BandLevel> bandLevels{
- {(mBandIndex.first + mBandIndex.second) >> 1, mBandLevel}};
- addBandLevelsParam(bandLevels);
- EXPECT_NO_FATAL_FAILURE(SetAndGetEqualizerParameters());
-}
-
-TEST_P(EqualizerTest, SetAndGetMultiBands) {
- addPresetParam(mPresetIndex.first);
- std::vector<Equalizer::BandLevel> bandLevels{
- {mBandIndex.first, mBandLevel},
- {mBandIndex.second, mBandLevel},
- {(mBandIndex.first + mBandIndex.second) >> 1, mBandLevel}};
- addBandLevelsParam(bandLevels);
- EXPECT_NO_FATAL_FAILURE(SetAndGetEqualizerParameters());
-}
-
-TEST_P(EqualizerTest, SetAndGetMultipleParams) {
- std::vector<Equalizer::BandLevel> bandLevels{
- {(mBandIndex.first + mBandIndex.second) >> 1, mBandLevel}};
- addBandLevelsParam(bandLevels);
- addPresetParam((mPresetIndex.first + mPresetIndex.second) >> 1);
- EXPECT_NO_FATAL_FAILURE(SetAndGetEqualizerParameters());
-}
-
+std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kDescPair;
INSTANTIATE_TEST_SUITE_P(
EqualizerTest, EqualizerTest,
- ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
- IFactory::descriptor, kEqualizerTypeUUID)),
- testing::ValuesIn(kBandLevels)),
+ ::testing::Combine(
+ testing::ValuesIn(kDescPair = EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, kEqualizerTypeUUID)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<Equalizer, int, Range::equalizer,
+ Equalizer::preset>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>)),
+ testing::ValuesIn(
+ EffectHelper::getTestValueSet<Equalizer, std::vector<Equalizer::BandLevel>,
+ Range::equalizer, Equalizer::bandLevels>(
+ kDescPair,
+ [](std::set<std::vector<Equalizer::BandLevel>>& bandLevels) {
+ return bandLevels;
+ }))),
[](const testing::TestParamInfo<EqualizerTest::ParamType>& info) {
auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
- std::string bandLevel = std::to_string(std::get<PARAM_BAND_LEVEL>(info.param));
+ std::string bandLevel =
+ ::android::internal::ToString(std::get<PARAM_BAND_LEVEL>(info.param));
std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
descriptor.common.name + "_UUID_" +
- descriptor.common.id.uuid.toString() + "_bandLevel_" + bandLevel;
+ descriptor.common.id.uuid.toString() + "_preset_" +
+ std::to_string(std::get<PARAM_PRESET>(info.param)) + "_bandLevel_" +
+ bandLevel;
std::replace_if(
name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
return name;
diff --git a/audio/aidl/vts/VtsHalHapticGeneratorTargetTest.cpp b/audio/aidl/vts/VtsHalHapticGeneratorTargetTest.cpp
index b8ea9c1..6c3016e 100644
--- a/audio/aidl/vts/VtsHalHapticGeneratorTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalHapticGeneratorTargetTest.cpp
@@ -27,7 +27,6 @@
using namespace android;
-using aidl::android::hardware::audio::effect::Capability;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::HapticGenerator;
using aidl::android::hardware::audio::effect::IEffect;
diff --git a/audio/aidl/vts/VtsHalLoudnessEnhancerTargetTest.cpp b/audio/aidl/vts/VtsHalLoudnessEnhancerTargetTest.cpp
index 305c243..75941ff 100644
--- a/audio/aidl/vts/VtsHalLoudnessEnhancerTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalLoudnessEnhancerTargetTest.cpp
@@ -24,7 +24,6 @@
using namespace android;
-using aidl::android::hardware::audio::effect::Capability;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::IFactory;
diff --git a/audio/aidl/vts/VtsHalNSTargetTest.cpp b/audio/aidl/vts/VtsHalNSTargetTest.cpp
index 93ad86d..16c79e3 100644
--- a/audio/aidl/vts/VtsHalNSTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalNSTargetTest.cpp
@@ -26,7 +26,6 @@
using namespace android;
-using aidl::android::hardware::audio::effect::Capability;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::IFactory;
@@ -34,13 +33,14 @@
using aidl::android::hardware::audio::effect::NoiseSuppression;
using aidl::android::hardware::audio::effect::Parameter;
-enum ParamName { PARAM_INSTANCE_NAME, PARAM_LEVEL };
-using NSParamTestParam =
- std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, NoiseSuppression::Level>;
+enum ParamName { PARAM_INSTANCE_NAME, PARAM_LEVEL, PARAM_TYPE };
+using NSParamTestParam = std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>,
+ NoiseSuppression::Level, NoiseSuppression::Type>;
class NSParamTest : public ::testing::TestWithParam<NSParamTestParam>, public EffectHelper {
public:
- NSParamTest() : mLevel(std::get<PARAM_LEVEL>(GetParam())) {
+ NSParamTest()
+ : mLevel(std::get<PARAM_LEVEL>(GetParam())), mType(std::get<PARAM_TYPE>(GetParam())) {
std::tie(mFactory, mDescriptor) = std::get<PARAM_INSTANCE_NAME>(GetParam());
}
@@ -75,6 +75,7 @@
std::shared_ptr<IEffect> mEffect;
Descriptor mDescriptor;
NoiseSuppression::Level mLevel;
+ NoiseSuppression::Type mType;
void SetAndGetParameters() {
for (auto& it : mTags) {
@@ -113,10 +114,19 @@
ns.set<NoiseSuppression::level>(level);
mTags.push_back({NoiseSuppression::level, ns});
}
+ void addTypeParam(NoiseSuppression::Type type) {
+ NoiseSuppression ns;
+ ns.set<NoiseSuppression::type>(type);
+ mTags.push_back({NoiseSuppression::type, ns});
+ }
static std::unordered_set<NoiseSuppression::Level> getLevelValues() {
return {ndk::enum_range<NoiseSuppression::Level>().begin(),
ndk::enum_range<NoiseSuppression::Level>().end()};
}
+ static std::unordered_set<NoiseSuppression::Type> getTypeValues() {
+ return {ndk::enum_range<NoiseSuppression::Type>().begin(),
+ ndk::enum_range<NoiseSuppression::Type>().end()};
+ }
private:
std::vector<std::pair<NoiseSuppression::Tag, NoiseSuppression>> mTags;
@@ -128,18 +138,27 @@
SetAndGetParameters();
}
+TEST_P(NSParamTest, SetAndGetType) {
+ EXPECT_NO_FATAL_FAILURE(addLevelParam(mLevel));
+ SetAndGetParameters();
+}
+
INSTANTIATE_TEST_SUITE_P(
NSParamTest, NSParamTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, kNoiseSuppressionTypeUUID)),
- testing::ValuesIn(NSParamTest::getLevelValues())),
+ testing::ValuesIn(NSParamTest::getLevelValues()),
+ testing::ValuesIn(NSParamTest::getTypeValues())),
[](const testing::TestParamInfo<NSParamTest::ParamType>& info) {
auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
std::string level = aidl::android::hardware::audio::effect::toString(
std::get<PARAM_LEVEL>(info.param));
+ std::string type = aidl::android::hardware::audio::effect::toString(
+ std::get<PARAM_TYPE>(info.param));
std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
descriptor.common.name + "_UUID_" +
- descriptor.common.id.uuid.toString() + "_level_" + level;
+ descriptor.common.id.uuid.toString() + "_level_" + level + "_type_" +
+ type;
std::replace_if(
name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
return name;
diff --git a/audio/aidl/vts/VtsHalPresetReverbTargetTest.cpp b/audio/aidl/vts/VtsHalPresetReverbTargetTest.cpp
index 19d5747..c9c2a31 100644
--- a/audio/aidl/vts/VtsHalPresetReverbTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalPresetReverbTargetTest.cpp
@@ -23,7 +23,6 @@
using namespace android;
-using aidl::android::hardware::audio::effect::Capability;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::IFactory;
@@ -84,7 +83,7 @@
// validate parameter
Descriptor desc;
ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
- const bool valid = isTagInRange(it.first, it.second, desc);
+ const bool valid = isParameterValid<PresetReverb, Range::presetReverb>(it.second, desc);
const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
// set parameter
@@ -113,27 +112,6 @@
mTags.push_back({PresetReverb::preset, pr});
}
- bool isTagInRange(const PresetReverb::Tag& tag, const PresetReverb& pr,
- const Descriptor& desc) const {
- const PresetReverb::Capability& prCap = desc.capability.get<Capability::presetReverb>();
- switch (tag) {
- case PresetReverb::preset: {
- PresetReverb::Presets preset = pr.get<PresetReverb::preset>();
- return isPresetInRange(prCap, preset);
- }
- default:
- return false;
- }
- return false;
- }
-
- bool isPresetInRange(const PresetReverb::Capability& cap, PresetReverb::Presets preset) const {
- for (auto i : cap.supportedPresets) {
- if (preset == i) return true;
- }
- return false;
- }
-
Parameter::Specific getDefaultParamSpecific() {
PresetReverb pr = PresetReverb::make<PresetReverb::preset>(PresetReverb::Presets::NONE);
Parameter::Specific specific =
diff --git a/audio/aidl/vts/VtsHalVirtualizerTargetTest.cpp b/audio/aidl/vts/VtsHalVirtualizerTargetTest.cpp
index 090de17..8b0210c 100644
--- a/audio/aidl/vts/VtsHalVirtualizerTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalVirtualizerTargetTest.cpp
@@ -22,7 +22,6 @@
using namespace android;
-using aidl::android::hardware::audio::effect::Capability;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::IFactory;
@@ -90,7 +89,7 @@
// validate parameter
Descriptor desc;
ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
- const bool valid = isTagInRange(it.first, it.second, desc);
+ const bool valid = isParameterValid<Virtualizer, Range::virtualizer>(it.second, desc);
const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
// set parameter
@@ -120,46 +119,6 @@
mTags.push_back({Virtualizer::strengthPm, vr});
}
- bool isTagInRange(const Virtualizer::Tag& tag, const Virtualizer& vr,
- const Descriptor& desc) const {
- const Virtualizer::Capability& vrCap = desc.capability.get<Capability::virtualizer>();
- switch (tag) {
- case Virtualizer::strengthPm: {
- int strength = vr.get<Virtualizer::strengthPm>();
- return isStrengthInRange(vrCap, strength);
- }
- default:
- return false;
- }
- return false;
- }
-
- bool isStrengthInRange(const Virtualizer::Capability& cap, int strength) const {
- return cap.strengthSupported && strength >= 0 && strength <= cap.maxStrengthPm;
- }
-
- static std::vector<int> getStrengthTestValues(
- std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kFactoryDescList) {
- const auto max = std::max_element(
- kFactoryDescList.begin(), kFactoryDescList.end(),
- [](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
- const std::pair<std::shared_ptr<IFactory>, Descriptor>& b) {
- return a.second.capability.get<Capability::virtualizer>().maxStrengthPm <
- b.second.capability.get<Capability::virtualizer>().maxStrengthPm;
- });
- if (max == kFactoryDescList.end()) {
- return {0};
- }
- int maxStrength = max->second.capability.get<Capability::virtualizer>().maxStrengthPm;
- return {std::numeric_limits<int>::min(),
- -1,
- 0,
- maxStrength >> 1,
- maxStrength,
- maxStrength + 1,
- std::numeric_limits<int>::max()};
- }
-
private:
std::vector<std::pair<Virtualizer::Tag, Virtualizer>> mTags;
void CleanUp() { mTags.clear(); }
@@ -170,13 +129,15 @@
SetAndGetVirtualizerParameters();
}
+std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kDescPair;
INSTANTIATE_TEST_SUITE_P(
VirtualizerTest, VirtualizerParamTest,
- ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
- IFactory::descriptor, kVirtualizerTypeUUID)),
- testing::ValuesIn(VirtualizerParamTest::getStrengthTestValues(
- EffectFactoryHelper::getAllEffectDescriptors(
- IFactory::descriptor, kVirtualizerTypeUUID)))),
+ ::testing::Combine(
+ testing::ValuesIn(kDescPair = EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, kVirtualizerTypeUUID)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<
+ Virtualizer, int, Range::virtualizer, Virtualizer::strengthPm>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<VirtualizerParamTest::ParamType>& info) {
auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
std::string strength = std::to_string(std::get<PARAM_STRENGTH>(info.param));
diff --git a/audio/aidl/vts/VtsHalVisualizerTargetTest.cpp b/audio/aidl/vts/VtsHalVisualizerTargetTest.cpp
index 242be3f..e2625cb 100644
--- a/audio/aidl/vts/VtsHalVisualizerTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalVisualizerTargetTest.cpp
@@ -26,7 +26,6 @@
using namespace android;
-using aidl::android::hardware::audio::effect::Capability;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::IFactory;
@@ -64,12 +63,11 @@
ASSERT_NE(nullptr, mFactory);
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
- Parameter::Specific specific = getDefaultParamSpecific();
Parameter::Common common = EffectHelper::createParamCommon(
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
IEffect::OpenEffectReturn ret;
- ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &ret, EX_NONE));
+ ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt, &ret, EX_NONE));
ASSERT_NE(nullptr, mEffect);
}
@@ -77,13 +75,6 @@
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
- Parameter::Specific getDefaultParamSpecific() {
- Visualizer vs = Visualizer::make<Visualizer::captureSamples>(
- mDescriptor.capability.get<Capability::visualizer>().captureSampleRange.max);
- Parameter::Specific specific =
- Parameter::Specific::make<Parameter::Specific::visualizer>(vs);
- return specific;
- }
static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
std::shared_ptr<IFactory> mFactory;
@@ -94,7 +85,7 @@
Visualizer::MeasurementMode mMeasurementMode = Visualizer::MeasurementMode::NONE;
int mLatency = 0;
- void SetAndGetCommonParameters() {
+ void SetAndGetParameters() {
for (auto& it : mCommonTags) {
auto& tag = it.first;
auto& vs = it.second;
@@ -102,7 +93,7 @@
// validate parameter
Descriptor desc;
ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
- const bool valid = isTagInRange(tag, vs, desc);
+ const bool valid = isParameterValid<Visualizer, Range::visualizer>(vs, desc);
const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
// set parameter
@@ -119,170 +110,39 @@
Visualizer::Id vsId;
vsId.set<Visualizer::Id::commonTag>(tag);
id.set<Parameter::Id::visualizerTag>(vsId);
- EXPECT_STATUS(EX_NONE, mEffect->getParameter(id, &getParam));
-
+ EXPECT_STATUS(EX_NONE, mEffect->getParameter(id, &getParam))
+ << " with: " << id.toString();
EXPECT_EQ(expectParam, getParam) << "\nexpect:" << expectParam.toString()
<< "\ngetParam:" << getParam.toString();
}
}
}
- void SetAndGetSetOnlyParameters() {
- for (auto& it : mSetOnlyParamTags) {
- auto& tag = it.first;
- auto& vs = it.second;
-
- // validate parameter
- Descriptor desc;
- ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
- const bool valid = isSetOnlyParamTagInRange(vs, desc);
- const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
-
- // set parameter
- Parameter expectParam;
- Parameter::Specific specific;
- specific.set<Parameter::Specific::visualizer>(vs);
- expectParam.set<Parameter::specific>(specific);
- ASSERT_STATUS(expected, mEffect->setParameter(expectParam));
-
- // parameter defined in this setOnlyParameter union must be settable via
- // setParameter(), but must not be gettable
- Parameter getParam;
- Parameter::Id id;
- Visualizer::Id vsId;
- vsId.set<Visualizer::Id::setOnlyParamTag>(tag);
- id.set<Parameter::Id::visualizerTag>(vsId);
- EXPECT_STATUS(EX_ILLEGAL_ARGUMENT, mEffect->getParameter(id, &getParam));
- }
- }
-
- void GetandSetGetOnlyParameters() {
- for (auto& tag : mGetOnlyParamTags) {
- // get parameter
- Parameter getParam;
- Parameter::Id id;
- Visualizer::Id vsId;
- vsId.set<Visualizer::Id::getOnlyParamTag>(tag);
- id.set<Parameter::Id::visualizerTag>(vsId);
- ASSERT_STATUS(EX_NONE, mEffect->getParameter(id, &getParam));
-
- // parameter defined in this getOnlyParameter union must be gettable via
- // getParameter(), but must not be settable
- // set parameter
- ASSERT_STATUS(EX_ILLEGAL_ARGUMENT, mEffect->setParameter(getParam));
- }
- }
-
void addCaptureSizeParam(int captureSize) {
- Visualizer vs;
- vs.set<Visualizer::captureSamples>(captureSize);
- mCommonTags.push_back({Visualizer::captureSamples, vs});
+ mCommonTags.push_back({Visualizer::captureSamples,
+ Visualizer::make<Visualizer::captureSamples>(captureSize)});
}
void addScalingModeParam(Visualizer::ScalingMode scalingMode) {
- Visualizer vs;
- vs.set<Visualizer::scalingMode>(scalingMode);
- mCommonTags.push_back({Visualizer::scalingMode, vs});
+ mCommonTags.push_back(
+ {Visualizer::scalingMode, Visualizer::make<Visualizer::scalingMode>(scalingMode)});
}
void addMeasurementModeParam(Visualizer::MeasurementMode measurementMode) {
- Visualizer vs;
- vs.set<Visualizer::measurementMode>(measurementMode);
- mCommonTags.push_back({Visualizer::measurementMode, vs});
+ mCommonTags.push_back({Visualizer::measurementMode,
+ Visualizer::make<Visualizer::measurementMode>(measurementMode)});
}
void addLatencyParam(int latency) {
- Visualizer vs;
- Visualizer::SetOnlyParameters setOnlyParam;
- setOnlyParam.set<Visualizer::SetOnlyParameters::latencyMs>(latency);
- vs.set<Visualizer::setOnlyParameters>(setOnlyParam);
- mSetOnlyParamTags.push_back({Visualizer::SetOnlyParameters::latencyMs, vs});
+ mCommonTags.push_back(
+ {Visualizer::latencyMs, Visualizer::make<Visualizer::latencyMs>(latency)});
}
- void addMeasurementTag() {
- mGetOnlyParamTags.push_back(Visualizer::GetOnlyParameters::measurement);
- }
-
- void addCaptureBytesTag() {
- mGetOnlyParamTags.push_back(Visualizer::GetOnlyParameters::captureSampleBuffer);
- }
-
- bool isTagInRange(const Visualizer::Tag& tag, const Visualizer& vs,
- const Descriptor& desc) const {
- const Visualizer::Capability& vsCap = desc.capability.get<Capability::visualizer>();
- switch (tag) {
- case Visualizer::captureSamples: {
- int captureSize = vs.get<Visualizer::captureSamples>();
- return captureSize >= vsCap.captureSampleRange.min &&
- captureSize <= vsCap.captureSampleRange.max;
- }
- case Visualizer::scalingMode:
- case Visualizer::measurementMode:
- return true;
- case Visualizer::setOnlyParameters: {
- auto setOnly = vs.get<Visualizer::setOnlyParameters>();
- if (setOnly.getTag() != Visualizer::SetOnlyParameters::latencyMs) {
- return false;
- }
- auto latencyMs = setOnly.get<Visualizer::SetOnlyParameters::latencyMs>();
- return latencyMs >= 0 && latencyMs <= vsCap.maxLatencyMs;
- }
- default:
- return false;
- }
- }
-
- bool isSetOnlyParamTagInRange(const Visualizer& vs, const Descriptor& desc) const {
- const Visualizer::Capability& vsCap = desc.capability.get<Capability::visualizer>();
- if (vs.getTag() != Visualizer::setOnlyParameters) return false;
- Visualizer::SetOnlyParameters setOnlyParam = vs.get<Visualizer::setOnlyParameters>();
- if (setOnlyParam.getTag() != Visualizer::SetOnlyParameters::latencyMs) return false;
- int latency = setOnlyParam.get<Visualizer::SetOnlyParameters::latencyMs>();
- return isLatencyInRange(vsCap, latency);
- }
-
- bool isLatencyInRange(const Visualizer::Capability& cap, int latency) const {
- return (latency >= 0 && latency <= cap.maxLatencyMs);
- }
-
- static std::unordered_set<int> getCaptureSizeValues() {
- auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kVisualizerTypeUUID);
- int minCaptureSize = std::numeric_limits<int>::max();
- int maxCaptureSize = std::numeric_limits<int>::min();
- for (const auto& it : descList) {
- maxCaptureSize = std::max(
- it.second.capability.get<Capability::visualizer>().captureSampleRange.max,
- maxCaptureSize);
- minCaptureSize = std::min(
- it.second.capability.get<Capability ::visualizer>().captureSampleRange.min,
- minCaptureSize);
- }
- return {std::numeric_limits<int>::min(), minCaptureSize - 1, minCaptureSize,
- (minCaptureSize + maxCaptureSize) >> 1, maxCaptureSize, maxCaptureSize + 1,
- std::numeric_limits<int>::max()};
- }
-
- static std::unordered_set<int> getLatencyValues() {
- auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kVisualizerTypeUUID);
- const auto max = std::max_element(
- descList.begin(), descList.end(),
- [](const std::pair<std::shared_ptr<IFactory>, Descriptor>& a,
- const std::pair<std::shared_ptr<IFactory>, Descriptor>& b) {
- return a.second.capability.get<Capability::visualizer>().maxLatencyMs <
- b.second.capability.get<Capability::visualizer>().maxLatencyMs;
- });
- if (max == descList.end()) {
- return {0};
- }
- int maxDelay = max->second.capability.get<Capability::visualizer>().maxLatencyMs;
- return {-1, 0, maxDelay >> 1, maxDelay - 1, maxDelay, maxDelay + 1};
- }
static std::unordered_set<Visualizer::MeasurementMode> getMeasurementModeValues() {
return {ndk::enum_range<Visualizer::MeasurementMode>().begin(),
ndk::enum_range<Visualizer::MeasurementMode>().end()};
}
+
static std::unordered_set<Visualizer::ScalingMode> getScalingModeValues() {
return {ndk::enum_range<Visualizer::ScalingMode>().begin(),
ndk::enum_range<Visualizer::ScalingMode>().end()};
@@ -290,53 +150,43 @@
private:
std::vector<std::pair<Visualizer::Tag, Visualizer>> mCommonTags;
- std::vector<std::pair<Visualizer::SetOnlyParameters::Tag, Visualizer>> mSetOnlyParamTags;
- std::vector<Visualizer::GetOnlyParameters::Tag> mGetOnlyParamTags;
- void CleanUp() {
- mCommonTags.clear();
- mSetOnlyParamTags.clear();
- mGetOnlyParamTags.clear();
- }
+ void CleanUp() { mCommonTags.clear(); }
};
TEST_P(VisualizerParamTest, SetAndGetCaptureSize) {
EXPECT_NO_FATAL_FAILURE(addCaptureSizeParam(mCaptureSize));
- SetAndGetCommonParameters();
+ SetAndGetParameters();
}
TEST_P(VisualizerParamTest, SetAndGetScalingMode) {
EXPECT_NO_FATAL_FAILURE(addScalingModeParam(mScalingMode));
- SetAndGetCommonParameters();
+ SetAndGetParameters();
}
TEST_P(VisualizerParamTest, SetAndGetMeasurementMode) {
EXPECT_NO_FATAL_FAILURE(addMeasurementModeParam(mMeasurementMode));
- SetAndGetCommonParameters();
+ SetAndGetParameters();
}
TEST_P(VisualizerParamTest, SetAndGetLatency) {
EXPECT_NO_FATAL_FAILURE(addLatencyParam(mLatency));
- SetAndGetSetOnlyParameters();
+ SetAndGetParameters();
}
-TEST_P(VisualizerParamTest, GetAndSetMeasurement) {
- EXPECT_NO_FATAL_FAILURE(addMeasurementTag());
- GetandSetGetOnlyParameters();
-}
-
-TEST_P(VisualizerParamTest, GetAndSetCaptureBytes) {
- EXPECT_NO_FATAL_FAILURE(addCaptureBytesTag());
- GetandSetGetOnlyParameters();
-}
-
+std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kDescPair;
INSTANTIATE_TEST_SUITE_P(
VisualizerParamTest, VisualizerParamTest,
- ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
- IFactory::descriptor, kVisualizerTypeUUID)),
- testing::ValuesIn(VisualizerParamTest::getCaptureSizeValues()),
- testing::ValuesIn(VisualizerParamTest::getScalingModeValues()),
- testing::ValuesIn(VisualizerParamTest::getMeasurementModeValues()),
- testing::ValuesIn(VisualizerParamTest::getLatencyValues())),
+ ::testing::Combine(
+ testing::ValuesIn(kDescPair = EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, kVisualizerTypeUUID)),
+ testing::ValuesIn(EffectHelper::getTestValueSet<Visualizer, int, Range::visualizer,
+ Visualizer::captureSamples>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>)),
+ testing::ValuesIn(VisualizerParamTest::getScalingModeValues()),
+ testing::ValuesIn(VisualizerParamTest::getMeasurementModeValues()),
+ testing::ValuesIn(EffectHelper::getTestValueSet<Visualizer, int, Range::visualizer,
+ Visualizer::latencyMs>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>))),
[](const testing::TestParamInfo<VisualizerParamTest::ParamType>& info) {
auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
std::string captureSize = std::to_string(std::get<PARAM_CAPTURE_SIZE>(info.param));
diff --git a/audio/aidl/vts/VtsHalVolumeTargetTest.cpp b/audio/aidl/vts/VtsHalVolumeTargetTest.cpp
index 34625e7..44ce146 100644
--- a/audio/aidl/vts/VtsHalVolumeTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalVolumeTargetTest.cpp
@@ -22,7 +22,6 @@
using namespace android;
-using aidl::android::hardware::audio::effect::Capability;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::IFactory;
@@ -84,9 +83,7 @@
// validate parameter
Descriptor desc;
ASSERT_STATUS(EX_NONE, mEffect->getDescriptor(&desc));
- // only set and get parameter if capability is valid
- ASSERT_TRUE(isCapabilityValid(desc));
- const bool valid = isTagInRange(it.first, it.second, desc);
+ const bool valid = isParameterValid<Volume, Range::volume>(it.second, desc);
const binder_exception_t expected = valid ? EX_NONE : EX_ILLEGAL_ARGUMENT;
// set parameter
@@ -123,42 +120,6 @@
mTags.push_back({Volume::mute, vol});
}
- bool isCapabilityValid(const Descriptor& desc) {
- const Volume::Capability& volCap = desc.capability.get<Capability::volume>();
- return (volCap.minLevelDb <= volCap.maxLevelDb);
- }
-
- bool isTagInRange(const Volume::Tag& tag, const Volume& vol, const Descriptor& desc) const {
- const Volume::Capability& volCap = desc.capability.get<Capability::volume>();
- switch (tag) {
- case Volume::levelDb: {
- int level = vol.get<Volume::levelDb>();
- return isLevelInRange(volCap, level);
- }
- case Volume::mute:
- return true;
- default:
- return false;
- }
- }
-
- static std::vector<int> getLevelTestValues(
- std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kFactoryDescList) {
- int minLevelDb = std::numeric_limits<int>::max();
- int maxLevelDb = std::numeric_limits<int>::min();
- for (const auto& it : kFactoryDescList) {
- maxLevelDb =
- std::max(it.second.capability.get<Capability::volume>().maxLevelDb, maxLevelDb);
- minLevelDb = std::min(it.second.capability.get<Capability ::volume>().minLevelDb,
- minLevelDb);
- }
- return {minLevelDb - 1, minLevelDb, -100, maxLevelDb, maxLevelDb + 1};
- }
-
- bool isLevelInRange(const Volume::Capability& volCap, int level) const {
- return level >= volCap.minLevelDb && level <= volCap.maxLevelDb;
- }
-
private:
std::vector<std::pair<Volume::Tag, Volume>> mTags;
void CleanUp() { mTags.clear(); }
@@ -174,14 +135,15 @@
SetAndGetParameters();
}
+std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> kDescPair;
INSTANTIATE_TEST_SUITE_P(
VolumeTest, VolumeParamTest,
::testing::Combine(
- testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kVolumeTypeUUID)),
- testing::ValuesIn(VolumeParamTest::getLevelTestValues(
- EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor,
- kVolumeTypeUUID))),
+ testing::ValuesIn(kDescPair = EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, kVolumeTypeUUID)),
+ testing::ValuesIn(
+ EffectHelper::getTestValueSet<Volume, int, Range::volume, Volume::levelDb>(
+ kDescPair, EffectHelper::expandTestValueBasic<int>)),
testing::Bool() /* mute */),
[](const testing::TestParamInfo<VolumeParamTest::ParamType>& info) {
auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LatencyMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LatencyMode.aidl
index 5583679..1140f9e 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LatencyMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LatencyMode.aidl
@@ -34,7 +34,9 @@
package android.hardware.bluetooth.audio;
@Backing(type="int") @VintfStability
enum LatencyMode {
- UNKNOWN = 0,
- LOW_LATENCY = 1,
- FREE = 2,
+ UNKNOWN,
+ LOW_LATENCY,
+ FREE,
+ DYNAMIC_SPATIAL_AUDIO_SOFTWARE,
+ DYNAMIC_SPATIAL_AUDIO_HARDWARE,
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl
index 7d53b0c..2945710 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl
@@ -41,5 +41,6 @@
char streamHandle;
int audioChannelAllocation;
android.hardware.bluetooth.audio.LeAudioCodecConfiguration leAudioCodecConfig;
+ char pcmStreamId;
}
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
index edb6795..679655c 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
@@ -42,5 +42,6 @@
parcelable StreamMap {
char streamHandle;
int audioChannelAllocation;
+ boolean isStreamActive;
}
}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LatencyMode.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LatencyMode.aidl
index 0c354f7..ec181c1 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LatencyMode.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LatencyMode.aidl
@@ -22,4 +22,6 @@
UNKNOWN,
LOW_LATENCY,
FREE,
+ DYNAMIC_SPATIAL_AUDIO_SOFTWARE,
+ DYNAMIC_SPATIAL_AUDIO_HARDWARE
}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl
index e9a1a0c..16503fb 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl
@@ -35,6 +35,10 @@
*/
int audioChannelAllocation;
LeAudioCodecConfiguration leAudioCodecConfig;
+ /*
+ * Pcm stream id to identify the source for given streamHandle.
+ */
+ char pcmStreamId;
}
CodecType codecType;
BroadcastStreamMap[] streamMap;
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
index 0d1e3de..f22f309 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
@@ -35,6 +35,10 @@
* Audio Location assigned number.
*/
int audioChannelAllocation;
+ /*
+ * The stream handle status
+ */
+ boolean isStreamActive;
}
CodecType codecType;
StreamMap[] streamMap;
diff --git a/bluetooth/audio/aidl/default/Android.bp b/bluetooth/audio/aidl/default/Android.bp
index cbf23dc..e4c2844 100644
--- a/bluetooth/audio/aidl/default/Android.bp
+++ b/bluetooth/audio/aidl/default/Android.bp
@@ -29,7 +29,7 @@
"libcutils",
"libfmq",
"liblog",
- "android.hardware.bluetooth.audio-V2-ndk",
+ "android.hardware.bluetooth.audio-V3-ndk",
"libbluetooth_audio_session_aidl",
],
}
diff --git a/bluetooth/audio/aidl/default/bluetooth_audio.xml b/bluetooth/audio/aidl/default/bluetooth_audio.xml
index c4b1872..c0bc55e 100644
--- a/bluetooth/audio/aidl/default/bluetooth_audio.xml
+++ b/bluetooth/audio/aidl/default/bluetooth_audio.xml
@@ -1,7 +1,7 @@
<manifest version="1.0" type="device">
<hal format="aidl">
<name>android.hardware.bluetooth.audio</name>
- <version>2</version>
+ <version>3</version>
<fqname>IBluetoothAudioProviderFactory/default</fqname>
</hal>
</manifest>
diff --git a/bluetooth/audio/aidl/vts/Android.bp b/bluetooth/audio/aidl/vts/Android.bp
index 3aed1b3..e03fb58 100644
--- a/bluetooth/audio/aidl/vts/Android.bp
+++ b/bluetooth/audio/aidl/vts/Android.bp
@@ -17,7 +17,7 @@
srcs: ["VtsHalBluetoothAudioTargetTest.cpp"],
shared_libs: [
"android.hardware.audio.common-V1-ndk",
- "android.hardware.bluetooth.audio-V2-ndk",
+ "android.hardware.bluetooth.audio-V3-ndk",
"android.hardware.common-V2-ndk",
"android.hardware.common.fmq-V1-ndk",
"libbase",
diff --git a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
index e9b74b7..6a913f7 100644
--- a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
+++ b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
@@ -1566,9 +1566,14 @@
};
for (auto& lc3_config : lc3_codec_configs) {
+ le_audio_broadcast_config.streamMap.resize(1);
le_audio_broadcast_config.streamMap[0]
.leAudioCodecConfig.set<LeAudioCodecConfiguration::lc3Config>(
lc3_config);
+ le_audio_broadcast_config.streamMap[0].streamHandle = 0x0;
+ le_audio_broadcast_config.streamMap[0].pcmStreamId = 0x0;
+ le_audio_broadcast_config.streamMap[0].audioChannelAllocation = 0x1 << 0;
+
DataMQDesc mq_desc;
auto aidl_retval = audio_provider_->startSession(
audio_port_, AudioConfiguration(le_audio_broadcast_config),
diff --git a/bluetooth/audio/utils/Android.bp b/bluetooth/audio/utils/Android.bp
index 70797a7..914d2b2 100644
--- a/bluetooth/audio/utils/Android.bp
+++ b/bluetooth/audio/utils/Android.bp
@@ -55,7 +55,7 @@
"libbinder_ndk",
"libfmq",
"liblog",
- "android.hardware.bluetooth.audio-V2-ndk",
+ "android.hardware.bluetooth.audio-V3-ndk",
"libhidlbase",
"libxml2",
],
@@ -75,7 +75,7 @@
shared_libs: [
"libbase",
"libbinder_ndk",
- "android.hardware.bluetooth.audio-V2-ndk",
+ "android.hardware.bluetooth.audio-V3-ndk",
"libxml2",
],
test_suites: [
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp
index 1dec900..0a804bb 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp
@@ -200,13 +200,21 @@
GetUnicastCapability(scenario.getEncode());
UnicastCapability unicast_decode_capability =
GetUnicastCapability(scenario.getDecode());
- // encode and decode cannot be unknown at the same time
- if (unicast_encode_capability.codecType == CodecType::UNKNOWN &&
- unicast_decode_capability.codecType == CodecType::UNKNOWN) {
- continue;
- }
BroadcastCapability broadcast_capability = {.codecType =
CodecType::UNKNOWN};
+
+ if (scenario.hasBroadcast()) {
+ broadcast_capability = GetBroadcastCapability(scenario.getBroadcast());
+ }
+
+ // At least one capability should be valid
+ if (unicast_encode_capability.codecType == CodecType::UNKNOWN &&
+ unicast_decode_capability.codecType == CodecType::UNKNOWN &&
+ broadcast_capability.codecType == CodecType::UNKNOWN) {
+ LOG(ERROR) << __func__ << ": None of the capability is valid.";
+ continue;
+ }
+
le_audio_codec_capabilities.push_back(
{.unicastEncodeCapability = unicast_encode_capability,
.unicastDecodeCapability = unicast_decode_capability,
@@ -252,6 +260,54 @@
return {.codecType = CodecType::UNKNOWN};
}
+BroadcastCapability BluetoothLeAudioCodecsProvider::GetBroadcastCapability(
+ const std::string& coding_direction) {
+ if (coding_direction == "invalid") {
+ return {.codecType = CodecType::UNKNOWN};
+ }
+
+ auto configuration_iter = configuration_map_.find(coding_direction);
+ if (configuration_iter == configuration_map_.end()) {
+ return {.codecType = CodecType::UNKNOWN};
+ }
+
+ auto codec_configuration_iter = codec_configuration_map_.find(
+ configuration_iter->second.getCodecConfiguration());
+ if (codec_configuration_iter == codec_configuration_map_.end()) {
+ return {.codecType = CodecType::UNKNOWN};
+ }
+
+ auto strategy_configuration_iter = strategy_configuration_map_.find(
+ configuration_iter->second.getStrategyConfiguration());
+ if (strategy_configuration_iter == strategy_configuration_map_.end()) {
+ return {.codecType = CodecType::UNKNOWN};
+ }
+
+ CodecType codec_type =
+ GetCodecType(codec_configuration_iter->second.getCodec());
+ std::vector<std::optional<Lc3Capabilities>> bcastLc3Cap(
+ 1, std::optional(ComposeLc3Capability(codec_configuration_iter->second)));
+
+ if (codec_type == CodecType::LC3) {
+ return ComposeBroadcastCapability(
+ codec_type,
+ GetAudioLocation(
+ strategy_configuration_iter->second.getAudioLocation()),
+ strategy_configuration_iter->second.getChannelCount(), bcastLc3Cap);
+ }
+ return {.codecType = CodecType::UNKNOWN};
+}
+
+template <class T>
+BroadcastCapability BluetoothLeAudioCodecsProvider::ComposeBroadcastCapability(
+ const CodecType& codec_type, const AudioLocation& audio_location,
+ const uint8_t& channel_count, const std::vector<T>& capability) {
+ return {.codecType = codec_type,
+ .supportedChannel = audio_location,
+ .channelCountPerStream = channel_count,
+ .leAudioCodecCapabilities = std::optional(capability)};
+}
+
template <class T>
UnicastCapability BluetoothLeAudioCodecsProvider::ComposeUnicastCapability(
const CodecType& codec_type, const AudioLocation& audio_location,
@@ -322,6 +378,10 @@
// 1. two connected device, one for L one for R
// 2. one connected device for both L and R
return true;
+ } else if (strategy_configuration.getConnectedDevice() == 0 &&
+ strategy_configuration.getChannelCount() == 2) {
+ // Broadcast
+ return true;
}
} else if (strategy_configuration.getAudioLocation() ==
setting::AudioLocation::MONO) {
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h
index e879984..06e4595 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h
+++ b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h
@@ -20,6 +20,7 @@
#include <android-base/logging.h>
#include <unordered_map>
+#include <vector>
#include "aidl_android_hardware_bluetooth_audio_setting.h"
@@ -66,12 +67,20 @@
static UnicastCapability GetUnicastCapability(
const std::string& coding_direction);
+ static BroadcastCapability GetBroadcastCapability(
+ const std::string& coding_direction);
+
template <class T>
static inline UnicastCapability ComposeUnicastCapability(
const CodecType& codec_type, const AudioLocation& audio_location,
const uint8_t& device_cnt, const uint8_t& channel_count,
const T& capability);
+ template <class T>
+ static inline BroadcastCapability ComposeBroadcastCapability(
+ const CodecType& codec_type, const AudioLocation& audio_location,
+ const uint8_t& channel_count, const std::vector<T>& capability);
+
static inline Lc3Capabilities ComposeLc3Capability(
const setting::CodecConfiguration& codec_configuration);
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProviderTest.cpp b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProviderTest.cpp
index 5393cd7..dba2749 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProviderTest.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProviderTest.cpp
@@ -46,7 +46,11 @@
// Define valid components for each list
// Scenario
static const Scenario kValidScenario(std::make_optional("OneChanStereo_16_1"),
- std::make_optional("OneChanStereo_16_1"));
+ std::make_optional("OneChanStereo_16_1"),
+ std::nullopt);
+static const Scenario kValidBroadcastScenario(
+ std::nullopt, std::nullopt, std::make_optional("BcastStereo_16_2"));
+
// Configuration
static const Configuration kValidConfigOneChanStereo_16_1(
std::make_optional("OneChanStereo_16_1"), std::make_optional("LC3_16k_1"),
@@ -69,11 +73,15 @@
std::make_optional("MONO_ONE_CIS_PER_DEVICE"),
std::make_optional(AudioLocation::MONO), std::make_optional(1),
std::make_optional(1));
+static const StrategyConfiguration kValidStrategyBroadcastStereo(
+ std::make_optional("BROADCAST_STEREO"),
+ std::make_optional(AudioLocation::STEREO), std::make_optional(0),
+ std::make_optional(2));
// Define valid test list built from above valid components
// Scenario, Configuration, CodecConfiguration, StrategyConfiguration
-static const std::vector<ScenarioList> kValidScenarioList = {
- ScenarioList(std::vector<Scenario>{kValidScenario})};
+static const std::vector<ScenarioList> kValidScenarioList = {ScenarioList(
+ std::vector<Scenario>{kValidScenario, kValidBroadcastScenario})};
static const std::vector<ConfigurationList> kValidConfigurationList = {
ConfigurationList(
std::vector<Configuration>{kValidConfigOneChanStereo_16_1})};
@@ -84,7 +92,7 @@
kValidStrategyConfigurationList = {
StrategyConfigurationList(std::vector<StrategyConfiguration>{
kValidStrategyStereoOneCis, kValidStrategyStereoTwoCis,
- kValidStrategyMonoOneCis})};
+ kValidStrategyMonoOneCis, kValidStrategyBroadcastStereo})};
class BluetoothLeAudioCodecsProviderTest
: public ::testing::TestWithParam<OffloadSetting> {
@@ -151,13 +159,15 @@
static std::vector<ScenarioList> CreateInvalidScenarios() {
std::vector<ScenarioList> invalid_scenario_test_cases;
invalid_scenario_test_cases.push_back(ScenarioList(std::vector<Scenario>{
- Scenario(std::nullopt, std::make_optional("OneChanStereo_16_1"))}));
-
- invalid_scenario_test_cases.push_back(ScenarioList(std::vector<Scenario>{
- Scenario(std::make_optional("OneChanStereo_16_1"), std::nullopt)}));
+ Scenario(std::nullopt, std::make_optional("OneChanStereo_16_1"),
+ std::nullopt)}));
invalid_scenario_test_cases.push_back(ScenarioList(
- std::vector<Scenario>{Scenario(std::nullopt, std::nullopt)}));
+ std::vector<Scenario>{Scenario(std::make_optional("OneChanStereo_16_1"),
+ std::nullopt, std::nullopt)}));
+
+ invalid_scenario_test_cases.push_back(ScenarioList(std::vector<Scenario>{
+ Scenario(std::nullopt, std::nullopt, std::nullopt)}));
invalid_scenario_test_cases.push_back(
ScenarioList(std::vector<Scenario>{}));
diff --git a/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xml b/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xml
index c7904b3..c8d1af0 100644
--- a/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xml
+++ b/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xml
@@ -40,6 +40,8 @@
<scenario encode="OneChanStereo_16_2" decode="OneChanMono_16_2"/>
<scenario encode="TwoChanStereo_16_2" decode="OneChanMono_16_2"/>
<scenario encode="OneChanMono_16_2" decode="OneChanMono_16_2"/>
+ <!-- broadcast -->
+ <scenario encode="invalid" decode="invalid" broadcast="BcastStereo_16_2"/>
</scenarioList>
<configurationList>
<configuration name="OneChanMono_16_1" codecConfiguration="LC3_16k_1" strategyConfiguration="MONO_ONE_CIS_PER_DEVICE"/>
@@ -48,6 +50,7 @@
<configuration name="OneChanMono_16_2" codecConfiguration="LC3_16k_2" strategyConfiguration="MONO_ONE_CIS_PER_DEVICE"/>
<configuration name="TwoChanStereo_16_2" codecConfiguration="LC3_16k_2" strategyConfiguration="STEREO_TWO_CISES_PER_DEVICE"/>
<configuration name="OneChanStereo_16_2" codecConfiguration="LC3_16k_2" strategyConfiguration="STEREO_ONE_CIS_PER_DEVICE"/>
+ <configuration name="BcastStereo_16_2" codecConfiguration="LC3_16k_2" strategyConfiguration="BROADCAST_STEREO"/>
</configurationList>
<codecConfigurationList>
<codecConfiguration name="LC3_16k_1" codec="LC3" samplingFrequency="16000" frameDurationUs="7500" octetsPerCodecFrame="30"/>
@@ -57,5 +60,6 @@
<strategyConfiguration name="STEREO_ONE_CIS_PER_DEVICE" audioLocation="STEREO" connectedDevice="2" channelCount="1"/>
<strategyConfiguration name="STEREO_TWO_CISES_PER_DEVICE" audioLocation="STEREO" connectedDevice="1" channelCount="2"/>
<strategyConfiguration name="MONO_ONE_CIS_PER_DEVICE" audioLocation="MONO" connectedDevice="1" channelCount="1"/>
+ <strategyConfiguration name="BROADCAST_STEREO" audioLocation="STEREO" connectedDevice="0" channelCount="2"/>
</strategyConfigurationList>
</leAudioOffloadSetting>
diff --git a/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xsd b/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xsd
index 213e597..8c2d6a1 100644
--- a/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xsd
+++ b/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xsd
@@ -32,6 +32,7 @@
<xs:complexType>
<xs:attribute name="encode" type="xs:string"/>
<xs:attribute name="decode" type="xs:string"/>
+ <xs:attribute name="broadcast" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="configuration">
diff --git a/bluetooth/audio/utils/le_audio_codec_capabilities/schema/current.txt b/bluetooth/audio/utils/le_audio_codec_capabilities/schema/current.txt
index 06aa21a..886350e 100644
--- a/bluetooth/audio/utils/le_audio_codec_capabilities/schema/current.txt
+++ b/bluetooth/audio/utils/le_audio_codec_capabilities/schema/current.txt
@@ -64,8 +64,10 @@
public class Scenario {
ctor public Scenario();
+ method public String getBroadcast();
method public String getDecode();
method public String getEncode();
+ method public void setBroadcast(String);
method public void setDecode(String);
method public void setEncode(String);
}
diff --git a/bluetooth/hci/test/h4_protocol_unittest.cc b/bluetooth/hci/test/h4_protocol_unittest.cc
index d6f74fc..d3fab61 100644
--- a/bluetooth/hci/test/h4_protocol_unittest.cc
+++ b/bluetooth/hci/test/h4_protocol_unittest.cc
@@ -50,6 +50,9 @@
static char iso_data[100] =
"A plane angle is the inclination to one another of two lines in a ...";
+// 5 seconds. Just don't hang.
+static constexpr size_t kTimeoutMs = 5000;
+
MATCHER_P3(PacketMatches, header_, header_length, payload,
"Match header_length bytes of header and then the payload") {
size_t payload_length = strlen(payload);
@@ -131,9 +134,9 @@
.WillOnce(Notify(promise));
}
- void WaitForTimeout(size_t timeout_ms, std::promise<void>* promise) {
+ void WaitForTimeout(std::promise<void>* promise) {
auto future = promise->get_future();
- auto status = future.wait_for(std::chrono::milliseconds(timeout_ms));
+ auto status = future.wait_for(std::chrono::milliseconds(kTimeoutMs));
EXPECT_EQ(status, std::future_status::ready);
}
@@ -263,10 +266,10 @@
WriteInboundIsoData(iso_data);
CallDataReady();
- WaitForTimeout(100, &acl_promise);
- WaitForTimeout(100, &sco_promise);
- WaitForTimeout(100, &event_promise);
- WaitForTimeout(100, &iso_promise);
+ WaitForTimeout(&acl_promise);
+ WaitForTimeout(&sco_promise);
+ WaitForTimeout(&event_promise);
+ WaitForTimeout(&iso_promise);
}
TEST_F(H4ProtocolTest, TestMultiplePackets) {
@@ -363,28 +366,28 @@
std::promise<void> promise;
ExpectInboundAclData(payload, &promise);
WriteInboundAclData(payload);
- WaitForTimeout(100, &promise);
+ WaitForTimeout(&promise);
}
void WriteAndExpectInboundScoData(char* payload) {
std::promise<void> promise;
ExpectInboundScoData(payload, &promise);
WriteInboundScoData(payload);
- WaitForTimeout(100, &promise);
+ WaitForTimeout(&promise);
}
void WriteAndExpectInboundEvent(char* payload) {
std::promise<void> promise;
ExpectInboundEvent(payload, &promise);
WriteInboundEvent(payload);
- WaitForTimeout(100, &promise);
+ WaitForTimeout(&promise);
}
void WriteAndExpectInboundIsoData(char* payload) {
std::promise<void> promise;
ExpectInboundIsoData(payload, &promise);
WriteInboundIsoData(payload);
- WaitForTimeout(100, &promise);
+ WaitForTimeout(&promise);
}
void WriteAndExpectManyInboundAclDataPackets(char* payload) {
@@ -436,6 +439,5 @@
EXPECT_CALL(disconnect_cb_, Call()).WillOnce(Notify(&promise));
close(chip_uart_fd_);
- // Fail if it takes longer than 100 ms.
- WaitForTimeout(100, &promise);
+ WaitForTimeout(&promise);
}
diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
index b0ae20e..5ea6ae2 100644
--- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
+++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
@@ -6318,8 +6318,6 @@
std::vector<AvailableStream>& outputStreams,
const AvailableStream* threshold,
bool maxResolution) {
- AvailableStream depthPreviewThreshold = {kMaxPreviewWidth, kMaxPreviewHeight,
- static_cast<int32_t>(PixelFormat::Y16)};
if (nullptr == staticMeta) {
return Status::ILLEGAL_ARGUMENT;
}
@@ -6345,8 +6343,12 @@
}
if(foundDepth == 0 && (0 == (depthEntry.count % 4))) {
- fillOutputStreams(&depthEntry, outputStreams, &depthPreviewThreshold,
- ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS_OUTPUT);
+ AvailableStream depthPreviewThreshold = {kMaxPreviewWidth, kMaxPreviewHeight,
+ static_cast<int32_t>(PixelFormat::Y16)};
+ const AvailableStream* depthThreshold =
+ (threshold != nullptr) ? threshold : &depthPreviewThreshold;
+ fillOutputStreams(&depthEntry, outputStreams, depthThreshold,
+ ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS_OUTPUT);
}
return Status::OK;
diff --git a/camera/provider/aidl/vts/camera_aidl_test.cpp b/camera/provider/aidl/vts/camera_aidl_test.cpp
index 48816ad9..12a26d2 100644
--- a/camera/provider/aidl/vts/camera_aidl_test.cpp
+++ b/camera/provider/aidl/vts/camera_aidl_test.cpp
@@ -751,8 +751,6 @@
std::vector<AvailableStream>& outputStreams,
const AvailableStream* threshold,
bool maxResolution) {
- AvailableStream depthPreviewThreshold = {kMaxPreviewWidth, kMaxPreviewHeight,
- static_cast<int32_t>(PixelFormat::Y16)};
if (nullptr == staticMeta) {
return Status::ILLEGAL_ARGUMENT;
}
@@ -778,7 +776,11 @@
}
if (foundDepth == 0 && (0 == (depthEntry.count % 4))) {
- fillOutputStreams(&depthEntry, outputStreams, &depthPreviewThreshold,
+ AvailableStream depthPreviewThreshold = {kMaxPreviewWidth, kMaxPreviewHeight,
+ static_cast<int32_t>(PixelFormat::Y16)};
+ const AvailableStream* depthThreshold =
+ (threshold != nullptr) ? threshold : &depthPreviewThreshold;
+ fillOutputStreams(&depthEntry, outputStreams, depthThreshold,
ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS_OUTPUT);
}
diff --git a/cas/aidl/default/OWNERS b/cas/aidl/OWNERS
similarity index 100%
rename from cas/aidl/default/OWNERS
rename to cas/aidl/OWNERS
diff --git a/compatibility_matrices/compatibility_matrix.4.xml b/compatibility_matrices/compatibility_matrix.4.xml
index 8ef0b3a..c898aab 100644
--- a/compatibility_matrices/compatibility_matrix.4.xml
+++ b/compatibility_matrices/compatibility_matrix.4.xml
@@ -171,7 +171,7 @@
<instance>default</instance>
</interface>
</hal>
- <hal format="hidl" optional="false">
+ <hal format="hidl" optional="true">
<name>android.hardware.gatekeeper</name>
<version>1.0</version>
<interface>
diff --git a/compatibility_matrices/compatibility_matrix.5.xml b/compatibility_matrices/compatibility_matrix.5.xml
index 12b85c7..c5a1dc2 100644
--- a/compatibility_matrices/compatibility_matrix.5.xml
+++ b/compatibility_matrices/compatibility_matrix.5.xml
@@ -192,7 +192,7 @@
<instance>default</instance>
</interface>
</hal>
- <hal format="hidl" optional="false">
+ <hal format="hidl" optional="true">
<name>android.hardware.gatekeeper</name>
<version>1.0</version>
<interface>
diff --git a/compatibility_matrices/compatibility_matrix.6.xml b/compatibility_matrices/compatibility_matrix.6.xml
index e19d2dd..1c76ee6 100644
--- a/compatibility_matrices/compatibility_matrix.6.xml
+++ b/compatibility_matrices/compatibility_matrix.6.xml
@@ -215,7 +215,7 @@
<instance>default</instance>
</interface>
</hal>
- <hal format="hidl" optional="false">
+ <hal format="hidl" optional="true">
<name>android.hardware.gatekeeper</name>
<version>1.0</version>
<interface>
diff --git a/compatibility_matrices/compatibility_matrix.8.xml b/compatibility_matrices/compatibility_matrix.8.xml
index eb649bf..c7b05e8 100644
--- a/compatibility_matrices/compatibility_matrix.8.xml
+++ b/compatibility_matrices/compatibility_matrix.8.xml
@@ -167,7 +167,7 @@
</hal>
<hal format="aidl" optional="true">
<name>android.hardware.bluetooth.audio</name>
- <version>2</version>
+ <version>3</version>
<interface>
<name>IBluetoothAudioProviderFactory</name>
<instance>default</instance>
diff --git a/neuralnetworks/1.2/utils/src/BurstUtils.cpp b/neuralnetworks/1.2/utils/src/BurstUtils.cpp
index b589c46..c4c096d 100644
--- a/neuralnetworks/1.2/utils/src/BurstUtils.cpp
+++ b/neuralnetworks/1.2/utils/src/BurstUtils.cpp
@@ -190,12 +190,13 @@
size_t index = 0;
// validate packet information
- if (data.size() == 0 || data[index].getDiscriminator() != discriminator::packetInformation) {
+ if (index >= data.size() ||
+ data.at(index).getDiscriminator() != discriminator::packetInformation) {
return NN_ERROR() << "FMQ Request packet ill-formed";
}
// unpackage packet information
- const FmqRequestDatum::PacketInformation& packetInfo = data[index].packetInformation();
+ const FmqRequestDatum::PacketInformation& packetInfo = data.at(index).packetInformation();
index++;
const uint32_t packetSize = packetInfo.packetSize;
const uint32_t numberOfInputOperands = packetInfo.numberOfInputOperands;
@@ -212,13 +213,14 @@
inputs.reserve(numberOfInputOperands);
for (size_t operand = 0; operand < numberOfInputOperands; ++operand) {
// validate input operand information
- if (data[index].getDiscriminator() != discriminator::inputOperandInformation) {
+ if (index >= data.size() ||
+ data.at(index).getDiscriminator() != discriminator::inputOperandInformation) {
return NN_ERROR() << "FMQ Request packet ill-formed";
}
// unpackage operand information
const FmqRequestDatum::OperandInformation& operandInfo =
- data[index].inputOperandInformation();
+ data.at(index).inputOperandInformation();
index++;
const bool hasNoValue = operandInfo.hasNoValue;
const V1_0::DataLocation location = operandInfo.location;
@@ -229,12 +231,13 @@
dimensions.reserve(numberOfDimensions);
for (size_t i = 0; i < numberOfDimensions; ++i) {
// validate dimension
- if (data[index].getDiscriminator() != discriminator::inputOperandDimensionValue) {
+ if (index >= data.size() ||
+ data.at(index).getDiscriminator() != discriminator::inputOperandDimensionValue) {
return NN_ERROR() << "FMQ Request packet ill-formed";
}
// unpackage dimension
- const uint32_t dimension = data[index].inputOperandDimensionValue();
+ const uint32_t dimension = data.at(index).inputOperandDimensionValue();
index++;
// store result
@@ -251,13 +254,14 @@
outputs.reserve(numberOfOutputOperands);
for (size_t operand = 0; operand < numberOfOutputOperands; ++operand) {
// validate output operand information
- if (data[index].getDiscriminator() != discriminator::outputOperandInformation) {
+ if (index >= data.size() ||
+ data.at(index).getDiscriminator() != discriminator::outputOperandInformation) {
return NN_ERROR() << "FMQ Request packet ill-formed";
}
// unpackage operand information
const FmqRequestDatum::OperandInformation& operandInfo =
- data[index].outputOperandInformation();
+ data.at(index).outputOperandInformation();
index++;
const bool hasNoValue = operandInfo.hasNoValue;
const V1_0::DataLocation location = operandInfo.location;
@@ -268,12 +272,13 @@
dimensions.reserve(numberOfDimensions);
for (size_t i = 0; i < numberOfDimensions; ++i) {
// validate dimension
- if (data[index].getDiscriminator() != discriminator::outputOperandDimensionValue) {
+ if (index >= data.size() ||
+ data.at(index).getDiscriminator() != discriminator::outputOperandDimensionValue) {
return NN_ERROR() << "FMQ Request packet ill-formed";
}
// unpackage dimension
- const uint32_t dimension = data[index].outputOperandDimensionValue();
+ const uint32_t dimension = data.at(index).outputOperandDimensionValue();
index++;
// store result
@@ -290,12 +295,13 @@
slots.reserve(numberOfPools);
for (size_t pool = 0; pool < numberOfPools; ++pool) {
// validate input operand information
- if (data[index].getDiscriminator() != discriminator::poolIdentifier) {
+ if (index >= data.size() ||
+ data.at(index).getDiscriminator() != discriminator::poolIdentifier) {
return NN_ERROR() << "FMQ Request packet ill-formed";
}
// unpackage operand information
- const int32_t poolId = data[index].poolIdentifier();
+ const int32_t poolId = data.at(index).poolIdentifier();
index++;
// store result
@@ -303,17 +309,17 @@
}
// validate measureTiming
- if (data[index].getDiscriminator() != discriminator::measureTiming) {
+ if (index >= data.size() || data.at(index).getDiscriminator() != discriminator::measureTiming) {
return NN_ERROR() << "FMQ Request packet ill-formed";
}
// unpackage measureTiming
- const V1_2::MeasureTiming measure = data[index].measureTiming();
+ const V1_2::MeasureTiming measure = data.at(index).measureTiming();
index++;
// validate packet information
if (index != packetSize) {
- return NN_ERROR() << "FMQ Result packet ill-formed";
+ return NN_ERROR() << "FMQ Request packet ill-formed";
}
// return request
@@ -328,12 +334,13 @@
size_t index = 0;
// validate packet information
- if (data.size() == 0 || data[index].getDiscriminator() != discriminator::packetInformation) {
+ if (index >= data.size() ||
+ data.at(index).getDiscriminator() != discriminator::packetInformation) {
return NN_ERROR() << "FMQ Result packet ill-formed";
}
// unpackage packet information
- const FmqResultDatum::PacketInformation& packetInfo = data[index].packetInformation();
+ const FmqResultDatum::PacketInformation& packetInfo = data.at(index).packetInformation();
index++;
const uint32_t packetSize = packetInfo.packetSize;
const V1_0::ErrorStatus errorStatus = packetInfo.errorStatus;
@@ -349,12 +356,13 @@
outputShapes.reserve(numberOfOperands);
for (size_t operand = 0; operand < numberOfOperands; ++operand) {
// validate operand information
- if (data[index].getDiscriminator() != discriminator::operandInformation) {
+ if (index >= data.size() ||
+ data.at(index).getDiscriminator() != discriminator::operandInformation) {
return NN_ERROR() << "FMQ Result packet ill-formed";
}
// unpackage operand information
- const FmqResultDatum::OperandInformation& operandInfo = data[index].operandInformation();
+ const FmqResultDatum::OperandInformation& operandInfo = data.at(index).operandInformation();
index++;
const bool isSufficient = operandInfo.isSufficient;
const uint32_t numberOfDimensions = operandInfo.numberOfDimensions;
@@ -364,12 +372,13 @@
dimensions.reserve(numberOfDimensions);
for (size_t i = 0; i < numberOfDimensions; ++i) {
// validate dimension
- if (data[index].getDiscriminator() != discriminator::operandDimensionValue) {
+ if (index >= data.size() ||
+ data.at(index).getDiscriminator() != discriminator::operandDimensionValue) {
return NN_ERROR() << "FMQ Result packet ill-formed";
}
// unpackage dimension
- const uint32_t dimension = data[index].operandDimensionValue();
+ const uint32_t dimension = data.at(index).operandDimensionValue();
index++;
// store result
@@ -381,12 +390,13 @@
}
// validate execution timing
- if (data[index].getDiscriminator() != discriminator::executionTiming) {
+ if (index >= data.size() ||
+ data.at(index).getDiscriminator() != discriminator::executionTiming) {
return NN_ERROR() << "FMQ Result packet ill-formed";
}
// unpackage execution timing
- const V1_2::Timing timing = data[index].executionTiming();
+ const V1_2::Timing timing = data.at(index).executionTiming();
index++;
// validate packet information
diff --git a/secure_element/1.0/vts/OWNERS b/secure_element/1.0/vts/OWNERS
deleted file mode 100644
index c7963e7..0000000
--- a/secure_element/1.0/vts/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-alisher@google.com
-jackcwyu@google.com
-georgekgchang@google.com
-zachoverflow@google.com
diff --git a/secure_element/1.0/vts/functional/OWNERS b/secure_element/1.0/vts/functional/OWNERS
deleted file mode 100644
index a7ee7e9..0000000
--- a/secure_element/1.0/vts/functional/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-# Bug component: 456592
-jackcwyu@google.com
diff --git a/secure_element/1.1/vts/OWNERS b/secure_element/1.1/vts/OWNERS
deleted file mode 100644
index c7963e7..0000000
--- a/secure_element/1.1/vts/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-alisher@google.com
-jackcwyu@google.com
-georgekgchang@google.com
-zachoverflow@google.com
diff --git a/secure_element/1.1/vts/functional/OWNERS b/secure_element/1.1/vts/functional/OWNERS
deleted file mode 100644
index a7ee7e9..0000000
--- a/secure_element/1.1/vts/functional/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-# Bug component: 456592
-jackcwyu@google.com
diff --git a/secure_element/1.2/vts/OWNERS b/secure_element/1.2/vts/OWNERS
deleted file mode 100644
index c7963e7..0000000
--- a/secure_element/1.2/vts/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-alisher@google.com
-jackcwyu@google.com
-georgekgchang@google.com
-zachoverflow@google.com
diff --git a/secure_element/1.2/vts/functional/OWNERS b/secure_element/1.2/vts/functional/OWNERS
deleted file mode 100644
index a7ee7e9..0000000
--- a/secure_element/1.2/vts/functional/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-# Bug component: 456592
-jackcwyu@google.com
diff --git a/secure_element/OWNERS b/secure_element/OWNERS
new file mode 100644
index 0000000..492696b
--- /dev/null
+++ b/secure_element/OWNERS
@@ -0,0 +1,5 @@
+# Bug component: 456592
+alisher@google.com
+jackcwyu@google.com
+georgekgchang@google.com
+henrichataing@google.com
diff --git a/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp b/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp
index 37ff1b2..2e96f7d 100644
--- a/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp
+++ b/secure_element/aidl/vts/VtsHalSecureElementTargetTest.cpp
@@ -106,6 +106,15 @@
EXPECT_OK(secure_element_->init(secure_element_callback_));
secure_element_callback_->expectCallbackHistory({true});
+
+ // Check if the basic channel is supported by the bound SE.
+ std::vector<uint8_t> basic_channel_response;
+ auto status =
+ secure_element_->openBasicChannel(kSelectableAid, 0x00, &basic_channel_response);
+ if (status.isOk()) {
+ basic_channel_supported_ = true;
+ secure_element_->closeChannel(0);
+ }
}
void TearDown() override {
@@ -143,6 +152,7 @@
std::shared_ptr<ISecureElement> secure_element_;
std::shared_ptr<MySecureElementCallback> secure_element_callback_;
+ bool basic_channel_supported_{false};
};
TEST_P(SecureElementAidl, init) {
@@ -159,14 +169,18 @@
LogicalChannelResponse logical_channel_response;
// reset called after init shall succeed.
- EXPECT_OK(secure_element_->openBasicChannel(kSelectableAid, 0x00, &basic_channel_response));
+ if (basic_channel_supported_) {
+ EXPECT_OK(secure_element_->openBasicChannel(kSelectableAid, 0x00, &basic_channel_response));
+ }
EXPECT_OK(secure_element_->openLogicalChannel(kSelectableAid, 0x00, &logical_channel_response));
EXPECT_OK(secure_element_->reset());
secure_element_callback_->expectCallbackHistory({true, false, true});
// All opened channels must be closed.
- EXPECT_NE(transmit(0), 0x9000);
+ if (basic_channel_supported_) {
+ EXPECT_NE(transmit(0), 0x9000);
+ }
EXPECT_NE(transmit(logical_channel_response.channelNumber), 0x9000);
}
@@ -190,6 +204,10 @@
TEST_P(SecureElementAidl, openBasicChannel) {
std::vector<uint8_t> response;
+ if (!basic_channel_supported_) {
+ return;
+ }
+
// openBasicChannel called with an invalid AID shall fail.
EXPECT_ERR(secure_element_->openBasicChannel(kNonSelectableAid, 0x00, &response));
@@ -199,7 +217,7 @@
EXPECT_OK(secure_element_->openBasicChannel(kSelectableAid, 0x00, &response));
EXPECT_GE(response.size(), 2u);
- // tramsmit called on the basic channel should succeed.
+ // transmit called on the basic channel should succeed.
EXPECT_EQ(transmit(0), 0x9000);
// openBasicChannel called a second time shall fail.
@@ -225,7 +243,7 @@
EXPECT_GE(response.channelNumber, 1u);
EXPECT_LE(response.channelNumber, 19u);
- // tramsmit called on the logical channel should succeed.
+ // transmit called on the logical channel should succeed.
EXPECT_EQ(transmit(response.channelNumber), 0x9000);
}
@@ -239,17 +257,19 @@
EXPECT_ERR(secure_element_->closeChannel(1));
// closeChannel called on basic channel closes the basic channel.
- EXPECT_OK(secure_element_->openBasicChannel(kSelectableAid, 0x00, &basic_channel_response));
- EXPECT_OK(secure_element_->closeChannel(0));
+ if (basic_channel_supported_) {
+ EXPECT_OK(secure_element_->openBasicChannel(kSelectableAid, 0x00, &basic_channel_response));
+ EXPECT_OK(secure_element_->closeChannel(0));
- // tramsmit called on the basic channel should fail.
- EXPECT_NE(transmit(0), 0x9000);
+ // transmit called on the basic channel should fail.
+ EXPECT_NE(transmit(0), 0x9000);
+ }
// closeChannel called on logical channel closes the logical channel.
EXPECT_OK(secure_element_->openLogicalChannel(kSelectableAid, 0x00, &logical_channel_response));
EXPECT_OK(secure_element_->closeChannel(logical_channel_response.channelNumber));
- // tramsmit called on the basic channel should fail.
+ // transmit called on the logical channel should fail.
EXPECT_NE(transmit(logical_channel_response.channelNumber), 0x9000);
}
diff --git a/security/dice/aidl/default/service.rs b/security/dice/aidl/default/service.rs
index eebf333..0197f2c 100644
--- a/security/dice/aidl/default/service.rs
+++ b/security/dice/aidl/default/service.rs
@@ -21,7 +21,6 @@
};
use diced_sample_inputs::make_sample_bcc_and_cdis;
use serde::{Deserialize, Serialize};
-use std::convert::TryInto;
use std::panic;
use std::sync::Arc;
@@ -76,7 +75,7 @@
// Saying hi.
log::info!("android.hardware.security.dice is starting.");
- let (cdi_attest, cdi_seal, bcc) =
+ let dice_artifacts =
make_sample_bcc_and_cdis().expect("Failed to construct sample dice chain.");
let hal_impl = Arc::new(
@@ -85,13 +84,9 @@
// This service does not start a thread pool. The main thread is the only thread
// joining the thread pool, thereby keeping the process single threaded.
ResidentHal::new(InsecureSerializableArtifacts {
- cdi_attest: cdi_attest[..]
- .try_into()
- .expect("Failed to convert cdi_attest to array reference."),
- cdi_seal: cdi_seal[..]
- .try_into()
- .expect("Failed to convert cdi_seal to array reference."),
- bcc,
+ cdi_attest: dice_artifacts.cdi_values.cdi_attest,
+ cdi_seal: dice_artifacts.cdi_values.cdi_seal,
+ bcc: dice_artifacts.bcc[..].to_vec(),
})
}
.expect("Failed to create ResidentHal implementation."),
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
index e9cbe10..588a1d4 100644
--- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
@@ -2052,9 +2052,10 @@
// Check whether the given named feature is available.
bool check_feature(const std::string& name) {
::android::sp<::android::IServiceManager> sm(::android::defaultServiceManager());
- ::android::sp<::android::IBinder> binder(sm->getService(::android::String16("package_native")));
+ ::android::sp<::android::IBinder> binder(
+ sm->waitForService(::android::String16("package_native")));
if (binder == nullptr) {
- GTEST_LOG_(ERROR) << "getService package_native failed";
+ GTEST_LOG_(ERROR) << "waitForService package_native failed";
return false;
}
::android::sp<::android::content::pm::IPackageManagerNative> packageMgr =
diff --git a/security/rkp/aidl/aidl_api/android.hardware.security.rkp/1/.hash b/security/rkp/aidl/aidl_api/android.hardware.security.rkp/1/.hash
index 404553b..1397c05 100644
--- a/security/rkp/aidl/aidl_api/android.hardware.security.rkp/1/.hash
+++ b/security/rkp/aidl/aidl_api/android.hardware.security.rkp/1/.hash
@@ -1 +1,2 @@
+976674616001f714f4a4df49ee45f548de828524
d285480d2e0002adc0ace80edf34aa725679512e
diff --git a/security/rkp/aidl/android/hardware/security/keymint/ProtectedData.aidl b/security/rkp/aidl/android/hardware/security/keymint/ProtectedData.aidl
index 57ee8cf..de94264 100644
--- a/security/rkp/aidl/android/hardware/security/keymint/ProtectedData.aidl
+++ b/security/rkp/aidl/android/hardware/security/keymint/ProtectedData.aidl
@@ -70,7 +70,7 @@
* ; HKDF. See details on use in ProtectedData comments above. The public key data
* ; included in the other field of PartyUInfo / PartyVInfo is encoded as:
* ; - a raw 32-byte public key for X25519
- * ; - uncompressed SEC-1 coordinate data (0x04 || x || y) for P-256
+ * ; - raw coordinate data (x || y) for P-256
* Context = [
* AlgorithmID : 3 ; AES-GCM 256
* PartyUInfo : [
diff --git a/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/CoolingDevice.aidl b/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/CoolingDevice.aidl
index dfd8686..dff3c4c 100644
--- a/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/CoolingDevice.aidl
+++ b/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/CoolingDevice.aidl
@@ -33,7 +33,7 @@
package android.hardware.thermal;
/* @hide */
-@VintfStability
+@JavaDerive(toString=true) @VintfStability
parcelable CoolingDevice {
android.hardware.thermal.CoolingType type;
String name;
diff --git a/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/Temperature.aidl b/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/Temperature.aidl
index 3bf08bf..ce70ab8 100644
--- a/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/Temperature.aidl
+++ b/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/Temperature.aidl
@@ -33,7 +33,7 @@
package android.hardware.thermal;
/* @hide */
-@VintfStability
+@JavaDerive(toString=true) @VintfStability
parcelable Temperature {
android.hardware.thermal.TemperatureType type;
String name;
diff --git a/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/TemperatureThreshold.aidl b/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/TemperatureThreshold.aidl
index c5ca4b9..a384d19 100644
--- a/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/TemperatureThreshold.aidl
+++ b/thermal/aidl/aidl_api/android.hardware.thermal/current/android/hardware/thermal/TemperatureThreshold.aidl
@@ -33,7 +33,7 @@
package android.hardware.thermal;
/* @hide */
-@VintfStability
+@JavaDerive(toString=true) @VintfStability
parcelable TemperatureThreshold {
android.hardware.thermal.TemperatureType type;
String name;
diff --git a/thermal/aidl/android/hardware/thermal/CoolingDevice.aidl b/thermal/aidl/android/hardware/thermal/CoolingDevice.aidl
index 1f2360d..0c5c17d 100644
--- a/thermal/aidl/android/hardware/thermal/CoolingDevice.aidl
+++ b/thermal/aidl/android/hardware/thermal/CoolingDevice.aidl
@@ -20,6 +20,7 @@
/* @hide */
@VintfStability
+@JavaDerive(toString=true)
parcelable CoolingDevice {
/**
* This cooling device type, CPU, GPU, BATTERY, and etc.
diff --git a/thermal/aidl/android/hardware/thermal/IThermal.aidl b/thermal/aidl/android/hardware/thermal/IThermal.aidl
index 7c23c17..c94edcd 100644
--- a/thermal/aidl/android/hardware/thermal/IThermal.aidl
+++ b/thermal/aidl/android/hardware/thermal/IThermal.aidl
@@ -36,9 +36,8 @@
* exist on boot. The method always returns and never removes from
* the list such cooling devices.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, getMessage() must be populated with the human-readable
- * error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
CoolingDevice[] getCoolingDevices();
@@ -54,9 +53,8 @@
* exist on boot. The method always returns and never removes from
* the list such cooling devices.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
CoolingDevice[] getCoolingDevicesWithType(in CoolingType type);
@@ -70,9 +68,8 @@
* they go offline, if these devices exist on boot. The method
* always returns and never removes such temperatures.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
Temperature[] getTemperatures();
@@ -88,9 +85,8 @@
* they go offline, if these devices exist on boot. The method
* always returns and never removes such temperatures.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
Temperature[] getTemperaturesWithType(in TemperatureType type);
@@ -110,9 +106,8 @@
* throttling status, use getTemperatures or registerThermalChangedCallback
* and listen to the callback.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
TemperatureThreshold[] getTemperatureThresholds();
@@ -135,9 +130,8 @@
* throttling status, use getTemperatures or registerThermalChangedCallback
* and listen to the callback.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
TemperatureThreshold[] getTemperatureThresholdsWithType(in TemperatureType type);
@@ -152,12 +146,10 @@
* thermal events. if nullptr callback is given, the status code will be
* STATUS_BAD_VALUE and the operation will fail.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message. If callback is given nullptr, the returned status code
- * will be STATUS_BAD_VALUE and the exception will be EX_ILLEGAL_ARGUMENT.
- * if callback is already registered, the returned status code will be
- * STATUS_INVALID_OPERATION, the exception will be EX_ILLEGAL_ARGUMENT.
+ * @throws EX_ILLEGAL_ARGUMENT If the callback is given nullptr or already registered. And the
+ * getMessage() must be populated with human-readable error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
void registerThermalChangedCallback(in IThermalChangedCallback callback);
@@ -174,12 +166,10 @@
* STATUS_BAD_VALUE and the operation will fail.
* @param type the type to be filtered.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message. If callback is given nullptr, the returned status code
- * will be STATUS_BAD_VALUE and the exception will be EX_ILLEGAL_ARGUMENT.
- * if callback is already registered, the returned status code will be
- * STATUS_INVALID_OPERATION, the exception will be EX_ILLEGAL_ARGUMENT.
+ * @throws EX_ILLEGAL_ARGUMENT If the callback is given nullptr or already registered. And the
+ * getMessage() must be populated with human-readable error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
void registerThermalChangedCallbackWithType(
in IThermalChangedCallback callback, in TemperatureType type);
@@ -192,12 +182,10 @@
* thermal events. if nullptr callback is given, the status code will be
* STATUS_BAD_VALUE and the operation will fail.
*
- * @throws ScopedAStatus Status of the operation. If status code is not
- * STATUS_OK, the getMessage() must be populated with the human-readable
- * error message. If callback is given nullptr, the returned status code
- * will be STATUS_BAD_VALUE and the exception will be EX_ILLEGAL_ARGUMENT.
- * if callback is not registered, the returned status code will be
- * STATUS_INVALID_OPERATION, the exception will be EX_ILLEGAL_ARGUMENT.
+ * @throws EX_ILLEGAL_ARGUMENT If the callback is given nullptr or not previously registered.
+ * And the getMessage() must be populated with human-readable error message.
+ * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully. And the
+ * getMessage() must be populated with human-readable error message.
*/
void unregisterThermalChangedCallback(in IThermalChangedCallback callback);
}
diff --git a/thermal/aidl/android/hardware/thermal/Temperature.aidl b/thermal/aidl/android/hardware/thermal/Temperature.aidl
index 281d68d..b3f6700 100644
--- a/thermal/aidl/android/hardware/thermal/Temperature.aidl
+++ b/thermal/aidl/android/hardware/thermal/Temperature.aidl
@@ -21,6 +21,7 @@
/* @hide */
@VintfStability
+@JavaDerive(toString=true)
parcelable Temperature {
/**
* This temperature's type.
diff --git a/thermal/aidl/android/hardware/thermal/TemperatureThreshold.aidl b/thermal/aidl/android/hardware/thermal/TemperatureThreshold.aidl
index 0714c82..94991ae 100644
--- a/thermal/aidl/android/hardware/thermal/TemperatureThreshold.aidl
+++ b/thermal/aidl/android/hardware/thermal/TemperatureThreshold.aidl
@@ -20,6 +20,7 @@
/* @hide */
@VintfStability
+@JavaDerive(toString=true)
parcelable TemperatureThreshold {
/**
* This temperature's type.
diff --git a/thermal/aidl/default/Thermal.cpp b/thermal/aidl/default/Thermal.cpp
index 5771e0e..f643d22 100644
--- a/thermal/aidl/default/Thermal.cpp
+++ b/thermal/aidl/default/Thermal.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#define LOG_TAG "thermal_service_example"
+
#include "Thermal.h"
#include <android-base/logging.h>
@@ -22,6 +24,18 @@
using ndk::ScopedAStatus;
+namespace {
+
+bool interfacesEqual(const std::shared_ptr<::ndk::ICInterface>& left,
+ const std::shared_ptr<::ndk::ICInterface>& right) {
+ if (left == nullptr || right == nullptr || !left->isRemote() || !right->isRemote()) {
+ return left == right;
+ }
+ return left->asBinder() == right->asBinder();
+}
+
+} // namespace
+
ScopedAStatus Thermal::getCoolingDevices(std::vector<CoolingDevice>* /* out_devices */) {
LOG(VERBOSE) << __func__;
return ScopedAStatus::ok();
@@ -61,12 +75,20 @@
const std::shared_ptr<IThermalChangedCallback>& in_callback) {
LOG(VERBOSE) << __func__ << " IThermalChangedCallback: " << in_callback;
if (in_callback == nullptr) {
- return ScopedAStatus::fromStatus(STATUS_BAD_VALUE);
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "Invalid nullptr callback");
}
- if (mCallbacks.find(in_callback) != mCallbacks.end()) {
- return ScopedAStatus::fromStatus(STATUS_INVALID_OPERATION);
+ {
+ std::lock_guard<std::mutex> _lock(thermal_callback_mutex_);
+ if (std::any_of(thermal_callbacks_.begin(), thermal_callbacks_.end(),
+ [&](const std::shared_ptr<IThermalChangedCallback>& c) {
+ return interfacesEqual(c, in_callback);
+ })) {
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "Callback already registered");
+ }
+ thermal_callbacks_.push_back(in_callback);
}
- mCallbacks.insert(in_callback);
return ScopedAStatus::ok();
}
@@ -75,26 +97,48 @@
LOG(VERBOSE) << __func__ << " IThermalChangedCallback: " << in_callback
<< ", TemperatureType: " << static_cast<int32_t>(in_type);
if (in_callback == nullptr) {
- return ScopedAStatus::fromStatus(STATUS_BAD_VALUE);
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "Invalid nullptr callback");
}
- if (mCallbacks.find(in_callback) != mCallbacks.end()) {
- return ScopedAStatus::fromStatus(STATUS_INVALID_OPERATION);
+ {
+ std::lock_guard<std::mutex> _lock(thermal_callback_mutex_);
+ if (std::any_of(thermal_callbacks_.begin(), thermal_callbacks_.end(),
+ [&](const std::shared_ptr<IThermalChangedCallback>& c) {
+ return interfacesEqual(c, in_callback);
+ })) {
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "Callback already registered");
+ }
+ thermal_callbacks_.push_back(in_callback);
}
- mCallbacks.insert(in_callback);
return ScopedAStatus::ok();
}
ScopedAStatus Thermal::unregisterThermalChangedCallback(
const std::shared_ptr<IThermalChangedCallback>& in_callback) {
LOG(VERBOSE) << __func__ << " IThermalChangedCallback: " << in_callback;
- bool found = false;
if (in_callback == nullptr) {
- return ScopedAStatus::fromStatus(STATUS_BAD_VALUE);
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "Invalid nullptr callback");
}
- if (mCallbacks.find(in_callback) == mCallbacks.end()) {
- return ScopedAStatus::fromStatus(STATUS_INVALID_OPERATION);
+ {
+ std::lock_guard<std::mutex> _lock(thermal_callback_mutex_);
+ bool removed = false;
+ thermal_callbacks_.erase(
+ std::remove_if(thermal_callbacks_.begin(), thermal_callbacks_.end(),
+ [&](const std::shared_ptr<IThermalChangedCallback>& c) {
+ if (interfacesEqual(c, in_callback)) {
+ removed = true;
+ return true;
+ }
+ return false;
+ }),
+ thermal_callbacks_.end());
+ if (!removed) {
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "Callback wasn't registered");
+ }
}
- mCallbacks.erase(in_callback);
return ScopedAStatus::ok();
}
diff --git a/thermal/aidl/default/Thermal.h b/thermal/aidl/default/Thermal.h
index 788af4a..8885e63 100644
--- a/thermal/aidl/default/Thermal.h
+++ b/thermal/aidl/default/Thermal.h
@@ -54,7 +54,8 @@
const std::shared_ptr<IThermalChangedCallback>& in_callback) override;
private:
- std::set<std::shared_ptr<IThermalChangedCallback>> mCallbacks;
+ std::mutex thermal_callback_mutex_;
+ std::vector<std::shared_ptr<IThermalChangedCallback>> thermal_callbacks_;
};
} // namespace example
diff --git a/thermal/aidl/default/main.cpp b/thermal/aidl/default/main.cpp
index 61d8ad0..9f4ddb8 100644
--- a/thermal/aidl/default/main.cpp
+++ b/thermal/aidl/default/main.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#define LOG_TAG "thermal_service_example"
+
#include "Thermal.h"
#include <android-base/logging.h>
diff --git a/thermal/aidl/vts/VtsHalThermalTargetTest.cpp b/thermal/aidl/vts/VtsHalThermalTargetTest.cpp
index b93250e..73c5dd2 100644
--- a/thermal/aidl/vts/VtsHalThermalTargetTest.cpp
+++ b/thermal/aidl/vts/VtsHalThermalTargetTest.cpp
@@ -95,21 +95,21 @@
mThermalCallback = ndk::SharedRefBase::make<ThermalCallback>();
ASSERT_NE(mThermalCallback, nullptr);
- auto ret = mThermal->registerThermalChangedCallback(mThermalCallback);
- ASSERT_TRUE(ret.isOk());
+ auto status = mThermal->registerThermalChangedCallback(mThermalCallback);
+ ASSERT_TRUE(status.isOk());
// Expect to fail if register again
- ret = mThermal->registerThermalChangedCallback(mThermalCallback);
- ASSERT_FALSE(ret.isOk());
- ASSERT_TRUE(ret.getStatus() == STATUS_INVALID_OPERATION);
+ status = mThermal->registerThermalChangedCallback(mThermalCallback);
+ ASSERT_FALSE(status.isOk());
+ ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
}
void TearDown() override {
- auto ret = mThermal->unregisterThermalChangedCallback(mThermalCallback);
- ASSERT_TRUE(ret.isOk());
+ auto status = mThermal->unregisterThermalChangedCallback(mThermalCallback);
+ ASSERT_TRUE(status.isOk());
// Expect to fail if unregister again
- ret = mThermal->unregisterThermalChangedCallback(mThermalCallback);
- ASSERT_FALSE(ret.isOk());
- ASSERT_TRUE(ret.getStatus() == STATUS_INVALID_OPERATION);
+ status = mThermal->unregisterThermalChangedCallback(mThermalCallback);
+ ASSERT_FALSE(status.isOk());
+ ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode());
}
protected:
diff --git a/tv/hdmi/cec/aidl/OWNERS b/tv/hdmi/OWNERS
similarity index 100%
rename from tv/hdmi/cec/aidl/OWNERS
rename to tv/hdmi/OWNERS
diff --git a/tv/hdmi/connection/aidl/OWNERS b/tv/hdmi/connection/aidl/OWNERS
deleted file mode 100644
index d9c6783..0000000
--- a/tv/hdmi/connection/aidl/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-# Bug component: 826094
-include platform/frameworks/base:/core/java/android/hardware/hdmi/OWNERS
\ No newline at end of file
diff --git a/tv/hdmi/earc/aidl/OWNERS b/tv/hdmi/earc/aidl/OWNERS
deleted file mode 100644
index d9c6783..0000000
--- a/tv/hdmi/earc/aidl/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-# Bug component: 826094
-include platform/frameworks/base:/core/java/android/hardware/hdmi/OWNERS
\ No newline at end of file
diff --git a/usb/gadget/aidl/default/UsbGadget.cpp b/usb/gadget/aidl/default/UsbGadget.cpp
index 72cf681..51f7f5b 100644
--- a/usb/gadget/aidl/default/UsbGadget.cpp
+++ b/usb/gadget/aidl/default/UsbGadget.cpp
@@ -91,6 +91,9 @@
ScopedAStatus UsbGadget::getCurrentUsbFunctions(const shared_ptr<IUsbGadgetCallback>& callback,
int64_t in_transactionId) {
+ if (callback == nullptr) {
+ return ScopedAStatus::fromExceptionCode(EX_NULL_POINTER);
+ }
ScopedAStatus ret = callback->getCurrentUsbFunctionsCb(
mCurrentUsbFunctions,
mCurrentUsbFunctionsApplied ? Status::FUNCTIONS_APPLIED : Status::FUNCTIONS_NOT_APPLIED,
diff --git a/uwb/aidl/Android.bp b/uwb/aidl/Android.bp
index 7dc2b7f..c537322 100755
--- a/uwb/aidl/Android.bp
+++ b/uwb/aidl/Android.bp
@@ -18,7 +18,11 @@
backend: {
java: {
sdk_version: "module_Tiramisu",
- enabled: false,
+ enabled: true,
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.uwb",
+ ],
},
ndk: {
apex_available: [