diff options
22 files changed, 180 insertions, 263 deletions
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioConfiguration.aidl index 50b54c30c0..3abfb31b7b 100644 --- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioConfiguration.aidl +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioConfiguration.aidl @@ -37,4 +37,5 @@ union AudioConfiguration { android.hardware.bluetooth.audio.PcmConfiguration pcmConfig; android.hardware.bluetooth.audio.CodecConfiguration a2dpConfig; android.hardware.bluetooth.audio.LeAudioConfiguration leAudioConfig; + android.hardware.bluetooth.audio.LeAudioBroadcastConfiguration leAudioBroadcastConfig; } diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/BroadcastConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl index 5fa392631b..7d53b0ca8e 100644 --- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/BroadcastConfiguration.aidl +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl @@ -33,8 +33,9 @@ package android.hardware.bluetooth.audio; @VintfStability -parcelable BroadcastConfiguration { - android.hardware.bluetooth.audio.BroadcastConfiguration.BroadcastStreamMap[] streamMap; +parcelable LeAudioBroadcastConfiguration { + android.hardware.bluetooth.audio.CodecType codecType; + android.hardware.bluetooth.audio.LeAudioBroadcastConfiguration.BroadcastStreamMap[] streamMap; @VintfStability parcelable BroadcastStreamMap { char streamHandle; diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl index 2bc179163f..edb6795ddc 100644 --- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl @@ -34,12 +34,13 @@ package android.hardware.bluetooth.audio; @VintfStability parcelable LeAudioConfiguration { - android.hardware.bluetooth.audio.LeAudioMode mode; - android.hardware.bluetooth.audio.LeAudioConfiguration.LeAudioModeConfig modeConfig; android.hardware.bluetooth.audio.CodecType codecType; + android.hardware.bluetooth.audio.LeAudioConfiguration.StreamMap[] streamMap; + int peerDelayUs; + android.hardware.bluetooth.audio.LeAudioCodecConfiguration leAudioCodecConfig; @VintfStability - union LeAudioModeConfig { - android.hardware.bluetooth.audio.UnicastConfiguration unicastConfig; - android.hardware.bluetooth.audio.BroadcastConfiguration broadcastConfig; + parcelable StreamMap { + char streamHandle; + int audioChannelAllocation; } } diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioMode.aidl deleted file mode 100644 index 766f6376c6..0000000000 --- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioMode.aidl +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/////////////////////////////////////////////////////////////////////////////// -// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // -/////////////////////////////////////////////////////////////////////////////// - -// This file is a snapshot of an AIDL file. Do not edit it manually. There are -// two cases: -// 1). this is a frozen version file - do not edit this in any case. -// 2). this is a 'current' file. If you make a backwards compatible change to -// the interface (from the latest frozen version), the build system will -// prompt you to update this file with `m <name>-update-api`. -// -// You must not make a backward incompatible change to any AIDL file built -// with the aidl_interface module type with versions property set. The module -// type is used to build AIDL files in a way that they can be used across -// independently updatable components of the system. If a device is shipped -// with such a backward incompatible change, it has a high risk of breaking -// later when a module using the interface is updated, e.g., Mainline modules. - -package android.hardware.bluetooth.audio; -@Backing(type="byte") @VintfStability -enum LeAudioMode { - UNKNOWN = 0, - UNICAST = 1, - BROADCAST = 2, -} diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SessionType.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SessionType.aidl index 72d7fb247a..baec9c2109 100644 --- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SessionType.aidl +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SessionType.aidl @@ -42,4 +42,6 @@ enum SessionType { LE_AUDIO_SOFTWARE_DECODING_DATAPATH = 5, LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH = 6, LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH = 7, + LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH = 8, + LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH = 9, } diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/UnicastConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/UnicastConfiguration.aidl deleted file mode 100644 index b385763fa6..0000000000 --- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/UnicastConfiguration.aidl +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/////////////////////////////////////////////////////////////////////////////// -// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // -/////////////////////////////////////////////////////////////////////////////// - -// This file is a snapshot of an AIDL file. Do not edit it manually. There are -// two cases: -// 1). this is a frozen version file - do not edit this in any case. -// 2). this is a 'current' file. If you make a backwards compatible change to -// the interface (from the latest frozen version), the build system will -// prompt you to update this file with `m <name>-update-api`. -// -// You must not make a backward incompatible change to any AIDL file built -// with the aidl_interface module type with versions property set. The module -// type is used to build AIDL files in a way that they can be used across -// independently updatable components of the system. If a device is shipped -// with such a backward incompatible change, it has a high risk of breaking -// later when a module using the interface is updated, e.g., Mainline modules. - -package android.hardware.bluetooth.audio; -@VintfStability -parcelable UnicastConfiguration { - android.hardware.bluetooth.audio.UnicastConfiguration.UnicastStreamMap[] streamMap; - int peerDelay; - android.hardware.bluetooth.audio.LeAudioCodecConfiguration leAudioCodecConfig; - @VintfStability - parcelable UnicastStreamMap { - char streamHandle; - int audioChannelAllocation; - } -} diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioConfiguration.aidl index 81b41dcf7f..a06337ec4a 100644 --- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioConfiguration.aidl +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioConfiguration.aidl @@ -17,6 +17,7 @@ package android.hardware.bluetooth.audio; import android.hardware.bluetooth.audio.CodecConfiguration; +import android.hardware.bluetooth.audio.LeAudioBroadcastConfiguration; import android.hardware.bluetooth.audio.LeAudioConfiguration; import android.hardware.bluetooth.audio.PcmConfiguration; @@ -28,4 +29,5 @@ union AudioConfiguration { PcmConfiguration pcmConfig; CodecConfiguration a2dpConfig; LeAudioConfiguration leAudioConfig; + LeAudioBroadcastConfiguration leAudioBroadcastConfig; } diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/BroadcastCapability.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/BroadcastCapability.aidl index cb63f88ea9..f1301fbad9 100644 --- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/BroadcastCapability.aidl +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/BroadcastCapability.aidl @@ -19,7 +19,6 @@ package android.hardware.bluetooth.audio; import android.hardware.bluetooth.audio.AudioLocation; import android.hardware.bluetooth.audio.CodecType; import android.hardware.bluetooth.audio.Lc3Capabilities; -import android.hardware.bluetooth.audio.LeAudioMode; /** * Used to specify the le audio broadcast codec capabilities for hardware offload. diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/BroadcastConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl index cfc9d3aa01..e9a1a0c6e9 100644 --- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/BroadcastConfiguration.aidl +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl @@ -16,14 +16,15 @@ package android.hardware.bluetooth.audio; +import android.hardware.bluetooth.audio.CodecType; import android.hardware.bluetooth.audio.LeAudioCodecConfiguration; @VintfStability -parcelable BroadcastConfiguration { +parcelable LeAudioBroadcastConfiguration { @VintfStability parcelable BroadcastStreamMap { /* - * The connection handle used for a unicast or a broadcast group. + * The connection handle used for a broadcast group. * Range: 0x0000 to 0xEFFF */ char streamHandle; @@ -35,5 +36,6 @@ parcelable BroadcastConfiguration { int audioChannelAllocation; LeAudioCodecConfiguration leAudioCodecConfig; } + CodecType codecType; BroadcastStreamMap[] streamMap; } diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl index 515794b247..0d1e3ded93 100644 --- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl @@ -16,22 +16,28 @@ package android.hardware.bluetooth.audio; -import android.hardware.bluetooth.audio.BroadcastConfiguration; import android.hardware.bluetooth.audio.CodecType; -import android.hardware.bluetooth.audio.LeAudioMode; -import android.hardware.bluetooth.audio.UnicastConfiguration; +import android.hardware.bluetooth.audio.LeAudioCodecConfiguration; @VintfStability parcelable LeAudioConfiguration { @VintfStability - union LeAudioModeConfig { - UnicastConfiguration unicastConfig; - BroadcastConfiguration broadcastConfig; + parcelable StreamMap { + /* + * The connection handle used for a unicast group. + * Range: 0x0000 to 0xEFFF + */ + char streamHandle; + /* + * Audio channel allocation is a bit field, each enabled bit means that given audio + * direction, i.e. "left", or "right" is used. Ordering of audio channels comes from the + * least significant bit to the most significant bit. The valus follows the Bluetooth SIG + * Audio Location assigned number. + */ + int audioChannelAllocation; } - /* - * The mode of the LE audio - */ - LeAudioMode mode; - LeAudioModeConfig modeConfig; CodecType codecType; + StreamMap[] streamMap; + int peerDelayUs; + LeAudioCodecConfiguration leAudioCodecConfig; } diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioMode.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioMode.aidl deleted file mode 100644 index 2cf019e9ad..0000000000 --- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioMode.aidl +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.hardware.bluetooth.audio; - -@VintfStability -@Backing(type="byte") -enum LeAudioMode { - UNKNOWN, - UNICAST, - BROADCAST, -} diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SessionType.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SessionType.aidl index 30faae31c9..95beee7489 100644 --- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SessionType.aidl +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SessionType.aidl @@ -33,19 +33,33 @@ enum SessionType { */ HEARING_AID_SOFTWARE_ENCODING_DATAPATH, /** - * Used when encoded by Bluetooth Stack and streaming to LE Audio device + * Used when audio is encoded by the Bluetooth Stack and is streamed to LE + * Audio unicast device. */ LE_AUDIO_SOFTWARE_ENCODING_DATAPATH, /** - * Used when decoded by Bluetooth Stack and streaming to audio framework + * Used when audio is decoded by the Bluetooth Stack and is streamed to LE + * Audio unicast device. */ LE_AUDIO_SOFTWARE_DECODING_DATAPATH, /** - * Encoding is done by HW an there is control only + * Used when audio is encoded by hardware offload and is streamed to LE + * Audio unicast device. This is a control path only. */ LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH, /** - * Decoding is done by HW an there is control only + * Used when audio is decoded by hardware offload and is streamed to LE + * Audio unicast device. This is a control path only. */ LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH, + /** + * Used when audio is encoded by the Bluetooth stack and is streamed to LE + * Audio broadcast channels. + */ + LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH, + /** + * Used when audio is encoded by hardware offload and is streamed to LE + * Audio broadcast channels. This is a control path only. + */ + LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH, } diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastCapability.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastCapability.aidl index cd8a4c1971..f8a924aeb4 100644 --- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastCapability.aidl +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastCapability.aidl @@ -19,7 +19,6 @@ package android.hardware.bluetooth.audio; import android.hardware.bluetooth.audio.AudioLocation; import android.hardware.bluetooth.audio.CodecType; import android.hardware.bluetooth.audio.Lc3Capabilities; -import android.hardware.bluetooth.audio.LeAudioMode; /** * Used to specify the le audio unicast codec capabilities for hardware offload. diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastConfiguration.aidl deleted file mode 100644 index 7be2c5b7bb..0000000000 --- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastConfiguration.aidl +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.hardware.bluetooth.audio; - -import android.hardware.bluetooth.audio.LeAudioCodecConfiguration; - -@VintfStability -parcelable UnicastConfiguration { - @VintfStability - parcelable UnicastStreamMap { - /* - * The connection handle used for a unicast or a broadcast group. - * Range: 0x0000 to 0xEFFF - */ - char streamHandle; - /* - * Audio channel allocation is a bit field, each enabled bit means that given audio - * direction, i.e. "left", or "right" is used. Ordering of audio channels comes from the - * least significant bit to the most significant bit. The valus follows the Bluetooth SIG - * Audio Location assigned number. - */ - int audioChannelAllocation; - } - UnicastStreamMap[] streamMap; - int peerDelay; - LeAudioCodecConfiguration leAudioCodecConfig; -} diff --git a/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp b/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp index 1e55a0bf7c..1e1680a4fd 100644 --- a/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp +++ b/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp @@ -64,6 +64,14 @@ ndk::ScopedAStatus BluetoothAudioProviderFactory::openProvider( case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH: provider = ndk::SharedRefBase::make<LeAudioOffloadInputAudioProvider>(); break; + case SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH: + provider = + ndk::SharedRefBase::make<LeAudioSoftwareBroadcastAudioProvider>(); + break; + case SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH: + provider = + ndk::SharedRefBase::make<LeAudioOffloadBroadcastAudioProvider>(); + break; default: provider = nullptr; break; @@ -93,7 +101,10 @@ ndk::ScopedAStatus BluetoothAudioProviderFactory::getProviderCapabilities( } else if (session_type == SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH || session_type == - SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH) { + SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH || + session_type == + SessionType:: + LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH) { std::vector<LeAudioCodecCapabilitiesSetting> db_codec_capabilities = BluetoothAudioCodecs::GetLeAudioOffloadCodecCapabilities(session_type); if (db_codec_capabilities.size()) { diff --git a/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp b/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp index 72ac9bdede..7a28513157 100644 --- a/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp +++ b/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp @@ -38,6 +38,12 @@ LeAudioOffloadInputAudioProvider::LeAudioOffloadInputAudioProvider() session_type_ = SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH; } +LeAudioOffloadBroadcastAudioProvider::LeAudioOffloadBroadcastAudioProvider() + : LeAudioOffloadAudioProvider() { + session_type_ = + SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH; +} + LeAudioOffloadAudioProvider::LeAudioOffloadAudioProvider() : BluetoothAudioProvider() {} diff --git a/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.h b/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.h index a27a2e71ce..6509a9e2b4 100644 --- a/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.h +++ b/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.h @@ -48,6 +48,12 @@ class LeAudioOffloadInputAudioProvider : public LeAudioOffloadAudioProvider { LeAudioOffloadInputAudioProvider(); }; +class LeAudioOffloadBroadcastAudioProvider + : public LeAudioOffloadAudioProvider { + public: + LeAudioOffloadBroadcastAudioProvider(); +}; + } // namespace audio } // namespace bluetooth } // namespace hardware diff --git a/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.cpp b/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.cpp index 67b7d60c0c..0fe205efe1 100644 --- a/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.cpp +++ b/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.cpp @@ -55,6 +55,11 @@ LeAudioSoftwareInputAudioProvider::LeAudioSoftwareInputAudioProvider() session_type_ = SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH; } +LeAudioSoftwareBroadcastAudioProvider::LeAudioSoftwareBroadcastAudioProvider() + : LeAudioSoftwareAudioProvider() { + session_type_ = SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH; +} + LeAudioSoftwareAudioProvider::LeAudioSoftwareAudioProvider() : BluetoothAudioProvider(), data_mq_(nullptr) {} @@ -78,7 +83,9 @@ ndk::ScopedAStatus LeAudioSoftwareAudioProvider::startSession( } uint32_t buffer_modifier = 0; - if (session_type_ == SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH) + if (session_type_ == SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH || + session_type_ == + SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH) buffer_modifier = kBufferOutCount; else if (session_type_ == SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH) buffer_modifier = kBufferInCount; diff --git a/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.h b/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.h index fa581820c6..ace4bff6a8 100644 --- a/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.h +++ b/bluetooth/audio/aidl/default/LeAudioSoftwareAudioProvider.h @@ -51,6 +51,12 @@ class LeAudioSoftwareInputAudioProvider : public LeAudioSoftwareAudioProvider { LeAudioSoftwareInputAudioProvider(); }; +class LeAudioSoftwareBroadcastAudioProvider + : public LeAudioSoftwareAudioProvider { + public: + LeAudioSoftwareBroadcastAudioProvider(); +}; + } // namespace audio } // namespace bluetooth } // namespace hardware diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp index 96cd9ef6cb..dd29011625 100644 --- a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp +++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp @@ -94,6 +94,8 @@ const AudioConfiguration BluetoothAudioSession::GetAudioConfig() { case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH: case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH: return AudioConfiguration(LeAudioConfiguration{}); + case SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH: + return AudioConfiguration(LeAudioBroadcastConfiguration{}); default: return AudioConfiguration(PcmConfiguration{}); } @@ -137,6 +139,8 @@ bool BluetoothAudioSession::IsSessionReady() { SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH || session_type_ == SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH || + session_type_ == + SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH || (data_mq_ != nullptr && data_mq_->isValid())); return stack_iface_ != nullptr && is_mq_valid && audio_config_ != nullptr; } @@ -259,7 +263,9 @@ bool BluetoothAudioSession::UpdateAudioConfig( (session_type_ == SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH || session_type_ == SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH || session_type_ == SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH || - session_type_ == SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH); + session_type_ == SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH || + session_type_ == + SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH); bool is_offload_a2dp_session = (session_type_ == SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH); bool is_offload_le_audio_session = diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioSessionControl.h b/bluetooth/audio/utils/aidl_session/BluetoothAudioSessionControl.h index aff01e5a26..451a31fb7e 100644 --- a/bluetooth/audio/utils/aidl_session/BluetoothAudioSessionControl.h +++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioSessionControl.h @@ -86,6 +86,8 @@ class BluetoothAudioSessionControl { case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH: case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH: return AudioConfiguration(LeAudioConfiguration{}); + case SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH: + return AudioConfiguration(LeAudioBroadcastConfiguration{}); default: return AudioConfiguration(PcmConfiguration{}); } diff --git a/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware.cpp b/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware.cpp index 632a389d8c..1ef9365918 100644 --- a/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware.cpp +++ b/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware.cpp @@ -418,100 +418,89 @@ inline Lc3Config_2_1 to_hidl_lc3_config_2_1( } inline Lc3CodecConfig_2_1 to_hidl_leaudio_config_2_1( - const LeAudioConfiguration& leaudio_config) { + const LeAudioConfiguration& unicast_config) { Lc3CodecConfig_2_1 hidl_lc3_codec_config = { .audioChannelAllocation = 0, }; - if (leaudio_config.modeConfig.getTag() == - LeAudioConfiguration::LeAudioModeConfig::unicastConfig) { - auto& unicast_config = - leaudio_config.modeConfig - .get<LeAudioConfiguration::LeAudioModeConfig::unicastConfig>(); - if (unicast_config.leAudioCodecConfig.getTag() == - LeAudioCodecConfiguration::lc3Config) { - LOG(FATAL) << __func__ << ": unexpected codec type(vendor?)"; - } - auto& le_codec_config = unicast_config.leAudioCodecConfig - .get<LeAudioCodecConfiguration::lc3Config>(); - - hidl_lc3_codec_config.lc3Config = to_hidl_lc3_config_2_1(le_codec_config); - - for (const auto& map : unicast_config.streamMap) { - hidl_lc3_codec_config.audioChannelAllocation |= - map.audioChannelAllocation; - } - } else { - // NOTE: Broadcast is not officially supported in HIDL - auto& bcast_config = - leaudio_config.modeConfig - .get<LeAudioConfiguration::LeAudioModeConfig::broadcastConfig>(); - if (bcast_config.streamMap.empty()) { - return hidl_lc3_codec_config; - } - if (bcast_config.streamMap[0].leAudioCodecConfig.getTag() != - LeAudioCodecConfiguration::lc3Config) { - LOG(FATAL) << __func__ << ": unexpected codec type(vendor?)"; - } - auto& le_codec_config = - bcast_config.streamMap[0] - .leAudioCodecConfig.get<LeAudioCodecConfiguration::lc3Config>(); - hidl_lc3_codec_config.lc3Config = to_hidl_lc3_config_2_1(le_codec_config); - - for (const auto& map : bcast_config.streamMap) { - hidl_lc3_codec_config.audioChannelAllocation |= - map.audioChannelAllocation; - } + if (unicast_config.leAudioCodecConfig.getTag() == + LeAudioCodecConfiguration::lc3Config) { + LOG(FATAL) << __func__ << ": unexpected codec type(vendor?)"; } + auto& le_codec_config = unicast_config.leAudioCodecConfig + .get<LeAudioCodecConfiguration::lc3Config>(); + hidl_lc3_codec_config.lc3Config = to_hidl_lc3_config_2_1(le_codec_config); + + for (const auto& map : unicast_config.streamMap) { + hidl_lc3_codec_config.audioChannelAllocation |= map.audioChannelAllocation; + } + return hidl_lc3_codec_config; +} + +inline Lc3CodecConfig_2_1 to_hidl_leaudio_broadcast_config_2_1( + const LeAudioBroadcastConfiguration& broadcast_config) { + Lc3CodecConfig_2_1 hidl_lc3_codec_config = { + .audioChannelAllocation = 0, + }; + // NOTE: Broadcast is not officially supported in HIDL + if (broadcast_config.streamMap.empty()) { + return hidl_lc3_codec_config; + } + if (broadcast_config.streamMap[0].leAudioCodecConfig.getTag() != + LeAudioCodecConfiguration::lc3Config) { + LOG(FATAL) << __func__ << ": unexpected codec type(vendor?)"; + } + auto& le_codec_config = + broadcast_config.streamMap[0] + .leAudioCodecConfig.get<LeAudioCodecConfiguration::lc3Config>(); + hidl_lc3_codec_config.lc3Config = to_hidl_lc3_config_2_1(le_codec_config); + + for (const auto& map : broadcast_config.streamMap) { + hidl_lc3_codec_config.audioChannelAllocation |= map.audioChannelAllocation; + } return hidl_lc3_codec_config; } inline LeAudioConfig_2_2 to_hidl_leaudio_config_2_2( - const LeAudioConfiguration& leaudio_config) { + const LeAudioConfiguration& unicast_config) { LeAudioConfig_2_2 hidl_leaudio_config; + hidl_leaudio_config.mode = LeAudioMode_2_2::UNICAST; + ::android::hardware::bluetooth::audio::V2_2::UnicastConfig + hidl_unicast_config; + hidl_unicast_config.peerDelay = + static_cast<uint32_t>(unicast_config.peerDelayUs / 1000); + + auto& lc3_config = unicast_config.leAudioCodecConfig + .get<LeAudioCodecConfiguration::lc3Config>(); + hidl_unicast_config.lc3Config = to_hidl_lc3_config_2_1(lc3_config); + + hidl_unicast_config.streamMap.resize(unicast_config.streamMap.size()); + for (int i = 0; i < unicast_config.streamMap.size(); i++) { + hidl_unicast_config.streamMap[i].audioChannelAllocation = + static_cast<uint32_t>( + unicast_config.streamMap[i].audioChannelAllocation); + hidl_unicast_config.streamMap[i].streamHandle = + static_cast<uint16_t>(unicast_config.streamMap[i].streamHandle); + } + return hidl_leaudio_config; +} - if (leaudio_config.modeConfig.getTag() == - LeAudioConfiguration::LeAudioModeConfig::unicastConfig) { - hidl_leaudio_config.mode = LeAudioMode_2_2::UNICAST; - auto& unicast_config = - leaudio_config.modeConfig - .get<LeAudioConfiguration::LeAudioModeConfig::unicastConfig>(); - ::android::hardware::bluetooth::audio::V2_2::UnicastConfig - hidl_unicast_config; - hidl_unicast_config.peerDelay = - static_cast<uint32_t>(unicast_config.peerDelay); - - auto& lc3_config = unicast_config.leAudioCodecConfig - .get<LeAudioCodecConfiguration::lc3Config>(); - hidl_unicast_config.lc3Config = to_hidl_lc3_config_2_1(lc3_config); - - hidl_unicast_config.streamMap.resize(unicast_config.streamMap.size()); - for (int i = 0; i < unicast_config.streamMap.size(); i++) { - hidl_unicast_config.streamMap[i].audioChannelAllocation = - static_cast<uint32_t>( - unicast_config.streamMap[i].audioChannelAllocation); - hidl_unicast_config.streamMap[i].streamHandle = - static_cast<uint16_t>(unicast_config.streamMap[i].streamHandle); - } - } else if (leaudio_config.modeConfig.getTag() == - LeAudioConfiguration::LeAudioModeConfig::broadcastConfig) { - hidl_leaudio_config.mode = LeAudioMode_2_2::BROADCAST; - auto bcast_config = - leaudio_config.modeConfig - .get<LeAudioConfiguration::LeAudioModeConfig::broadcastConfig>(); - ::android::hardware::bluetooth::audio::V2_2::BroadcastConfig - hidl_bcast_config; - hidl_bcast_config.streamMap.resize(bcast_config.streamMap.size()); - for (int i = 0; i < bcast_config.streamMap.size(); i++) { - hidl_bcast_config.streamMap[i].audioChannelAllocation = - static_cast<uint32_t>( - bcast_config.streamMap[i].audioChannelAllocation); - hidl_bcast_config.streamMap[i].streamHandle = - static_cast<uint16_t>(bcast_config.streamMap[i].streamHandle); - hidl_bcast_config.streamMap[i].lc3Config = to_hidl_lc3_config_2_1( - bcast_config.streamMap[i] - .leAudioCodecConfig.get<LeAudioCodecConfiguration::lc3Config>()); - } +inline LeAudioConfig_2_2 to_hidl_leaudio_broadcast_config_2_2( + const LeAudioBroadcastConfiguration& broadcast_config) { + LeAudioConfig_2_2 hidl_leaudio_config; + hidl_leaudio_config.mode = LeAudioMode_2_2::BROADCAST; + ::android::hardware::bluetooth::audio::V2_2::BroadcastConfig + hidl_bcast_config; + hidl_bcast_config.streamMap.resize(broadcast_config.streamMap.size()); + for (int i = 0; i < broadcast_config.streamMap.size(); i++) { + hidl_bcast_config.streamMap[i].audioChannelAllocation = + static_cast<uint32_t>( + broadcast_config.streamMap[i].audioChannelAllocation); + hidl_bcast_config.streamMap[i].streamHandle = + static_cast<uint16_t>(broadcast_config.streamMap[i].streamHandle); + hidl_bcast_config.streamMap[i].lc3Config = to_hidl_lc3_config_2_1( + broadcast_config.streamMap[i] + .leAudioCodecConfig.get<LeAudioCodecConfiguration::lc3Config>()); } return hidl_leaudio_config; } @@ -532,6 +521,10 @@ inline AudioConfig_2_1 to_hidl_audio_config_2_1( hidl_audio_config.leAudioCodecConfig(to_hidl_leaudio_config_2_1( audio_config.get<AudioConfiguration::leAudioConfig>())); break; + case AudioConfiguration::leAudioBroadcastConfig: + hidl_audio_config.leAudioCodecConfig(to_hidl_leaudio_broadcast_config_2_1( + audio_config.get<AudioConfiguration::leAudioBroadcastConfig>())); + break; } return hidl_audio_config; } @@ -552,6 +545,10 @@ inline AudioConfig_2_2 to_hidl_audio_config_2_2( hidl_audio_config.leAudioConfig(to_hidl_leaudio_config_2_2( audio_config.get<AudioConfiguration::leAudioConfig>())); break; + case AudioConfiguration::leAudioBroadcastConfig: + hidl_audio_config.leAudioConfig(to_hidl_leaudio_broadcast_config_2_2( + audio_config.get<AudioConfiguration::leAudioBroadcastConfig>())); + break; } return hidl_audio_config; } |