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

Commit dbbe9864 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "A2dpService: do not mute music during BT A2DP device switch" into rvc-dev

parents cf9e5b52 51881672
Loading
Loading
Loading
Loading
+0 −11
Original line number Original line Diff line number Diff line
@@ -551,14 +551,7 @@ public class A2dpService extends ProfileService {
            updateAndBroadcastActiveDevice(device);
            updateAndBroadcastActiveDevice(device);
            // Make sure the Audio Manager knows the previous Active device is disconnected,
            // Make sure the Audio Manager knows the previous Active device is disconnected,
            // and the new Active device is connected.
            // and the new Active device is connected.
            // Also, mute and unmute the output during the switch to avoid audio glitches.
            boolean wasMuted = false;
            if (previousActiveDevice != null) {
            if (previousActiveDevice != null) {
                if (!mAudioManager.isStreamMute(AudioManager.STREAM_MUSIC)) {
                    mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
                            AudioManager.ADJUST_MUTE, AudioManager.FLAG_BLUETOOTH_ABS_VOLUME);
                    wasMuted = true;
                }
                mAudioManager.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(
                mAudioManager.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(
                        previousActiveDevice, BluetoothProfile.STATE_DISCONNECTED,
                        previousActiveDevice, BluetoothProfile.STATE_DISCONNECTED,
                        BluetoothProfile.A2DP, true, -1);
                        BluetoothProfile.A2DP, true, -1);
@@ -594,10 +587,6 @@ public class A2dpService extends ProfileService {
            // change, so the Audio Service can reset accordingly the audio
            // change, so the Audio Service can reset accordingly the audio
            // feeding parameters in the Audio HAL to the Bluetooth stack.
            // feeding parameters in the Audio HAL to the Bluetooth stack.
            mAudioManager.handleBluetoothA2dpDeviceConfigChange(newActiveDevice);
            mAudioManager.handleBluetoothA2dpDeviceConfigChange(newActiveDevice);
            if (wasMuted) {
                mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
                        AudioManager.ADJUST_UNMUTE, AudioManager.FLAG_BLUETOOTH_ABS_VOLUME);
            }
        }
        }
        return true;
        return true;
    }
    }