Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d90cde3 authored by Eric Laurent's avatar Eric Laurent Committed by android-build-merger
Browse files

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

am: 5dbea795

Change-Id: I7e65a5ddaeac9dfe506cea82a8397341289b5e78
parents 9007e168 5dbea795
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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();
+30 −7
Original line number Diff line number Diff line
@@ -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;
@@ -292,7 +293,19 @@ int EffectCreate(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, eff
    }

    // create effect in library
    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;
Loading