From e2432ea1a71a61027b86673955618205a3b5ac9b Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Thu, 12 Jan 2023 17:47:31 +0100 Subject: [PATCH] audio: Add supportsBluetoothVariableLatency API to IModule Add API to query if the Module supports control of variable latency over playback paths. Bug: 197823000 Test: atest VtsHalAudioCoreTargetTest Change-Id: I3a08d682a1a639d8373869725e12702fff962d53 --- .../current/android/hardware/audio/core/IModule.aidl | 1 + audio/aidl/android/hardware/audio/core/IModule.aidl | 11 +++++++++++ .../aidl/android/hardware/audio/core/IStreamOut.aidl | 6 ++++-- audio/aidl/default/Module.cpp | 6 ++++++ audio/aidl/default/include/core-impl/Module.h | 1 + audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp | 6 ++++++ 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/audio/aidl/aidl_api/android.hardware.audio.core/current/android/hardware/audio/core/IModule.aidl b/audio/aidl/aidl_api/android.hardware.audio.core/current/android/hardware/audio/core/IModule.aidl index 1e798e16f8..e8fdd7469c 100644 --- a/audio/aidl/aidl_api/android.hardware.audio.core/current/android/hardware/audio/core/IModule.aidl +++ b/audio/aidl/aidl_api/android.hardware.audio.core/current/android/hardware/audio/core/IModule.aidl @@ -69,6 +69,7 @@ interface IModule { void addDeviceEffect(int portConfigId, in android.hardware.audio.effect.IEffect effect); void removeDeviceEffect(int portConfigId, in android.hardware.audio.effect.IEffect effect); android.media.audio.common.AudioMMapPolicyInfo[] getMmapPolicyInfos(android.media.audio.common.AudioMMapPolicyType mmapPolicyType); + boolean supportsVariableLatency(); @VintfStability parcelable OpenInputStreamArguments { int portConfigId; diff --git a/audio/aidl/android/hardware/audio/core/IModule.aidl b/audio/aidl/android/hardware/audio/core/IModule.aidl index 7d170992e3..1b25f17805 100644 --- a/audio/aidl/android/hardware/audio/core/IModule.aidl +++ b/audio/aidl/android/hardware/audio/core/IModule.aidl @@ -822,4 +822,15 @@ interface IModule { * @return The vector with mmap policy information. */ AudioMMapPolicyInfo[] getMmapPolicyInfos(AudioMMapPolicyType mmapPolicyType); + + /** + * Indicates if this module supports variable latency control for instance + * over Bluetooth A2DP or LE Audio links. + * + * If supported, all instances of IStreamOut interface returned by this module must + * implement getRecommendedLatencyModes() and setLatencyMode() APIs. + * + * @return Whether the module supports variable latency control. + */ + boolean supportsVariableLatency(); } diff --git a/audio/aidl/android/hardware/audio/core/IStreamOut.aidl b/audio/aidl/android/hardware/audio/core/IStreamOut.aidl index b60b0fd4de..0e58addd7d 100644 --- a/audio/aidl/android/hardware/audio/core/IStreamOut.aidl +++ b/audio/aidl/android/hardware/audio/core/IStreamOut.aidl @@ -157,7 +157,8 @@ interface IStreamOut { * * Implementation for this method is mandatory only on specific spatial * audio streams indicated by AUDIO_OUTPUT_FLAG_SPATIALIZER flag if they can - * be routed to a BT classic sink. + * be routed to a BT sinks or if the implementation indicates support + * on all streams via IModule.supportsVariableLatency(). * * @return Currently supported latency modes. * @throws EX_ILLEGAL_STATE If the stream is closed. @@ -172,7 +173,8 @@ interface IStreamOut { * * Implementation for this method is mandatory only on specific spatial * audio streams indicated by AUDIO_OUTPUT_FLAG_SPATIALIZER flag if they can - * be routed to a BT classic sink. + * be routed to a BT sinks or if the implementation indicates support + * on all streams via IModule.supportsVariableLatency(). * * @throws EX_ILLEGAL_ARGUMENT If the specified mode is not supported. * @throws EX_ILLEGAL_STATE If the stream is closed. diff --git a/audio/aidl/default/Module.cpp b/audio/aidl/default/Module.cpp index 9ca26d2ba7..40d32b35fc 100644 --- a/audio/aidl/default/Module.cpp +++ b/audio/aidl/default/Module.cpp @@ -1145,4 +1145,10 @@ ndk::ScopedAStatus Module::getMmapPolicyInfos(AudioMMapPolicyType mmapPolicyType return ndk::ScopedAStatus::ok(); } +ndk::ScopedAStatus Module::supportsVariableLatency(bool* _aidl_return) { + LOG(DEBUG) << __func__; + *_aidl_return = false; + return ndk::ScopedAStatus::ok(); +} + } // namespace aidl::android::hardware::audio::core diff --git a/audio/aidl/default/include/core-impl/Module.h b/audio/aidl/default/include/core-impl/Module.h index 555506a9ba..c09520f19b 100644 --- a/audio/aidl/default/include/core-impl/Module.h +++ b/audio/aidl/default/include/core-impl/Module.h @@ -114,6 +114,7 @@ class Module : public BnModule { ::aidl::android::media::audio::common::AudioMMapPolicyType mmapPolicyType, std::vector<::aidl::android::media::audio::common::AudioMMapPolicyInfo>* _aidl_return) override; + ndk::ScopedAStatus supportsVariableLatency(bool* _aidl_return) override; void cleanUpPatch(int32_t patchId); ndk::ScopedAStatus createStreamContext( diff --git a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp index 21ad0e642d..fa2fce8bcd 100644 --- a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp +++ b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp @@ -1907,6 +1907,12 @@ TEST_P(AudioCoreModule, GetMmapPolicyInfos) { } } +TEST_P(AudioCoreModule, BluetoothVariableLatency) { + bool isSupported = false; + EXPECT_IS_OK(module->supportsVariableLatency(&isSupported)); + LOG(INFO) << "supportsVariableLatency: " << isSupported; +} + class AudioCoreBluetooth : public AudioCoreModuleBase, public testing::TestWithParam { public: void SetUp() override {