From 20e5c1733ed109a908d07fde18de75a0348bfa2f Mon Sep 17 00:00:00 2001 From: Shunkai Yao Date: Mon, 12 Dec 2022 07:09:01 +0000 Subject: [PATCH] Effect AIDL: update IFactory.queryEffects to return Descriptor Add queryEffect for effect libraries. Change Descriptor in each effect implementation to be static so extern C function can access. Bug: 261646550 Test: atest VtsHalAudioEffectTargetTest Change-Id: Id7badec592becf37b27be6022106f443e5976880 --- audio/aidl/Android.bp | 3 +- .../hardware/audio/effect/Capability.aidl | 3 +- .../{Reverb.aidl => EnvironmentalReverb.aidl} | 4 +- .../hardware/audio/effect/IFactory.aidl | 2 +- .../hardware/audio/effect/Parameter.aidl | 8 +- .../hardware/audio/effect/PresetReverb.aidl | 59 +++++++++++ .../hardware/audio/effect/Capability.aidl | 6 +- .../{Reverb.aidl => EnvironmentalReverb.aidl} | 14 +-- .../hardware/audio/effect/IFactory.aidl | 8 +- .../hardware/audio/effect/Parameter.aidl | 11 ++- .../hardware/audio/effect/PresetReverb.aidl | 98 +++++++++++++++++++ .../android/hardware/audio/effect/state.gv | 32 +++--- 12 files changed, 208 insertions(+), 40 deletions(-) rename audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/{Reverb.aidl => EnvironmentalReverb.aidl} (95%) create mode 100644 audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/PresetReverb.aidl rename audio/aidl/android/hardware/audio/effect/{Reverb.aidl => EnvironmentalReverb.aidl} (82%) create mode 100644 audio/aidl/android/hardware/audio/effect/PresetReverb.aidl diff --git a/audio/aidl/Android.bp b/audio/aidl/Android.bp index 691cf34177..05c7649c90 100644 --- a/audio/aidl/Android.bp +++ b/audio/aidl/Android.bp @@ -177,6 +177,7 @@ aidl_interface { "android/hardware/audio/effect/Descriptor.aidl", "android/hardware/audio/effect/Downmix.aidl", "android/hardware/audio/effect/DynamicsProcessing.aidl", + "android/hardware/audio/effect/EnvironmentalReverb.aidl", "android/hardware/audio/effect/Equalizer.aidl", "android/hardware/audio/effect/Flags.aidl", "android/hardware/audio/effect/HapticGenerator.aidl", @@ -184,8 +185,8 @@ aidl_interface { "android/hardware/audio/effect/IFactory.aidl", "android/hardware/audio/effect/LoudnessEnhancer.aidl", "android/hardware/audio/effect/Parameter.aidl", + "android/hardware/audio/effect/PresetReverb.aidl", "android/hardware/audio/effect/Processing.aidl", - "android/hardware/audio/effect/Reverb.aidl", "android/hardware/audio/effect/State.aidl", "android/hardware/audio/effect/VendorExtension.aidl", "android/hardware/audio/effect/Virtualizer.aidl", 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 06f2bfeb33..60c88d36a4 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 @@ -38,10 +38,11 @@ union Capability { 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.Reverb.Capability reverb; + 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; diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Reverb.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl similarity index 95% rename from audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Reverb.aidl rename to audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl index 8ad4848368..fcf08c369f 100644 --- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Reverb.aidl +++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/EnvironmentalReverb.aidl @@ -33,7 +33,7 @@ package android.hardware.audio.effect; @VintfStability -union Reverb { +union EnvironmentalReverb { android.hardware.audio.effect.VendorExtension vendor; int roomLevelMb; int roomHfLevelMb; @@ -47,7 +47,7 @@ union Reverb { @VintfStability union Id { int vendorExtensionTag; - android.hardware.audio.effect.Reverb.Tag commonTag; + android.hardware.audio.effect.EnvironmentalReverb.Tag commonTag; } @VintfStability parcelable Capability { diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/IFactory.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/IFactory.aidl index 5b85d33a29..a6c138c0ef 100644 --- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/IFactory.aidl +++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/IFactory.aidl @@ -34,7 +34,7 @@ package android.hardware.audio.effect; @VintfStability interface IFactory { - android.hardware.audio.effect.Descriptor.Identity[] queryEffects(in @nullable android.media.audio.common.AudioUuid type, in @nullable android.media.audio.common.AudioUuid implementation, in @nullable android.media.audio.common.AudioUuid proxy); + android.hardware.audio.effect.Descriptor[] queryEffects(in @nullable android.media.audio.common.AudioUuid type, in @nullable android.media.audio.common.AudioUuid implementation, in @nullable android.media.audio.common.AudioUuid proxy); android.hardware.audio.effect.Processing[] queryProcessing(in @nullable android.hardware.audio.effect.Processing.Type type); android.hardware.audio.effect.IEffect createEffect(in android.media.audio.common.AudioUuid implUuid); void destroyEffect(in android.hardware.audio.effect.IEffect handle); 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 321c286fca..0635c138c2 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 @@ -46,10 +46,11 @@ union Parameter { android.hardware.audio.effect.BassBoost.Id bassBoostTag; android.hardware.audio.effect.Downmix.Id downmixTag; android.hardware.audio.effect.DynamicsProcessing.Id dynamicsProcessingTag; + android.hardware.audio.effect.EnvironmentalReverb.Id environmentalReverbTag; android.hardware.audio.effect.Equalizer.Id equalizerTag; android.hardware.audio.effect.HapticGenerator.Id hapticGeneratorTag; android.hardware.audio.effect.LoudnessEnhancer.Id loudnessEnhancerTag; - android.hardware.audio.effect.Reverb.Id reverbTag; + android.hardware.audio.effect.PresetReverb.Id presetReverbTag; android.hardware.audio.effect.Virtualizer.Id virtualizerTag; android.hardware.audio.effect.Visualizer.Id visualizerTag; android.hardware.audio.effect.Volume.Id volumeTag; @@ -73,10 +74,11 @@ union Parameter { android.hardware.audio.effect.BassBoost bassBoost; android.hardware.audio.effect.Downmix downmix; android.hardware.audio.effect.DynamicsProcessing dynamicsProcessing; + android.hardware.audio.effect.EnvironmentalReverb environmentalReverb; android.hardware.audio.effect.Equalizer equalizer; - android.hardware.audio.effect.LoudnessEnhancer loudnessEnhancer; android.hardware.audio.effect.HapticGenerator hapticGenerator; - android.hardware.audio.effect.Reverb reverb; + android.hardware.audio.effect.LoudnessEnhancer loudnessEnhancer; + android.hardware.audio.effect.PresetReverb presetReverb; android.hardware.audio.effect.Virtualizer virtualizer; android.hardware.audio.effect.Visualizer visualizer; android.hardware.audio.effect.Volume volume; 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 new file mode 100644 index 0000000000..24a9ce1ef2 --- /dev/null +++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/PresetReverb.aidl @@ -0,0 +1,59 @@ +/* + * 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. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m -update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.audio.effect; +@VintfStability +union PresetReverb { + android.hardware.audio.effect.VendorExtension vendor; + android.hardware.audio.effect.PresetReverb.Presets preset; + @Backing(type="int") @VintfStability + enum Presets { + NONE = 0, + SMALLROOM = 1, + MEDIUMROOM = 2, + LARGEROOM = 3, + MEDIUMHALL = 4, + LARGEHALL = 5, + PLATE = 6, + } + @VintfStability + union Id { + 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/android/hardware/audio/effect/Capability.aidl b/audio/aidl/android/hardware/audio/effect/Capability.aidl index f741f338bf..414978325f 100644 --- a/audio/aidl/android/hardware/audio/effect/Capability.aidl +++ b/audio/aidl/android/hardware/audio/effect/Capability.aidl @@ -19,10 +19,11 @@ package android.hardware.audio.effect; 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.Reverb; +import android.hardware.audio.effect.PresetReverb; import android.hardware.audio.effect.VendorExtension; import android.hardware.audio.effect.Virtualizer; import android.hardware.audio.effect.Visualizer; @@ -51,10 +52,11 @@ union Capability { BassBoost.Capability bassBoost; Downmix.Capability downmix; DynamicsProcessing.Capability dynamicsProcessing; + EnvironmentalReverb.Capability environmentalReverb; Equalizer.Capability equalizer; HapticGenerator.Capability hapticGenerator; LoudnessEnhancer.Capability loudnessEnhancer; - Reverb.Capability reverb; + PresetReverb.Capability presetReverb; Virtualizer.Capability virtualizer; Visualizer.Capability visualizer; Volume.Capability volume; diff --git a/audio/aidl/android/hardware/audio/effect/Reverb.aidl b/audio/aidl/android/hardware/audio/effect/EnvironmentalReverb.aidl similarity index 82% rename from audio/aidl/android/hardware/audio/effect/Reverb.aidl rename to audio/aidl/android/hardware/audio/effect/EnvironmentalReverb.aidl index f60c2ea56c..3df0d27ec9 100644 --- a/audio/aidl/android/hardware/audio/effect/Reverb.aidl +++ b/audio/aidl/android/hardware/audio/effect/EnvironmentalReverb.aidl @@ -19,24 +19,26 @@ package android.hardware.audio.effect; import android.hardware.audio.effect.VendorExtension; /** - * Reverb specific definitions. + * Environmental Reverb specific definitions. * - * All parameters defined in union Reverb must be gettable and settable. The capabilities defined in - * Reverb.Capability can only acquired with IEffect.getDescriptor() and not settable. + * 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. */ + @VintfStability -union Reverb { +union EnvironmentalReverb { /** * Effect parameter tag to identify the parameters for getParameter(). */ @VintfStability union Id { int vendorExtensionTag; - Reverb.Tag commonTag; + EnvironmentalReverb.Tag commonTag; } /** - * Vendor Reverb implementation definition for additional parameters. + * Vendor EnvironmentalReverb implementation definition for additional parameters. */ VendorExtension vendor; diff --git a/audio/aidl/android/hardware/audio/effect/IFactory.aidl b/audio/aidl/android/hardware/audio/effect/IFactory.aidl index 59433599be..b80e6ac13d 100644 --- a/audio/aidl/android/hardware/audio/effect/IFactory.aidl +++ b/audio/aidl/android/hardware/audio/effect/IFactory.aidl @@ -31,8 +31,8 @@ import android.media.audio.common.AudioUuid; @VintfStability interface IFactory { /** - * Return a list of effect identities supported by this device, with the optional - * filter by type and/or by instance UUID. + * Return a list of effect descriptors supported by this device, with the optional filter by + * type and/or by instance UUID. * * @param type UUID identifying the effect type. * This is an optional parameter, pass in null if this parameter is not necessary; if non @@ -43,9 +43,9 @@ interface IFactory { * @param proxy Indicates the proxy UUID filter to query. * This is an optional parameter, pass in null if this parameter is not necessary; if * non null, used as a filter for effect proxy UUIDs. - * @return List of effect identities supported and filtered by type/implementation UUID. + * @return List of effect Descriptors supported and filtered by type/implementation/proxy UUID. */ - Descriptor.Identity[] queryEffects(in @nullable AudioUuid type, + Descriptor[] queryEffects(in @nullable AudioUuid type, in @nullable AudioUuid implementation, in @nullable AudioUuid proxy); /** diff --git a/audio/aidl/android/hardware/audio/effect/Parameter.aidl b/audio/aidl/android/hardware/audio/effect/Parameter.aidl index e7d3d5efd5..d7a6a27d85 100644 --- a/audio/aidl/android/hardware/audio/effect/Parameter.aidl +++ b/audio/aidl/android/hardware/audio/effect/Parameter.aidl @@ -19,10 +19,11 @@ package android.hardware.audio.effect; 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.Reverb; +import android.hardware.audio.effect.PresetReverb; import android.hardware.audio.effect.VendorExtension; import android.hardware.audio.effect.Virtualizer; import android.hardware.audio.effect.Visualizer; @@ -73,10 +74,11 @@ union Parameter { BassBoost.Id bassBoostTag; Downmix.Id downmixTag; DynamicsProcessing.Id dynamicsProcessingTag; + EnvironmentalReverb.Id environmentalReverbTag; Equalizer.Id equalizerTag; HapticGenerator.Id hapticGeneratorTag; LoudnessEnhancer.Id loudnessEnhancerTag; - Reverb.Id reverbTag; + PresetReverb.Id presetReverbTag; Virtualizer.Id virtualizerTag; Visualizer.Id visualizerTag; Volume.Id volumeTag; @@ -150,10 +152,11 @@ union Parameter { BassBoost bassBoost; Downmix downmix; DynamicsProcessing dynamicsProcessing; + EnvironmentalReverb environmentalReverb; Equalizer equalizer; - LoudnessEnhancer loudnessEnhancer; HapticGenerator hapticGenerator; - Reverb reverb; + LoudnessEnhancer loudnessEnhancer; + PresetReverb presetReverb; Virtualizer virtualizer; Visualizer visualizer; Volume volume; diff --git a/audio/aidl/android/hardware/audio/effect/PresetReverb.aidl b/audio/aidl/android/hardware/audio/effect/PresetReverb.aidl new file mode 100644 index 0000000000..6048eea4af --- /dev/null +++ b/audio/aidl/android/hardware/audio/effect/PresetReverb.aidl @@ -0,0 +1,98 @@ +/* + * 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; + +/** + * 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. + */ +@VintfStability +union PresetReverb { + /** + * Presets enum definition. + */ + @VintfStability + @Backing(type="int") + enum Presets { + /** + * No reverb or reflections + */ + NONE, + /** + * A small room less than five meters in length + */ + SMALLROOM, + /** + * A medium room with a length of ten meters or less. + */ + MEDIUMROOM, + /** + * A large-sized room suitable for live performances. + */ + LARGEROOM, + /** + * A medium-sized hall. + */ + MEDIUMHALL, + /** + * a large-sized hall suitable for a full orchestra. + */ + LARGEHALL, + /** + * Synthesis of the traditional plate reverb. + */ + PLATE, + } + + /** + * Effect parameter tag to identify the parameters for getParameter(). + */ + @VintfStability + union Id { + int vendorExtensionTag; + PresetReverb.Tag commonTag; + } + + /** + * Vendor PresetReverb implementation definition for additional parameters. + */ + VendorExtension vendor; + + /** + * Capability supported by effect implementation. + */ + @VintfStability + parcelable Capability { + VendorExtension extension; + + /** + * List of presets supported. + */ + Presets[] supportedPresets; + } + + /** + * Get current reverb preset when used in getParameter. + * Enable a preset reverb when used in setParameter. + */ + Presets preset; +} diff --git a/audio/aidl/android/hardware/audio/effect/state.gv b/audio/aidl/android/hardware/audio/effect/state.gv index e19e6c7a1d..c88521e316 100644 --- a/audio/aidl/android/hardware/audio/effect/state.gv +++ b/audio/aidl/android/hardware/audio/effect/state.gv @@ -16,21 +16,21 @@ // To render: "dot -Tpng state.gv -o state.png" digraph effect_state_machine { - node [shape=point style=filled fillcolor=black width=0.5] I; - node [shape=doublecircle] F; - node [shape=oval width=1]; - node [fillcolor=lightgreen] INIT; - node [fillcolor=lightblue] IDLE; - node [fillcolor=lightyellow] PROCESSING; + node[shape = point style = filled fillcolor = black width = 0.5] I; + node[shape = doublecircle] F; + node[shape = oval width = 1]; + node[fillcolor = lightgreen] INIT; + node[fillcolor = lightblue] IDLE; + node[fillcolor = lightyellow] PROCESSING; - I -> INIT [label="IFactory.createEffect" labelfontcolor="navy"]; - INIT -> F [label="IFactory.destroyEffect"]; - INIT -> IDLE [label="open()" labelfontcolor="lime"]; - IDLE -> PROCESSING [label="command(START"]; - PROCESSING -> IDLE [label="command(STOP)\ncommand(RESET)"]; - IDLE -> INIT [label="close()"]; + I -> INIT[label = "IFactory.createEffect" labelfontcolor = "navy"]; + INIT -> F[label = "IFactory.destroyEffect"]; + INIT -> IDLE[label = "open()" labelfontcolor = "lime"]; + IDLE -> PROCESSING[label = "command(START"]; + PROCESSING -> IDLE[label = "command(STOP)\ncommand(RESET)"]; + IDLE -> INIT[label = "close()"]; - INIT -> INIT [label="getState\ngetDescriptor"]; - IDLE -> IDLE [label="getXXX\nsetParameter\ncommand(RESET)"]; - PROCESSING -> PROCESSING [label="getXXX\nsetParameter"]; -} \ No newline at end of file + INIT -> INIT[label = "getState\ngetDescriptor"]; + IDLE -> IDLE[label = "getXXX\nsetParameter\ncommand(RESET)"]; + PROCESSING -> PROCESSING[label = "getXXX\nsetParameter"]; +}