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

Commit 55e3304a authored by Rongxuan Liu's avatar Rongxuan Liu
Browse files

[le audio] Get Broadcast quality based on selected output codec config

Get Broadcast Audio Quality based on selected output codec config
instead of input codec config for connected sink devices.

Bug: 370236114
Flag: EXEMPT; trivial fix covered by unit tests
Test: atest LeAudioBroadcastServiceTest
Test: manual testing with specific remote devices
Change-Id: Ibb9578e89e04eabc698b4fed947464153daa7958
parent 9d0a929c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1239,7 +1239,7 @@ public class LeAudioService extends ProfileService {

            BluetoothLeAudioCodecStatus codecStatus = getCodecStatus(groupId);
            if (codecStatus != null
                    && !codecStatus.isInputCodecConfigSelectable(BROADCAST_HIGH_QUALITY_CONFIG)) {
                    && !codecStatus.isOutputCodecConfigSelectable(BROADCAST_HIGH_QUALITY_CONFIG)) {
                // If any sink device does not support high quality audio config,
                // set all subgroup audio quality to standard quality for now before multi codec
                // config support is ready
+46 −3
Original line number Diff line number Diff line
@@ -534,7 +534,7 @@ public class LeAudioBroadcastServiceTest {
    }

    @Test
    public void testCreateBroadcast_updateQualityToStandard() {
    public void testCreateBroadcast_noAudioQualityUpdate() {
        byte[] code = {0x00, 0x01, 0x00, 0x02};
        int groupId = 1;

@@ -551,9 +551,52 @@ public class LeAudioBroadcastServiceTest {
        BluetoothLeBroadcastSettings settings = buildBroadcastSettingsFromMetadata(meta, code, 1);

        when(mBassClientService.getConnectedDevices()).thenReturn(List.of(mDevice));
        // update selectable configs to be STANDARD quality
        // update input selectable configs to be STANDARD quality
        // keep output selectable configs as HIGH quality
        injectGroupSelectableCodecConfigChanged(
                groupId, INPUT_SELECTABLE_CONFIG_STANDARD, OUTPUT_SELECTABLE_CONFIG_STANDARD);
                groupId, INPUT_SELECTABLE_CONFIG_STANDARD, OUTPUT_SELECTABLE_CONFIG_HIGH);
        injectGroupCurrentCodecConfigChanged(groupId, LC3_16KHZ_CONFIG, LC3_48KHZ_CONFIG);

        mService.createBroadcast(settings);

        // Test data with only one subgroup
        // Verify quality is  not updated to standard because HIGH is selectable in output
        int[] expectedQualityArray = {BluetoothLeBroadcastSubgroupSettings.QUALITY_HIGH};
        byte[][] expectedDataArray = {
            settings.getSubgroupSettings().get(0).getContentMetadata().getRawMetadata()
        };

        verify(mLeAudioBroadcasterNativeInterface, times(1))
                .createBroadcast(
                        eq(true),
                        eq(TEST_BROADCAST_NAME),
                        eq(code),
                        eq(settings.getPublicBroadcastMetadata().getRawMetadata()),
                        eq(expectedQualityArray),
                        eq(expectedDataArray));
    }

    @Test
    public void testCreateBroadcast_updateAudioQualityToStandard() {
        byte[] code = {0x00, 0x01, 0x00, 0x02};
        int groupId = 1;

        initializeNative();
        prepareConnectedUnicastDevice(groupId, mDevice);

        synchronized (mService.mBroadcastCallbacks) {
            mService.mBroadcastCallbacks.register(mCallbacks);
        }

        BluetoothLeAudioContentMetadata.Builder meta_builder =
                new BluetoothLeAudioContentMetadata.Builder();
        BluetoothLeAudioContentMetadata meta = meta_builder.build();
        BluetoothLeBroadcastSettings settings = buildBroadcastSettingsFromMetadata(meta, code, 1);

        when(mBassClientService.getConnectedDevices()).thenReturn(List.of(mDevice));
        // update output selectable configs to be STANDARD quality
        injectGroupSelectableCodecConfigChanged(
                groupId, INPUT_SELECTABLE_CONFIG_HIGH, OUTPUT_SELECTABLE_CONFIG_STANDARD);
        injectGroupCurrentCodecConfigChanged(groupId, LC3_16KHZ_CONFIG, LC3_48KHZ_CONFIG);

        mService.createBroadcast(settings);