diff --git a/audio/effect/6.0/IEffectsFactory.hal b/audio/effect/6.0/IEffectsFactory.hal index e08b2deb4b..4c37bad2e2 100644 --- a/audio/effect/6.0/IEffectsFactory.hal +++ b/audio/effect/6.0/IEffectsFactory.hal @@ -48,11 +48,15 @@ interface IEffectsFactory { * stream. * @param ioHandle identifies the output or input stream this effect is * directed to in audio HAL. + * @param device identifies the sink or source device this effect is directed to in the + * audio HAL. Must be specified if session is AudioSessionConsts.DEVICE. + * "device" is the AudioPortHandle used for the device when the audio + * patch is created at the audio HAL. * @return retval operation completion status. * @return result the interface for the created effect. * @return effectId the unique ID of the effect to be used with * IStream::addEffect and IStream::removeEffect methods. */ - createEffect(Uuid uid, AudioSession session, AudioIoHandle ioHandle) + createEffect(Uuid uid, AudioSession session, AudioIoHandle ioHandle, AudioPortHandle device) generates (Result retval, IEffect result, uint64_t effectId); }; diff --git a/audio/effect/all-versions/default/EffectsFactory.cpp b/audio/effect/all-versions/default/EffectsFactory.cpp index 6283e7bc13..acce7deaad 100644 --- a/audio/effect/all-versions/default/EffectsFactory.cpp +++ b/audio/effect/all-versions/default/EffectsFactory.cpp @@ -133,9 +133,9 @@ exit: return Void(); } -Return EffectsFactory::getDescriptor(const Uuid& uid, getDescriptor_cb _hidl_cb) { +Return EffectsFactory::getDescriptor(const Uuid& uuid, getDescriptor_cb _hidl_cb) { effect_uuid_t halUuid; - HidlUtils::uuidToHal(uid, &halUuid); + HidlUtils::uuidToHal(uuid, &halUuid); effect_descriptor_t halDescriptor; status_t status = EffectGetDescriptor(&halUuid, &halDescriptor); EffectDescriptor descriptor; @@ -154,13 +154,31 @@ Return EffectsFactory::getDescriptor(const Uuid& uid, getDescriptor_cb _hi return Void(); } -Return EffectsFactory::createEffect(const Uuid& uid, int32_t session, int32_t ioHandle, - createEffect_cb _hidl_cb) { +#if MAJOR_VERSION <= 5 +Return EffectsFactory::createEffect(const Uuid& uuid, int32_t session, int32_t ioHandle, + EffectsFactory::createEffect_cb _hidl_cb) { + return createEffectImpl(uuid, session, ioHandle, AUDIO_PORT_HANDLE_NONE, _hidl_cb); +} +#else +Return EffectsFactory::createEffect(const Uuid& uuid, int32_t session, int32_t ioHandle, + int32_t device, + EffectsFactory::createEffect_cb _hidl_cb) { + return createEffectImpl(uuid, session, ioHandle, device, _hidl_cb); +} +#endif + +Return EffectsFactory::createEffectImpl(const Uuid& uuid, int32_t session, int32_t ioHandle, + int32_t device, createEffect_cb _hidl_cb) { effect_uuid_t halUuid; - HidlUtils::uuidToHal(uid, &halUuid); + HidlUtils::uuidToHal(uuid, &halUuid); effect_handle_t handle; Result retval(Result::OK); - status_t status = EffectCreate(&halUuid, session, ioHandle, &handle); + status_t status; + if (session == AUDIO_SESSION_DEVICE) { + status = EffectCreateOnDevice(&halUuid, device, ioHandle, &handle); + } else { + status = EffectCreate(&halUuid, session, ioHandle, &handle); + } sp effect; uint64_t effectId = EffectMap::INVALID_ID; if (status == OK) { diff --git a/audio/effect/all-versions/default/EffectsFactory.h b/audio/effect/all-versions/default/EffectsFactory.h index f0d09ec3a4..0b86836e4b 100644 --- a/audio/effect/all-versions/default/EffectsFactory.h +++ b/audio/effect/all-versions/default/EffectsFactory.h @@ -47,9 +47,15 @@ using namespace ::android::hardware::audio::effect::CPP_VERSION; struct EffectsFactory : public IEffectsFactory { // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffectsFactory follow. Return getAllDescriptors(getAllDescriptors_cb _hidl_cb) override; - Return getDescriptor(const Uuid& uid, getDescriptor_cb _hidl_cb) override; - Return createEffect(const Uuid& uid, int32_t session, int32_t ioHandle, + Return getDescriptor(const Uuid& uuid, getDescriptor_cb _hidl_cb) override; +#if MAJOR_VERSION <= 5 + Return createEffect(const Uuid& uuid, int32_t session, int32_t ioHandle, createEffect_cb _hidl_cb) override; +#else + Return createEffect(const Uuid& uuid, int32_t session, int32_t ioHandle, int32_t device, + createEffect_cb _hidl_cb) override; +#endif + Return debugDump( const hidl_handle& fd); //< in CPP_VERSION::IEffectsFactory only, alias of debug Return debug(const hidl_handle& fd, const hidl_vec& options) override; @@ -57,6 +63,8 @@ struct EffectsFactory : public IEffectsFactory { private: static sp dispatchEffectInstanceCreation(const effect_descriptor_t& halDescriptor, effect_handle_t handle); + Return createEffectImpl(const Uuid& uuid, int32_t session, int32_t ioHandle, + int32_t device, createEffect_cb _hidl_cb); }; extern "C" IEffectsFactory* HIDL_FETCH_IEffectsFactory(const char* name); diff --git a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp index 3c712b5ca3..c151d3ad22 100644 --- a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp +++ b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp @@ -134,13 +134,16 @@ EFFECT_TEST(AudioEffectsFactoryHidlTest, CreateEffect) { Result retval = Result::NOT_INITIALIZED; sp effect; ret = effectsFactory->createEffect( - effectUuid, 1 /*session*/, 1 /*ioHandle*/, - [&](Result r, const sp& result, uint64_t /*effectId*/) { - retval = r; - if (r == Result::OK) { - effect = result; - } - }); + effectUuid, 1 /*session*/, 1 /*ioHandle*/, +#if MAJOR_VERSION >= 6 + 0 /*device*/, +#endif + [&](Result r, const sp& result, uint64_t /*effectId*/) { + retval = r; + if (r == Result::OK) { + effect = result; + } + }); EXPECT_TRUE(ret.isOk()); EXPECT_EQ(Result::OK, retval); EXPECT_NE(nullptr, effect.get()); @@ -236,12 +239,15 @@ void AudioEffectHidlTest::findAndCreateEffect(const Uuid& type) { Uuid effectUuid; findEffectInstance(type, &effectUuid); Return ret = effectsFactory->createEffect( - effectUuid, 1 /*session*/, 1 /*ioHandle*/, - [&](Result r, const sp& result, uint64_t /*effectId*/) { - if (r == Result::OK) { - effect = result; - } - }); + effectUuid, 1 /*session*/, 1 /*ioHandle*/, +#if MAJOR_VERSION >= 6 + 0 /*device*/, +#endif + [&](Result r, const sp& result, uint64_t /*effectId*/) { + if (r == Result::OK) { + effect = result; + } + }); ASSERT_TRUE(ret.isOk()); } diff --git a/current.txt b/current.txt index bdfb58fa73..ec8e5d33a2 100644 --- a/current.txt +++ b/current.txt @@ -601,7 +601,7 @@ bca5379d5065e2e08b6ad7308ffc8a71a972fc0698bec678ea32eea786d01cb5 android.hardwar 8bc597d166e07e9eba633267fc2872c4c53d13d3f0025b778c98e13324a165de android.hardware.audio.effect@6.0::IDownmixEffect 9ee022c81e79da6051fde0836c1c1c4d5414e0c9a6cccc0ce17a90346ceb1391 android.hardware.audio.effect@6.0::IEffect 75c99a70577d543359910a0b378bcbf5a0d6076712e58e6864cd8803f76c8684 android.hardware.audio.effect@6.0::IEffectBufferProviderCallback -5910bdd600fc6501a67233a9a3f4f21dda86af08c05497322712600131d1fa8f android.hardware.audio.effect@6.0::IEffectsFactory +b138d519696f23af2c7cb92c532178c35f4b3a5c1b689260b1c308fe00249f8b android.hardware.audio.effect@6.0::IEffectsFactory dd377f404a8e71f6191d295e10067db629b0f0c28e594af906f2bea5d87fe2cc android.hardware.audio.effect@6.0::IEnvironmentalReverbEffect 455e085e136767302ec34d02b51a085c310e79bf500b76dda7c96a7f3637f11a android.hardware.audio.effect@6.0::IEqualizerEffect 24b5e107a0cbd2b322f764a4d5f7fb8b5d8c337a060b9a4a26b9af050c57b5d0 android.hardware.audio.effect@6.0::ILoudnessEnhancerEffect