Merge "Audio effect HAL: Add device ID to createEffect API" am: 7408b1d575 am: a462b797c2

Change-Id: I942c516054a0e6c9ad83edbe767db15b2422e96f
This commit is contained in:
Automerger Merge Worker 2020-01-13 22:05:38 +00:00
commit 84e61fa46d
5 changed files with 59 additions and 23 deletions

View file

@ -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);
};

View file

@ -133,9 +133,9 @@ exit:
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;
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<void> EffectsFactory::getDescriptor(const Uuid& uid, getDescriptor_cb _hi
return Void();
}
Return<void> EffectsFactory::createEffect(const Uuid& uid, int32_t session, int32_t ioHandle,
createEffect_cb _hidl_cb) {
#if MAJOR_VERSION <= 5
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;
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<IEffect> effect;
uint64_t effectId = EffectMap::INVALID_ID;
if (status == OK) {

View file

@ -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<void> getAllDescriptors(getAllDescriptors_cb _hidl_cb) override;
Return<void> getDescriptor(const Uuid& uid, getDescriptor_cb _hidl_cb) override;
Return<void> createEffect(const Uuid& uid, int32_t session, int32_t ioHandle,
Return<void> getDescriptor(const Uuid& uuid, getDescriptor_cb _hidl_cb) override;
#if MAJOR_VERSION <= 5
Return<void> createEffect(const Uuid& uuid, int32_t session, int32_t ioHandle,
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(
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;
@ -57,6 +63,8 @@ struct EffectsFactory : public IEffectsFactory {
private:
static sp<IEffect> dispatchEffectInstanceCreation(const effect_descriptor_t& halDescriptor,
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);

View file

@ -96,13 +96,16 @@ TEST_P(AudioEffectsFactoryHidlTest, CreateEffect) {
Result retval = Result::NOT_INITIALIZED;
sp<IEffect> effect;
ret = effectsFactory->createEffect(
effectUuid, 1 /*session*/, 1 /*ioHandle*/,
[&](Result r, const sp<IEffect>& 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<IEffect>& 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());
@ -191,12 +194,15 @@ void AudioEffectHidlTest::findAndCreateEffect(const Uuid& type) {
Uuid effectUuid;
findEffectInstance(type, &effectUuid);
Return<void> ret = effectsFactory->createEffect(
effectUuid, 1 /*session*/, 1 /*ioHandle*/,
[&](Result r, const sp<IEffect>& 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<IEffect>& result, uint64_t /*effectId*/) {
if (r == Result::OK) {
effect = result;
}
});
ASSERT_TRUE(ret.isOk());
}

View file

@ -606,7 +606,7 @@ b495a43bd6ff0c34a391824b0ba1a3f3f34b4a869690611a9a0afc404d75aa84 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