Starting with Android 14, partners and SoC vendors are encouraged to replace the current HIDL HAL implementation with an AIDL HAL implementation.
To facilitate a smooth transition from HIDL Audio HAL to an AIDL Audio HAL, some of the key differences are highlighted on this page. This page also shows the mapping between the AIDL and HIDL interfaces for the Audio HAL.
Difference between AIDL and HIDL Audio HAL implementation
The main differences between the HIDL structure and the AIDL structure are as follows:
- In AIDL Audio Core HAL, the - IConfiginterface is introduced as a replacement for the system-wide parameters in XML files in HIDL HAL. The framework reads these parameters from the Core HAL instead of the vendor configuration file. As an example, the list of surround formats that are surfaced for user control is provided by the- IConfig.getSurroundSoundConfigmethod in the Core HAL.- In AIDL Audio Effects HAL, the - effectProxylogic defined in XML files in HIDL Effects HAL is moved to the audio framework. The audio framework queries all effect instances in the system using- IFactory.queryEffects, and all effect processings using- IFactory.queryProcessing.
- To avoid confusion with use of the term device for audio device types, - IDevicein HIDL Audio HAL is renamed to- IModulein the AIDL Audio HAL.
- The AIDL Audio HAL replaces - IPrimaryDevice. The framework sends updates about the current audio mode and screen rotation to every- IModuleinstance. A dedicated- IBluetoothinterface handles parameters related to Bluetooth synchronous connection oriented (BT SCO) and Hands-Free Profile (HFP). A dedicated- ITelephonyinterface provides telephony-specific controls. You can retrieve instances of both of these interfaces from the primary instance of the- IModuleinterface. See the comparison tables on Core HAL and Feature-related functionality for more information.
- IDevicesFactoryis removed in AIDL Audio HAL to avoid redundancy. HAL modules (that is,- IModuleinterface instances) are now registered directly with the Service Manager using the names of the module instances, such as- bluetoothor- r_submix. The only exception is the- primarymodule which registers under the instance name- default.
AIDL and HIDL Audio HAL mapping
The tables in the following sections show the mapping between the HIDL and AIDL Audio HAL interfaces. See Audio HAL for more information on the directory structure.
Core HAL
All HIDL interfaces are within the android.hardware.audio@N.M package, where
N.M denotes the Major.Minor version. All AIDL interfaces are within
the android.hardware.audio.core package.
| HIDL API interfaces and configuration files | AIDL API interfaces | 
|---|---|
| IDevicesFactory | Registration of IModulewithServiceManager. | 
| IDevice | IModule | 
| IPrimaryDevice | ITelephonyIBluetooth | 
| IStreamIStreamInIStreamOut | StreamDescriptorIStreamInIStreamCommonIStreamOut | 
| audio_policy_configuration.xmlaudio_policy_engine_configuration.xml | IConfigIModule | 
| Configurable Audio Policy files | Use the HIDL implementation for Android 14. | 
Audio ports, dynamic profiles, routes and patches
In this table, elements of XML files are designated using angle brackets.
| HIDL API interface methods and configuration files elements | AIDL API interface methods | 
|---|---|
| <attachedDevices><defaultOutputDevice><mixPorts><devicePorts> | IModule.getAudioPorts | 
| IDevice.getAudioPortIDevice.setConnectedState | IModule.connectExternalDeviceIModule.disconnectExternalDevice | 
| IStream.getSupportedProfiles | IModule.connectExternalDevice | 
| < routes> | IModule.getAudioRoutes | 
| IDevice.createAudioPatchIDevice.updateAudioPatchIDevice.releaseAudioPatchIStream.getDevicesIStream.setDevicesSpecification of the device in IDevice.openInputStreamIDevice.openOutputStream | IModule.setAudioPatchIModule.setAudioPortConfigIModule.resetAudioPatch | 
Audio port configurations and streams
| HIDL API interface methods | AIDL API interface methods | 
|---|---|
| IStream.getAudioPropertiesIStream.setAudioPropertiesIStreamIn.getAudioSource | IModule.getAudioPortConfigsIModule.setAudioPortConfig | 
| IDevice.openInputStreamIDevice.openOutputStreamIStreamIn.prepareForReadingIStreamOut.prepareForWritingIStream.createMmapBuffer | IModule.openInputStreamIModule.openOutputStream | 
| IStream.close | IStreamCommon.close | 
| IStreamIn.updateSinkMetadataIStreamOut.updateSourceMetadata | IStreamIn.updateMetadataIStreamOut.updateMetadata | 
| IStream.standby | StreamDescriptor.Command.standby | 
| IStream.pauseIStream.resume | StreamDescriptor.Command.pause.start | 
| IStream.startIStream.stop(MMAP Streams) | StreamDescriptor.Command.startor.burst.pause(input) and/or.flush(output) | 
| IStreamOut.drainIStreamOut.flush | StreamDescriptor.Command.drain.flush | 
| IStreamOut.setCallbackIStreamOut.clearCallback | IModule.openOutputStreamIStreamCommon.close | 
| IStreamOut.getPresentationPositionandIStreamIn.getCapturePositionIStreamOut.getLatencyIStream.getMmapPositionIStreamIn.getInputFramesLost | StreamDescriptor.Reply.observableStreamDescriptor.Reply.latencyMsStreamDescriptor.Reply.hardwareStreamDescriptor.Reply.xrunFrames | 
| IDevice.getInputBufferSizeIStreamOut.getLatencyIStream.getBufferSizeIStream.getFrameSizeIStream.getFrameCount | IModule.setAudioPatch, nominal latency, and minimal buffer
      size are part of theAudioPatchstructure returned by the HAL.
      Actual buffer size in frames is part of theStreamDescriptorstructure, together with frame size in bytes. Buffer size in bytes can be
      calculated by multiplying these two numbers. | 
