diff --git a/audio/7.0/IDevice.hal b/audio/7.0/IDevice.hal index eecd92ed7c..e30e5456bc 100644 --- a/audio/7.0/IDevice.hal +++ b/audio/7.0/IDevice.hal @@ -117,7 +117,7 @@ interface IDevice { AudioIoHandle ioHandle, DeviceAddress device, AudioConfig config, - bitfield flags, + vec flags, SourceMetadata sourceMetadata) generates ( Result retval, IStreamOut outStream, @@ -142,7 +142,7 @@ interface IDevice { AudioIoHandle ioHandle, DeviceAddress device, AudioConfig config, - bitfield flags, + vec flags, SinkMetadata sinkMetadata) generates ( Result retval, IStreamIn inStream, diff --git a/audio/7.0/IStream.hal b/audio/7.0/IStream.hal index 789cb1dfd1..4fe8218b28 100644 --- a/audio/7.0/IStream.hal +++ b/audio/7.0/IStream.hal @@ -44,49 +44,23 @@ interface IStream { getBufferSize() generates (uint64_t bufferSize); /** - * 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 - * played by the hardware (typically without sample-rate conversions). + * Return supported audio profiles for this particular stream. This method + * is normally called for streams opened on devices that use dynamic + * profiles, e.g. HDMI and USB interfaces. Please note that supported + * profiles of the stream may differ from the capabilities of the connected + * physical device. * - * This function is only called for dynamic profile. If called for - * non-dynamic profile is should return NOT_SUPPORTED or the same list - * as in audio_policy_configuration.xml. - * - * Calling this method is equivalent to getting - * AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES on the legacy HAL. - * - * - * @param format audio format for which the sample rates are supported. - * @return retval operation completion status. - * Must be OK if the format is supported. - * @return sampleRateHz supported sample rates. - */ - getSupportedSampleRates(AudioFormat format) - generates (Result retval, vec sampleRates); - - /** - * Return supported channel masks of the stream. Calling this method is - * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_CHANNELS on the legacy - * HAL. - * - * @param format audio format for which the channel masks are supported. - * @return retval operation completion status. - * Must be OK if the format is supported. - * @return masks supported audio masks. - */ - getSupportedChannelMasks(AudioFormat format) - generates (Result retval, vec> masks); - - /** - * Return supported audio formats of the stream. Calling this method is - * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_FORMATS on the legacy - * HAL. + * For devices with fixed configurations, e.g. built-in audio devices, all + * the profiles are specified in the audio_policy_configuration.xml + * file. For such devices, this method must return the configuration from + * the config file, or NOT_SUPPORTED retval. * * @return retval operation completion status. - * @return formats supported audio formats. + * @return formats supported audio profiles. * Must be non empty if retval is OK. */ - getSupportedFormats() generates (Result retval, vec formats); + getSupportedProfiles() + generates (Result retval, vec profiles); /** * Retrieves basic stream configuration: sample rate, audio format, @@ -94,18 +68,18 @@ interface IStream { * * @return config basic stream configuration. */ - getAudioProperties() generates (AudioBasicConfig config); + getAudioProperties() generates (AudioConfigBase config); /** * Sets stream parameters. Only sets parameters that are specified. - * See the description of AudioBasicConfig for the details. + * See the description of AudioConfigBase for the details. * * Optional method. If implemented, only called on a stopped stream. * * @param config basic stream configuration. * @return retval operation completion status. */ - setAudioProperties(AudioBasicConfig config) generates (Result retval); + setAudioProperties(AudioConfigBase config) generates (Result retval); /** * Applies audio effect to the stream. diff --git a/audio/7.0/config/api/current.txt b/audio/7.0/config/api/current.txt index fd9a8ef200..ac8dc8ae0c 100644 --- a/audio/7.0/config/api/current.txt +++ b/audio/7.0/config/api/current.txt @@ -228,6 +228,33 @@ package audio.policy.configuration.V7_0 { enum_constant public static final audio.policy.configuration.V7_0.AudioFormat AUDIO_FORMAT_WMA_PRO; } + public enum AudioInOutFlag { + method public String getRawName(); + enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_INPUT_FLAG_DIRECT; + enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_INPUT_FLAG_FAST; + 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_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; + enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD; + enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_DEEP_BUFFER; + enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_DIRECT; + enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_DIRECT_PCM; + enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_FAST; + enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_HW_AV_SYNC; + 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_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; + enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_SYNC; + enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_TTS; + enum_constant public static final audio.policy.configuration.V7_0.AudioInOutFlag AUDIO_OUTPUT_FLAG_VOIP_RX; + } + public class AudioPolicyConfiguration { ctor public AudioPolicyConfiguration(); method public audio.policy.configuration.V7_0.GlobalConfiguration getGlobalConfiguration(); @@ -396,7 +423,7 @@ package audio.policy.configuration.V7_0 { public static class MixPorts.MixPort { ctor public MixPorts.MixPort(); - method public String getFlags(); + method public java.util.List getFlags(); method public audio.policy.configuration.V7_0.Gains getGains(); method public long getMaxActiveCount(); method public long getMaxOpenCount(); @@ -404,7 +431,7 @@ package audio.policy.configuration.V7_0 { method public java.util.List getPreferredUsage(); method public java.util.List getProfile(); method public audio.policy.configuration.V7_0.Role getRole(); - method public void setFlags(String); + method public void setFlags(java.util.List); method public void setGains(audio.policy.configuration.V7_0.Gains); method public void setMaxActiveCount(long); method public void setMaxOpenCount(long); diff --git a/audio/7.0/config/audio_policy_configuration.xsd b/audio/7.0/config/audio_policy_configuration.xsd index 4555a88034..20fe02002e 100644 --- a/audio/7.0/config/audio_policy_configuration.xsd +++ b/audio/7.0/config/audio_policy_configuration.xsd @@ -155,16 +155,41 @@ - + - "|" separated list of audio_output_flags_t or audio_input_flags_t. + The flags indicate suggested stream attributes supported by the profile. - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/audio/7.0/config/update_audio_policy_config.sh b/audio/7.0/config/update_audio_policy_config.sh index 8714b5f2d3..051a0df916 100755 --- a/audio/7.0/config/update_audio_policy_config.sh +++ b/audio/7.0/config/update_audio_policy_config.sh @@ -128,6 +128,7 @@ updateFile() { for F in $SOURCE_FILES; do updateFile ${F} "channelMasks" "," updateFile ${F} "samplingRates" "," + updateFile ${F} "flags" "|" done; updateIncludes() { diff --git a/audio/7.0/types.hal b/audio/7.0/types.hal index 15ca4921b0..4a9e28915a 100644 --- a/audio/7.0/types.hal +++ b/audio/7.0/types.hal @@ -357,56 +357,15 @@ struct PlaybackRate { }; /** - * The audio output flags serve two purposes: + * The audio flags serve two purposes: * - * - when an output stream is created they indicate its attributes; + * - when a stream is created they indicate its attributes; * - * - when present in an output profile descriptor listed for a particular audio - * hardware module, they indicate that an output stream can be opened that + * - when present in a profile descriptor listed for a particular audio + * hardware module, they indicate that a stream can be opened that * supports the attributes indicated by the flags. + * + * See 'audioIoFlag' 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, -}; - -/** - * The audio input flags are analogous to audio output flags. - */ -@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 -}; +typedef string AudioInOutFlag; diff --git a/audio/common/7.0/types.hal b/audio/common/7.0/types.hal index 94d0af7673..31c7388329 100644 --- a/audio/common/7.0/types.hal +++ b/audio/common/7.0/types.hal @@ -112,12 +112,28 @@ typedef string AudioFormat; typedef string AudioChannelMask; /** - * Basic configuration applicable to any stream of audio. + * Base configuration attributes applicable to any stream of audio. */ -struct AudioBasicConfig { +struct AudioConfigBase { + AudioFormat format; // 'DEFAULT' means 'unspecified' uint32_t sampleRateHz; // 0 means 'unspecified' vec channelMask; // empty means 'unspecified' - AudioFormat format; // 'DEFAULT' means 'unspecified' +}; + +/** + * Configurations supported for a certain audio format. + */ +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; }; /** @@ -136,18 +152,21 @@ enum AudioMode : int32_t { CALL_SCREEN = 4, }; +/** + * 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. + */ +typedef string AudioDevice; + /** * Specifies a device address in case when several devices of the same type * can be connected (e.g. BT A2DP, USB). */ struct DeviceAddress { - /** - * 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; + /** The type of the device. */ + AudioDevice deviceType; safe_union Address { /** * The address may be left unspecified if 'device' specifies @@ -209,7 +228,7 @@ enum AudioEncapsulationMode : int32_t { * Additional information about the stream passed to hardware decoders. */ struct AudioOffloadInfo { - AudioBasicConfig base; + AudioConfigBase base; AudioStreamType streamType; uint32_t bitRatePerSecond; int64_t durationMicroseconds; // -1 if unknown @@ -227,7 +246,7 @@ struct AudioOffloadInfo { * Commonly used audio stream configuration parameters. */ struct AudioConfig { - AudioBasicConfig base; + AudioConfigBase base; AudioOffloadInfo offloadInfo; uint64_t frameCount; }; @@ -372,9 +391,9 @@ struct AudioPortConfig { /** * Basic parameters: sampling rate, format, channel mask. Only some of the * parameters (or none) may be set. See the documentation of the - * AudioBasicConfig struct. + * AudioConfigBase struct. */ - AudioBasicConfig config; + AudioConfigBase config; /** Associated gain control. */ safe_union OptionalGain { Monostate unspecified; @@ -401,13 +420,6 @@ struct AudioPort { */ string name; /** 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; diff --git a/audio/common/all-versions/default/VersionUtils.h b/audio/common/all-versions/default/VersionUtils.h index e7755b1a7a..9bfca0cdcc 100644 --- a/audio/common/all-versions/default/VersionUtils.h +++ b/audio/common/all-versions/default/VersionUtils.h @@ -31,7 +31,7 @@ typedef common::CPP_VERSION::AudioDevice AudioDeviceBitfield; typedef common::CPP_VERSION::AudioChannelMask AudioChannelBitfield; typedef common::CPP_VERSION::AudioOutputFlag AudioOutputFlagBitfield; typedef common::CPP_VERSION::AudioInputFlag AudioInputFlagBitfield; -#elif MAJOR_VERSION >= 4 +#elif MAJOR_VERSION >= 4 && MAJOR_VERSION <= 6 typedef hidl_bitfield AudioDeviceBitfield; typedef hidl_bitfield AudioChannelBitfield; typedef hidl_bitfield AudioOutputFlagBitfield; diff --git a/audio/core/all-versions/default/include/core/default/Device.h b/audio/core/all-versions/default/include/core/default/Device.h index b0e72d9600..907acd7d7d 100644 --- a/audio/core/all-versions/default/include/core/default/Device.h +++ b/audio/core/all-versions/default/include/core/default/Device.h @@ -43,8 +43,10 @@ using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; +#if MAJOR_VERSION <= 6 using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioInputFlagBitfield; using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioOutputFlagBitfield; +#endif using namespace ::android::hardware::audio::common::CPP_VERSION; using namespace ::android::hardware::audio::CPP_VERSION;