Switch the framework AIDL to use AudioChannelLayout
'AudioChannelLayout' is a new type that will be used both by HAL
and framework interfaces. This CL changes the framework interfaces
to use it instead of 'AudioChannelMask' type which was used to
pass legacy 'audio_channel_mask_t' transparently via the AIDL
layer.
Remove the implementation of 'Parcelable' from AudioProfile and
AudioPortConfig in libaudiofoundation because the implementation
not used after converting audio fwk interfaces to AIDL, and
Parcelable's interface methods do not allow passing in any
context. In our case the context is the direction of the I/O
('isInput' flag) which is usually available externally, but absent
from the encapsulated data of these classes.
Update the audiofoundation_parcelable_test, switch to use of static
libs for the framework code so they can run on a device with
default system libraries.
Bug: 188932434
Test: check audio on device
Test: atest audiofoundation_parcelable_test
Change-Id: Ie59cdd64f001330ad4b5094264957198809a10a1
diff --git a/media/libaudioclient/IAudioFlinger.cpp b/media/libaudioclient/IAudioFlinger.cpp
index 5da56b8..5f12f71 100644
--- a/media/libaudioclient/IAudioFlinger.cpp
+++ b/media/libaudioclient/IAudioFlinger.cpp
@@ -55,7 +55,9 @@
ConversionResult<media::CreateTrackRequest> IAudioFlinger::CreateTrackInput::toAidl() const {
media::CreateTrackRequest aidl;
aidl.attr = VALUE_OR_RETURN(legacy2aidl_audio_attributes_t_AudioAttributesInternal(attr));
- aidl.config = VALUE_OR_RETURN(legacy2aidl_audio_config_t_AudioConfig(config));
+ // Do not be mislead by 'Input'--this is an input to 'createTrack', which creates output tracks.
+ aidl.config = VALUE_OR_RETURN(legacy2aidl_audio_config_t_AudioConfig(
+ config, false /*isInput*/));
aidl.clientInfo = VALUE_OR_RETURN(legacy2aidl_AudioClient_AudioClient(clientInfo));
aidl.sharedBuffer = VALUE_OR_RETURN(legacy2aidl_NullableIMemory_SharedFileRegion(sharedBuffer));
aidl.notificationsPerBuffer = VALUE_OR_RETURN(convertIntegral<int32_t>(notificationsPerBuffer));
@@ -74,7 +76,9 @@
IAudioFlinger::CreateTrackInput::fromAidl(const media::CreateTrackRequest& aidl) {
IAudioFlinger::CreateTrackInput legacy;
legacy.attr = VALUE_OR_RETURN(aidl2legacy_AudioAttributesInternal_audio_attributes_t(aidl.attr));
- legacy.config = VALUE_OR_RETURN(aidl2legacy_AudioConfig_audio_config_t(aidl.config));
+ // Do not be mislead by 'Input'--this is an input to 'createTrack', which creates output tracks.
+ legacy.config = VALUE_OR_RETURN(
+ aidl2legacy_AudioConfig_audio_config_t(aidl.config, false /*isInput*/));
legacy.clientInfo = VALUE_OR_RETURN(aidl2legacy_AudioClient_AudioClient(aidl.clientInfo));
legacy.sharedBuffer = VALUE_OR_RETURN(aidl2legacy_NullableSharedFileRegion_IMemory(aidl.sharedBuffer));
legacy.notificationsPerBuffer = VALUE_OR_RETURN(
@@ -139,7 +143,8 @@
IAudioFlinger::CreateRecordInput::toAidl() const {
media::CreateRecordRequest aidl;
aidl.attr = VALUE_OR_RETURN(legacy2aidl_audio_attributes_t_AudioAttributesInternal(attr));
- aidl.config = VALUE_OR_RETURN(legacy2aidl_audio_config_base_t_AudioConfigBase(config));
+ aidl.config = VALUE_OR_RETURN(
+ legacy2aidl_audio_config_base_t_AudioConfigBase(config, true /*isInput*/));
aidl.clientInfo = VALUE_OR_RETURN(legacy2aidl_AudioClient_AudioClient(clientInfo));
aidl.riid = VALUE_OR_RETURN(legacy2aidl_audio_unique_id_t_int32_t(riid));
aidl.maxSharedAudioHistoryMs = VALUE_OR_RETURN(
@@ -159,7 +164,8 @@
IAudioFlinger::CreateRecordInput legacy;
legacy.attr = VALUE_OR_RETURN(
aidl2legacy_AudioAttributesInternal_audio_attributes_t(aidl.attr));
- legacy.config = VALUE_OR_RETURN(aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.config));
+ legacy.config = VALUE_OR_RETURN(
+ aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.config, true /*isInput*/));
legacy.clientInfo = VALUE_OR_RETURN(aidl2legacy_AudioClient_AudioClient(aidl.clientInfo));
legacy.riid = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_unique_id_t(aidl.riid));
legacy.maxSharedAudioHistoryMs = VALUE_OR_RETURN(
@@ -412,8 +418,8 @@
int32_t sampleRateAidl = VALUE_OR_RETURN(convertIntegral<int32_t>(sampleRate));
media::AudioFormatDescription formatAidl = VALUE_OR_RETURN(
legacy2aidl_audio_format_t_AudioFormatDescription(format));
- media::AudioChannelMask channelMaskAidl = VALUE_OR_RETURN(
- legacy2aidl_audio_channel_mask_t_AudioChannelMask(channelMask));
+ media::AudioChannelLayout channelMaskAidl = VALUE_OR_RETURN(
+ legacy2aidl_audio_channel_mask_t_AudioChannelLayout(channelMask, true /*isInput*/));
int64_t aidlRet;
RETURN_IF_ERROR(statusTFromBinderStatus(
mDelegate->getInputBufferSize(sampleRateAidl, formatAidl, channelMaskAidl,
@@ -939,13 +945,13 @@
Status AudioFlingerServerAdapter::getInputBufferSize(int32_t sampleRate,
const media::AudioFormatDescription& format,
- media::AudioChannelMask channelMask,
+ const media::AudioChannelLayout& channelMask,
int64_t* _aidl_return) {
uint32_t sampleRateLegacy = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(sampleRate));
audio_format_t formatLegacy = VALUE_OR_RETURN_BINDER(
aidl2legacy_AudioFormatDescription_audio_format_t(format));
audio_channel_mask_t channelMaskLegacy = VALUE_OR_RETURN_BINDER(
- aidl2legacy_AudioChannelMask_audio_channel_mask_t(channelMask));
+ aidl2legacy_AudioChannelLayout_audio_channel_mask_t(channelMask, true /*isInput*/));
size_t size = mDelegate->getInputBufferSize(sampleRateLegacy, formatLegacy, channelMaskLegacy);
*_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int64_t>(size));
return Status::ok();