From c9dbca51e607ba75b72b5b6becb1e3a066bb8fde Mon Sep 17 00:00:00 2001 From: Mikhail Naganov Date: Wed, 30 Sep 2020 20:27:12 +0000 Subject: [PATCH] audio: Align lists of enum values between framework and HAL Enum values defined in the XSD now correspond to the "no system definitions" lists of enums in system/media/audio/audio-hal-enums.h. Added channel masks that used to be in s/m/a/audio-base-utils.h. Removed use of "vectors of vectors" for channel masks since individual channels are not allowed to be used in the APM config and at the HAL transport level. Fixed definition of the gain mode of audio ports: 1. Since it's a bit mask in the framework, it must be a list in the audio policy configuration XML file. Note that the old definition is compatible with the new one as one element is a valid list. 2. As gain mode is defined in the XSD file, it shouldn't be defined again in types.hal. Bug: 122858783 Bug: 142480271 Test: audio smoke tests Change-Id: I2df5eb4bc4a393611d3adb0ee30583767197591b Merged-In: I2df5eb4bc4a393611d3adb0ee30583767197591b --- audio/7.0/config/api/current.txt | 31 ++++++---- .../7.0/config/audio_policy_configuration.xsd | 60 +++++++++++++------ .../audio_policy_configuration_V7_0-enums.h | 8 +++ audio/common/7.0/types.hal | 28 ++++----- .../vts/functional/AudioPrimaryHidlHalTest.h | 2 +- 5 files changed, 82 insertions(+), 47 deletions(-) diff --git a/audio/7.0/config/api/current.txt b/audio/7.0/config/api/current.txt index ac8dc8ae0c..453ed16d4f 100644 --- a/audio/7.0/config/api/current.txt +++ b/audio/7.0/config/api/current.txt @@ -44,10 +44,12 @@ package audio.policy.configuration.V7_0 { enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_IN_VOICE_CALL_MONO; enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO; enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_IN_VOICE_UPLINK_MONO; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_NONE; enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_2POINT0POINT2; enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_2POINT1; enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_2POINT1POINT2; enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_3POINT0POINT2; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_3POINT1; enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_3POINT1POINT2; enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_5POINT1; enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_5POINT1POINT2; @@ -70,6 +72,8 @@ package audio.policy.configuration.V7_0 { enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_STEREO_HAPTIC_A; enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_STEREO_HAPTIC_AB; enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_SURROUND; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_TRI; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_TRI_BACK; } public enum AudioContentType { @@ -87,6 +91,7 @@ package audio.policy.configuration.V7_0 { enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET; enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_IN_AUX_DIGITAL; enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_IN_BACK_MIC; + enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_IN_BLE_HEADSET; enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_IN_BLUETOOTH_A2DP; enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_IN_BLUETOOTH_BLE; enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET; @@ -117,6 +122,8 @@ package audio.policy.configuration.V7_0 { enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET; enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_OUT_AUX_DIGITAL; enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_OUT_AUX_LINE; + enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_OUT_BLE_HEADSET; + enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_OUT_BLE_SPEAKER; enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_OUT_BLUETOOTH_A2DP; enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES; enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER; @@ -191,7 +198,6 @@ package audio.policy.configuration.V7_0 { enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_APTX_HD; enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_APTX_TWSP; enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_CELT; - enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_DEFAULT; enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_DOLBY_TRUEHD; enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_DSD; enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_DTS; @@ -206,9 +212,11 @@ package audio.policy.configuration.V7_0 { enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_HE_AAC_V1; enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_HE_AAC_V2; enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_IEC61937; + enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_LC3; enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_LDAC; enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_LHDC; enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_LHDC_LL; + enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_MAT; enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_MAT_1_0; enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_MAT_2_0; enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_MAT_2_1; @@ -228,6 +236,13 @@ package audio.policy.configuration.V7_0 { enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_WMA_PRO; } + public enum AudioGainMode { + method public String getRawName(); + enum_constant public static final audio.policy.configuration.V7_0.AudioGainMode AUDIO_GAIN_MODE_CHANNELS; + enum_constant public static final audio.policy.configuration.V7_0.AudioGainMode AUDIO_GAIN_MODE_JOINT; + enum_constant public static final audio.policy.configuration.V7_0.AudioGainMode AUDIO_GAIN_MODE_RAMP; + } + public enum AudioInOutFlag { method public String getRawName(); enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_INPUT_FLAG_DIRECT; @@ -235,6 +250,7 @@ package audio.policy.configuration.V7_0 { enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_INPUT_FLAG_HW_AV_SYNC; enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_INPUT_FLAG_HW_HOTWORD; enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_INPUT_FLAG_MMAP_NOIRQ; + enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_INPUT_FLAG_NONE; enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_INPUT_FLAG_RAW; enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_INPUT_FLAG_SYNC; enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_INPUT_FLAG_VOIP_TX; @@ -247,6 +263,7 @@ package audio.policy.configuration.V7_0 { enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO; enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_INCALL_MUSIC; enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_MMAP_NOIRQ; + enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_NONE; enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_NON_BLOCKING; enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_PRIMARY; enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_RAW; @@ -291,6 +308,7 @@ package audio.policy.configuration.V7_0 { enum_constant public static final audio.policy.configuration.V7_0.AudioStreamType AUDIO_STREAM_ALARM; enum_constant public static final audio.policy.configuration.V7_0.AudioStreamType AUDIO_STREAM_ASSISTANT; enum_constant public static final audio.policy.configuration.V7_0.AudioStreamType AUDIO_STREAM_BLUETOOTH_SCO; + enum_constant public static final audio.policy.configuration.V7_0.AudioStreamType AUDIO_STREAM_CALL_ASSISTANT; enum_constant public static final audio.policy.configuration.V7_0.AudioStreamType AUDIO_STREAM_DTMF; enum_constant public static final audio.policy.configuration.V7_0.AudioStreamType AUDIO_STREAM_ENFORCED_AUDIBLE; enum_constant public static final audio.policy.configuration.V7_0.AudioStreamType AUDIO_STREAM_MUSIC; @@ -364,13 +382,6 @@ package audio.policy.configuration.V7_0 { enum_constant public static final audio.policy.configuration.V7_0.EngineSuffix configurable; } - public enum GainMode { - method public String getRawName(); - enum_constant public static final audio.policy.configuration.V7_0.GainMode AUDIO_GAIN_MODE_CHANNELS; - enum_constant public static final audio.policy.configuration.V7_0.GainMode AUDIO_GAIN_MODE_JOINT; - enum_constant public static final audio.policy.configuration.V7_0.GainMode AUDIO_GAIN_MODE_RAMP; - } - public class Gains { ctor public Gains(); method public java.util.List getGain(); @@ -384,7 +395,7 @@ package audio.policy.configuration.V7_0 { method public int getMaxValueMB(); method public int getMinRampMs(); method public int getMinValueMB(); - method public audio.policy.configuration.V7_0.GainMode getMode(); + method public java.util.List getMode(); method public String getName(); method public int getStepValueMB(); method public boolean getUseForVolume(); @@ -394,7 +405,7 @@ package audio.policy.configuration.V7_0 { method public void setMaxValueMB(int); method public void setMinRampMs(int); method public void setMinValueMB(int); - method public void setMode(audio.policy.configuration.V7_0.GainMode); + method public void setMode(java.util.List); method public void setName(String); method public void setStepValueMB(int); method public void setUseForVolume(boolean); diff --git a/audio/7.0/config/audio_policy_configuration.xsd b/audio/7.0/config/audio_policy_configuration.xsd index 20fe02002e..67848287ef 100644 --- a/audio/7.0/config/audio_policy_configuration.xsd +++ b/audio/7.0/config/audio_policy_configuration.xsd @@ -159,9 +159,13 @@ The flags indicate suggested stream attributes supported by the profile. + Use of AUDIO_{INPUT|OUTPUT}_FLAG_NONE in the XML file isn't required + as empty flag lists are allowed. However these constants are useful for + representing an empty enum value. + @@ -177,6 +181,7 @@ + @@ -251,8 +256,8 @@ - + @@ -271,6 +276,8 @@ + + @@ -279,8 +286,8 @@ - + @@ -302,6 +309,7 @@ + @@ -321,7 +329,6 @@ - @@ -342,22 +349,14 @@ - - - - - - - - - - - + + + @@ -377,17 +376,26 @@ + + + + + + + + + + + - + - - @@ -397,6 +405,7 @@ + @@ -465,9 +474,13 @@ + + + + @@ -538,19 +551,27 @@ - + + + + + + + + + - + @@ -670,6 +691,7 @@ + diff --git a/audio/common/7.0/enums/include/audio_policy_configuration_V7_0-enums.h b/audio/common/7.0/enums/include/audio_policy_configuration_V7_0-enums.h index d5fedce100..cedcab3cc2 100644 --- a/audio/common/7.0/enums/include/audio_policy_configuration_V7_0-enums.h +++ b/audio/common/7.0/enums/include/audio_policy_configuration_V7_0-enums.h @@ -25,6 +25,8 @@ namespace audio::policy::configuration::V7_0 { static inline size_t getChannelCount(AudioChannelMask mask) { switch (mask) { + case AudioChannelMask::AUDIO_CHANNEL_NONE: + return 0; case AudioChannelMask::AUDIO_CHANNEL_OUT_MONO: case AudioChannelMask::AUDIO_CHANNEL_IN_MONO: case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_1: @@ -42,9 +44,12 @@ static inline size_t getChannelCount(AudioChannelMask mask) { case AudioChannelMask::AUDIO_CHANNEL_OUT_2POINT1: case AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO_HAPTIC_A: case AudioChannelMask::AUDIO_CHANNEL_OUT_MONO_HAPTIC_AB: + case AudioChannelMask::AUDIO_CHANNEL_OUT_TRI: + case AudioChannelMask::AUDIO_CHANNEL_OUT_TRI_BACK: case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_3: return 3; case AudioChannelMask::AUDIO_CHANNEL_OUT_2POINT0POINT2: + case AudioChannelMask::AUDIO_CHANNEL_OUT_3POINT1: case AudioChannelMask::AUDIO_CHANNEL_OUT_QUAD: case AudioChannelMask::AUDIO_CHANNEL_OUT_QUAD_BACK: case AudioChannelMask::AUDIO_CHANNEL_OUT_QUAD_SIDE: @@ -158,6 +163,8 @@ static inline bool isOutputDevice(AudioDevice device) { case AudioDevice::AUDIO_DEVICE_OUT_USB_HEADSET: case AudioDevice::AUDIO_DEVICE_OUT_HEARING_AID: case AudioDevice::AUDIO_DEVICE_OUT_ECHO_CANCELLER: + case AudioDevice::AUDIO_DEVICE_OUT_BLE_HEADSET: + case AudioDevice::AUDIO_DEVICE_OUT_BLE_SPEAKER: case AudioDevice::AUDIO_DEVICE_OUT_DEFAULT: case AudioDevice::AUDIO_DEVICE_OUT_STUB: return true; @@ -189,6 +196,7 @@ static inline bool isOutputDevice(AudioDevice device) { case AudioDevice::AUDIO_DEVICE_IN_BLUETOOTH_BLE: case AudioDevice::AUDIO_DEVICE_IN_HDMI_ARC: case AudioDevice::AUDIO_DEVICE_IN_ECHO_REFERENCE: + case AudioDevice::AUDIO_DEVICE_IN_BLE_HEADSET: case AudioDevice::AUDIO_DEVICE_IN_DEFAULT: case AudioDevice::AUDIO_DEVICE_IN_STUB: return false; diff --git a/audio/common/7.0/types.hal b/audio/common/7.0/types.hal index 31c7388329..0d0fa7e91c 100644 --- a/audio/common/7.0/types.hal +++ b/audio/common/7.0/types.hal @@ -106,6 +106,8 @@ typedef string AudioFormat; /** * Audio channel mask indicates presence of particular channels. + * Note that every value is already a mask comprised of individual + * channels. * See 'audioChannelMask' in audio_policy_configuration.xsd for the * list of allowed values. */ @@ -127,13 +129,8 @@ struct AudioProfile { AudioFormat format; /** List of the sample rates (in Hz) supported by the profile. */ vec sampleRates; - /** - * List of channel masks supported by the profile. Every subvector might be - * comprised of several individual channel mask entries for non-traditional - * channel masks, e.g. a combination "OUT_FRONT_LEFT,OUT_FRONT_CENTER" which - * doesn't have a corresponding predefined channel mask. - */ - vec> channelMasks; + /** List of channel masks supported by the profile. */ + vec channelMasks; }; /** @@ -299,21 +296,18 @@ struct SinkMetadata { /** * Type of gain control exposed by an audio port. + * See 'audioGainMode' in audio_policy_configuration.xsd for the + * list of allowed values. */ -@export(name="", value_prefix="AUDIO_GAIN_MODE_") -enum AudioGainMode : uint32_t { - JOINT = 0x1, // supports joint channel gain control - CHANNELS = 0x2, // supports separate channel gain control - RAMP = 0x4 // supports gain ramps -}; +typedef string AudioGainMode; /** * An audio_gain struct is a representation of a gain stage. * A gain stage is always attached to an audio port. */ struct AudioGain { - bitfield mode; - vec channelMask; // channels which gain an be controlled + vec mode; // modes of operation + AudioChannelMask channelMask; // channels which gain can be controlled int32_t minValue; // minimum gain value in millibels int32_t maxValue; // maximum gain value in millibels int32_t defaultValue; // default gain value in millibels @@ -328,8 +322,8 @@ struct AudioGain { */ struct AudioGainConfig { int32_t index; // index of the corresponding AudioGain in AudioPort.gains - AudioGainMode mode; - vec channelMask; // channels which gain value follows + vec mode; // modes of operation + AudioChannelMask channelMask; // channels which gain value follows /** * Gain values in millibels for each channel ordered from LSb to MSb in * channel mask. The number of values is 1 in joint mode or diff --git a/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h b/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h index 5e4b414d29..0a9d5ee166 100644 --- a/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h +++ b/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h @@ -1150,7 +1150,7 @@ static void testSetAudioProperties(IStream* stream) { for (const auto& channelMask : profile.channelMasks) { AudioConfigBase config{.format = profile.format, .sampleRateHz = sampleRate, - .channelMask = channelMask}; + .channelMask = {{channelMask}}}; auto ret = stream->setAudioProperties(config); EXPECT_TRUE(ret.isOk()); EXPECT_EQ(Result::OK, ret) << config.format << "; " << config.sampleRateHz << "; "