Audio Effects connection
| HIDL API interface methods | AIDL API interface methods | 
|---|---|
| IDevice.addDeviceEffectIDevice.removeDeviceEffect | IModule.addDeviceEffectIModule.removeDeviceEffect | 
| IStream.addEffectIStream.removeEffect | IStreamCommon.addEffectIStreamCommon.removeEffect | 
System-wide configuration
System-wide configuration that was previously defined in audio policy XML
configuration files (namely, audio_policy_configuration.xml and
audio_policy_engine_configuration.xml) must be provided through IConfig.
However, to ease the transition to AIDL, vendors still have the option of using
the same XML files they previously used to set system-wide configuration. The
reference implementation for IConfig contains the code necessary for
representing information from the XML file using AIDL data types, which
facilitates conversion from XML to AIDL.
| HIDL configuration file elements | AIDL API interface methods | 
|---|---|
| <globalConfiguration><speaker_drc_enabled><call_screen_mode_supported><engine_library> | Separated into two different methods: ITelephony.getSupportedAudioModesIConfig.getEngineConfig | 
| <volumes>, OR<volumeGroups>,<ProductStrategies> | IConfig.getEngineConfig | 
| <surroundSound> | IConfig.getSurroundSoundConfig | 
- 
  speaker_drc_enabledis removed from the configuration file as this configuration item isn't used within the system. All devices must have DRC enabled.
Feature-related functionality
| HIDL API interface methods | AIDL API interface | 
|---|---|
| IDevice.setMasterVolumeIDevice.getMasterVolumeIDevice.setMicMuteIDevice.getMicMuteIDevice.setMasterMuteIDevice.getMasterMute | IModule.\* | 
| IPrimaryDevice.getTtyModeIPrimaryDevice.setTtyModeIPrimaryDevice.getHacEnabledIPrimaryDevice.setHacEnabledIPrimaryDevice.setVoiceVolume | ITelephony.TelecomConfig.\* | 
| IPrimaryDevice.setBtScoHeadsetDebugNameIPrimaryDevice.getBtScoNrecEnabledIPrimaryDevice.setBtScoNrecEnabledIPrimaryDevice.getBtScoWidebandEnabledIPrimaryDevice.setBtScoWidebandEnabled,IPrimaryDevice.getBtHfpEnabledIPrimaryDevice.setBtHfpEnabledIPrimaryDevice.setBtHfpSampleRateIPrimaryDevice.setBtHfpVolume | IBluetooth.ScoConfig.\*IBluetooth.HfpConfig.\* | 
| IPrimaryDevice.setModeIPrimaryDevice.updateRotation | ITelephony.switchAudioModeIModule.updateAudioModeIModule.updateScreenRotation | 
| IDevice.setScreenStateIDevice.getMicrophones | IModule.updateScreenStateIModule.getMicrophones | 
| IDevice.getHwAvSyncIStream.setHwAvSync | IModule.generateHwAvSyncIdIStreamCommon.updateHwAvSyncId | 
| IStreamIn.setGainIStreamIn.setMicrophoneDirectionIStreamIn.setMicrophoneFieldDimension | IStreamIn.setHwGainIStreamIn.setMicrophoneDirectionIStreamIn.setMicrophoneFieldDimension | 
| IStreamOut.getDualMonoModeIStreamOut.setDualMonoModeIStreamOut.getPlaybackRateParametersIStreamOut.setPlaybackRateParametersIStreamOut.selectPresentationIStreamOut.getAudioDescriptionMixLevelIStreamOut.setAudioDescriptionMixLevelIStreamOut.setLatencyModeIStreamOut.getRecommendedLatencyModes | IStreamOut.\* | 
| IStreamOut.setEventCallbackIStreamOut.setLatencyModeCallback | IModule.openOutputStream(callbacks are combined intoIStreamOutEventCallback) | 
| IDevice.get/setParametersIStream.get/setParameters | IModule.get/setVendorParametersIStreamCommon.get/setVendorParameters | 
Obsolete methods
| HIDL API interface methods | Comments | 
|---|---|
| IDevice.initCheckIDevice.close | The HAL module publishes itself with the ServiceManageronly on
    successful initialization. At that point, it is considered to be permanent
    and can't be closed. | 
