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

am: 5dbea795bb

Change-Id: I7e65a5ddaeac9dfe506cea82a8397341289b5e78
gugelfrei
Eric Laurent 5 years ago committed by android-build-merger
commit 9d90cde38e

@ -105,12 +105,26 @@ status_t EffectsFactoryHalHidl::getDescriptor(
status_t EffectsFactoryHalHidl::createEffect(
const effect_uuid_t *pEffectUuid, int32_t sessionId, int32_t ioId,
sp<EffectHalInterface> *effect) {
int32_t deviceId __unused, sp<EffectHalInterface> *effect) {
if (mEffectsFactory == 0) return NO_INIT;
Uuid hidlUuid;
HidlUtils::uuidFromHal(*pEffectUuid, &hidlUuid);
Result retval = Result::NOT_INITIALIZED;
Return<void> ret = mEffectsFactory->createEffect(
Return<void> ret;
#if MAJOR_VERSION >= 6
ret = mEffectsFactory->createEffect(
hidlUuid, sessionId, ioId, deviceId,
[&](Result r, const sp<IEffect>& result, uint64_t effectId) {
retval = r;
if (retval == Result::OK) {
*effect = new EffectHalHidl(result, effectId);
}
});
#else
if (sessionId == AUDIO_SESSION_DEVICE && ioId == AUDIO_IO_HANDLE_NONE) {
return INVALID_OPERATION;
}
ret = mEffectsFactory->createEffect(
hidlUuid, sessionId, ioId,
[&](Result r, const sp<IEffect>& result, uint64_t effectId) {
retval = r;
@ -118,6 +132,7 @@ status_t EffectsFactoryHalHidl::createEffect(
*effect = new EffectHalHidl(result, effectId);
}
});
#endif
if (ret.isOk()) {
if (retval == Result::OK) return OK;
else if (retval == Result::INVALID_ARGUMENTS) return NAME_NOT_FOUND;

@ -49,7 +49,7 @@ class EffectsFactoryHalHidl : public EffectsFactoryHalInterface, public Conversi
// To release the effect engine, it is necessary to release references
// to the returned effect object.
virtual status_t createEffect(const effect_uuid_t *pEffectUuid,
int32_t sessionId, int32_t ioId,
int32_t sessionId, int32_t ioId, int32_t deviceId,
sp<EffectHalInterface> *effect);
virtual status_t dumpEffects(int fd);

@ -41,7 +41,7 @@ class EffectsFactoryHalInterface : public RefBase
// To release the effect engine, it is necessary to release references
// to the returned effect object.
virtual status_t createEffect(const effect_uuid_t *pEffectUuid,
int32_t sessionId, int32_t ioId,
int32_t sessionId, int32_t ioId, int32_t deviceId,
sp<EffectHalInterface> *effect) = 0;
virtual status_t dumpEffects(int fd) = 0;

@ -164,6 +164,7 @@ DownmixerBufferProvider::DownmixerBufferProvider(
if (mEffectsFactory->createEffect(&sDwnmFxDesc.uuid,
sessionId,
SESSION_ID_INVALID_AND_IGNORED,
AUDIO_PORT_HANDLE_NONE,
&mDownmixInterface) != 0) {
ALOGE("DownmixerBufferProvider() error creating downmixer effect");
mDownmixInterface.clear();

@ -254,7 +254,8 @@ int EffectGetDescriptor(const effect_uuid_t *uuid, effect_descriptor_t *pDescrip
return ret;
}
int EffectCreate(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle)
int doEffectCreate(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, int32_t deviceId,
effect_handle_t *pHandle)
{
list_elem_t *e = gLibraryList;
lib_entry_t *l = NULL;
@ -268,9 +269,9 @@ int EffectCreate(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, eff
}
ALOGV("EffectCreate() UUID: %08X-%04X-%04X-%04X-%02X%02X%02X%02X%02X%02X\n",
uuid->timeLow, uuid->timeMid, uuid->timeHiAndVersion,
uuid->clockSeq, uuid->node[0], uuid->node[1],uuid->node[2],
uuid->node[3],uuid->node[4],uuid->node[5]);
uuid->timeLow, uuid->timeMid, uuid->timeHiAndVersion,
uuid->clockSeq, uuid->node[0], uuid->node[1], uuid->node[2],
uuid->node[3], uuid->node[4], uuid->node[5]);
ret = init();
@ -282,17 +283,29 @@ int EffectCreate(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, eff
pthread_mutex_lock(&gLibLock);
ret = findEffect(NULL, uuid, &l, &d);
if (ret < 0){
if (ret < 0) {
// Sub effects are not associated with the library->effects,
// so, findEffect will fail. Search for the effect in gSubEffectList.
ret = findSubEffect(uuid, &l, &d);
if (ret < 0 ) {
if (ret < 0) {
goto exit;
}
}
// create effect in library
ret = l->desc->create_effect(uuid, sessionId, ioId, &itfe);
if (sessionId == AUDIO_SESSION_DEVICE) {
if (l->desc->version >= EFFECT_LIBRARY_API_VERSION_3_1) {
ALOGI("EffectCreate() create_effect_3_1");
ret = l->desc->create_effect_3_1(uuid, sessionId, ioId, deviceId, &itfe);
} else {
ALOGE("EffectCreate() cannot create device effect on library with API version < 3.1");
ret = -ENOSYS;
}
} else {
ALOGI("EffectCreate() create_effect");
ret = l->desc->create_effect(uuid, sessionId, ioId, &itfe);
}
if (ret != 0) {
ALOGW("EffectCreate() library %s: could not create fx %s, error %d", l->name, d->name, ret);
goto exit;
@ -324,6 +337,16 @@ exit:
return ret;
}
int EffectCreate(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId,
effect_handle_t *pHandle) {
return doEffectCreate(uuid, sessionId, ioId, AUDIO_PORT_HANDLE_NONE, pHandle);
}
int EffectCreateOnDevice(const effect_uuid_t *uuid, int32_t deviceId, int32_t ioId,
effect_handle_t *pHandle) {
return doEffectCreate(uuid, AUDIO_SESSION_DEVICE, ioId, deviceId, pHandle);
}
int EffectRelease(effect_handle_t handle)
{
effect_entry_t *fx;

@ -27,6 +27,8 @@
extern "C" {
#endif
#define EFFECT_LIBRARY_API_VERSION_CURRENT EFFECT_LIBRARY_API_VERSION_3_1
#define PROPERTY_IGNORE_EFFECTS "ro.audio.ignore_effects"
typedef struct list_elem_s {

@ -94,7 +94,7 @@ bool loadLibrary(const char* relativePath, lib_entry_t* libEntry) noexcept {
}
uint32_t majorVersion = EFFECT_API_VERSION_MAJOR(description->version);
uint32_t expectedMajorVersion = EFFECT_API_VERSION_MAJOR(EFFECT_LIBRARY_API_VERSION);
uint32_t expectedMajorVersion = EFFECT_API_VERSION_MAJOR(EFFECT_LIBRARY_API_VERSION_CURRENT);
if (majorVersion != expectedMajorVersion) {
ALOGE("Unsupported major version %#08x, expected %#08x for library %s",
majorVersion, expectedMajorVersion, path);

@ -117,6 +117,36 @@ ANDROID_API
int EffectCreate(const effect_uuid_t *pEffectUuid, int32_t sessionId, int32_t ioId,
effect_handle_t *pHandle);
////////////////////////////////////////////////////////////////////////////////
//
// Function: EffectCreateOnDevice
//
// Description: Same as EffectCreate but uesed when creating an effect attached to a
// particular audio device instance
//
// Input:
// pEffectUuid: pointer to the effect uuid.
// deviceId: identifies the sink or source device this effect is directed to in
// audio HAL. Must be specified if sessionId is AUDIO_SESSION_DEVICE.
// deviceId is the audio_port_handle_t used for the device when the audio
// patch is created at the audio HAL.//
// ioId: identifies the output or input stream this effect is directed to at audio HAL.
// For future use especially with tunneled HW accelerated effects
// Input/Output:
// pHandle: address where to return the effect handle.
//
// Output:
// returned value: 0 successful operation.
// -ENODEV factory failed to initialize
// -EINVAL invalid pEffectUuid or pHandle
// -ENOENT no effect with this uuid found
// *pHandle: updated with the effect handle.
//
////////////////////////////////////////////////////////////////////////////////
ANDROID_API
int EffectCreateOnDevice(const effect_uuid_t *pEffectUuid, int32_t deviceId, int32_t ioId,
effect_handle_t *pHandle);
////////////////////////////////////////////////////////////////////////////////
//
// Function: EffectRelease

@ -97,7 +97,7 @@ AudioFlinger::EffectModule::EffectModule(ThreadBase *thread,
sp<EffectsFactoryHalInterface> effectsFactory = audioFlinger->getEffectsFactory();
if (effectsFactory != 0) {
mStatus = effectsFactory->createEffect(
&desc->uuid, sessionId, thread->id(), &mEffectInterface);
&desc->uuid, sessionId, thread->id(), AUDIO_PORT_HANDLE_NONE, &mEffectInterface);
}
}

Loading…
Cancel
Save