audio: Implement proper parsing of masks in XsdcConversion
Since the parsed XML uses compliant separator for lists in attribute values, there is no need to use legacy 'maskFromString' function. Bug: 305281224 Test: atest VtsHalAudioCoreTargetTest Change-Id: Ib257fd010b923ac651931e5976f9b1363d693f1b
This commit is contained in:
parent
394e2527b5
commit
cc21b6f2e6
1 changed files with 13 additions and 9 deletions
|
@ -141,11 +141,12 @@ ConversionResult<AudioPortExt> createAudioPortExt(const ap_xsd::MixPorts::MixPor
|
|||
}
|
||||
|
||||
ConversionResult<int> convertGainModeToAidl(const std::vector<ap_xsd::AudioGainMode>& gainModeVec) {
|
||||
static const char gainModeSeparator = ' ';
|
||||
int gainModeMask = 0;
|
||||
for (const ap_xsd::AudioGainMode& gainMode : gainModeVec) {
|
||||
gainModeMask |= static_cast<int>(::android::GainModeConverter::maskFromString(
|
||||
ap_xsd::toString(gainMode), &gainModeSeparator));
|
||||
audio_gain_mode_t legacyGainMode;
|
||||
if (::android::GainModeConverter::fromString(ap_xsd::toString(gainMode), legacyGainMode)) {
|
||||
gainModeMask |= static_cast<int>(legacyGainMode);
|
||||
}
|
||||
}
|
||||
return gainModeMask;
|
||||
}
|
||||
|
@ -204,22 +205,25 @@ ConversionResult<AudioProfile> convertAudioProfileToAidl(const ap_xsd::Profile&
|
|||
ConversionResult<AudioIoFlags> convertIoFlagsToAidl(
|
||||
const std::vector<ap_xsd::AudioInOutFlag>& flags, const ap_xsd::Role role,
|
||||
bool flagsForMixPort) {
|
||||
static const char flagSeparator = ' ';
|
||||
int flagMask = 0;
|
||||
if ((role == ap_xsd::Role::sink && flagsForMixPort) ||
|
||||
(role == ap_xsd::Role::source && !flagsForMixPort)) {
|
||||
for (const ap_xsd::AudioInOutFlag& flag : flags) {
|
||||
flagMask |= static_cast<int>(::android::InputFlagConverter::maskFromString(
|
||||
ap_xsd::toString(flag), &flagSeparator));
|
||||
audio_input_flags_t legacyFlag;
|
||||
if (::android::InputFlagConverter::fromString(ap_xsd::toString(flag), legacyFlag)) {
|
||||
flagMask |= static_cast<int>(legacyFlag);
|
||||
}
|
||||
}
|
||||
return AudioIoFlags::make<AudioIoFlags::Tag::input>(flagMask);
|
||||
} else {
|
||||
for (const ap_xsd::AudioInOutFlag& flag : flags) {
|
||||
flagMask |= static_cast<int>(::android::OutputFlagConverter::maskFromString(
|
||||
ap_xsd::toString(flag), &flagSeparator));
|
||||
audio_output_flags_t legacyFlag;
|
||||
if (::android::OutputFlagConverter::fromString(ap_xsd::toString(flag), legacyFlag)) {
|
||||
flagMask |= static_cast<int>(legacyFlag);
|
||||
}
|
||||
}
|
||||
return AudioIoFlags::make<AudioIoFlags::Tag::output>(flagMask);
|
||||
}
|
||||
return AudioIoFlags::make<AudioIoFlags::Tag::output>(flagMask);
|
||||
}
|
||||
|
||||
ConversionResult<AudioPort> convertDevicePortToAidl(
|
||||
|
|
Loading…
Reference in a new issue