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

Commit 4e9661c8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "AAudio: bump priority of AAudio Mixer to match FastMixer"

parents df916761 2ebf6629
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -78,6 +78,11 @@ void AAudioService::registerClient(const sp<IAAudioClient>& client) {
    AAudioClientTracker::getInstance().registerClient(pid, client);
}

bool AAudioService::isCallerInService() {
    return mAudioClient.clientPid == IPCThreadState::self()->getCallingPid() &&
        mAudioClient.clientUid == IPCThreadState::self()->getCallingUid();
}

aaudio_handle_t AAudioService::openStream(const aaudio::AAudioStreamRequest &request,
                                          aaudio::AAudioStreamConfiguration &configurationOutput) {
    aaudio_result_t result = AAUDIO_OK;
@@ -105,8 +110,7 @@ aaudio_handle_t AAudioService::openStream(const aaudio::AAudioStreamRequest &req
    if (sharingMode == AAUDIO_SHARING_MODE_EXCLUSIVE) {
        // only trust audioserver for in service indication
        bool inService = false;
        if (mAudioClient.clientPid == IPCThreadState::self()->getCallingPid() &&
                mAudioClient.clientUid == IPCThreadState::self()->getCallingUid()) {
        if (isCallerInService()) {
            inService = request.isInService();
        }
        serviceStream = new AAudioServiceStreamMMAP(*this, inService);
@@ -274,12 +278,14 @@ aaudio_result_t AAudioService::registerAudioThread(aaudio_handle_t streamHandle,
        result = AAUDIO_ERROR_INVALID_STATE;
    } else {
        const pid_t ownerPid = IPCThreadState::self()->getCallingPid(); // TODO review
        int32_t priority = isCallerInService()
            ? kRealTimeAudioPriorityService : kRealTimeAudioPriorityClient;
        serviceStream->setRegisteredThread(clientThreadId);
        int err = android::requestPriority(ownerPid, clientThreadId,
                                           DEFAULT_AUDIO_PRIORITY, true /* isForApp */);
                                           priority, true /* isForApp */);
        if (err != 0) {
            ALOGE("AAudioService::registerAudioThread(%d) failed, errno = %d, priority = %d",
                  clientThreadId, errno, DEFAULT_AUDIO_PRIORITY);
                  clientThreadId, errno, priority);
            result = AAUDIO_ERROR_INTERNAL;
        }
    }
+8 −3
Original line number Diff line number Diff line
@@ -87,6 +87,10 @@ public:

private:

    /** @return true if the client is the audioserver
     */
    bool isCallerInService();

    /**
     * Lookup stream and then validate access to the stream.
     * @param streamHandle
@@ -106,9 +110,10 @@ private:

    aaudio::AAudioStreamTracker     mStreamTracker;

    enum constants {
        DEFAULT_AUDIO_PRIORITY = 2
    };
    // TODO  Extract the priority constants from services/audioflinger/Threads.cpp
    // and share them with this code. Look for "kPriorityFastMixer".
    static constexpr int32_t        kRealTimeAudioPriorityClient = 2;
    static constexpr int32_t        kRealTimeAudioPriorityService = 3;
};

} /* namespace android */