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
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 1e798e1..e8fdd74 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 @@
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 7d17099..1b25f17 100644
--- a/audio/aidl/android/hardware/audio/core/IModule.aidl
+++ b/audio/aidl/android/hardware/audio/core/IModule.aidl
@@ -822,4 +822,15 @@
* @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 b60b0fd..0e58add 100644
--- a/audio/aidl/android/hardware/audio/core/IStreamOut.aidl
+++ b/audio/aidl/android/hardware/audio/core/IStreamOut.aidl
@@ -157,7 +157,8 @@
*
* 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 @@
*
* 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 9ca26d2..40d32b3 100644
--- a/audio/aidl/default/Module.cpp
+++ b/audio/aidl/default/Module.cpp
@@ -1145,4 +1145,10 @@
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 555506a..c09520f 100644
--- a/audio/aidl/default/include/core-impl/Module.h
+++ b/audio/aidl/default/include/core-impl/Module.h
@@ -114,6 +114,7 @@
::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 21ad0e6..fa2fce8 100644
--- a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
@@ -1907,6 +1907,12 @@
}
}
+TEST_P(AudioCoreModule, BluetoothVariableLatency) {
+ bool isSupported = false;
+ EXPECT_IS_OK(module->supportsVariableLatency(&isSupported));
+ LOG(INFO) << "supportsVariableLatency: " << isSupported;
+}
+
class AudioCoreBluetooth : public AudioCoreModuleBase, public testing::TestWithParam<std::string> {
public:
void SetUp() override {