audio: HAL V7 tweaks

- rename AudioBasicConfig -> AudioConfigBase to better
  match a similar structure in audio.h;

- define AudioProfile structure for defining an I/O profile;

- use AudioProfile to replace IStream.getSupported* methods
  with a single IStream.getSupportedProfiles method;

- define AudioDevice type for convenience and clarity;

- move enums definition for AudioInputFlags and AudioOutputFlags
  into XSD. This allows parsing APM config w/o depending on
  the framework code.

Bug: 142480271
Test: m
Change-Id: I1951b2de383751fe53b96954dfd02cdd1ab6cc8f
This commit is contained in:
Mikhail Naganov
2020-09-24 18:00:44 +00:00
parent 69e6fc6e15
commit 648ec5b750
9 changed files with 119 additions and 119 deletions

View File

@@ -117,7 +117,7 @@ interface IDevice {
AudioIoHandle ioHandle,
DeviceAddress device,
AudioConfig config,
bitfield<AudioOutputFlag> flags,
vec<AudioInOutFlag> flags,
SourceMetadata sourceMetadata) generates (
Result retval,
IStreamOut outStream,
@@ -142,7 +142,7 @@ interface IDevice {
AudioIoHandle ioHandle,
DeviceAddress device,
AudioConfig config,
bitfield<AudioInputFlag> flags,
vec<AudioInOutFlag> flags,
SinkMetadata sinkMetadata) generates (
Result retval,
IStreamIn inStream,

View File

@@ -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<uint32_t> 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<vec<AudioChannelMask>> 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<AudioFormat> formats);
getSupportedProfiles()
generates (Result retval, vec<AudioProfile> 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.

View File

@@ -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<audio.policy.configuration.V7_0.AudioInOutFlag> 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<audio.policy.configuration.V7_0.AudioUsage> getPreferredUsage();
method public java.util.List<audio.policy.configuration.V7_0.Profile> getProfile();
method public audio.policy.configuration.V7_0.Role getRole();
method public void setFlags(String);
method public void setFlags(java.util.List<audio.policy.configuration.V7_0.AudioInOutFlag>);
method public void setGains(audio.policy.configuration.V7_0.Gains);
method public void setMaxActiveCount(long);
method public void setMaxOpenCount(long);

View File

@@ -155,16 +155,41 @@
<xs:element name="item" type="xs:token" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="audioInOutFlags">
<xs:simpleType name="audioInOutFlag">
<xs:annotation>
<xs:documentation xml:lang="en">
"|" separated list of audio_output_flags_t or audio_input_flags_t.
The flags indicate suggested stream attributes supported by the profile.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="|[_A-Z]+(\|[_A-Z]+)*"/>
<xs:enumeration value="AUDIO_OUTPUT_FLAG_DIRECT" />
<xs:enumeration value="AUDIO_OUTPUT_FLAG_PRIMARY" />
<xs:enumeration value="AUDIO_OUTPUT_FLAG_FAST" />
<xs:enumeration value="AUDIO_OUTPUT_FLAG_DEEP_BUFFER" />
<xs:enumeration value="AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD" />
<xs:enumeration value="AUDIO_OUTPUT_FLAG_NON_BLOCKING" />
<xs:enumeration value="AUDIO_OUTPUT_FLAG_HW_AV_SYNC" />
<xs:enumeration value="AUDIO_OUTPUT_FLAG_TTS" />
<xs:enumeration value="AUDIO_OUTPUT_FLAG_RAW" />
<xs:enumeration value="AUDIO_OUTPUT_FLAG_SYNC" />
<xs:enumeration value="AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO" />
<xs:enumeration value="AUDIO_OUTPUT_FLAG_DIRECT_PCM" />
<xs:enumeration value="AUDIO_OUTPUT_FLAG_MMAP_NOIRQ" />
<xs:enumeration value="AUDIO_OUTPUT_FLAG_VOIP_RX" />
<xs:enumeration value="AUDIO_OUTPUT_FLAG_INCALL_MUSIC" />
<xs:enumeration value="AUDIO_INPUT_FLAG_FAST" />
<xs:enumeration value="AUDIO_INPUT_FLAG_HW_HOTWORD" />
<xs:enumeration value="AUDIO_INPUT_FLAG_RAW" />
<xs:enumeration value="AUDIO_INPUT_FLAG_SYNC" />
<xs:enumeration value="AUDIO_INPUT_FLAG_MMAP_NOIRQ" />
<xs:enumeration value="AUDIO_INPUT_FLAG_VOIP_TX" />
<xs:enumeration value="AUDIO_INPUT_FLAG_HW_AV_SYNC" />
<xs:enumeration value="AUDIO_INPUT_FLAG_DIRECT" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="audioInOutFlags">
<xs:list itemType="audioInOutFlag" />
</xs:simpleType>
<xs:simpleType name="role">
<xs:restriction base="xs:string">
<xs:enumeration value="sink"/>

View File

@@ -128,6 +128,7 @@ updateFile() {
for F in $SOURCE_FILES; do
updateFile ${F} "channelMasks" ","
updateFile ${F} "samplingRates" ","
updateFile ${F} "flags" "|"
done;
updateIncludes() {

View File

@@ -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;

View File

@@ -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<AudioChannelMask> 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<uint32_t> 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<vec<AudioChannelMask>> 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<uint32_t> sampleRates;
/** List of channel masks supported by the profile. */
vec<AudioChannelMask> channelMasks;
};
vec<AudioProfile> profiles;
/** List of gain controls attached to the port. */
vec<AudioGain> gains;

View File

@@ -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<common::CPP_VERSION::AudioDevice> AudioDeviceBitfield;
typedef hidl_bitfield<common::CPP_VERSION::AudioChannelMask> AudioChannelBitfield;
typedef hidl_bitfield<common::CPP_VERSION::AudioOutputFlag> AudioOutputFlagBitfield;

View File

@@ -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;