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

Commit 08959c63 authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "Request permission for global audio effects." into gingerbread

parents 127146ee 14beea48
Loading
Loading
Loading
Loading
+18 −14
Original line number Diff line number Diff line
@@ -4656,13 +4656,25 @@ sp<IEffect> AudioFlinger::createEffect(pid_t pid,
    {
        Mutex::Autolock _l(mLock);

        // check recording permission for visualizer
        if (memcmp(&pDesc->type, SL_IID_VISUALIZATION, sizeof(effect_uuid_t)) == 0 ||
            memcmp(&pDesc->uuid, &VISUALIZATION_UUID_, sizeof(effect_uuid_t)) == 0) {
            if (!recordingAllowed()) {
        // check audio settings permission for global effects
        if (sessionId == AudioSystem::SESSION_OUTPUT_MIX && !settingsAllowed()) {
            lStatus = PERMISSION_DENIED;
            goto Exit;
        }

        // Session AudioSystem::SESSION_OUTPUT_STAGE is reserved for output stage effects
        // that can only be created by audio policy manager (running in same process)
        if (sessionId == AudioSystem::SESSION_OUTPUT_STAGE && getpid() != pid) {
            lStatus = PERMISSION_DENIED;
            goto Exit;
        }

        // check recording permission for visualizer
        if ((memcmp(&pDesc->type, SL_IID_VISUALIZATION, sizeof(effect_uuid_t)) == 0 ||
             memcmp(&pDesc->uuid, &VISUALIZATION_UUID_, sizeof(effect_uuid_t)) == 0) &&
            !recordingAllowed()) {
            lStatus = PERMISSION_DENIED;
            goto Exit;
        }

        if (!EffectIsNullUuid(&pDesc->uuid)) {
@@ -4727,14 +4739,6 @@ sp<IEffect> AudioFlinger::createEffect(pid_t pid,
            goto Exit;
        }

        // Session AudioSystem::SESSION_OUTPUT_STAGE is reserved for output stage effects
        // that can only be created by audio policy manager (running in same process)
        if (sessionId == AudioSystem::SESSION_OUTPUT_STAGE &&
                getpid() != pid) {
            lStatus = INVALID_OPERATION;
            goto Exit;
        }

        // return effect descriptor
        memcpy(pDesc, &desc, sizeof(effect_descriptor_t));