diff --git a/audio/7.0/IDevice.hal b/audio/7.0/IDevice.hal index 7082d6b7ab..eecd92ed7c 100644 --- a/audio/7.0/IDevice.hal +++ b/audio/7.0/IDevice.hal @@ -315,7 +315,6 @@ interface IDevice { * INVALID_STATE if the device was already closed * or there are streams currently opened. */ - @exit close() generates (Result retval); /** diff --git a/audio/7.0/IStream.hal b/audio/7.0/IStream.hal index dacd3fd342..789cb1dfd1 100644 --- a/audio/7.0/IStream.hal +++ b/audio/7.0/IStream.hal @@ -43,13 +43,6 @@ interface IStream { */ getBufferSize() generates (uint64_t bufferSize); - /** - * Return the sampling rate in Hz. - * - * @return sampleRateHz sample rate in Hz. - */ - getSampleRate() generates (uint32_t sampleRateHz); - /** * Return supported native sampling rates of the stream for a given format. * A supported native sample rate is a sample rate that can be efficiently @@ -71,23 +64,6 @@ interface IStream { getSupportedSampleRates(AudioFormat format) generates (Result retval, vec sampleRates); - /** - * Sets the sampling rate of the stream. Calling this method is equivalent - * to setting AUDIO_PARAMETER_STREAM_SAMPLING_RATE on the legacy HAL. - * Optional method. If implemented, only called on a stopped stream. - * - * @param sampleRateHz sample rate in Hz. - * @return retval operation completion status. - */ - setSampleRate(uint32_t sampleRateHz) generates (Result retval); - - /** - * Return the channel mask of the stream. - * - * @return mask channel mask. - */ - getChannelMask() generates (bitfield mask); - /** * Return supported channel masks of the stream. Calling this method is * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_CHANNELS on the legacy @@ -99,24 +75,7 @@ interface IStream { * @return masks supported audio masks. */ getSupportedChannelMasks(AudioFormat format) - generates (Result retval, vec> masks); - - /** - * Sets the channel mask of the stream. Calling this method is equivalent to - * setting AUDIO_PARAMETER_STREAM_CHANNELS on the legacy HAL. - * Optional method - * - * @param format audio format. - * @return retval operation completion status. - */ - setChannelMask(bitfield mask) generates (Result retval); - - /** - * Return the audio format of the stream. - * - * @return format audio format. - */ - getFormat() generates (AudioFormat format); + generates (Result retval, vec> masks); /** * Return supported audio formats of the stream. Calling this method is @@ -130,25 +89,23 @@ interface IStream { getSupportedFormats() generates (Result retval, vec formats); /** - * Sets the audio format of the stream. Calling this method is equivalent to - * setting AUDIO_PARAMETER_STREAM_FORMAT on the legacy HAL. - * Optional method + * Retrieves basic stream configuration: sample rate, audio format, + * channel mask. * - * @param format audio format. - * @return retval operation completion status. + * @return config basic stream configuration. */ - setFormat(AudioFormat format) generates (Result retval); + getAudioProperties() generates (AudioBasicConfig config); /** - * Convenience method for retrieving several stream parameters in - * one transaction. + * Sets stream parameters. Only sets parameters that are specified. + * See the description of AudioBasicConfig for the details. * - * @return sampleRateHz sample rate in Hz. - * @return mask channel mask. - * @return format audio format. + * Optional method. If implemented, only called on a stopped stream. + * + * @param config basic stream configuration. + * @return retval operation completion status. */ - getAudioProperties() generates ( - uint32_t sampleRateHz, bitfield mask, AudioFormat format); + setAudioProperties(AudioBasicConfig config) generates (Result retval); /** * Applies audio effect to the stream. @@ -312,6 +269,5 @@ interface IStream { * output stream interface. * INVALID_STATE if the stream was already closed. */ - @exit close() generates (Result retval); }; diff --git a/audio/7.0/IStreamIn.hal b/audio/7.0/IStreamIn.hal index 15e436359e..0a3f24b840 100644 --- a/audio/7.0/IStreamIn.hal +++ b/audio/7.0/IStreamIn.hal @@ -100,7 +100,7 @@ interface IStreamIn extends IStream { * * The driver operates on a dedicated thread. The client must ensure that * the thread is given an appropriate priority and assigned to correct - * scheduler and cgroup. For this purpose, the method returns identifiers + * scheduler and cgroup. For this purpose, the method returns the identifier * of the driver thread. * * @param frameSize the size of a single frame, in bytes. @@ -115,7 +115,9 @@ interface IStreamIn extends IStream { * specified at the stream opening. * @return statusMQ a message queue used for passing status from the driver * using ReadStatus structures. - * @return threadInfo identifiers of the driver's dedicated thread. + * @return threadId identifier of the driver's dedicated thread; the caller + * may adjust the thread priority to match the priority + * of the thread that provides audio data. */ prepareForReading(uint32_t frameSize, uint32_t framesCount) generates ( @@ -123,7 +125,7 @@ interface IStreamIn extends IStream { fmq_sync commandMQ, fmq_sync dataMQ, fmq_sync statusMQ, - ThreadInfo threadInfo); + int32_t threadId); /** * Return the amount of input frames lost in the audio driver since the last diff --git a/audio/7.0/IStreamOut.hal b/audio/7.0/IStreamOut.hal index 208beb6363..38d750f76b 100644 --- a/audio/7.0/IStreamOut.hal +++ b/audio/7.0/IStreamOut.hal @@ -95,7 +95,7 @@ interface IStreamOut extends IStream { * * The driver operates on a dedicated thread. The client must ensure that * the thread is given an appropriate priority and assigned to correct - * scheduler and cgroup. For this purpose, the method returns identifiers + * scheduler and cgroup. For this purpose, the method returns the identifier * of the driver thread. * * @param frameSize the size of a single frame, in bytes. @@ -109,7 +109,9 @@ interface IStreamOut extends IStream { * specified at the stream opening. * @return statusMQ a message queue used for passing status from the driver * using WriteStatus structures. - * @return threadInfo identifiers of the driver's dedicated thread. + * @return threadId identifier of the driver's dedicated thread; the caller + * may adjust the thread priority to match the priority + * of the thread that provides audio data. */ prepareForWriting(uint32_t frameSize, uint32_t framesCount) generates ( @@ -117,7 +119,7 @@ interface IStreamOut extends IStream { fmq_sync commandMQ, fmq_sync dataMQ, fmq_sync statusMQ, - ThreadInfo threadInfo); + int32_t threadId); /** * Return the number of audio frames written by the audio DSP to DAC since diff --git a/audio/7.0/config/api/current.txt b/audio/7.0/config/api/current.txt index 98c5eac982..fd9a8ef200 100644 --- a/audio/7.0/config/api/current.txt +++ b/audio/7.0/config/api/current.txt @@ -6,6 +6,81 @@ package audio.policy.configuration.V7_0 { method public java.util.List getItem(); } + public enum AudioChannelMask { + method public String getRawName(); + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_1; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_10; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_11; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_12; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_13; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_14; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_15; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_16; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_17; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_18; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_19; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_2; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_20; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_21; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_22; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_23; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_24; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_3; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_4; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_5; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_6; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_7; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_8; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_INDEX_MASK_9; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_IN_2POINT0POINT2; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_IN_2POINT1POINT2; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_IN_3POINT0POINT2; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_IN_3POINT1POINT2; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_IN_5POINT1; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_IN_6; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_IN_FRONT_BACK; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_IN_MONO; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_IN_STEREO; + 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_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_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; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_5POINT1POINT4; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_5POINT1_BACK; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_5POINT1_SIDE; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_6POINT1; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_7POINT1; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_7POINT1POINT2; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_7POINT1POINT4; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_HAPTIC_AB; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_MONO; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_MONO_HAPTIC_A; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_MONO_HAPTIC_AB; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_PENTA; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_QUAD; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_QUAD_BACK; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_QUAD_SIDE; + enum_constant public static final audio.policy.configuration.V7_0.AudioChannelMask AUDIO_CHANNEL_OUT_STEREO; + 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; + } + + public enum AudioContentType { + method public String getRawName(); + enum_constant public static final audio.policy.configuration.V7_0.AudioContentType AUDIO_CONTENT_TYPE_MOVIE; + enum_constant public static final audio.policy.configuration.V7_0.AudioContentType AUDIO_CONTENT_TYPE_MUSIC; + enum_constant public static final audio.policy.configuration.V7_0.AudioContentType AUDIO_CONTENT_TYPE_SONIFICATION; + enum_constant public static final audio.policy.configuration.V7_0.AudioContentType AUDIO_CONTENT_TYPE_SPEECH; + enum_constant public static final audio.policy.configuration.V7_0.AudioContentType AUDIO_CONTENT_TYPE_UNKNOWN; + } + public enum AudioDevice { method public String getRawName(); enum_constant public static final audio.policy.configuration.V7_0.AudioDevice AUDIO_DEVICE_IN_AMBIENT; @@ -116,6 +191,7 @@ 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; @@ -164,18 +240,59 @@ package audio.policy.configuration.V7_0 { method public void setVersion(audio.policy.configuration.V7_0.Version); } + public enum AudioSource { + method public String getRawName(); + enum_constant public static final audio.policy.configuration.V7_0.AudioSource AUDIO_SOURCE_CAMCORDER; + enum_constant public static final audio.policy.configuration.V7_0.AudioSource AUDIO_SOURCE_DEFAULT; + enum_constant public static final audio.policy.configuration.V7_0.AudioSource AUDIO_SOURCE_ECHO_REFERENCE; + enum_constant public static final audio.policy.configuration.V7_0.AudioSource AUDIO_SOURCE_FM_TUNER; + enum_constant public static final audio.policy.configuration.V7_0.AudioSource AUDIO_SOURCE_HOTWORD; + enum_constant public static final audio.policy.configuration.V7_0.AudioSource AUDIO_SOURCE_MIC; + enum_constant public static final audio.policy.configuration.V7_0.AudioSource AUDIO_SOURCE_REMOTE_SUBMIX; + enum_constant public static final audio.policy.configuration.V7_0.AudioSource AUDIO_SOURCE_UNPROCESSED; + enum_constant public static final audio.policy.configuration.V7_0.AudioSource AUDIO_SOURCE_VOICE_CALL; + enum_constant public static final audio.policy.configuration.V7_0.AudioSource AUDIO_SOURCE_VOICE_COMMUNICATION; + enum_constant public static final audio.policy.configuration.V7_0.AudioSource AUDIO_SOURCE_VOICE_DOWNLINK; + enum_constant public static final audio.policy.configuration.V7_0.AudioSource AUDIO_SOURCE_VOICE_PERFORMANCE; + enum_constant public static final audio.policy.configuration.V7_0.AudioSource AUDIO_SOURCE_VOICE_RECOGNITION; + enum_constant public static final audio.policy.configuration.V7_0.AudioSource AUDIO_SOURCE_VOICE_UPLINK; + } + + public enum AudioStreamType { + method public String getRawName(); + enum_constant public static final audio.policy.configuration.V7_0.AudioStreamType AUDIO_STREAM_ACCESSIBILITY; + 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_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; + enum_constant public static final audio.policy.configuration.V7_0.AudioStreamType AUDIO_STREAM_NOTIFICATION; + enum_constant public static final audio.policy.configuration.V7_0.AudioStreamType AUDIO_STREAM_PATCH; + enum_constant public static final audio.policy.configuration.V7_0.AudioStreamType AUDIO_STREAM_REROUTING; + enum_constant public static final audio.policy.configuration.V7_0.AudioStreamType AUDIO_STREAM_RING; + enum_constant public static final audio.policy.configuration.V7_0.AudioStreamType AUDIO_STREAM_SYSTEM; + enum_constant public static final audio.policy.configuration.V7_0.AudioStreamType AUDIO_STREAM_TTS; + enum_constant public static final audio.policy.configuration.V7_0.AudioStreamType AUDIO_STREAM_VOICE_CALL; + } + public enum AudioUsage { method public String getRawName(); enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_ALARM; + enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_ANNOUNCEMENT; enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY; enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE; enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_ASSISTANCE_SONIFICATION; enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_ASSISTANT; + enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_CALL_ASSISTANT; + enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_EMERGENCY; enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_GAME; enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_MEDIA; enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_NOTIFICATION; enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE; + enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_SAFETY; enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_UNKNOWN; + enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_VEHICLE_STATUS; enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_VIRTUAL_SOURCE; enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_VOICE_COMMUNICATION; enum_constant public static final audio.policy.configuration.V7_0.AudioUsage AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING; @@ -234,7 +351,7 @@ package audio.policy.configuration.V7_0 { public static class Gains.Gain { ctor public Gains.Gain(); - method public String getChannel_mask(); + method public audio.policy.configuration.V7_0.AudioChannelMask getChannel_mask(); method public int getDefaultValueMB(); method public int getMaxRampMs(); method public int getMaxValueMB(); @@ -244,7 +361,7 @@ package audio.policy.configuration.V7_0 { method public String getName(); method public int getStepValueMB(); method public boolean getUseForVolume(); - method public void setChannel_mask(String); + method public void setChannel_mask(audio.policy.configuration.V7_0.AudioChannelMask); method public void setDefaultValueMB(int); method public void setMaxRampMs(int); method public void setMaxValueMB(int); @@ -327,14 +444,14 @@ package audio.policy.configuration.V7_0 { public class Profile { ctor public Profile(); - method public String getChannelMasks(); + method public java.util.List getChannelMasks(); method public String getFormat(); method public String getName(); - method public String getSamplingRates(); - method public void setChannelMasks(String); + method public java.util.List getSamplingRates(); + method public void setChannelMasks(java.util.List); method public void setFormat(String); method public void setName(String); - method public void setSamplingRates(String); + method public void setSamplingRates(java.util.List); } public class Reference { @@ -365,24 +482,6 @@ package audio.policy.configuration.V7_0 { method public void setType(audio.policy.configuration.V7_0.MixType); } - public enum Stream { - method public String getRawName(); - enum_constant public static final audio.policy.configuration.V7_0.Stream AUDIO_STREAM_ACCESSIBILITY; - enum_constant public static final audio.policy.configuration.V7_0.Stream AUDIO_STREAM_ALARM; - enum_constant public static final audio.policy.configuration.V7_0.Stream AUDIO_STREAM_ASSISTANT; - enum_constant public static final audio.policy.configuration.V7_0.Stream AUDIO_STREAM_BLUETOOTH_SCO; - enum_constant public static final audio.policy.configuration.V7_0.Stream AUDIO_STREAM_DTMF; - enum_constant public static final audio.policy.configuration.V7_0.Stream AUDIO_STREAM_ENFORCED_AUDIBLE; - enum_constant public static final audio.policy.configuration.V7_0.Stream AUDIO_STREAM_MUSIC; - enum_constant public static final audio.policy.configuration.V7_0.Stream AUDIO_STREAM_NOTIFICATION; - enum_constant public static final audio.policy.configuration.V7_0.Stream AUDIO_STREAM_PATCH; - enum_constant public static final audio.policy.configuration.V7_0.Stream AUDIO_STREAM_REROUTING; - enum_constant public static final audio.policy.configuration.V7_0.Stream AUDIO_STREAM_RING; - enum_constant public static final audio.policy.configuration.V7_0.Stream AUDIO_STREAM_SYSTEM; - enum_constant public static final audio.policy.configuration.V7_0.Stream AUDIO_STREAM_TTS; - enum_constant public static final audio.policy.configuration.V7_0.Stream AUDIO_STREAM_VOICE_CALL; - } - public class SurroundFormats { ctor public SurroundFormats(); method public java.util.List getFormat(); @@ -412,10 +511,10 @@ package audio.policy.configuration.V7_0 { method public audio.policy.configuration.V7_0.DeviceCategory getDeviceCategory(); method public java.util.List getPoint(); method public String getRef(); - method public audio.policy.configuration.V7_0.Stream getStream(); + method public audio.policy.configuration.V7_0.AudioStreamType getStream(); method public void setDeviceCategory(audio.policy.configuration.V7_0.DeviceCategory); method public void setRef(String); - method public void setStream(audio.policy.configuration.V7_0.Stream); + method public void setStream(audio.policy.configuration.V7_0.AudioStreamType); } public class Volumes { diff --git a/audio/7.0/config/audio_policy_configuration.xsd b/audio/7.0/config/audio_policy_configuration.xsd index 19c6f70536..4555a88034 100644 --- a/audio/7.0/config/audio_policy_configuration.xsd +++ b/audio/7.0/config/audio_policy_configuration.xsd @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. --> - - Version of the interface the hal implements. + Version of the interface the hal implements. Note that this + relates to legacy HAL API versions since HIDL APIs are versioned + using other mechanisms. @@ -154,7 +155,6 @@ - @@ -212,9 +212,6 @@ - @@ -252,7 +249,6 @@ - @@ -298,10 +294,9 @@ - + @@ -382,9 +377,14 @@ - + + + Audio usage specifies the intended use case for the sound being played. + Please consult frameworks/base/media/java/android/media/AudioAttributes.java + for the description of each value. + + @@ -399,34 +399,119 @@ + + + + + - - - - - - - - + - Comma (",") separated list of channel flags - from audio_channel_mask_t. + Audio content type expresses the general category of the content. + Please consult frameworks/base/media/java/android/media/AudioAttributes.java + for the description of each value. - + + + + + + + + + + + + Audio channel mask specifies presence of particular channels. + There are two representations: + - representation position (traditional discrete channel specification, + e.g. "left", "right"); + - indexed (this is similar to "tracks" in audio mixing, channels + are represented using numbers). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -441,7 +526,7 @@ - + @@ -537,9 +622,14 @@ - - + + + + Audio stream type describing the intended use case of a stream. + Please consult frameworks/base/media/java/android/media/AudioSystem.java + for the description of each value. + + @@ -557,8 +647,32 @@ - + + + + An audio source defines the intended use case for the sound being recorded. + Please consult frameworks/base/media/java/android/media/MediaRecorder.java + for the description of each value. + + + + + + + + + + + + + + + + + + + + @@ -591,7 +705,7 @@ - + diff --git a/audio/7.0/config/update_audio_policy_config.sh b/audio/7.0/config/update_audio_policy_config.sh new file mode 100755 index 0000000000..8714b5f2d3 --- /dev/null +++ b/audio/7.0/config/update_audio_policy_config.sh @@ -0,0 +1,159 @@ +#!/bin/bash + +# Copyright (C) 2020 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 script is used to update audio policy configuration files +# to comply with the updated audio_policy_configuration.xsd from V7.0. +# +# The main difference is the separator used in lists for attributes. +# Since the XML Schema Definition standard only allows space to be +# used as a separator (see https://www.w3.org/TR/xmlschema11-2/#list-datatypes) +# the previous versions used a regular expression to validate lists +# in attribute values. E.g. the channel masks were validated using +# the following regexp: [_A-Z][_A-Z0-9]*(,[_A-Z][_A-Z0-9]*)* +# This has an obvious drawback of missing typos in the config file. +# +# The V7.0 has shifted to defining most of the frequently changed +# types in the XSD schema only. This allows for verifying all the values +# in lists, but in order to comply with XML Schema requirements +# list elements must be separated by space. +# +# Since the APM config files typically use include directives, +# the script must be pointed to the main APM config file and will +# take care all the included files automatically. +# If the included file is a shared version from 'frameworks/av', +# instead of updating it the script checks if there is a newer +# version with the corresponding name suffix (e.g. +# 'a2dp_audio_policy_configuration_7_0.xml') and updates the include +# path instead. + +set -euo pipefail + +if (echo "$@" | grep -qe -h); then + echo "This script will update Audio Policy Manager config file" + echo "to the format required by V7.0 XSD schema from a previous" + echo "version." + echo + echo "USAGE: $0 [APM_XML_FILE] [OLD_VERSION]" + echo " APM_XML_FILE specifies the path to audio_policy_configuration.xml" + echo " relative to Android repository root" + echo " OLD_VERSION specifies the version of schema currently used" + echo + echo "Example: $0 device/generic/goldfish/audio/policy/audio_policy_configuration.xml 6.0" + exit +fi +readonly HAL_DIRECTORY=hardware/interfaces/audio +readonly SHARED_CONFIGS_DIRECTORY=frameworks/av/services/audiopolicy/config +readonly OLD_VERSION=${2:-$(ls ${ANDROID_BUILD_TOP}/${HAL_DIRECTORY} | grep -E '[0-9]+\.[0-9]+' | + sort -n | tail -n1)} +readonly NEW_VERSION=7.0 +readonly NEW_VERSION_UNDERSCORE=7_0 + +readonly SOURCE_CONFIG=${ANDROID_BUILD_TOP}/$1 + +# First, validate the input using the schema of the current version + +echo Validating the source against the $OLD_VERSION schema +xmllint --noout --xinclude \ + --nofixup-base-uris --path "$ANDROID_BUILD_TOP/$SHARED_CONFIGS_DIRECTORY" \ + --schema ${ANDROID_BUILD_TOP}/${HAL_DIRECTORY}/${OLD_VERSION}/config/audio_policy_configuration.xsd \ + ${SOURCE_CONFIG} +if [ $? -ne 0 ]; then + echo + echo "Config file fails validation for the specified version $OLD_VERSION--unsafe to update" + exit 1 +fi + +# Find all the source files recursively + +SOURCE_FILES=${SOURCE_CONFIG} +SHARED_FILES= +findIncludes() { + local FILES_TO_CHECK= + for F in $1; do + local FOUND_INCLUDES=$(grep -Po ' channelMask; // empty means 'unspecified' + AudioFormat format; // 'DEFAULT' means 'unspecified' }; /** @@ -607,301 +136,55 @@ enum AudioMode : int32_t { CALL_SCREEN = 4, }; -@export(name="", value_prefix="AUDIO_DEVICE_") -enum AudioDevice : uint32_t { - NONE = 0x0, - /** reserved bits */ - BIT_IN = 0x80000000, - BIT_DEFAULT = 0x40000000, - /** output devices */ - OUT_EARPIECE = 0x1, - OUT_SPEAKER = 0x2, - OUT_WIRED_HEADSET = 0x4, - OUT_WIRED_HEADPHONE = 0x8, - OUT_BLUETOOTH_SCO = 0x10, - OUT_BLUETOOTH_SCO_HEADSET = 0x20, - OUT_BLUETOOTH_SCO_CARKIT = 0x40, - OUT_BLUETOOTH_A2DP = 0x80, - OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100, - OUT_BLUETOOTH_A2DP_SPEAKER = 0x200, - OUT_AUX_DIGITAL = 0x400, - OUT_HDMI = OUT_AUX_DIGITAL, - /** uses an analog connection (multiplexed over the USB pins for instance) */ - OUT_ANLG_DOCK_HEADSET = 0x800, - OUT_DGTL_DOCK_HEADSET = 0x1000, - /** USB accessory mode: Android device is USB device and dock is USB host */ - OUT_USB_ACCESSORY = 0x2000, - /** USB host mode: Android device is USB host and dock is USB device */ - OUT_USB_DEVICE = 0x4000, - OUT_REMOTE_SUBMIX = 0x8000, - /** Telephony voice TX path */ - OUT_TELEPHONY_TX = 0x10000, - /** Analog jack with line impedance detected */ - OUT_LINE = 0x20000, - /** HDMI Audio Return Channel */ - OUT_HDMI_ARC = 0x40000, - /** S/PDIF out */ - OUT_SPDIF = 0x80000, - /** FM transmitter out */ - OUT_FM = 0x100000, - /** Line out for av devices */ - OUT_AUX_LINE = 0x200000, - /** limited-output speaker device for acoustic safety */ - OUT_SPEAKER_SAFE = 0x400000, - OUT_IP = 0x800000, - /** audio bus implemented by the audio system (e.g an MOST stereo channel) */ - OUT_BUS = 0x1000000, - OUT_PROXY = 0x2000000, - OUT_USB_HEADSET = 0x4000000, - OUT_HEARING_AID = 0x8000000, - OUT_ECHO_CANCELLER = 0x10000000, - OUT_DEFAULT = BIT_DEFAULT, - // Note that the 2.0 OUT_ALL* have been moved to helper functions - - /** input devices */ - IN_COMMUNICATION = BIT_IN | 0x1, - IN_AMBIENT = BIT_IN | 0x2, - IN_BUILTIN_MIC = BIT_IN | 0x4, - IN_BLUETOOTH_SCO_HEADSET = BIT_IN | 0x8, - IN_WIRED_HEADSET = BIT_IN | 0x10, - IN_AUX_DIGITAL = BIT_IN | 0x20, - IN_HDMI = IN_AUX_DIGITAL, - /** Telephony voice RX path */ - IN_VOICE_CALL = BIT_IN | 0x40, - IN_TELEPHONY_RX = IN_VOICE_CALL, - IN_BACK_MIC = BIT_IN | 0x80, - IN_REMOTE_SUBMIX = BIT_IN | 0x100, - IN_ANLG_DOCK_HEADSET = BIT_IN | 0x200, - IN_DGTL_DOCK_HEADSET = BIT_IN | 0x400, - IN_USB_ACCESSORY = BIT_IN | 0x800, - IN_USB_DEVICE = BIT_IN | 0x1000, - /** FM tuner input */ - IN_FM_TUNER = BIT_IN | 0x2000, - /** TV tuner input */ - IN_TV_TUNER = BIT_IN | 0x4000, - /** Analog jack with line impedance detected */ - IN_LINE = BIT_IN | 0x8000, - /** S/PDIF in */ - IN_SPDIF = BIT_IN | 0x10000, - IN_BLUETOOTH_A2DP = BIT_IN | 0x20000, - IN_LOOPBACK = BIT_IN | 0x40000, - IN_IP = BIT_IN | 0x80000, - /** audio bus implemented by the audio system (e.g an MOST stereo channel) */ - IN_BUS = BIT_IN | 0x100000, - IN_PROXY = BIT_IN | 0x1000000, - IN_USB_HEADSET = BIT_IN | 0x2000000, - IN_BLUETOOTH_BLE = BIT_IN | 0x4000000, - IN_ECHO_REFERENCE = BIT_IN | 0x10000000, - IN_DEFAULT = BIT_IN | BIT_DEFAULT, - - // Note that the 2.0 IN_ALL* have been moved to helper functions -}; - -/** - * IEEE 802 MAC address. - */ -typedef uint8_t[6] MacAddress; - /** * Specifies a device address in case when several devices of the same type * can be connected (e.g. BT A2DP, USB). */ struct DeviceAddress { - AudioDevice device; // discriminator - union Address { - MacAddress mac; // used for BLUETOOTH_A2DP_* - uint8_t[4] ipv4; // used for IP + /** + * Audio device specifies type (or category) of audio I/O device + * (e.g. speaker or headphones). + * See 'audioDevice' in audio_policy_configuration.xsd for the + * list of allowed values. + */ + string deviceType; + safe_union Address { + /** + * The address may be left unspecified if 'device' specifies + * a physical device unambiguously. + */ + Monostate unspecified; + /** IEEE 802 MAC address. Set for Bluetooth devices. */ + uint8_t[6] mac; + /** IPv4 Address. Set for IPv4 devices. */ + uint8_t[4] ipv4; + /** IPv6 Address. Set for IPv6 devices. */ + uint16_t[8] ipv6; + /** PCI bus Address. Set for USB devices. */ struct Alsa { int32_t card; int32_t device; - } alsa; // used for USB_* + } alsa; + /** Arbitrary BUS device unique address. Not interpreted by the framework. */ + string bus; + /** Arbitrary REMOTE_SUBMIX device unique address. Not interpreted by the HAL. */ + string rSubmix; } address; - /** Arbitrary BUS device unique address. Should not be interpreted by the framework. */ - string busAddress; - /** Arbitrary REMOTE_SUBMIX device unique address. Should not be interpreted by the HAL. */ - string rSubmixAddress; }; /** - * The audio output flags serve two purposes: - * - * - when an AudioTrack is created they indicate a "wish" to be connected to an - * output stream with attributes corresponding to the specified flags; - * - * - when present in an output profile descriptor listed for a particular audio - * hardware module, they indicate that an output stream can be opened that - * supports the attributes indicated by the flags. - * - * The audio policy manager will try to match the flags in the request - * (when getOuput() is called) to an available output stream. + * Audio usage specifies the intended use case for the sound being played. + * See 'audioUsage' in audio_policy_configuration.xsd for the + * list of allowed values. */ -@export(name="audio_output_flags_t", value_prefix="AUDIO_OUTPUT_FLAG_") -enum AudioOutputFlag : int32_t { - NONE = 0x0, // no attributes - DIRECT = 0x1, // this output directly connects a track - // to one output stream: no software mixer - PRIMARY = 0x2, // this output is the primary output of the device. It is - // unique and must be present. It is opened by default and - // receives routing, audio mode and volume controls related - // to voice calls. - FAST = 0x4, // output supports "fast tracks", defined elsewhere - DEEP_BUFFER = 0x8, // use deep audio buffers - COMPRESS_OFFLOAD = 0x10, // offload playback of compressed streams to - // hardware codec - NON_BLOCKING = 0x20, // use non-blocking write - HW_AV_SYNC = 0x40, // output uses a hardware A/V sync - TTS = 0x80, // output for streams transmitted through speaker at a - // sample rate high enough to accommodate lower-range - // ultrasonic p/b - RAW = 0x100, // minimize signal processing - SYNC = 0x200, // synchronize I/O streams - IEC958_NONAUDIO = 0x400, // Audio stream contains compressed audio in SPDIF - // data bursts, not PCM. - DIRECT_PCM = 0x2000, // Audio stream containing PCM data that needs - // to pass through compress path for DSP post proc. - MMAP_NOIRQ = 0x4000, // output operates in MMAP no IRQ mode. - VOIP_RX = 0x8000, // preferred output for VoIP calls. - /** preferred output for call music */ - INCALL_MUSIC = 0x10000, -}; +typedef string AudioUsage; /** - * The audio input flags are analogous to audio output flags. - * Currently they are used only when an AudioRecord is created, - * to indicate a preference to be connected to an input stream with - * attributes corresponding to the specified flags. + * Audio content type expresses the general category of the content. + * See 'audioContentType' in audio_policy_configuration.xsd for the + * list of allowed values. */ -@export(name="audio_input_flags_t", value_prefix="AUDIO_INPUT_FLAG_") -enum AudioInputFlag : int32_t { - NONE = 0x0, // no attributes - FAST = 0x1, // prefer an input that supports "fast tracks" - HW_HOTWORD = 0x2, // prefer an input that captures from hw hotword source - RAW = 0x4, // minimize signal processing - SYNC = 0x8, // synchronize I/O streams - MMAP_NOIRQ = 0x10, // input operates in MMAP no IRQ mode. - VOIP_TX = 0x20, // preferred input for VoIP calls. - HW_AV_SYNC = 0x40, // input connected to an output that uses a hardware A/V sync - DIRECT = 0x80, // for acquiring encoded streams -}; - -@export(name="audio_usage_t", value_prefix="AUDIO_USAGE_") -enum AudioUsage : int32_t { - // These values must kept in sync with - // frameworks/base/media/java/android/media/AudioAttributes.java - // Note that not all framework values are exposed - /** - * Usage value to use when the usage is unknown. - */ - UNKNOWN = 0, - /** - * Usage value to use when the usage is media, such as music, or movie - * soundtracks. - */ - MEDIA = 1, - /** - * Usage value to use when the usage is voice communications, such as - * telephony or VoIP. - */ - VOICE_COMMUNICATION = 2, - /** - * Usage value to use when the usage is in-call signalling, such as with - * a "busy" beep, or DTMF tones. - */ - VOICE_COMMUNICATION_SIGNALLING = 3, - /** - * Usage value to use when the usage is an alarm (e.g. wake-up alarm). - */ - ALARM = 4, - /** - * Usage value to use when the usage is a generic notification. - */ - NOTIFICATION = 5, - /** - * Usage value to use when the usage is telephony ringtone. - */ - NOTIFICATION_TELEPHONY_RINGTONE = 6, - /** - * Usage value to use when the usage is for accessibility, such as with - * a screen reader. - */ - ASSISTANCE_ACCESSIBILITY = 11, - /** - * Usage value to use when the usage is driving or navigation directions. - */ - ASSISTANCE_NAVIGATION_GUIDANCE = 12, - /** - * Usage value to use when the usage is sonification, such as with user - * interface sounds. - */ - ASSISTANCE_SONIFICATION = 13, - /** - * Usage value to use when the usage is for game audio. - */ - GAME = 14, - /** - * Usage value to use when feeding audio to the platform and replacing - * "traditional" audio source, such as audio capture devices. - */ - VIRTUAL_SOURCE = 15, - /** - * Usage value to use for audio responses to user queries, audio - * instructions or help utterances. - */ - ASSISTANT = 16, - /** - * Usage value to use for assistant voice interaction with remote caller - * on Cell and VoIP calls. - */ - CALL_ASSISTANT = 17, - /** - * Usage value to use when the usage is an emergency. - */ - EMERGENCY = 1000, - /** - * Usage value to use when the usage is a safety sound. - */ - SAFETY = 1001, - /** - * Usage value to use when the usage is a vehicle status. - */ - VEHICLE_STATUS = 1002, - /** - * Usage value to use when the usage is an announcement. - */ - ANNOUNCEMENT = 1003, -}; - -/** Type of audio generated by an application. */ -@export(name="audio_content_type_t", value_prefix="AUDIO_CONTENT_TYPE_") -enum AudioContentType : uint32_t { - // Do not change these values without updating their counterparts - // in frameworks/base/media/java/android/media/AudioAttributes.java - /** - * Content type value to use when the content type is unknown, or other than - * the ones defined. - */ - UNKNOWN = 0, - /** - * Content type value to use when the content type is speech. - */ - SPEECH = 1, - /** - * Content type value to use when the content type is music. - */ - MUSIC = 2, - /** - * Content type value to use when the content type is a soundtrack, - * typically accompanying a movie or TV program. - */ - MOVIE = 3, - /** - * Content type value to use when the content type is a sound used to - * accompany a user action, such as a beep or sound effect expressing a key - * click, or event, such as the type of a sound for a bonus being received - * in a game. These sounds are mostly synthesized or short Foley sounds. - */ - SONIFICATION = 4, -}; +typedef string AudioContentType; /** Encapsulation mode used for sending audio compressed data. */ @export(name="audio_encapsulation_mode_t", value_prefix="AUDIO_ENCAPSULATION_MODE_") @@ -926,9 +209,7 @@ enum AudioEncapsulationMode : int32_t { * Additional information about the stream passed to hardware decoders. */ struct AudioOffloadInfo { - uint32_t sampleRateHz; - bitfield channelMask; - AudioFormat format; + AudioBasicConfig base; AudioStreamType streamType; uint32_t bitRatePerSecond; int64_t durationMicroseconds; // -1 if unknown @@ -946,9 +227,7 @@ struct AudioOffloadInfo { * Commonly used audio stream configuration parameters. */ struct AudioConfig { - uint32_t sampleRateHz; - bitfield channelMask; - AudioFormat format; + AudioBasicConfig base; AudioOffloadInfo offloadInfo; uint64_t frameCount; }; @@ -985,8 +264,7 @@ struct RecordTrackMetadata { safe_union Destination { Monostate unspecified; DeviceAddress device; - }; - Destination destination; + } destination; }; /** Metadatas of the sink of a StreamIn. */ @@ -994,7 +272,6 @@ struct SinkMetadata { vec tracks; }; - /* * * Volume control @@ -1017,7 +294,7 @@ enum AudioGainMode : uint32_t { */ struct AudioGain { bitfield mode; - bitfield channelMask; // channels which gain an be controlled + vec channelMask; // channels which gain an 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 @@ -1033,10 +310,8 @@ struct AudioGain { struct AudioGainConfig { int32_t index; // index of the corresponding AudioGain in AudioPort.gains AudioGainMode mode; - AudioChannelMask channelMask; // channels which gain value follows + vec channelMask; // channels which gain value follows /** - * 4 = sizeof(AudioChannelMask), - * 8 is not "FCC_8", so it won't need to be changed for > 8 channels. * 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 * popcount(channel_mask). @@ -1060,132 +335,85 @@ struct AudioGainConfig { * the interface. */ -/** Audio port role: either source or sink */ -@export(name="audio_port_role_t", value_prefix="AUDIO_PORT_ROLE_") -enum AudioPortRole : int32_t { - NONE, - SOURCE, - SINK, -}; - /** - * Audio port type indicates if it is a session (e.g AudioTrack), a mix (e.g - * PlaybackThread output) or a physical device (e.g OUT_SPEAKER) + * A helper aggregate structure providing parameters that depend on the + * port role. */ -@export(name="audio_port_type_t", value_prefix="AUDIO_PORT_TYPE_") -enum AudioPortType : int32_t { - NONE, - DEVICE, - MIX, - SESSION, -}; - -/** - * Extension for audio port configuration structure when the audio port is a - * hardware device. - */ -struct AudioPortConfigDeviceExt { - AudioModuleHandle hwModule; // module the device is attached to - AudioDevice type; // device type (e.g OUT_SPEAKER) - uint8_t[32] address; // device address. "" if N/A -}; - -/** - * Extension for audio port configuration structure when the audio port is an - * audio session. - */ -struct AudioPortConfigSessionExt { +safe_union AudioPortExtendedInfo { + /** Set when no information is provided. */ + Monostate unspecified; + /** Set when the audio port is an audio device. */ + DeviceAddress device; + /** Set when the audio port is a mix. The handle is of a stream. */ + struct AudioPortMixExt { + /** I/O handle of the input/output stream. */ + AudioIoHandle ioHandle; + safe_union UseCase { + /** Specified when the port is in the SOURCE role. */ + AudioStreamType stream; + /** Specified when the port is in the SINK role. */ + AudioSource source; + } useCase; + } mix; + /** Set when the audio port is an audio session. */ AudioSession session; }; -/** - * Flags indicating which fields are to be considered in AudioPortConfig. - */ -@export(name="", value_prefix="AUDIO_PORT_CONFIG_") -enum AudioPortConfigMask : uint32_t { - SAMPLE_RATE = 0x1, - CHANNEL_MASK = 0x2, - FORMAT = 0x4, - GAIN = 0x8, -}; - /** * Audio port configuration structure used to specify a particular configuration * of an audio port. */ struct AudioPortConfig { + /** + * The 'id' field is set when it is needed to select the port and + * apply new configuration for it. + */ AudioPortHandle id; - bitfield configMask; - uint32_t sampleRateHz; - bitfield channelMask; - AudioFormat format; - AudioGainConfig gain; - AudioPortType type; // type is used as a discriminator for Ext union - AudioPortRole role; // role is used as a discriminator for UseCase union - union Ext { - AudioPortConfigDeviceExt device; - struct AudioPortConfigMixExt { - AudioModuleHandle hwModule; // module the stream is attached to - AudioIoHandle ioHandle; // I/O handle of the input/output stream - union UseCase { - AudioStreamType stream; - AudioSource source; - } useCase; - } mix; - AudioPortConfigSessionExt session; - } ext; + /** + * Basic parameters: sampling rate, format, channel mask. Only some of the + * parameters (or none) may be set. See the documentation of the + * AudioBasicConfig struct. + */ + AudioBasicConfig config; + /** Associated gain control. */ + safe_union OptionalGain { + Monostate unspecified; + AudioGainConfig config; + } gain; + /** Parameters that depend on the actual port role. */ + AudioPortExtendedInfo ext; }; /** - * Extension for audio port structure when the audio port is a hardware device. + * Audio port structure describes the capabilities of an audio port + * as well as its current configuration. */ -struct AudioPortDeviceExt { - AudioModuleHandle hwModule; // module the device is attached to - AudioDevice type; - /** 32 byte string identifying the port. */ - uint8_t[32] address; -}; - -/** - * Latency class of the audio mix. - */ -@export(name="audio_mix_latency_class_t", value_prefix="AUDIO_LATENCY_") -enum AudioMixLatencyClass : int32_t { - LOW, - NORMAL -}; - -struct AudioPortMixExt { - AudioModuleHandle hwModule; // module the stream is attached to - AudioIoHandle ioHandle; // I/O handle of the stream - AudioMixLatencyClass latencyClass; -}; - -/** - * Extension for audio port structure when the audio port is an audio session. - */ -struct AudioPortSessionExt { - AudioSession session; -}; - struct AudioPort { + /** + * Unique identifier of the port within this HAL service. When calling + * from the client side functions like IDevice.getAudioPort is it allowed + * to only specify the 'id' and leave the other fields unspecified. + */ AudioPortHandle id; - AudioPortRole role; + /** + * Human-readable name describing the function of the port. + * E.g. "telephony_tx" or "fm_tuner". + */ string name; - vec sampleRates; - vec> channelMasks; - vec formats; + /** List of audio profiles supported by the port. */ + struct AudioProfile { + AudioFormat format; + /** List of the sample rates supported by the profile. */ + vec sampleRates; + /** List of channel masks supported by the profile. */ + vec channelMasks; + }; + vec profiles; + /** List of gain controls attached to the port. */ vec gains; - AudioPortConfig activeConfig; // current audio port configuration - AudioPortType type; // type is used as a discriminator - union Ext { - AudioPortDeviceExt device; - AudioPortMixExt mix; - AudioPortSessionExt session; - } ext; -}; - -struct ThreadInfo { - int64_t pid; - int64_t tid; + /** + * Current configuration of the audio port, may have all the fields left + * unspecified. + */ + AudioPortConfig activeConfig; }; diff --git a/audio/effect/7.0/IEffect.hal b/audio/effect/7.0/IEffect.hal index 5b176dc2f3..aa94f6ddcd 100644 --- a/audio/effect/7.0/IEffect.hal +++ b/audio/effect/7.0/IEffect.hal @@ -56,7 +56,6 @@ interface IEffect { * * @return retval operation completion status. */ - @callflow(next={"prepareForProcessing"}) enable() generates (Result retval); /** @@ -64,7 +63,6 @@ interface IEffect { * * @return retval operation completion status. */ - @callflow(next={"close"}) disable() generates (Result retval); /** @@ -78,7 +76,7 @@ interface IEffect { * @param device output device specification. * @return retval operation completion status. */ - setDevice(bitfield device) generates (Result retval); + setDevice(DeviceAddress device) generates (Result retval); /** * Set and get volume. Used by audio framework to delegate volume control to @@ -147,7 +145,7 @@ interface IEffect { * @param device input device specification. * @return retval operation completion status. */ - setInputDevice(bitfield device) generates (Result retval); + setInputDevice(DeviceAddress device) generates (Result retval); /** * Read audio parameters configurations for input and output buffers. @@ -251,7 +249,6 @@ interface IEffect { * the queue. * @return statusMQ a message queue used for passing status from the effect. */ - @callflow(next={"setProcessBuffers"}) prepareForProcessing() generates (Result retval, fmq_sync statusMQ); /** @@ -416,6 +413,5 @@ interface IEffect { * @return retval OK in case the success. * INVALID_STATE if the effect was already closed. */ - @exit close() generates (Result retval); }; diff --git a/audio/effect/7.0/IVirtualizerEffect.hal b/audio/effect/7.0/IVirtualizerEffect.hal index 0e6ff54403..141b4e6797 100644 --- a/audio/effect/7.0/IVirtualizerEffect.hal +++ b/audio/effect/7.0/IVirtualizerEffect.hal @@ -48,7 +48,7 @@ interface IVirtualizerEffect extends IEffect { struct SpeakerAngle { /** Speaker channel mask */ - bitfield mask; + vec mask; // all angles are expressed in degrees and // are relative to the listener. int16_t azimuth; // 0 is the direction the listener faces @@ -61,17 +61,17 @@ interface IVirtualizerEffect extends IEffect { * Retrieves virtual speaker angles for the given channel mask on the * specified device. */ - getVirtualSpeakerAngles(bitfield mask, AudioDevice device) + getVirtualSpeakerAngles(vec mask, DeviceAddress device) generates (Result retval, vec speakerAngles); /** * Forces the virtualizer effect for the given output device. */ - forceVirtualizationMode(AudioDevice device) generates (Result retval); + forceVirtualizationMode(DeviceAddress device) generates (Result retval); /** * Returns audio device reflecting the current virtualization mode, - * AUDIO_DEVICE_NONE when not virtualizing. + * Device type can be empty when not virtualizing. */ - getVirtualizationMode() generates (Result retval, AudioDevice device); + getVirtualizationMode() generates (Result retval, DeviceAddress device); }; diff --git a/audio/effect/7.0/types.hal b/audio/effect/7.0/types.hal index 7f5a38238f..fe4ee51584 100644 --- a/audio/effect/7.0/types.hal +++ b/audio/effect/7.0/types.hal @@ -257,7 +257,7 @@ enum EffectConfigParameters : int32_t { struct EffectBufferConfig { AudioBuffer buffer; uint32_t samplingRateHz; - bitfield channels; + AudioChannelMask channels; AudioFormat format; EffectBufferAccess accessMode; bitfield mask; @@ -276,8 +276,8 @@ enum EffectFeature : int32_t { }; struct EffectAuxChannelsConfig { - bitfield mainChannels; // channel mask for main channels - bitfield auxChannels; // channel mask for auxiliary channels + vec mainChannels; // channel mask for main channels + vec auxChannels; // channel mask for auxiliary channels }; struct EffectOffloadParameter {