| IDevice.supportsAudioPatchesIStreamOut.supportsPauseAndResumeIStreamOut.supportsDrain | Support for patches, pause, resume and drain is mandatory. | 
| IStreamOut.getRenderPositionIStreamOut.getNextWriteTimestamp | Obsolete. | 
Vendor extensions
In the HIDL API, vendor extensions are implemented using the getParameters or
setParameters methods from the IDevice and IStream interfaces. These
methods accept arbitrary strings.
In the AIDL API, there are corresponding methods, such as getVendorParameters
or setVendorParameters, which take arbitrary Parcelable instances by using
encapsulation within ParcelableHolders.
Other changes
Other general changes are as follows:
- To improve the testability of HAL APIs, in the AIDL version, we introduce debugging options that are used by VTS tests and are available through the - ModuleDebugparcelable. These options instruct the HAL to emulate certain functionality (for example, connection of external devices), which otherwise requires manual intervention and use of external testing equipment.
- When the framework or the VTS test sets the - sys.audio.restart.halsystem property to- 1, HAL services must restart. The- audioserver.rcfile handles the restart. While implementing the HAL, use the appropriate HAL service name listed in the- audioserver.rcfile. In Android 14, the name- vendor.audio-hal-aidlis added specifically for the AIDL version of the HAL.
Effects HAL
All HIDL interfaces are within the android.hardware.audio.effect@N.M*
package, where N.M is the Major.Minor version. All AIDL interfaces
are within the android.hardware.audio.effect package.
| HIDL API interfaces and configuration files | AIDL API interfaces | 
|---|---|
| IEffectsFactory | IFactory | 
| IEffect | IEffect | 
| audio_effects.xml | IEffect | 
Effect Factory
| HIDL API interfaces (android.hardware.audio.effect@X.X) | AIDL API interfaces (android.hardware.audio.effect) | 
|---|---|
| IEffectsFactory.getAllDescriptors | IFactory.queryEffectswith null UUID parameter | 
| IEffectsFactory.getDescriptor | IFactory.queryEffectswith UUID parameter | 
| IEffectsFactory.createEffect | IFactory.createEffect | 
| audio_effects.xml | IFactory.queryProcessingIFactory.queryEffects | 
Effect interfaces
| HIDL API interfaces (android.hardware.audio.effect@X.X) | AIDL API interfaces (android.hardware.audio.effect) | 
|---|---|
| IEffect.init | IEffect.open | 
| IEffect.setConfig | IEffect.setParameter | 
| IEffect.enable | IEffect.command(CommandId::START) | 
| IEffect.disable | IEffect.command(CommandId::STOP) | 
| IEffect.reset | IEffect.command(CommandId::RESET) | 
| IEffect.getDescriptor | IEffect.getDescriptor | 
| IEffect.command | Map to IEffect.command,IEffect.setParameter, orIEffect.getParameterbased on the type of legacy HIDL
       command | 
| N/A | IEffect.getState | 
| IEffect.setParameter | IEffect.setParameter | 
| IEffect.getParameter | IEffect.getParameter | 
Effect Commands
| HIDL API interfaces (android.hardware.audio.effect@X.X) | AIDL API interfaces (android.hardware.audio.effect) | 
|---|---|
| EFFECT_CMD_INIT | IEffect.open | 
| EFFECT_CMD_RESET | CommandId.RESET | 
| EFFECT_CMD_ENABLE | IEffect.command(CommandId::START) | 
| EFFECT_CMD_DISABLE | IEffect.command(CommandId::STOP) | 
| EFFECT_CMD_SET_PARAM_DEFERRED | Deprecated in Effects AIDL HAL | 
| EFFECT_CMD_SET_PARAM_COMMIT | Deprecated in Effects AIDL HAL | 
| EFFECT_CMD_SET_CONFIGEFFECT_CMD_SET_PARAMEFFECT_CMD_SET_DEVICEEFFECT_CMD_SET_VOLUMEEFFECT_CMD_SET_AUDIO_MODEEFFECT_CMD_SET_CONFIG_REVERSEEFFECT_CMD_SET_INPUT_DEVICEEFFECT_CMD_SET_FEATURE_CONFIGEFFECT_CMD_SET_AUDIO_SOURCE | IEffect.setParameter | 
| EFFECT_CMD_GET_PARAMEFFECT_CMD_GET_CONFIGEFFECT_CMD_GET_CONFIG_REVERSEEFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGSEFFECT_CMD_GET_FEATURE_CONFIGVISUALIZER_CMD_MEASUREEFFECT_CMD_FIRST_PROPRIETARY(same as VISUALIZER_CMD_CAPTURE) | IEffect.getParameter | 
| EFFECT_CMD_OFFLOAD | Deprecated. In AIDL, offload and non-offload mode switches are handled in the framework. | 
| EFFECT_CMD_DUMP | Handled by the built-in binder transaction AIBinder_dump. | 
Common Effect parameters definition
| HIDL definition (android.hardware.audio.effect@X.X) | AIDL definition | 
|---|---|
| Types.hal | Flags.aidlParameter.aidl | 
Specific Effects definition
| HIDL API interfaces (android.hardware.audio.effect@X.X) | AIDL API interfaces (android.hardware.audio.effect) | 
|---|---|
| I$EffectType$.hal | $EffectType$.aidl |