From 593d8f4519112bad127161b1a3de8e57396f83f1 Mon Sep 17 00:00:00 2001 From: Omer Osman Date: Thu, 25 Aug 2022 00:10:08 +0000 Subject: [PATCH] Update Opus over A2DP to use BluetoothCodecConfig api Bug: 240635097 Test: sink device using bds-dev Change-Id: I573133a3f0cad910f935311e053c4f6fde5a2fc7 --- media/java/android/media/AudioSystem.java | 6 ++---- .../src/com/android/settingslib/bluetooth/A2dpProfile.java | 4 +--- services/core/java/com/android/server/audio/BtHelper.java | 4 +--- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java index 444366adf2652..58ce49b5fda9a 100644 --- a/media/java/android/media/AudioSystem.java +++ b/media/java/android/media/AudioSystem.java @@ -65,8 +65,6 @@ public class AudioSystem private static final String TAG = "AudioSystem"; - private static final int SOURCE_CODEC_TYPE_OPUS = 6; // TODO remove in U - // private constructor to prevent instantiating AudioSystem private AudioSystem() { throw new UnsupportedOperationException("Trying to instantiate AudioSystem"); @@ -293,7 +291,7 @@ public class AudioSystem case AUDIO_FORMAT_APTX_HD: return BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD; case AUDIO_FORMAT_LDAC: return BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC; case AUDIO_FORMAT_LC3: return BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3; - case AUDIO_FORMAT_OPUS: return SOURCE_CODEC_TYPE_OPUS; // TODO update in U + case AUDIO_FORMAT_OPUS: return BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS; default: Log.e(TAG, "Unknown audio format 0x" + Integer.toHexString(audioFormat) + " for conversion to BT codec"); @@ -336,7 +334,7 @@ public class AudioSystem return AudioSystem.AUDIO_FORMAT_LDAC; case BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3: return AudioSystem.AUDIO_FORMAT_LC3; - case SOURCE_CODEC_TYPE_OPUS: // TODO update in U + case BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS: return AudioSystem.AUDIO_FORMAT_OPUS; default: Log.e(TAG, "Unknown BT codec 0x" + Integer.toHexString(btCodec) diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java index 19409865284cc..b64dcca63ac95 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpProfile.java @@ -43,8 +43,6 @@ import java.util.List; public class A2dpProfile implements LocalBluetoothProfile { private static final String TAG = "A2dpProfile"; - private static final int SOURCE_CODEC_TYPE_OPUS = 6; // TODO remove in U - private Context mContext; private BluetoothA2dp mService; @@ -333,7 +331,7 @@ public class A2dpProfile implements LocalBluetoothProfile { case BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3: index = 6; break; - case SOURCE_CODEC_TYPE_OPUS: // TODO update in U + case BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS: index = 7; break; } diff --git a/services/core/java/com/android/server/audio/BtHelper.java b/services/core/java/com/android/server/audio/BtHelper.java index 66a4527bc2cbc..4adbfaa79c69f 100644 --- a/services/core/java/com/android/server/audio/BtHelper.java +++ b/services/core/java/com/android/server/audio/BtHelper.java @@ -53,8 +53,6 @@ public class BtHelper { private static final String TAG = "AS.BtHelper"; - private static final int SOURCE_CODEC_TYPE_OPUS = 6; // TODO remove in U - private final @NonNull AudioDeviceBroker mDeviceBroker; BtHelper(@NonNull AudioDeviceBroker broker) { @@ -913,7 +911,7 @@ public class BtHelper { return "ENCODING_APTX_HD"; case BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC: return "ENCODING_LDAC"; - case SOURCE_CODEC_TYPE_OPUS: // TODO update in U + case BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS: return "ENCODING_OPUS"; default: return "ENCODING_BT_CODEC_TYPE(" + btCodecType + ")";