Loading bluetooth/audio/2.2/Android.bp 0 → 100644 +32 −0 Original line number Diff line number Diff line // This file is autogenerated by hidl-gen -Landroidbp. package { // See: http://go/android-license-faq // A large-scale-change added 'default_applicable_licenses' to import // all of the 'license_kinds' from "hardware_interfaces_license" // to get the below license kinds: // SPDX-license-identifier-Apache-2.0 default_applicable_licenses: ["hardware_interfaces_license"], } hidl_interface { name: "android.hardware.bluetooth.audio@2.2", root: "android.hardware", srcs: [ "types.hal", "IBluetoothAudioProvider.hal", "IBluetoothAudioProvidersFactory.hal", ], interfaces: [ "android.hardware.audio.common@5.0", "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", "android.hidl.base@1.0", "android.hidl.safe_union@1.0", ], apex_available: [ "//apex_available:platform", "com.android.bluetooth.updatable", ], gen_java: false, } bluetooth/audio/2.2/IBluetoothAudioProvider.hal 0 → 100644 +62 −0 Original line number Diff line number Diff line /* * 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@2.2; import @2.1::IBluetoothAudioProvider; import @2.0::IBluetoothAudioPort; import @2.0::Status; /** * HAL interface from the Bluetooth stack to the Audio HAL * * The Bluetooth stack calls methods in this interface to start and end audio * sessions and sends callback events to the Audio HAL. * * Note: For HIDL APIs with a "generates" statement, the callback parameter used * for return value must be invoked synchronously before the API call returns. */ interface IBluetoothAudioProvider extends @2.1::IBluetoothAudioProvider { /** * This method indicates that the Bluetooth stack is ready to stream audio. * It registers an instance of IBluetoothAudioPort with and provides the * current negotiated codec to the Audio HAL. After this method is called, * the Audio HAL can invoke IBluetoothAudioPort.startStream(). * * Note: endSession() must be called to unregister this IBluetoothAudioPort * * @param hostIf An instance of IBluetoothAudioPort for stream control * @param audioConfig The audio configuration negotiated with the remote * device. The PCM parameters are set if software based encoding, * otherwise the correct codec configuration is used for hardware * encoding. * * @return status One of the following * SUCCESS if this IBluetoothAudioPort was successfully registered with * the Audio HAL * UNSUPPORTED_CODEC_CONFIGURATION if the Audio HAL cannot register this * IBluetoothAudioPort with the given codec configuration * FAILURE if the Audio HAL cannot register this IBluetoothAudioPort for * any other reason * @return dataMQ The fast message queue for audio data from/to this * provider. Audio data will be in PCM format as specified by the * audioConfig.pcmConfig parameter. Invalid if streaming is offloaded * from/to hardware or on failure. */ startSession_2_2(IBluetoothAudioPort hostIf, AudioConfiguration audioConfig) generates (Status status, fmq_sync<uint8_t> dataMQ); }; bluetooth/audio/2.2/IBluetoothAudioProvidersFactory.hal 0 → 100644 +33 −0 Original line number Diff line number Diff line /* * 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@2.2; import @2.1::IBluetoothAudioProvidersFactory; /** * This factory allows a HAL implementation to be split into multiple * independent providers. * * When the Bluetooth stack is ready to create an audio session, it must first * obtain the IBluetoothAudioProvider for that session type by calling * openProvider(). * * Note: For HIDL APIs with a "generates" statement, the callback parameter used * for return value must be invoked synchronously before the API call returns. */ interface IBluetoothAudioProvidersFactory extends @2.1::IBluetoothAudioProvidersFactory { }; bluetooth/audio/2.2/default/A2dpOffloadAudioProvider.cpp 0 → 100644 +95 −0 Original line number Diff line number Diff line /* * 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. */ #define LOG_TAG "BTAudioProviderA2dpOffload" #include "A2dpOffloadAudioProvider.h" #include <android-base/logging.h> #include <fmq/MessageQueue.h> #include <hidl/MQDescriptor.h> #include "BluetoothAudioSessionReport_2_2.h" #include "BluetoothAudioSupportedCodecsDB_2_1.h" namespace android { namespace hardware { namespace bluetooth { namespace audio { namespace V2_2 { namespace implementation { using ::android::bluetooth::audio::BluetoothAudioSessionReport_2_2; using ::android::hardware::kSynchronizedReadWrite; using ::android::hardware::MessageQueue; using ::android::hardware::Void; using ::android::hardware::bluetooth::audio::V2_0::AudioConfiguration; using DataMQ = MessageQueue<uint8_t, kSynchronizedReadWrite>; A2dpOffloadAudioProvider::A2dpOffloadAudioProvider() : BluetoothAudioProvider() { session_type_ = V2_1::SessionType::A2DP_HARDWARE_OFFLOAD_DATAPATH; } bool A2dpOffloadAudioProvider::isValid(const V2_0::SessionType& sessionType) { return isValid(static_cast<V2_1::SessionType>(sessionType)); } bool A2dpOffloadAudioProvider::isValid(const V2_1::SessionType& sessionType) { return (sessionType == session_type_); } Return<void> A2dpOffloadAudioProvider::startSession( const sp<IBluetoothAudioPort>& hostIf, const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) { /** * Initialize the audio platform if audioConfiguration is supported. * Save the IBluetoothAudioPort interface, so that it can be used * later to send stream control commands to the HAL client, based on * interaction with Audio framework. */ if (audioConfig.getDiscriminator() != AudioConfiguration::hidl_discriminator::codecConfig) { LOG(WARNING) << __func__ << " - Invalid Audio Configuration=" << toString(audioConfig); _hidl_cb(BluetoothAudioStatus::UNSUPPORTED_CODEC_CONFIGURATION, DataMQ::Descriptor()); return Void(); } else if (!android::bluetooth::audio::IsOffloadCodecConfigurationValid( session_type_, audioConfig.codecConfig())) { _hidl_cb(BluetoothAudioStatus::UNSUPPORTED_CODEC_CONFIGURATION, DataMQ::Descriptor()); return Void(); } return BluetoothAudioProvider::startSession(hostIf, audioConfig, _hidl_cb); } Return<void> A2dpOffloadAudioProvider::onSessionReady( startSession_cb _hidl_cb) { BluetoothAudioSessionReport_2_2::OnSessionStarted(session_type_, stack_iface_, nullptr, audio_config_); _hidl_cb(BluetoothAudioStatus::SUCCESS, DataMQ::Descriptor()); return Void(); } } // namespace implementation } // namespace V2_2 } // namespace audio } // namespace bluetooth } // namespace hardware } // namespace android bluetooth/audio/2.2/default/A2dpOffloadAudioProvider.h 0 → 100644 +48 −0 Original line number Diff line number Diff line /* * 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. */ #pragma once #include "BluetoothAudioProvider.h" namespace android { namespace hardware { namespace bluetooth { namespace audio { namespace V2_2 { namespace implementation { class A2dpOffloadAudioProvider : public BluetoothAudioProvider { public: A2dpOffloadAudioProvider(); bool isValid(const V2_1::SessionType& sessionType) override; bool isValid(const V2_0::SessionType& sessionType) override; Return<void> startSession(const sp<V2_0::IBluetoothAudioPort>& hostIf, const V2_0::AudioConfiguration& audioConfig, startSession_cb _hidl_cb) override; private: Return<void> onSessionReady(startSession_cb _hidl_cb) override; }; } // namespace implementation } // namespace V2_2 } // namespace audio } // namespace bluetooth } // namespace hardware } // namespace android Loading
bluetooth/audio/2.2/Android.bp 0 → 100644 +32 −0 Original line number Diff line number Diff line // This file is autogenerated by hidl-gen -Landroidbp. package { // See: http://go/android-license-faq // A large-scale-change added 'default_applicable_licenses' to import // all of the 'license_kinds' from "hardware_interfaces_license" // to get the below license kinds: // SPDX-license-identifier-Apache-2.0 default_applicable_licenses: ["hardware_interfaces_license"], } hidl_interface { name: "android.hardware.bluetooth.audio@2.2", root: "android.hardware", srcs: [ "types.hal", "IBluetoothAudioProvider.hal", "IBluetoothAudioProvidersFactory.hal", ], interfaces: [ "android.hardware.audio.common@5.0", "android.hardware.bluetooth.audio@2.0", "android.hardware.bluetooth.audio@2.1", "android.hidl.base@1.0", "android.hidl.safe_union@1.0", ], apex_available: [ "//apex_available:platform", "com.android.bluetooth.updatable", ], gen_java: false, }
bluetooth/audio/2.2/IBluetoothAudioProvider.hal 0 → 100644 +62 −0 Original line number Diff line number Diff line /* * 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@2.2; import @2.1::IBluetoothAudioProvider; import @2.0::IBluetoothAudioPort; import @2.0::Status; /** * HAL interface from the Bluetooth stack to the Audio HAL * * The Bluetooth stack calls methods in this interface to start and end audio * sessions and sends callback events to the Audio HAL. * * Note: For HIDL APIs with a "generates" statement, the callback parameter used * for return value must be invoked synchronously before the API call returns. */ interface IBluetoothAudioProvider extends @2.1::IBluetoothAudioProvider { /** * This method indicates that the Bluetooth stack is ready to stream audio. * It registers an instance of IBluetoothAudioPort with and provides the * current negotiated codec to the Audio HAL. After this method is called, * the Audio HAL can invoke IBluetoothAudioPort.startStream(). * * Note: endSession() must be called to unregister this IBluetoothAudioPort * * @param hostIf An instance of IBluetoothAudioPort for stream control * @param audioConfig The audio configuration negotiated with the remote * device. The PCM parameters are set if software based encoding, * otherwise the correct codec configuration is used for hardware * encoding. * * @return status One of the following * SUCCESS if this IBluetoothAudioPort was successfully registered with * the Audio HAL * UNSUPPORTED_CODEC_CONFIGURATION if the Audio HAL cannot register this * IBluetoothAudioPort with the given codec configuration * FAILURE if the Audio HAL cannot register this IBluetoothAudioPort for * any other reason * @return dataMQ The fast message queue for audio data from/to this * provider. Audio data will be in PCM format as specified by the * audioConfig.pcmConfig parameter. Invalid if streaming is offloaded * from/to hardware or on failure. */ startSession_2_2(IBluetoothAudioPort hostIf, AudioConfiguration audioConfig) generates (Status status, fmq_sync<uint8_t> dataMQ); };
bluetooth/audio/2.2/IBluetoothAudioProvidersFactory.hal 0 → 100644 +33 −0 Original line number Diff line number Diff line /* * 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@2.2; import @2.1::IBluetoothAudioProvidersFactory; /** * This factory allows a HAL implementation to be split into multiple * independent providers. * * When the Bluetooth stack is ready to create an audio session, it must first * obtain the IBluetoothAudioProvider for that session type by calling * openProvider(). * * Note: For HIDL APIs with a "generates" statement, the callback parameter used * for return value must be invoked synchronously before the API call returns. */ interface IBluetoothAudioProvidersFactory extends @2.1::IBluetoothAudioProvidersFactory { };
bluetooth/audio/2.2/default/A2dpOffloadAudioProvider.cpp 0 → 100644 +95 −0 Original line number Diff line number Diff line /* * 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. */ #define LOG_TAG "BTAudioProviderA2dpOffload" #include "A2dpOffloadAudioProvider.h" #include <android-base/logging.h> #include <fmq/MessageQueue.h> #include <hidl/MQDescriptor.h> #include "BluetoothAudioSessionReport_2_2.h" #include "BluetoothAudioSupportedCodecsDB_2_1.h" namespace android { namespace hardware { namespace bluetooth { namespace audio { namespace V2_2 { namespace implementation { using ::android::bluetooth::audio::BluetoothAudioSessionReport_2_2; using ::android::hardware::kSynchronizedReadWrite; using ::android::hardware::MessageQueue; using ::android::hardware::Void; using ::android::hardware::bluetooth::audio::V2_0::AudioConfiguration; using DataMQ = MessageQueue<uint8_t, kSynchronizedReadWrite>; A2dpOffloadAudioProvider::A2dpOffloadAudioProvider() : BluetoothAudioProvider() { session_type_ = V2_1::SessionType::A2DP_HARDWARE_OFFLOAD_DATAPATH; } bool A2dpOffloadAudioProvider::isValid(const V2_0::SessionType& sessionType) { return isValid(static_cast<V2_1::SessionType>(sessionType)); } bool A2dpOffloadAudioProvider::isValid(const V2_1::SessionType& sessionType) { return (sessionType == session_type_); } Return<void> A2dpOffloadAudioProvider::startSession( const sp<IBluetoothAudioPort>& hostIf, const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) { /** * Initialize the audio platform if audioConfiguration is supported. * Save the IBluetoothAudioPort interface, so that it can be used * later to send stream control commands to the HAL client, based on * interaction with Audio framework. */ if (audioConfig.getDiscriminator() != AudioConfiguration::hidl_discriminator::codecConfig) { LOG(WARNING) << __func__ << " - Invalid Audio Configuration=" << toString(audioConfig); _hidl_cb(BluetoothAudioStatus::UNSUPPORTED_CODEC_CONFIGURATION, DataMQ::Descriptor()); return Void(); } else if (!android::bluetooth::audio::IsOffloadCodecConfigurationValid( session_type_, audioConfig.codecConfig())) { _hidl_cb(BluetoothAudioStatus::UNSUPPORTED_CODEC_CONFIGURATION, DataMQ::Descriptor()); return Void(); } return BluetoothAudioProvider::startSession(hostIf, audioConfig, _hidl_cb); } Return<void> A2dpOffloadAudioProvider::onSessionReady( startSession_cb _hidl_cb) { BluetoothAudioSessionReport_2_2::OnSessionStarted(session_type_, stack_iface_, nullptr, audio_config_); _hidl_cb(BluetoothAudioStatus::SUCCESS, DataMQ::Descriptor()); return Void(); } } // namespace implementation } // namespace V2_2 } // namespace audio } // namespace bluetooth } // namespace hardware } // namespace android
bluetooth/audio/2.2/default/A2dpOffloadAudioProvider.h 0 → 100644 +48 −0 Original line number Diff line number Diff line /* * 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. */ #pragma once #include "BluetoothAudioProvider.h" namespace android { namespace hardware { namespace bluetooth { namespace audio { namespace V2_2 { namespace implementation { class A2dpOffloadAudioProvider : public BluetoothAudioProvider { public: A2dpOffloadAudioProvider(); bool isValid(const V2_1::SessionType& sessionType) override; bool isValid(const V2_0::SessionType& sessionType) override; Return<void> startSession(const sp<V2_0::IBluetoothAudioPort>& hostIf, const V2_0::AudioConfiguration& audioConfig, startSession_cb _hidl_cb) override; private: Return<void> onSessionReady(startSession_cb _hidl_cb) override; }; } // namespace implementation } // namespace V2_2 } // namespace audio } // namespace bluetooth } // namespace hardware } // namespace android