Loading services/core/java/com/android/server/audio/AudioDeviceBroker.java +3 −2 Original line number Diff line number Diff line Loading @@ -1772,6 +1772,7 @@ public class AudioDeviceBroker { @Override public void handleMessage(Message msg) { int muteCheckDelayMs = BTA2DP_MUTE_CHECK_DELAY_MS; switch (msg.what) { case MSG_RESTORE_DEVICES: synchronized (mSetModeLock) { Loading Loading @@ -1872,7 +1873,7 @@ public class AudioDeviceBroker { btInfo.mDevice, btInfo.mProfile, btInfo.mIsLeOutput, "MSG_L_BLUETOOTH_DEVICE_CONFIG_CHANGE"); synchronized (mDeviceStateLock) { mDeviceInventory.onBluetoothDeviceConfigChange(btInfo, muteCheckDelayMs += mDeviceInventory.onBluetoothDeviceConfigChange(btInfo, codecAndChanged.first, codecAndChanged.second, BtHelper.EVENT_DEVICE_CONFIG_CHANGE); } Loading Loading @@ -2062,7 +2063,7 @@ public class AudioDeviceBroker { // Give some time to Bluetooth service to post a connection message // in case of active device switch if (MESSAGES_MUTE_MUSIC.contains(msg.what)) { sendMsg(MSG_CHECK_MUTE_MUSIC, SENDMSG_REPLACE, BTA2DP_MUTE_CHECK_DELAY_MS); sendMsg(MSG_CHECK_MUTE_MUSIC, SENDMSG_REPLACE, muteCheckDelayMs); } if (isMessageHandledUnderWakelock(msg.what)) { Loading services/core/java/com/android/server/audio/AudioDeviceInventory.java +23 −5 Original line number Diff line number Diff line Loading @@ -860,9 +860,25 @@ public class AudioDeviceInventory { } } // Additional delay added to the music mute duration when a codec config change is executed. static final int BT_CONFIG_CHANGE_MUTE_DELAY_MS = 500; /** * Handles a Bluetooth link codec configuration change communicated by the Bluetooth stack. * Called when either A2DP or LE Audio codec encoding or sampling rate changes: * the change is communicated to native audio policy to eventually reconfigure the audio * path. * Also used to notify a change in preferred mode (duplex or output) for Bluetooth profiles. * * @param btInfo contains all information on the Bluetooth device and profile * @param codec the requested audio encoding (e.g SBC) * @param codecChanged true if a codec parameter changed, false for preferred mode change * @param event currently only EVENT_DEVICE_CONFIG_CHANGE * @return an optional additional delay in milliseconds to add to the music mute period in * case of an actual codec reconfiguration. */ @GuardedBy("mDeviceBroker.mDeviceStateLock") /*package*/ void onBluetoothDeviceConfigChange( /*package*/ int onBluetoothDeviceConfigChange( @NonNull AudioDeviceBroker.BtDeviceInfo btInfo, @AudioSystem.AudioFormatNativeEnumForBtCodec int codec, boolean codecChanged, int event) { Loading @@ -870,10 +886,11 @@ public class AudioDeviceInventory { + "onBluetoothDeviceConfigChange") .set(MediaMetrics.Property.EVENT, BtHelper.deviceEventToString(event)); int delayMs = 0; final BluetoothDevice btDevice = btInfo.mDevice; if (btDevice == null) { mmi.set(MediaMetrics.Property.EARLY_RETURN, "btDevice null").record(); return; return delayMs; } if (AudioService.DEBUG_DEVICES) { Log.d(TAG, "onBluetoothDeviceConfigChange btDevice=" + btDevice); Loading @@ -895,7 +912,7 @@ public class AudioDeviceInventory { .printSlog(EventLogger.Event.ALOGI, TAG)); mmi.set(MediaMetrics.Property.EARLY_RETURN, "A2dp config change ignored") .record(); return; return delayMs; } final String key = DeviceInfo.makeDeviceListKey( AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, address); Loading @@ -903,7 +920,7 @@ public class AudioDeviceInventory { if (di == null) { Log.e(TAG, "invalid null DeviceInfo in onBluetoothDeviceConfigChange"); mmi.set(MediaMetrics.Property.EARLY_RETURN, "null DeviceInfo").record(); return; return delayMs; } mmi.set(MediaMetrics.Property.ADDRESS, address) Loading @@ -911,7 +928,6 @@ public class AudioDeviceInventory { .set(MediaMetrics.Property.INDEX, volume) .set(MediaMetrics.Property.NAME, di.mDeviceName); if (event == BtHelper.EVENT_DEVICE_CONFIG_CHANGE) { if (btInfo.mProfile == BluetoothProfile.A2DP || btInfo.mProfile == BluetoothProfile.LE_AUDIO Loading Loading @@ -939,6 +955,7 @@ public class AudioDeviceInventory { + address + " codec=" + AudioSystem.audioFormatToString(codec)) .printSlog(EventLogger.Event.ALOGI, TAG)); delayMs = BT_CONFIG_CHANGE_MUTE_DELAY_MS; } } } Loading @@ -948,6 +965,7 @@ public class AudioDeviceInventory { } } mmi.record(); return delayMs; } /*package*/ void onMakeA2dpDeviceUnavailableNow(String address, int a2dpCodec) { Loading Loading
services/core/java/com/android/server/audio/AudioDeviceBroker.java +3 −2 Original line number Diff line number Diff line Loading @@ -1772,6 +1772,7 @@ public class AudioDeviceBroker { @Override public void handleMessage(Message msg) { int muteCheckDelayMs = BTA2DP_MUTE_CHECK_DELAY_MS; switch (msg.what) { case MSG_RESTORE_DEVICES: synchronized (mSetModeLock) { Loading Loading @@ -1872,7 +1873,7 @@ public class AudioDeviceBroker { btInfo.mDevice, btInfo.mProfile, btInfo.mIsLeOutput, "MSG_L_BLUETOOTH_DEVICE_CONFIG_CHANGE"); synchronized (mDeviceStateLock) { mDeviceInventory.onBluetoothDeviceConfigChange(btInfo, muteCheckDelayMs += mDeviceInventory.onBluetoothDeviceConfigChange(btInfo, codecAndChanged.first, codecAndChanged.second, BtHelper.EVENT_DEVICE_CONFIG_CHANGE); } Loading Loading @@ -2062,7 +2063,7 @@ public class AudioDeviceBroker { // Give some time to Bluetooth service to post a connection message // in case of active device switch if (MESSAGES_MUTE_MUSIC.contains(msg.what)) { sendMsg(MSG_CHECK_MUTE_MUSIC, SENDMSG_REPLACE, BTA2DP_MUTE_CHECK_DELAY_MS); sendMsg(MSG_CHECK_MUTE_MUSIC, SENDMSG_REPLACE, muteCheckDelayMs); } if (isMessageHandledUnderWakelock(msg.what)) { Loading
services/core/java/com/android/server/audio/AudioDeviceInventory.java +23 −5 Original line number Diff line number Diff line Loading @@ -860,9 +860,25 @@ public class AudioDeviceInventory { } } // Additional delay added to the music mute duration when a codec config change is executed. static final int BT_CONFIG_CHANGE_MUTE_DELAY_MS = 500; /** * Handles a Bluetooth link codec configuration change communicated by the Bluetooth stack. * Called when either A2DP or LE Audio codec encoding or sampling rate changes: * the change is communicated to native audio policy to eventually reconfigure the audio * path. * Also used to notify a change in preferred mode (duplex or output) for Bluetooth profiles. * * @param btInfo contains all information on the Bluetooth device and profile * @param codec the requested audio encoding (e.g SBC) * @param codecChanged true if a codec parameter changed, false for preferred mode change * @param event currently only EVENT_DEVICE_CONFIG_CHANGE * @return an optional additional delay in milliseconds to add to the music mute period in * case of an actual codec reconfiguration. */ @GuardedBy("mDeviceBroker.mDeviceStateLock") /*package*/ void onBluetoothDeviceConfigChange( /*package*/ int onBluetoothDeviceConfigChange( @NonNull AudioDeviceBroker.BtDeviceInfo btInfo, @AudioSystem.AudioFormatNativeEnumForBtCodec int codec, boolean codecChanged, int event) { Loading @@ -870,10 +886,11 @@ public class AudioDeviceInventory { + "onBluetoothDeviceConfigChange") .set(MediaMetrics.Property.EVENT, BtHelper.deviceEventToString(event)); int delayMs = 0; final BluetoothDevice btDevice = btInfo.mDevice; if (btDevice == null) { mmi.set(MediaMetrics.Property.EARLY_RETURN, "btDevice null").record(); return; return delayMs; } if (AudioService.DEBUG_DEVICES) { Log.d(TAG, "onBluetoothDeviceConfigChange btDevice=" + btDevice); Loading @@ -895,7 +912,7 @@ public class AudioDeviceInventory { .printSlog(EventLogger.Event.ALOGI, TAG)); mmi.set(MediaMetrics.Property.EARLY_RETURN, "A2dp config change ignored") .record(); return; return delayMs; } final String key = DeviceInfo.makeDeviceListKey( AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, address); Loading @@ -903,7 +920,7 @@ public class AudioDeviceInventory { if (di == null) { Log.e(TAG, "invalid null DeviceInfo in onBluetoothDeviceConfigChange"); mmi.set(MediaMetrics.Property.EARLY_RETURN, "null DeviceInfo").record(); return; return delayMs; } mmi.set(MediaMetrics.Property.ADDRESS, address) Loading @@ -911,7 +928,6 @@ public class AudioDeviceInventory { .set(MediaMetrics.Property.INDEX, volume) .set(MediaMetrics.Property.NAME, di.mDeviceName); if (event == BtHelper.EVENT_DEVICE_CONFIG_CHANGE) { if (btInfo.mProfile == BluetoothProfile.A2DP || btInfo.mProfile == BluetoothProfile.LE_AUDIO Loading Loading @@ -939,6 +955,7 @@ public class AudioDeviceInventory { + address + " codec=" + AudioSystem.audioFormatToString(codec)) .printSlog(EventLogger.Event.ALOGI, TAG)); delayMs = BT_CONFIG_CHANGE_MUTE_DELAY_MS; } } } Loading @@ -948,6 +965,7 @@ public class AudioDeviceInventory { } } mmi.record(); return delayMs; } /*package*/ void onMakeA2dpDeviceUnavailableNow(String address, int a2dpCodec) { Loading