Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 899badd4 authored by Trevor Knight's avatar Trevor Knight Committed by Automerger Merge Worker
Browse files

Merge "Add converstions for AIDL<->native for new speaker layout field" into...

Merge "Add converstions for AIDL<->native for new speaker layout field" into main am: 58173759 am: 3d44e75e

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/3317216



Change-Id: Ib77759d2427c85296c5243a03568390f81127410
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 97e57dde 3d44e75e
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -2352,6 +2352,15 @@ aidl2legacy_AudioPortDeviceExt_audio_port_config_device_ext(const AudioPortDevic
    audio_port_config_device_ext legacy{};
    RETURN_IF_ERROR(aidl2legacy_AudioDevice_audio_device(
                    aidl.device, &legacy.type, legacy.address));
    const bool isInput = false;  // speaker_layout_channel_mask only represents output.
    if (aidl.speakerLayout.has_value()) {
        legacy.speaker_layout_channel_mask =
                VALUE_OR_RETURN(aidl2legacy_AudioChannelLayout_audio_channel_mask_t(
                        aidl.speakerLayout.value(), isInput));
    } else {
        // Default to none when the field is null in the AIDL.
        legacy.speaker_layout_channel_mask = AUDIO_CHANNEL_NONE;
    }
    return legacy;
}

@@ -2360,6 +2369,14 @@ ConversionResult<AudioPortDeviceExt> legacy2aidl_audio_port_config_device_ext_Au
    AudioPortDeviceExt aidl;
    aidl.device = VALUE_OR_RETURN(
            legacy2aidl_audio_device_AudioDevice(legacy.type, legacy.address));
    const bool isInput = false;  // speaker_layout_channel_mask only represents output.
    // The AIDL speakerLayout is nullable and if set, can only be a layoutMask.
    if (audio_channel_mask_is_valid(legacy.speaker_layout_channel_mask) &&
        audio_channel_mask_get_representation(legacy.speaker_layout_channel_mask) ==
                AUDIO_CHANNEL_REPRESENTATION_POSITION) {
        aidl.speakerLayout = VALUE_OR_RETURN(legacy2aidl_audio_channel_mask_t_AudioChannelLayout(
                legacy.speaker_layout_channel_mask, isInput));
    }
    return aidl;
}

+19 −0
Original line number Diff line number Diff line
@@ -689,6 +689,25 @@ INSTANTIATE_TEST_SUITE_P(AudioEncapsulationMetadataType,
                                         AudioEncapsulationMetadataType::FRAMEWORK_TUNER,
                                         AudioEncapsulationMetadataType::DVB_AD_DESCRIPTOR));

TEST(AudioPortDeviceExt_speakerLayoutRoundTripTest, Aidl2Legacy2Aidl_layoutMask) {
    AudioPortDeviceExt initial{};
    initial.speakerLayout = make_ACL_Stereo();
    auto conv = aidl2legacy_AudioPortDeviceExt_audio_port_config_device_ext(initial);
    ASSERT_TRUE(conv.ok());
    auto convBack = legacy2aidl_audio_port_config_device_ext_AudioPortDeviceExt(conv.value());
    ASSERT_TRUE(convBack.ok());
    EXPECT_EQ(initial, convBack.value());
}

TEST(AudioPortDeviceExt_speakerLayoutRoundTripTest, Aidl2Legacy2Aidl_null) {
    const AudioPortDeviceExt initial{};  // speakerLayout is null
    auto conv = aidl2legacy_AudioPortDeviceExt_audio_port_config_device_ext(initial);
    ASSERT_TRUE(conv.ok());
    auto convBack = legacy2aidl_audio_port_config_device_ext_AudioPortDeviceExt(conv.value());
    ASSERT_TRUE(convBack.ok());
    EXPECT_EQ(initial, convBack.value());
}

class AudioGainModeRoundTripTest : public testing::TestWithParam<AudioGainMode> {};
TEST_P(AudioGainModeRoundTripTest, Aidl2Legacy2Aidl) {
    const auto initial = GetParam();