Effect AIDL: queryEffect with Descriptor for all effects implementation
Add queryEffect for effect libraries.
Change Descriptor in each effect implementation to be static so
extern C function can access.
Update vts test cases.
Bug: 261646550
Test: atest VtsHalAudioEffectTargetTest
Change-Id: I8e5d7240db31a0d09b17541c39d9e4c15e1eea73
diff --git a/audio/aidl/default/include/effect-impl/EffectImpl.h b/audio/aidl/default/include/effect-impl/EffectImpl.h
index f5e2aec..e7d081f 100644
--- a/audio/aidl/default/include/effect-impl/EffectImpl.h
+++ b/audio/aidl/default/include/effect-impl/EffectImpl.h
@@ -28,6 +28,9 @@
#include "effect-impl/EffectThread.h"
#include "effect-impl/EffectTypes.h"
+extern "C" binder_exception_t destroyEffect(
+ const std::shared_ptr<aidl::android::hardware::audio::effect::IEffect>& instanceSp);
+
namespace aidl::android::hardware::audio::effect {
class EffectImpl : public BnEffect, public EffectThread {
diff --git a/audio/aidl/default/include/effect-impl/EffectTypes.h b/audio/aidl/default/include/effect-impl/EffectTypes.h
index fc6a01d..58c8672 100644
--- a/audio/aidl/default/include/effect-impl/EffectTypes.h
+++ b/audio/aidl/default/include/effect-impl/EffectTypes.h
@@ -26,10 +26,14 @@
std::shared_ptr<aidl::android::hardware::audio::effect::IEffect>*);
typedef binder_exception_t (*EffectDestroyFunctor)(
const std::shared_ptr<aidl::android::hardware::audio::effect::IEffect>&);
+typedef binder_exception_t (*EffectQueryFunctor)(
+ const ::aidl::android::media::audio::common::AudioUuid*,
+ aidl::android::hardware::audio::effect::Descriptor*);
struct effect_dl_interface_s {
EffectCreateFunctor createEffectFunc;
EffectDestroyFunctor destroyEffectFunc;
+ EffectQueryFunctor queryEffectFunc;
};
namespace aidl::android::hardware::audio::effect {
@@ -102,6 +106,15 @@
} \
} while (0)
+#define RETURN_IF_BINDER_EXCEPTION(functor) \
+ { \
+ binder_exception_t exception = functor; \
+ if (EX_NONE != exception) { \
+ LOG(ERROR) << #functor << ": failed with error " << exception; \
+ return ndk::ScopedAStatus::fromExceptionCode(exception); \
+ } \
+ }
+
static inline bool stringToUuid(const char* str,
::aidl::android::media::audio::common::AudioUuid* uuid) {
RETURN_VALUE_IF(!uuid || !str, false, "nullPtr");
diff --git a/audio/aidl/default/include/effectFactory-impl/EffectFactory.h b/audio/aidl/default/include/effectFactory-impl/EffectFactory.h
index 7edace0..5903276 100644
--- a/audio/aidl/default/include/effectFactory-impl/EffectFactory.h
+++ b/audio/aidl/default/include/effectFactory-impl/EffectFactory.h
@@ -20,6 +20,7 @@
#include <map>
#include <optional>
#include <set>
+#include <tuple>
#include <vector>
#include <aidl/android/hardware/audio/effect/BnFactory.h>
@@ -37,14 +38,14 @@
* @param in_type Type UUID.
* @param in_instance Instance UUID.
* @param in_proxy Proxy UUID.
- * @param out_descriptor List of identities .
+ * @param out_descriptor List of Descriptors.
* @return ndk::ScopedAStatus
*/
ndk::ScopedAStatus queryEffects(
const std::optional<::aidl::android::media::audio::common::AudioUuid>& in_type,
const std::optional<::aidl::android::media::audio::common::AudioUuid>& in_instance,
const std::optional<::aidl::android::media::audio::common::AudioUuid>& in_proxy,
- std::vector<Descriptor::Identity>* out_descriptor) override;
+ std::vector<Descriptor>* out_descriptor) override;
/**
* @brief Query list of defined processing, with the optional filter by AudioStreamType
@@ -82,12 +83,19 @@
const EffectConfig mConfig;
~Factory();
// Set of effect descriptors supported by the devices.
+ std::set<Descriptor> mDescSet;
std::set<Descriptor::Identity> mIdentitySet;
- std::map<aidl::android::media::audio::common::AudioUuid /* implementationUUID */,
- std::pair<std::unique_ptr<void, std::function<void(void*)>> /* dlHandle */,
- std::unique_ptr<struct effect_dl_interface_s>>>
- mEffectLibMap;
+ static constexpr int kMapEntryHandleIndex = 0;
+ static constexpr int kMapEntryInterfaceIndex = 1;
+ static constexpr int kMapEntryLibNameIndex = 2;
+ typedef std::tuple<std::unique_ptr<void, std::function<void(void*)>> /* dlHandle */,
+ std::unique_ptr<struct effect_dl_interface_s> /* interfaces */,
+ std::string /* library name */>
+ DlEntry;
+
+ std::map<aidl::android::media::audio::common::AudioUuid /* implUUID */, DlEntry> mEffectLibMap;
+
std::map<std::weak_ptr<IEffect>, aidl::android::media::audio::common::AudioUuid,
std::owner_less<>>
mEffectUuidMap;
@@ -101,6 +109,8 @@
const ::aidl::android::media::audio::common::AudioUuid& typeUuid,
const std::optional<::aidl::android::media::audio::common::AudioUuid> proxyUuid);
void loadEffectLibs();
+ /* Get effect_dl_interface_s from library handle */
+ void getDlSyms(DlEntry& entry);
};
} // namespace aidl::android::hardware::audio::effect