Merge "Audio effect HAL: Add device ID to createEffect API"

This commit is contained in:
Eric Laurent
2020-01-13 21:39:45 +00:00
committed by Gerrit Code Review
5 changed files with 59 additions and 23 deletions

View File

@@ -48,11 +48,15 @@ interface IEffectsFactory {
* stream. * stream.
* @param ioHandle identifies the output or input stream this effect is * @param ioHandle identifies the output or input stream this effect is
* directed to in audio HAL. * 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 retval operation completion status.
* @return result the interface for the created effect. * @return result the interface for the created effect.
* @return effectId the unique ID of the effect to be used with * @return effectId the unique ID of the effect to be used with
* IStream::addEffect and IStream::removeEffect methods. * 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); generates (Result retval, IEffect result, uint64_t effectId);
}; };

View File

@@ -133,9 +133,9 @@ exit:
return Void(); return Void();
} }
Return<void> EffectsFactory::getDescriptor(const Uuid& uid, getDescriptor_cb _hidl_cb) { Return<void> EffectsFactory::getDescriptor(const Uuid& uuid, getDescriptor_cb _hidl_cb) {
effect_uuid_t halUuid; effect_uuid_t halUuid;
HidlUtils::uuidToHal(uid, &halUuid); HidlUtils::uuidToHal(uuid, &halUuid);
effect_descriptor_t halDescriptor; effect_descriptor_t halDescriptor;
status_t status = EffectGetDescriptor(&halUuid, &halDescriptor); status_t status = EffectGetDescriptor(&halUuid, &halDescriptor);
EffectDescriptor descriptor; EffectDescriptor descriptor;
@@ -154,13 +154,31 @@ Return<void> EffectsFactory::getDescriptor(const Uuid& uid, getDescriptor_cb _hi
return Void(); return Void();
} }
Return<void> EffectsFactory::createEffect(const Uuid& uid, int32_t session, int32_t ioHandle, #if MAJOR_VERSION <= 5
createEffect_cb _hidl_cb) { Return<void> 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<void> 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<void> EffectsFactory::createEffectImpl(const Uuid& uuid, int32_t session, int32_t ioHandle,
int32_t device, createEffect_cb _hidl_cb) {
effect_uuid_t halUuid; effect_uuid_t halUuid;
HidlUtils::uuidToHal(uid, &halUuid); HidlUtils::uuidToHal(uuid, &halUuid);
effect_handle_t handle; effect_handle_t handle;
Result retval(Result::OK); 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<IEffect> effect; sp<IEffect> effect;
uint64_t effectId = EffectMap::INVALID_ID; uint64_t effectId = EffectMap::INVALID_ID;
if (status == OK) { if (status == OK) {

View File

@@ -47,9 +47,15 @@ using namespace ::android::hardware::audio::effect::CPP_VERSION;
struct EffectsFactory : public IEffectsFactory { struct EffectsFactory : public IEffectsFactory {
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffectsFactory follow. // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffectsFactory follow.
Return<void> getAllDescriptors(getAllDescriptors_cb _hidl_cb) override; Return<void> getAllDescriptors(getAllDescriptors_cb _hidl_cb) override;
Return<void> getDescriptor(const Uuid& uid, getDescriptor_cb _hidl_cb) override; Return<void> getDescriptor(const Uuid& uuid, getDescriptor_cb _hidl_cb) override;
Return<void> createEffect(const Uuid& uid, int32_t session, int32_t ioHandle, #if MAJOR_VERSION <= 5
Return<void> createEffect(const Uuid& uuid, int32_t session, int32_t ioHandle,
createEffect_cb _hidl_cb) override; createEffect_cb _hidl_cb) override;
#else
Return<void> createEffect(const Uuid& uuid, int32_t session, int32_t ioHandle, int32_t device,
createEffect_cb _hidl_cb) override;
#endif
Return<void> debugDump( Return<void> debugDump(
const hidl_handle& fd); //< in CPP_VERSION::IEffectsFactory only, alias of debug const hidl_handle& fd); //< in CPP_VERSION::IEffectsFactory only, alias of debug
Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
@@ -57,6 +63,8 @@ struct EffectsFactory : public IEffectsFactory {
private: private:
static sp<IEffect> dispatchEffectInstanceCreation(const effect_descriptor_t& halDescriptor, static sp<IEffect> dispatchEffectInstanceCreation(const effect_descriptor_t& halDescriptor,
effect_handle_t handle); effect_handle_t handle);
Return<void> 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); extern "C" IEffectsFactory* HIDL_FETCH_IEffectsFactory(const char* name);

View File

@@ -96,13 +96,16 @@ TEST_P(AudioEffectsFactoryHidlTest, CreateEffect) {
Result retval = Result::NOT_INITIALIZED; Result retval = Result::NOT_INITIALIZED;
sp<IEffect> effect; sp<IEffect> effect;
ret = effectsFactory->createEffect( ret = effectsFactory->createEffect(
effectUuid, 1 /*session*/, 1 /*ioHandle*/, effectUuid, 1 /*session*/, 1 /*ioHandle*/,
[&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) { #if MAJOR_VERSION >= 6
retval = r; 0 /*device*/,
if (r == Result::OK) { #endif
effect = result; [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) {
} retval = r;
}); if (r == Result::OK) {
effect = result;
}
});
EXPECT_TRUE(ret.isOk()); EXPECT_TRUE(ret.isOk());
EXPECT_EQ(Result::OK, retval); EXPECT_EQ(Result::OK, retval);
EXPECT_NE(nullptr, effect.get()); EXPECT_NE(nullptr, effect.get());
@@ -191,12 +194,15 @@ void AudioEffectHidlTest::findAndCreateEffect(const Uuid& type) {
Uuid effectUuid; Uuid effectUuid;
findEffectInstance(type, &effectUuid); findEffectInstance(type, &effectUuid);
Return<void> ret = effectsFactory->createEffect( Return<void> ret = effectsFactory->createEffect(
effectUuid, 1 /*session*/, 1 /*ioHandle*/, effectUuid, 1 /*session*/, 1 /*ioHandle*/,
[&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) { #if MAJOR_VERSION >= 6
if (r == Result::OK) { 0 /*device*/,
effect = result; #endif
} [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) {
}); if (r == Result::OK) {
effect = result;
}
});
ASSERT_TRUE(ret.isOk()); ASSERT_TRUE(ret.isOk());
} }

View File

@@ -600,7 +600,7 @@ b495a43bd6ff0c34a391824b0ba1a3f3f34b4a869690611a9a0afc404d75aa84 android.hardwar
8bc597d166e07e9eba633267fc2872c4c53d13d3f0025b778c98e13324a165de android.hardware.audio.effect@6.0::IDownmixEffect 8bc597d166e07e9eba633267fc2872c4c53d13d3f0025b778c98e13324a165de android.hardware.audio.effect@6.0::IDownmixEffect
9ee022c81e79da6051fde0836c1c1c4d5414e0c9a6cccc0ce17a90346ceb1391 android.hardware.audio.effect@6.0::IEffect 9ee022c81e79da6051fde0836c1c1c4d5414e0c9a6cccc0ce17a90346ceb1391 android.hardware.audio.effect@6.0::IEffect
75c99a70577d543359910a0b378bcbf5a0d6076712e58e6864cd8803f76c8684 android.hardware.audio.effect@6.0::IEffectBufferProviderCallback 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 dd377f404a8e71f6191d295e10067db629b0f0c28e594af906f2bea5d87fe2cc android.hardware.audio.effect@6.0::IEnvironmentalReverbEffect
455e085e136767302ec34d02b51a085c310e79bf500b76dda7c96a7f3637f11a android.hardware.audio.effect@6.0::IEqualizerEffect 455e085e136767302ec34d02b51a085c310e79bf500b76dda7c96a7f3637f11a android.hardware.audio.effect@6.0::IEqualizerEffect
24b5e107a0cbd2b322f764a4d5f7fb8b5d8c337a060b9a4a26b9af050c57b5d0 android.hardware.audio.effect@6.0::ILoudnessEnhancerEffect 24b5e107a0cbd2b322f764a4d5f7fb8b5d8c337a060b9a4a26b9af050c57b5d0 android.hardware.audio.effect@6.0::ILoudnessEnhancerEffect