diff options
74 files changed, 1001 insertions, 191 deletions
diff --git a/audio/7.1/Android.bp b/audio/7.1/Android.bp index d0d96b6cf6..52980e2626 100644 --- a/audio/7.1/Android.bp +++ b/audio/7.1/Android.bp @@ -13,11 +13,13 @@ hidl_interface { name: "android.hardware.audio@7.1", root: "android.hardware", srcs: [ + "types.hal", "IDevice.hal", "IDevicesFactory.hal", "IPrimaryDevice.hal", "IStreamIn.hal", "IStreamOut.hal", + "IStreamOutLatencyModeCallback.hal", ], interfaces: [ "android.hardware.audio@7.0", diff --git a/audio/7.1/IStreamOut.hal b/audio/7.1/IStreamOut.hal index 092a9a0f40..b2013cff8c 100644 --- a/audio/7.1/IStreamOut.hal +++ b/audio/7.1/IStreamOut.hal @@ -16,7 +16,54 @@ package android.hardware.audio@7.1; +import @7.0::Result; import @7.0::IStreamOut; +import IStreamOutLatencyModeCallback; + interface IStreamOut extends @7.0::IStreamOut { + /** + * Indicates the requested latency mode for this output stream. + * + * The requested mode can be one of the modes returned by + * getRecommendedLatencyModes() API. + * + * Optional method. + * Mandated only on specific spatial audio streams indicated by + * AUDIO_OUTPUT_FLAG_SPATIALIZER flag if they can be routed to a BT classic sink. + * + * @return retval operation completion status. + */ + setLatencyMode(LatencyMode mode) generates (Result retval); + + /** + * Indicates which latency modes are currently supported on this output stream. + * If the transport protocol (e.g Bluetooth A2DP) used by this output stream to reach + * the output device supports variable latency modes, the HAL indicates which + * modes are currently supported. + * The framework can then call setLatencyMode() with one of the supported modes to select + * the desired operation mode. + * + * Optional method. + * Mandated only on specific spatial audio streams indicated by + * AUDIO_OUTPUT_FLAG_SPATIALIZER flag if they can be routed to a BT classic sink. + * + * @return retval operation completion status. + * @return modes currrently supported latency modes. + */ + getRecommendedLatencyModes() generates (Result retval, vec<LatencyMode> modes); + + /** + * Set the callback interface for notifying changes in supported latency modes. + * + * Calling this method with a null pointer will result in releasing + * the callback. + * + * Optional method. + * Mandated only on specific spatial audio streams indicated by + * AUDIO_OUTPUT_FLAG_SPATIALIZER flag if they can be routed to a BT classic sink. + * + * @return retval operation completion status. + */ + setLatencyModeCallback(IStreamOutLatencyModeCallback callback) generates (Result retval); }; diff --git a/audio/7.1/IStreamOutLatencyModeCallback.hal b/audio/7.1/IStreamOutLatencyModeCallback.hal new file mode 100644 index 0000000000..45b453f12f --- /dev/null +++ b/audio/7.1/IStreamOutLatencyModeCallback.hal @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2022 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.audio@7.1; + +/** + * Callback interface for output stream variable latency mode feature. + */ +interface IStreamOutLatencyModeCallback { + /** + * Called with the new list of supported latency modes when a change occurs. + */ + oneway onRecommendedLatencyModeChanged(vec<LatencyMode> modes); +}; diff --git a/audio/7.1/config/api/current.txt b/audio/7.1/config/api/current.txt index 01c2e4bbd5..0a0eb02e19 100644 --- a/audio/7.1/config/api/current.txt +++ b/audio/7.1/config/api/current.txt @@ -62,6 +62,8 @@ package android.audio.policy.configuration.V7_1 { enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_7POINT1; enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_7POINT1POINT2; enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_7POINT1POINT4; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_9POINT1POINT4; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_9POINT1POINT6; enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_HAPTIC_AB; enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_MONO; enum_constant public static final android.audio.policy.configuration.V7_1.AudioChannelMask AUDIO_CHANNEL_OUT_MONO_HAPTIC_A; @@ -125,6 +127,7 @@ package android.audio.policy.configuration.V7_1 { enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET; enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_AUX_DIGITAL; enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_AUX_LINE; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_BLE_BROADCAST; enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_BLE_HEADSET; enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_BLE_SPEAKER; enum_constant public static final android.audio.policy.configuration.V7_1.AudioDevice AUDIO_DEVICE_OUT_BLUETOOTH_A2DP; @@ -284,6 +287,7 @@ package android.audio.policy.configuration.V7_1 { enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_NON_BLOCKING; enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_PRIMARY; enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_RAW; + enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_SPATIALIZER; enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_SYNC; enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_TTS; enum_constant public static final android.audio.policy.configuration.V7_1.AudioInOutFlag AUDIO_OUTPUT_FLAG_VOIP_RX; diff --git a/audio/7.1/config/audio_policy_configuration.xsd b/audio/7.1/config/audio_policy_configuration.xsd index 731bb7c75f..defb50651d 100644 --- a/audio/7.1/config/audio_policy_configuration.xsd +++ b/audio/7.1/config/audio_policy_configuration.xsd @@ -179,6 +179,7 @@ <xs:enumeration value="AUDIO_OUTPUT_FLAG_VOIP_RX" /> <xs:enumeration value="AUDIO_OUTPUT_FLAG_INCALL_MUSIC" /> <xs:enumeration value="AUDIO_OUTPUT_FLAG_GAPLESS_OFFLOAD" /> + <xs:enumeration value="AUDIO_OUTPUT_FLAG_SPATIALIZER" /> <xs:enumeration value="AUDIO_INPUT_FLAG_FAST" /> <xs:enumeration value="AUDIO_INPUT_FLAG_HW_HOTWORD" /> <xs:enumeration value="AUDIO_INPUT_FLAG_RAW" /> @@ -276,6 +277,7 @@ <xs:enumeration value="AUDIO_DEVICE_OUT_ECHO_CANCELLER"/> <xs:enumeration value="AUDIO_DEVICE_OUT_BLE_HEADSET"/> <xs:enumeration value="AUDIO_DEVICE_OUT_BLE_SPEAKER"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_BLE_BROADCAST"/> <xs:enumeration value="AUDIO_DEVICE_OUT_DEFAULT"/> <xs:enumeration value="AUDIO_DEVICE_OUT_STUB"/> @@ -510,6 +512,8 @@ <xs:enumeration value="AUDIO_CHANNEL_OUT_7POINT1"/> <xs:enumeration value="AUDIO_CHANNEL_OUT_7POINT1POINT2"/> <xs:enumeration value="AUDIO_CHANNEL_OUT_7POINT1POINT4"/> + <xs:enumeration value="AUDIO_CHANNEL_OUT_9POINT1POINT4"/> + <xs:enumeration value="AUDIO_CHANNEL_OUT_9POINT1POINT6"/> <xs:enumeration value="AUDIO_CHANNEL_OUT_13POINT_360RA"/> <xs:enumeration value="AUDIO_CHANNEL_OUT_22POINT2"/> <xs:enumeration value="AUDIO_CHANNEL_OUT_MONO_HAPTIC_A"/> diff --git a/audio/7.1/types.hal b/audio/7.1/types.hal new file mode 100644 index 0000000000..9d8ee4def2 --- /dev/null +++ b/audio/7.1/types.hal @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2022 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.audio@7.1; + +/** + * Latency modes used for the variable latency feature on output streams. + * Used by setLatencyMode() and getRecommendedLatencyModes() methods. + */ + +@export(name="audio_latency_mode_t", value_prefix="AUDIO_LATENCY_MODE_") +enum LatencyMode : int32_t { + /** No specific constraint on the latency */ + FREE = 0, + /** A relatively low latency compatible with head tracking operation (e.g less than 100ms) */ + LOW = 1, +}; diff --git a/audio/common/7.1/enums/include/android_audio_policy_configuration_V7_1-enums.h b/audio/common/7.1/enums/include/android_audio_policy_configuration_V7_1-enums.h index 815f869e93..6f6a0ca0c1 100644 --- a/audio/common/7.1/enums/include/android_audio_policy_configuration_V7_1-enums.h +++ b/audio/common/7.1/enums/include/android_audio_policy_configuration_V7_1-enums.h @@ -97,10 +97,12 @@ static inline size_t getChannelCount(AudioChannelMask mask) { case AudioChannelMask::AUDIO_CHANNEL_OUT_13POINT_360RA: case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_13: return 13; + case AudioChannelMask::AUDIO_CHANNEL_OUT_9POINT1POINT4: case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_14: return 14; case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_15: return 15; + case AudioChannelMask::AUDIO_CHANNEL_OUT_9POINT1POINT6: case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_16: return 16; case AudioChannelMask::AUDIO_CHANNEL_INDEX_MASK_17: @@ -170,6 +172,7 @@ static inline bool isOutputDevice(AudioDevice device) { case AudioDevice::AUDIO_DEVICE_OUT_ECHO_CANCELLER: case AudioDevice::AUDIO_DEVICE_OUT_BLE_HEADSET: case AudioDevice::AUDIO_DEVICE_OUT_BLE_SPEAKER: + case AudioDevice::AUDIO_DEVICE_OUT_BLE_BROADCAST: case AudioDevice::AUDIO_DEVICE_OUT_DEFAULT: case AudioDevice::AUDIO_DEVICE_OUT_STUB: return true; diff --git a/audio/core/all-versions/default/StreamOut.cpp b/audio/core/all-versions/default/StreamOut.cpp index d4a89d7bf9..09df4ed43d 100644 --- a/audio/core/all-versions/default/StreamOut.cpp +++ b/audio/core/all-versions/default/StreamOut.cpp @@ -761,6 +761,73 @@ int StreamOut::asyncEventCallback(stream_event_callback_type_t event, void* para ALOGW_IF(!result.isOk(), "Client callback failed: %s", result.description().c_str()); return 0; } + +#if MAJOR_VERSION == 7 && MINOR_VERSION == 1 +Return<Result> StreamOut::setLatencyMode(LatencyMode mode) { + return mStream->set_latency_mode != nullptr + ? Stream::analyzeStatus( + "set_latency_mode", + mStream->set_latency_mode(mStream, + static_cast<audio_latency_mode_t>(mode))) + : Result::NOT_SUPPORTED; +}; + +Return<void> StreamOut::getRecommendedLatencyModes(getRecommendedLatencyModes_cb _hidl_cb) { + Result retval = Result::NOT_SUPPORTED; + hidl_vec<LatencyMode> hidlModes; + size_t num_modes = AUDIO_LATENCY_MODE_CNT; + audio_latency_mode_t modes[AUDIO_LATENCY_MODE_CNT]; + + if (mStream->get_recommended_latency_modes != nullptr && + mStream->get_recommended_latency_modes(mStream, &modes[0], &num_modes) == 0) { + if (num_modes == 0 || num_modes > AUDIO_LATENCY_MODE_CNT) { + ALOGW("%s invalid number of modes returned: %zu", __func__, num_modes); + retval = Result::INVALID_STATE; + } else { + hidlModes.resize(num_modes); + for (size_t i = 0; i < num_modes; ++i) { + hidlModes[i] = static_cast<LatencyMode>(modes[i]); + } + retval = Result::OK; + } + } + _hidl_cb(retval, hidlModes); + return Void(); +}; + +// static +void StreamOut::latencyModeCallback(audio_latency_mode_t* modes, size_t num_modes, void* cookie) { + StreamOut* self = reinterpret_cast<StreamOut*>(cookie); + sp<IStreamOutLatencyModeCallback> callback = self->mLatencyModeCallback.load(); + if (callback.get() == nullptr) return; + + ALOGV("%s", __func__); + + if (num_modes == 0 || num_modes > AUDIO_LATENCY_MODE_CNT) { + ALOGW("%s invalid number of modes returned: %zu", __func__, num_modes); + return; + } + + hidl_vec<LatencyMode> hidlModes(num_modes); + for (size_t i = 0; i < num_modes; ++i) { + hidlModes[i] = static_cast<LatencyMode>(modes[i]); + } + Return<void> result = callback->onRecommendedLatencyModeChanged(hidlModes); + ALOGW_IF(!result.isOk(), "Client callback failed: %s", result.description().c_str()); +} + +Return<Result> StreamOut::setLatencyModeCallback( + const sp<IStreamOutLatencyModeCallback>& callback) { + if (mStream->set_latency_mode_callback == nullptr) return Result::NOT_SUPPORTED; + int result = mStream->set_latency_mode_callback(mStream, StreamOut::latencyModeCallback, this); + if (result == 0) { + mLatencyModeCallback = callback; + } + return Stream::analyzeStatus("set_latency_mode_callback", result, {ENOSYS} /*ignore*/); +}; + +#endif + #endif } // namespace implementation diff --git a/audio/core/all-versions/default/include/core/default/StreamOut.h b/audio/core/all-versions/default/include/core/default/StreamOut.h index 60ad5d5ea1..ce5253fe79 100644 --- a/audio/core/all-versions/default/include/core/default/StreamOut.h +++ b/audio/core/all-versions/default/include/core/default/StreamOut.h @@ -153,6 +153,12 @@ struct StreamOut : public IStreamOut { Result doUpdateSourceMetadata(const SourceMetadata& sourceMetadata); #if MAJOR_VERSION >= 7 Result doUpdateSourceMetadataV7(const SourceMetadata& sourceMetadata); +#if MAJOR_VERSION == 7 && MINOR_VERSION == 1 + Return<Result> setLatencyMode(LatencyMode mode) override; + Return<void> getRecommendedLatencyModes(getRecommendedLatencyModes_cb _hidl_cb) override; + Return<Result> setLatencyModeCallback( + const sp<IStreamOutLatencyModeCallback>& callback) override; +#endif #endif #endif // MAJOR_VERSION >= 4 @@ -163,6 +169,9 @@ struct StreamOut : public IStreamOut { mediautils::atomic_sp<IStreamOutCallback> mCallback; // for non-blocking write and drain #if MAJOR_VERSION >= 6 mediautils::atomic_sp<IStreamOutEventCallback> mEventCallback; +#if MAJOR_VERSION == 7 && MINOR_VERSION == 1 + mediautils::atomic_sp<IStreamOutLatencyModeCallback> mLatencyModeCallback; +#endif #endif std::unique_ptr<CommandMQ> mCommandMQ; std::unique_ptr<DataMQ> mDataMQ; @@ -177,6 +186,9 @@ struct StreamOut : public IStreamOut { #if MAJOR_VERSION >= 6 static int asyncEventCallback(stream_event_callback_type_t event, void* param, void* cookie); +#if MAJOR_VERSION == 7 && MINOR_VERSION == 1 + static void latencyModeCallback(audio_latency_mode_t* modes, size_t num_modes, void* cookie); +#endif #endif }; diff --git a/bluetooth/audio/2.2/OWNERS b/bluetooth/audio/2.2/OWNERS new file mode 100644 index 0000000000..84f5b1e8c0 --- /dev/null +++ b/bluetooth/audio/2.2/OWNERS @@ -0,0 +1,3 @@ +aliceypkuo@google.com +ugoyu@google.com +sattiraju@google.com diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveCapabilities.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveCapabilities.aidl new file mode 100644 index 0000000000..4e5dfe66c2 --- /dev/null +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveCapabilities.aidl @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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 AptxAdaptiveCapabilities { + int[] sampleRateHz; + android.hardware.bluetooth.audio.AptxAdaptiveChannelMode[] channelMode; + byte[] bitsPerSample; + android.hardware.bluetooth.audio.AptxMode[] aptxMode; + android.hardware.bluetooth.audio.AptxSinkBuffering sinkBufferingMs; + android.hardware.bluetooth.audio.AptxAdaptiveTimeToPlay ttp; + android.hardware.bluetooth.audio.AptxAdaptiveInputMode inputMode; + int inputFadeDurationMs; + byte[] aptxAdaptiveConfigStream; +} diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveChannelMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveChannelMode.aidl new file mode 100644 index 0000000000..0499b706ff --- /dev/null +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveChannelMode.aidl @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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="int") @VintfStability +enum AptxAdaptiveChannelMode { + JOINT_STEREO = 0, + MONO = 1, + DUAL_MONO = 2, + TWS_STEREO = 4, + UNKNOWN = 255, +} diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveConfiguration.aidl new file mode 100644 index 0000000000..aab05213b4 --- /dev/null +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveConfiguration.aidl @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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 AptxAdaptiveConfiguration { + int sampleRateHz; + android.hardware.bluetooth.audio.AptxAdaptiveChannelMode channelMode; + byte bitsPerSample; + android.hardware.bluetooth.audio.AptxMode aptxMode; + android.hardware.bluetooth.audio.AptxSinkBuffering sinkBufferingMs; + android.hardware.bluetooth.audio.AptxAdaptiveTimeToPlay ttp; + android.hardware.bluetooth.audio.AptxAdaptiveInputMode inputMode; + int inputFadeDurationMs; + byte[] aptxAdaptiveConfigStream; +} diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveInputMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveInputMode.aidl new file mode 100644 index 0000000000..f7029396c6 --- /dev/null +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveInputMode.aidl @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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="int") @VintfStability +enum AptxAdaptiveInputMode { + STEREO = 0, + DUAL_MONO = 1, +} 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/AptxAdaptiveTimeToPlay.aidl index b385763fa6..35606667cb 100644 --- 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/AptxAdaptiveTimeToPlay.aidl @@ -1,5 +1,5 @@ /* - * Copyright 2021 The Android Open Source Project + * Copyright 2022 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. @@ -33,13 +33,11 @@ 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; - } +parcelable AptxAdaptiveTimeToPlay { + byte lowLowLatency; + byte highLowLatency; + byte lowHighQuality; + byte highHighQuality; + byte lowTws; + byte highTws; } diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxMode.aidl new file mode 100644 index 0000000000..d5dd9d9deb --- /dev/null +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxMode.aidl @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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="int") @VintfStability +enum AptxMode { + UNKNOWN = 0, + HIGH_QUALITY = 4096, + LOW_LATENCY = 8192, + ULTRA_LOW_LATENCY = 16384, +} diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxSinkBuffering.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxSinkBuffering.aidl new file mode 100644 index 0000000000..527418e308 --- /dev/null +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxSinkBuffering.aidl @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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 AptxSinkBuffering { + byte minLowLatency; + byte maxLowLatency; + byte minHighQuality; + byte maxHighQuality; + byte minTws; + byte maxTws; +} 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/CodecCapabilities.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecCapabilities.aidl index 948c04a513..6efdcb745e 100644 --- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecCapabilities.aidl +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecCapabilities.aidl @@ -46,6 +46,7 @@ parcelable CodecCapabilities { android.hardware.bluetooth.audio.AacCapabilities aacCapabilities; android.hardware.bluetooth.audio.LdacCapabilities ldacCapabilities; android.hardware.bluetooth.audio.AptxCapabilities aptxCapabilities; + android.hardware.bluetooth.audio.AptxAdaptiveCapabilities aptxAdaptiveCapabilities; android.hardware.bluetooth.audio.Lc3Capabilities lc3Capabilities; android.hardware.bluetooth.audio.CodecCapabilities.VendorCapabilities vendorCapabilities; } diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecConfiguration.aidl index 32bccd8501..77a6b1b0f2 100644 --- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecConfiguration.aidl +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecConfiguration.aidl @@ -51,6 +51,7 @@ parcelable CodecConfiguration { android.hardware.bluetooth.audio.AacConfiguration aacConfig; android.hardware.bluetooth.audio.LdacConfiguration ldacConfig; android.hardware.bluetooth.audio.AptxConfiguration aptxConfig; + android.hardware.bluetooth.audio.AptxAdaptiveConfiguration aptxAdaptiveConfig; android.hardware.bluetooth.audio.Lc3Configuration lc3Config; android.hardware.bluetooth.audio.CodecConfiguration.VendorConfiguration vendorConfig; } diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl index 3a5f951005..1522cb4fd6 100644 --- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl @@ -42,4 +42,5 @@ enum CodecType { LDAC = 5, LC3 = 6, VENDOR = 7, + APTX_ADAPTIVE = 8, } diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioPort.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioPort.aidl index 9a1557a488..cc3c6419de 100644 --- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioPort.aidl +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioPort.aidl @@ -40,4 +40,6 @@ interface IBluetoothAudioPort { void suspendStream(); void updateSourceMetadata(in android.hardware.audio.common.SourceMetadata sourceMetadata); void updateSinkMetadata(in android.hardware.audio.common.SinkMetadata sinkMetadata); + void setLatencyMode(in android.hardware.bluetooth.audio.LatencyMode latencyMode); + void setCodecType(in android.hardware.bluetooth.audio.CodecType codecType); } diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl index 0dcba2e818..6e0bd9855b 100644 --- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl +++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl @@ -39,4 +39,5 @@ interface IBluetoothAudioProvider { void streamStarted(in android.hardware.bluetooth.audio.BluetoothAudioStatus status); void streamSuspended(in android.hardware.bluetooth.audio.BluetoothAudioStatus status); void updateAudioConfiguration(in android.hardware.bluetooth.audio.AudioConfiguration audioConfig); + void setLowLatencyModeAllowed(in boolean allowed); } 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/LatencyMode.aidl index 766f6376c6..5583679412 100644 --- 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/LatencyMode.aidl @@ -1,5 +1,5 @@ /* - * Copyright 2021 The Android Open Source Project + * Copyright 2022 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. @@ -32,9 +32,9 @@ // later when a module using the interface is updated, e.g., Mainline modules. package android.hardware.bluetooth.audio; -@Backing(type="byte") @VintfStability -enum LeAudioMode { +@Backing(type="int") @VintfStability +enum LatencyMode { UNKNOWN = 0, - UNICAST = 1, - BROADCAST = 2, + LOW_LATENCY = 1, + FREE = 2, } 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/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/android/hardware/bluetooth/audio/AptxAdaptiveCapabilities.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveCapabilities.aidl new file mode 100644 index 0000000000..6a567041bf --- /dev/null +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveCapabilities.aidl @@ -0,0 +1,37 @@ +/* + * Copyright 2022 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.AptxAdaptiveChannelMode; +import android.hardware.bluetooth.audio.AptxMode; +import android.hardware.bluetooth.audio.AptxSinkBuffering; +import android.hardware.bluetooth.audio.AptxAdaptiveTimeToPlay; +import android.hardware.bluetooth.audio.AptxAdaptiveInputMode; + + +@VintfStability +parcelable AptxAdaptiveCapabilities { + int[] sampleRateHz; + AptxAdaptiveChannelMode[] channelMode; + byte[] bitsPerSample; + AptxMode[] aptxMode; + AptxSinkBuffering sinkBufferingMs; + AptxAdaptiveTimeToPlay ttp; + AptxAdaptiveInputMode inputMode; + int inputFadeDurationMs; + byte[] aptxAdaptiveConfigStream; +} diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveChannelMode.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveChannelMode.aidl new file mode 100644 index 0000000000..c5e89b11b7 --- /dev/null +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveChannelMode.aidl @@ -0,0 +1,31 @@ +/* + * Copyright 2022 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="int") +enum AptxAdaptiveChannelMode { + /* Joint Stereo - default mode */ + JOINT_STEREO = 0, + /* Legacy Mono */ + MONO = 1, + /* Two streams L & R in a single channel (TWS) */ + DUAL_MONO = 2, + /* Stereo - For TWS+ where L and R are different links */ + TWS_STEREO = 4, + UNKNOWN = 0xFF, +} diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveConfiguration.aidl new file mode 100644 index 0000000000..84c3119c69 --- /dev/null +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveConfiguration.aidl @@ -0,0 +1,36 @@ +/* + * Copyright 2022 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.AptxAdaptiveChannelMode; +import android.hardware.bluetooth.audio.AptxMode; +import android.hardware.bluetooth.audio.AptxSinkBuffering; +import android.hardware.bluetooth.audio.AptxAdaptiveTimeToPlay; +import android.hardware.bluetooth.audio.AptxAdaptiveInputMode; + +@VintfStability +parcelable AptxAdaptiveConfiguration { + int sampleRateHz; + AptxAdaptiveChannelMode channelMode; + byte bitsPerSample; + AptxMode aptxMode; + AptxSinkBuffering sinkBufferingMs; + AptxAdaptiveTimeToPlay ttp; + AptxAdaptiveInputMode inputMode; + int inputFadeDurationMs; + byte[] aptxAdaptiveConfigStream; +} diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveInputMode.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveInputMode.aidl new file mode 100644 index 0000000000..c2f0fc9008 --- /dev/null +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveInputMode.aidl @@ -0,0 +1,24 @@ +/* + * Copyright 2022 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="int") +enum AptxAdaptiveInputMode { + STEREO = 0x00, + DUAL_MONO = 0x01, +} diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveTimeToPlay.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveTimeToPlay.aidl new file mode 100644 index 0000000000..9bcf1a4658 --- /dev/null +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveTimeToPlay.aidl @@ -0,0 +1,27 @@ +/* + * Copyright 2022 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 +parcelable AptxAdaptiveTimeToPlay { + byte lowLowLatency; + byte highLowLatency; + byte lowHighQuality; + byte highHighQuality; + byte lowTws; + byte highTws; +} diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxMode.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxMode.aidl new file mode 100644 index 0000000000..2422d69fdc --- /dev/null +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxMode.aidl @@ -0,0 +1,24 @@ +/* + * Copyright 2022 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="int") +enum AptxMode { + UNKNOWN = 0x00, + HIGH_QUALITY = 0x1000, + LOW_LATENCY = 0x2000, + ULTRA_LOW_LATENCY = 0x4000, +} diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxSinkBuffering.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxSinkBuffering.aidl new file mode 100644 index 0000000000..3593b5d05d --- /dev/null +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxSinkBuffering.aidl @@ -0,0 +1,28 @@ +/* + * Copyright 2022 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 +parcelable AptxSinkBuffering { + byte minLowLatency; + byte maxLowLatency; + byte minHighQuality; + byte maxHighQuality; + byte minTws; + byte maxTws; +} + 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/CodecCapabilities.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecCapabilities.aidl index 41e243168c..9fcdf1c362 100644 --- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecCapabilities.aidl +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecCapabilities.aidl @@ -18,6 +18,7 @@ package android.hardware.bluetooth.audio; import android.hardware.bluetooth.audio.AacCapabilities; import android.hardware.bluetooth.audio.AptxCapabilities; +import android.hardware.bluetooth.audio.AptxAdaptiveCapabilities; import android.hardware.bluetooth.audio.CodecType; import android.hardware.bluetooth.audio.Lc3Capabilities; import android.hardware.bluetooth.audio.LdacCapabilities; @@ -39,6 +40,7 @@ parcelable CodecCapabilities { AacCapabilities aacCapabilities; LdacCapabilities ldacCapabilities; AptxCapabilities aptxCapabilities; + AptxAdaptiveCapabilities aptxAdaptiveCapabilities; Lc3Capabilities lc3Capabilities; VendorCapabilities vendorCapabilities; } diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecConfiguration.aidl index 3679537af7..5ed12e3179 100644 --- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecConfiguration.aidl +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecConfiguration.aidl @@ -18,6 +18,7 @@ package android.hardware.bluetooth.audio; import android.hardware.bluetooth.audio.AacConfiguration; import android.hardware.bluetooth.audio.AptxConfiguration; +import android.hardware.bluetooth.audio.AptxAdaptiveConfiguration; import android.hardware.bluetooth.audio.CodecType; import android.hardware.bluetooth.audio.Lc3Configuration; import android.hardware.bluetooth.audio.LdacConfiguration; @@ -41,6 +42,7 @@ parcelable CodecConfiguration { AacConfiguration aacConfig; LdacConfiguration ldacConfig; AptxConfiguration aptxConfig; + AptxAdaptiveConfiguration aptxAdaptiveConfig; Lc3Configuration lc3Config; VendorConfiguration vendorConfig; } diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl index 9c3308194e..386876e295 100644 --- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl @@ -27,4 +27,5 @@ enum CodecType { LDAC, LC3, VENDOR, + APTX_ADAPTIVE, } diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioPort.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioPort.aidl index 827f57d91b..81c2ce29cd 100644 --- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioPort.aidl +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioPort.aidl @@ -18,6 +18,8 @@ package android.hardware.bluetooth.audio; import android.hardware.audio.common.SinkMetadata; import android.hardware.audio.common.SourceMetadata; +import android.hardware.bluetooth.audio.CodecType; +import android.hardware.bluetooth.audio.LatencyMode; import android.hardware.bluetooth.audio.PresentationPosition; /** @@ -78,4 +80,18 @@ interface IBluetoothAudioPort { * @param sinkMetadata as passed from Audio Framework */ void updateSinkMetadata(in SinkMetadata sinkMetadata); + + /** + * Called when latency mode is changed. + * + * @param latencyMode latency mode from audio + */ + void setLatencyMode(in LatencyMode latencyMode); + + /** + * Called when codec type is changed. + * + * @param codecType codec type from audio + */ + void setCodecType(in CodecType codecType); } diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl index 6f88f3041a..ca6f691d91 100644 --- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl @@ -82,4 +82,12 @@ interface IBluetoothAudioProvider { * encoding. */ void updateAudioConfiguration(in AudioConfiguration audioConfig); + + /** + * Called when the supported latency mode is updated. + * + * @param allowed If the peripheral devices can't keep up with low latency + * mode, the API will be called with supported is false. + */ + void setLowLatencyModeAllowed(in boolean allowed); } diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioMode.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LatencyMode.aidl index 2cf019e9ad..0c354f73d5 100644 --- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioMode.aidl +++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LatencyMode.aidl @@ -1,5 +1,5 @@ /* - * Copyright 2021 The Android Open Source Project + * Copyright 2022 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. @@ -17,9 +17,9 @@ package android.hardware.bluetooth.audio; @VintfStability -@Backing(type="byte") -enum LeAudioMode { +@Backing(type="int") +enum LatencyMode { UNKNOWN, - UNICAST, - BROADCAST, + LOW_LATENCY, + FREE, } 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/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/BluetoothAudioProvider.cpp b/bluetooth/audio/aidl/default/BluetoothAudioProvider.cpp index c2ffa2efa2..54e82d10fc 100644 --- a/bluetooth/audio/aidl/default/BluetoothAudioProvider.cpp +++ b/bluetooth/audio/aidl/default/BluetoothAudioProvider.cpp @@ -121,6 +121,19 @@ ndk::ScopedAStatus BluetoothAudioProvider::updateAudioConfiguration( return ndk::ScopedAStatus::ok(); } +ndk::ScopedAStatus BluetoothAudioProvider::setLowLatencyModeAllowed( + bool allowed) { + LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_); + + if (stack_iface_ == nullptr) { + LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_) + << " has NO session"; + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); + } + LOG(INFO) << __func__ << " - allowed " << allowed; + return ndk::ScopedAStatus::ok(); +} + void BluetoothAudioProvider::binderDiedCallbackAidl(void* ptr) { LOG(ERROR) << __func__ << " - BluetoothAudio Service died"; auto provider = static_cast<BluetoothAudioProvider*>(ptr); diff --git a/bluetooth/audio/aidl/default/BluetoothAudioProvider.h b/bluetooth/audio/aidl/default/BluetoothAudioProvider.h index f7acbdf7e3..393aaba7b6 100644 --- a/bluetooth/audio/aidl/default/BluetoothAudioProvider.h +++ b/bluetooth/audio/aidl/default/BluetoothAudioProvider.h @@ -46,6 +46,7 @@ class BluetoothAudioProvider : public BnBluetoothAudioProvider { ndk::ScopedAStatus streamSuspended(BluetoothAudioStatus status); ndk::ScopedAStatus updateAudioConfiguration( const AudioConfiguration& audio_config); + ndk::ScopedAStatus setLowLatencyModeAllowed(bool allowed); virtual bool isValid(const SessionType& sessionType) = 0; 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/BluetoothAudioCodecs.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp index b857fb8cf5..a6fd798d97 100644 --- a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp +++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp @@ -360,6 +360,7 @@ BluetoothAudioCodecs::GetA2dpOffloadCodecCapabilities( break; case CodecType::UNKNOWN: case CodecType::VENDOR: + case CodecType::APTX_ADAPTIVE: break; } } @@ -423,6 +424,7 @@ bool BluetoothAudioCodecs::IsOffloadCodecConfigurationValid( return true; } break; + case CodecType::APTX_ADAPTIVE: case CodecType::UNKNOWN: case CodecType::VENDOR: break; @@ -491,4 +493,4 @@ BluetoothAudioCodecs::GetLeAudioOffloadCodecCapabilities( } // namespace bluetooth } // namespace hardware } // namespace android -} // namespace aidl
\ No newline at end of file +} // namespace aidl diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp index f626db83bd..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 = @@ -508,6 +514,36 @@ void BluetoothAudioSession::UpdateSinkMetadata( } } +void BluetoothAudioSession::SetLatencyMode(LatencyMode latency_mode) { + std::lock_guard<std::recursive_mutex> guard(mutex_); + if (!IsSessionReady()) { + LOG(DEBUG) << __func__ << " - SessionType=" << toString(session_type_) + << " has NO session"; + return; + } + + auto hal_retval = stack_iface_->setLatencyMode(latency_mode); + if (!hal_retval.isOk()) { + LOG(WARNING) << __func__ << " - IBluetoothAudioPort SessionType=" + << toString(session_type_) << " failed"; + } +} + +void BluetoothAudioSession::SetCodecType(CodecType codec_type) { + std::lock_guard<std::recursive_mutex> guard(mutex_); + if (!IsSessionReady()) { + LOG(DEBUG) << __func__ << " - SessionType=" << toString(session_type_) + << " has NO session"; + return; + } + + auto hal_retval = stack_iface_->setCodecType(codec_type); + if (!hal_retval.isOk()) { + LOG(WARNING) << __func__ << " - IBluetoothAudioPort SessionType=" + << toString(session_type_) << " failed"; + } +} + bool BluetoothAudioSession::IsAidlAvailable() { if (is_aidl_checked) return is_aidl_available; is_aidl_available = diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.h b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.h index 73bc0f8b4e..5adc0e2f89 100644 --- a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.h +++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.h @@ -20,6 +20,7 @@ #include <aidl/android/hardware/audio/common/SourceMetadata.h> #include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.h> #include <aidl/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.h> +#include <aidl/android/hardware/bluetooth/audio/LatencyMode.h> #include <aidl/android/hardware/bluetooth/audio/SessionType.h> #include <fmq/AidlMessageQueue.h> #include <hardware/audio.h> @@ -164,6 +165,8 @@ class BluetoothAudioSession { bool GetPresentationPosition(PresentationPosition& presentation_position); void UpdateSourceMetadata(const struct source_metadata& source_metadata); void UpdateSinkMetadata(const struct sink_metadata& sink_metadata); + void SetLatencyMode(LatencyMode latency_mode); + void SetCodecType(CodecType codec_type); // The control function writes stream to FMQ size_t OutWritePcmData(const void* buffer, size_t bytes); 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; } diff --git a/bluetooth/audio/utils/session/BluetoothAudioSupportedCodecsDB_2_2.cpp b/bluetooth/audio/utils/session/BluetoothAudioSupportedCodecsDB_2_2.cpp index 4c99b0f620..decff7046f 100644 --- a/bluetooth/audio/utils/session/BluetoothAudioSupportedCodecsDB_2_2.cpp +++ b/bluetooth/audio/utils/session/BluetoothAudioSupportedCodecsDB_2_2.cpp @@ -77,9 +77,13 @@ static AudioLocation monoAudio = AudioLocation::UNKNOWN; // Stores the supported setting of audio location, connected device, and the // channel count for each device std::vector<std::tuple<AudioLocation, uint8_t, uint8_t>> - supportedDeviceSetting = {std::make_tuple(stereoAudio, 2, 1), - std::make_tuple(monoAudio, 1, 2), - std::make_tuple(monoAudio, 1, 1)}; + supportedDeviceSetting = { + // Stereo, two connected device, one for L one for R + std::make_tuple(stereoAudio, 2, 1), + // Stereo, one connected device for both L and R + std::make_tuple(stereoAudio, 1, 2), + // Mono + std::make_tuple(monoAudio, 1, 1)}; bool IsOffloadLeAudioConfigurationValid( const ::android::hardware::bluetooth::audio::V2_1::SessionType& diff --git a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/PrepareModelConfig.aidl b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/PrepareModelConfig.aidl index 85c924fe31..1f44ba724f 100644 --- a/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/PrepareModelConfig.aidl +++ b/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/current/android/hardware/neuralnetworks/PrepareModelConfig.aidl @@ -39,7 +39,8 @@ parcelable PrepareModelConfig { long deadlineNs; ParcelFileDescriptor[] modelCache; ParcelFileDescriptor[] dataCache; - byte[] cacheToken; + byte[32] cacheToken; android.hardware.neuralnetworks.TokenValuePair[] compilationHints; android.hardware.neuralnetworks.ExtensionNameAndPrefix[] extensionNameToPrefix; + const int BYTE_SIZE_OF_CACHE_TOKEN = 32; } diff --git a/neuralnetworks/aidl/android/hardware/neuralnetworks/IDevice.aidl b/neuralnetworks/aidl/android/hardware/neuralnetworks/IDevice.aidl index 821b9febfe..7808fc2b73 100644 --- a/neuralnetworks/aidl/android/hardware/neuralnetworks/IDevice.aidl +++ b/neuralnetworks/aidl/android/hardware/neuralnetworks/IDevice.aidl @@ -39,7 +39,7 @@ interface IDevice { /** * The byte size of the cache token. */ - const int BYTE_SIZE_OF_CACHE_TOKEN = 32; + const int BYTE_SIZE_OF_CACHE_TOKEN = PrepareModelConfig.BYTE_SIZE_OF_CACHE_TOKEN; /** * The maximum number of files for each type of cache in compilation caching. */ diff --git a/neuralnetworks/aidl/android/hardware/neuralnetworks/IPreparedModel.aidl b/neuralnetworks/aidl/android/hardware/neuralnetworks/IPreparedModel.aidl index 949804ea59..f752750514 100644 --- a/neuralnetworks/aidl/android/hardware/neuralnetworks/IPreparedModel.aidl +++ b/neuralnetworks/aidl/android/hardware/neuralnetworks/IPreparedModel.aidl @@ -204,6 +204,12 @@ interface IPreparedModel { * appropriate ErrorStatus value. If the inputs to the function are valid and there is no error, * createReusableExecution must construct a reusable execution. * + * This method will be called when a client requests a reusable execution with consistent + * request and execution config. For single-time execution, + * {@link IPreparedModel::executeSynchronouslyWithConfig} or + * {@link IPreparedModel::executeFencedWithConfig} is preferred, because the overhead of + * setting up a reusable execution can be avoided. + * * @param request The input and output information on which the prepared model is to be * executed. * @param config Specifies the execution configuration parameters. @@ -223,6 +229,10 @@ interface IPreparedModel { * ExecutionConfig} instead of a list of configuration parameters, and ExecutionConfig contains * more configuration parameters than are passed to executeSynchronously. * + * This method is preferred when a client requests a single-time synchronous execution. + * For reusable execution with consistent request and execution config, + * {@link IPreparedModel::createReusableExecution} must be called. + * * @param request The input and output information on which the prepared model is to be * executed. * @param config Specifies the execution configuration parameters. @@ -246,6 +256,10 @@ interface IPreparedModel { * ExecutionConfig} instead of a list of configuration parameters, and ExecutionConfig contains * more configuration parameters than are passed to executeFenced. * + * This method is preferred when a client requests a single-time fenced execution. + * For reusable execution with consistent request and execution config, + * {@link IPreparedModel::createReusableExecution} must be called. + * * @param request The input and output information on which the prepared model is to be * executed. The outputs in the request must have fully specified dimensions. * @param waitFor A vector of sync fence file descriptors. Execution must not start until all diff --git a/neuralnetworks/aidl/android/hardware/neuralnetworks/PrepareModelConfig.aidl b/neuralnetworks/aidl/android/hardware/neuralnetworks/PrepareModelConfig.aidl index 96df968464..55bd291be9 100644 --- a/neuralnetworks/aidl/android/hardware/neuralnetworks/PrepareModelConfig.aidl +++ b/neuralnetworks/aidl/android/hardware/neuralnetworks/PrepareModelConfig.aidl @@ -28,6 +28,11 @@ import android.hardware.neuralnetworks.TokenValuePair; @VintfStability parcelable PrepareModelConfig { /** + * The byte size of the cache token. + */ + const int BYTE_SIZE_OF_CACHE_TOKEN = 32; + + /** * Indicates the intended execution behavior of a prepared model. */ ExecutionPreference preference; @@ -66,7 +71,7 @@ parcelable PrepareModelConfig { */ ParcelFileDescriptor[] dataCache; /** - * A caching token of length IDevice::BYTE_SIZE_OF_CACHE_TOKEN identifying + * A caching token of length BYTE_SIZE_OF_CACHE_TOKEN identifying * the prepared model. The same token will be provided when * retrieving the prepared model from the cache files with * IDevice::prepareModelFromCache. Tokens should be chosen to have a low @@ -77,7 +82,7 @@ parcelable PrepareModelConfig { * indicating that caching information is not provided, this * token must be ignored. */ - byte[] cacheToken; + byte[BYTE_SIZE_OF_CACHE_TOKEN] cacheToken; /** * A vector of token / value pairs represent vendor specific * compilation hints or metadata. The provided TokenValuePairs must not diff --git a/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/Conversions.h b/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/Conversions.h index af587150b1..71a28effdf 100644 --- a/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/Conversions.h +++ b/neuralnetworks/aidl/utils/include/nnapi/hal/aidl/Conversions.h @@ -27,6 +27,7 @@ #include <aidl/android/hardware/neuralnetworks/Extension.h> #include <aidl/android/hardware/neuralnetworks/ExtensionNameAndPrefix.h> #include <aidl/android/hardware/neuralnetworks/ExtensionOperandTypeInformation.h> +#include <aidl/android/hardware/neuralnetworks/IDevice.h> #include <aidl/android/hardware/neuralnetworks/Memory.h> #include <aidl/android/hardware/neuralnetworks/Model.h> #include <aidl/android/hardware/neuralnetworks/Operand.h> @@ -219,6 +220,7 @@ nn::GeneralResult<std::vector<TokenValuePair>> convert( #endif // NN_AIDL_V4_OR_ABOVE nn::GeneralResult<std::vector<int32_t>> toSigned(const std::vector<uint32_t>& vec); +std::vector<uint8_t> toVec(const std::array<uint8_t, IDevice::BYTE_SIZE_OF_CACHE_TOKEN>& token); } // namespace aidl::android::hardware::neuralnetworks::utils diff --git a/neuralnetworks/aidl/utils/src/Conversions.cpp b/neuralnetworks/aidl/utils/src/Conversions.cpp index 9b897c43ac..83fda10ce2 100644 --- a/neuralnetworks/aidl/utils/src/Conversions.cpp +++ b/neuralnetworks/aidl/utils/src/Conversions.cpp @@ -614,7 +614,7 @@ struct overloaded : Ts... { using Ts::operator()...; }; template <class... Ts> -overloaded(Ts...)->overloaded<Ts...>; +overloaded(Ts...) -> overloaded<Ts...>; #ifdef __ANDROID__ nn::GeneralResult<common::NativeHandle> aidlHandleFromNativeHandle( @@ -1190,4 +1190,8 @@ nn::GeneralResult<std::vector<int32_t>> toSigned(const std::vector<uint32_t>& ve return std::vector<int32_t>(vec.begin(), vec.end()); } +std::vector<uint8_t> toVec(const std::array<uint8_t, IDevice::BYTE_SIZE_OF_CACHE_TOKEN>& token) { + return std::vector<uint8_t>(token.begin(), token.end()); +} + } // namespace aidl::android::hardware::neuralnetworks::utils diff --git a/neuralnetworks/aidl/utils/src/Device.cpp b/neuralnetworks/aidl/utils/src/Device.cpp index f3f4fdbba1..b64a40dcaa 100644 --- a/neuralnetworks/aidl/utils/src/Device.cpp +++ b/neuralnetworks/aidl/utils/src/Device.cpp @@ -229,7 +229,6 @@ nn::GeneralResult<nn::SharedPreparedModel> Device::prepareModel( const auto aidlDeadline = NN_TRY(convert(deadline)); auto aidlModelCache = NN_TRY(convert(modelCache)); auto aidlDataCache = NN_TRY(convert(dataCache)); - const auto aidlToken = NN_TRY(convert(token)); const auto cb = ndk::SharedRefBase::make<PreparedModelCallback>(kFeatureLevel); const auto scoped = kDeathHandler.protectCallback(cb.get()); @@ -240,12 +239,13 @@ nn::GeneralResult<nn::SharedPreparedModel> Device::prepareModel( const auto ret = kDevice->prepareModelWithConfig( aidlModel, {aidlPreference, aidlPriority, aidlDeadline, std::move(aidlModelCache), - std::move(aidlDataCache), aidlToken, std::move(aidlHints), + std::move(aidlDataCache), token, std::move(aidlHints), std::move(aidlExtensionPrefix)}, cb); HANDLE_ASTATUS(ret) << "prepareModel failed"; return cb->get(); } + const auto aidlToken = NN_TRY(convert(token)); const auto ret = kDevice->prepareModel(aidlModel, aidlPreference, aidlPriority, aidlDeadline, aidlModelCache, aidlDataCache, aidlToken, cb); HANDLE_ASTATUS(ret) << "prepareModel failed"; diff --git a/neuralnetworks/aidl/utils/src/InvalidDevice.cpp b/neuralnetworks/aidl/utils/src/InvalidDevice.cpp index 33270ff381..44f8ea9ff8 100644 --- a/neuralnetworks/aidl/utils/src/InvalidDevice.cpp +++ b/neuralnetworks/aidl/utils/src/InvalidDevice.cpp @@ -189,7 +189,8 @@ ndk::ScopedAStatus InvalidDevice::prepareModelWithConfig( } } return prepareModel(model, config.preference, config.priority, config.deadlineNs, - config.modelCache, config.dataCache, config.cacheToken, callback); + config.modelCache, config.dataCache, utils::toVec(config.cacheToken), + callback); } ndk::ScopedAStatus InvalidDevice::prepareModelFromCache( diff --git a/neuralnetworks/aidl/vts/functional/Utils.h b/neuralnetworks/aidl/vts/functional/Utils.h index 4e0a4aafa3..ccb0778ac5 100644 --- a/neuralnetworks/aidl/vts/functional/Utils.h +++ b/neuralnetworks/aidl/vts/functional/Utils.h @@ -21,6 +21,7 @@ #include <gtest/gtest.h> #include <algorithm> +#include <array> #include <iosfwd> #include <string> #include <utility> @@ -47,6 +48,7 @@ inline constexpr int64_t kNoDeadline = -1; inline constexpr int64_t kOmittedTimeoutDuration = -1; inline constexpr int64_t kNoDuration = -1; inline const std::vector<uint8_t> kEmptyCacheToken(IDevice::BYTE_SIZE_OF_CACHE_TOKEN); +inline const std::array<uint8_t, IDevice::BYTE_SIZE_OF_CACHE_TOKEN> kEmptyCacheTokenArray{}; // Returns the amount of space needed to store a value of the specified type. // diff --git a/neuralnetworks/aidl/vts/functional/ValidateModel.cpp b/neuralnetworks/aidl/vts/functional/ValidateModel.cpp index 931ba258b3..060434ed08 100644 --- a/neuralnetworks/aidl/vts/functional/ValidateModel.cpp +++ b/neuralnetworks/aidl/vts/functional/ValidateModel.cpp @@ -85,7 +85,7 @@ static void validatePrepareModelWithConfig(const std::shared_ptr<IDevice>& devic std::shared_ptr<PreparedModelCallback> preparedModelCallback = ndk::SharedRefBase::make<PreparedModelCallback>(); const auto prepareLaunchStatus = device->prepareModelWithConfig( - model, {preference, priority, kNoDeadline, {}, {}, kEmptyCacheToken, {}, {}}, + model, {preference, priority, kNoDeadline, {}, {}, kEmptyCacheTokenArray, {}, {}}, preparedModelCallback); ASSERT_FALSE(prepareLaunchStatus.isOk()); ASSERT_EQ(prepareLaunchStatus.getExceptionCode(), EX_SERVICE_SPECIFIC); diff --git a/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.cpp b/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.cpp index 51b4805134..bf87f15aa5 100644 --- a/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.cpp +++ b/neuralnetworks/aidl/vts/functional/VtsHalNeuralnetworks.cpp @@ -72,7 +72,7 @@ void createPreparedModel(const std::shared_ptr<IDevice>& device, const Model& mo kNoDeadline, {}, {}, - kEmptyCacheToken, + kEmptyCacheTokenArray, {}, {}}, preparedModelCallback); diff --git a/neuralnetworks/utils/adapter/aidl/src/Device.cpp b/neuralnetworks/utils/adapter/aidl/src/Device.cpp index 84aaddbe9d..1b90a1ab4b 100644 --- a/neuralnetworks/utils/adapter/aidl/src/Device.cpp +++ b/neuralnetworks/utils/adapter/aidl/src/Device.cpp @@ -312,8 +312,8 @@ ndk::ScopedAStatus Device::prepareModelWithConfig( const std::shared_ptr<IPreparedModelCallback>& callback) { const auto result = adapter::prepareModel( kDevice, kExecutor, model, config.preference, config.priority, config.deadlineNs, - config.modelCache, config.dataCache, config.cacheToken, config.compilationHints, - config.extensionNameToPrefix, callback); + config.modelCache, config.dataCache, utils::toVec(config.cacheToken), + config.compilationHints, config.extensionNameToPrefix, callback); if (!result.has_value()) { const auto& [message, code] = result.error(); const auto aidlCode = utils::convert(code).value_or(ErrorStatus::GENERAL_FAILURE); diff --git a/security/keymint/aidl/android/hardware/security/keymint/DeviceInfo.aidl b/security/keymint/aidl/android/hardware/security/keymint/DeviceInfo.aidl index 153a04f2b5..abb2a7b7cd 100644 --- a/security/keymint/aidl/android/hardware/security/keymint/DeviceInfo.aidl +++ b/security/keymint/aidl/android/hardware/security/keymint/DeviceInfo.aidl @@ -40,7 +40,9 @@ parcelable DeviceInfo { * "vb_state" : "green" / "yellow" / "orange", // Taken from the AVB values * "bootloader_state" : "locked" / "unlocked", // Taken from the AVB values * "vbmeta_digest": bstr, // Taken from the AVB values - * "os_version" : tstr, // Same as android.os.Build.VERSION.release + * ? "os_version" : tstr, // Same as + * // android.os.Build.VERSION.release + * // Not optional for TEE. * "system_patch_level" : uint, // YYYYMMDD * "boot_patch_level" : uint, // YYYYMMDD * "vendor_patch_level" : uint, // YYYYMMDD diff --git a/security/keymint/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp b/security/keymint/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp index 927d7d7daf..e2d75ce099 100644 --- a/security/keymint/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp +++ b/security/keymint/aidl/vts/functional/VtsRemotelyProvisionedComponentTests.cpp @@ -492,7 +492,6 @@ class CertificateRequestTest : public VtsRemotelyProvisionedComponentTests { ASSERT_NE(allowList.find(deviceInfo->get("bootloader_state")->asTstr()->value()), allowList.end()); checkType(deviceInfo, cppbor::BSTR, "vbmeta_digest"); - checkType(deviceInfo, cppbor::TSTR, "os_version"); checkType(deviceInfo, cppbor::UINT, "system_patch_level"); checkType(deviceInfo, cppbor::UINT, "boot_patch_level"); checkType(deviceInfo, cppbor::UINT, "vendor_patch_level"); @@ -502,6 +501,9 @@ class CertificateRequestTest : public VtsRemotelyProvisionedComponentTests { allowList = getAllowedSecurityLevels(); ASSERT_NE(allowList.find(deviceInfo->get("security_level")->asTstr()->value()), allowList.end()); + if (deviceInfo->get("security_level")->asTstr()->value() == "tee") { + checkType(deviceInfo, cppbor::TSTR, "os_version"); + } break; case 1: checkType(deviceInfo, cppbor::TSTR, "security_level"); |