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

Commit c74eba8e authored by Eric Laurent's avatar Eric Laurent Committed by Automerger Merge Worker
Browse files

AudioFlinger: limit ability to create a Spatializer effect am: f690c468

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/15852974

Change-Id: Id138f3a7286b5b66390990985b52f5a3847cc7e8
parents 5dc32098 f690c468
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@
#include <system/audio_effects/effect_ns.h>
#include <system/audio_effects/effect_aec.h>
#include <system/audio_effects/effect_hapticgenerator.h>
#include <system/audio_effects/effect_spatializer.h>

#include <audio_utils/primitives.h>

@@ -3746,6 +3747,15 @@ status_t AudioFlinger::createEffect(const media::CreateEffectRequest& request,
            goto Exit;
        }

        // Only audio policy service can create a spatializer effect
        if ((memcmp(&descOut.type, FX_IID_SPATIALIZER, sizeof(effect_uuid_t)) == 0) &&
            (callingUid != AID_AUDIOSERVER || currentPid != getpid())) {
            ALOGW("%s: attempt to create a spatializer effect from uid/pid %d/%d",
                    __func__, callingUid, currentPid);
            lStatus = PERMISSION_DENIED;
            goto Exit;
        }

        if (io == AUDIO_IO_HANDLE_NONE && sessionId == AUDIO_SESSION_OUTPUT_MIX) {
            // if the output returned by getOutputForEffect() is removed before we lock the
            // mutex below, the call to checkPlaybackThread_l(io) below will detect it
+7 −0
Original line number Diff line number Diff line
@@ -1336,6 +1336,13 @@ status_t AudioFlinger::PlaybackThread::checkEffectCompatibility_l(
        return BAD_VALUE;
    }

    if (memcmp(&desc->type, FX_IID_SPATIALIZER, sizeof(effect_uuid_t)) == 0
            && mType != SPATIALIZER) {
        ALOGW("%s: attempt to create a spatializer effect on a thread of type %d",
                __func__, mType);
        return BAD_VALUE;
    }

    switch (mType) {
    case MIXER: {
#ifndef MULTICHANNEL_EFFECT_CHAIN