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

Commit a0536515 authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

Merge "AudioFlinger: Enforce per uid track limitation"

parents c2d93b0d 689e82c6
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -205,6 +205,16 @@ public:
protected:
protected:
    DISALLOW_COPY_AND_ASSIGN(TrackBase);
    DISALLOW_COPY_AND_ASSIGN(TrackBase);


    void releaseCblk() {
        if (mCblk != nullptr) {
            mCblk->~audio_track_cblk_t();   // destroy our shared-structure.
            if (mClient == 0) {
                free(mCblk);
            }
            mCblk = nullptr;
        }
    }

    // AudioBufferProvider interface
    // AudioBufferProvider interface
    virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer) = 0;
    virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer) = 0;
    virtual void releaseBuffer(AudioBufferProvider::Buffer* buffer);
    virtual void releaseBuffer(AudioBufferProvider::Buffer* buffer);
+7 −10
Original line number Original line Diff line number Diff line
@@ -237,12 +237,7 @@ AudioFlinger::ThreadBase::TrackBase::~TrackBase()
{
{
    // delete the proxy before deleting the shared memory it refers to, to avoid dangling reference
    // delete the proxy before deleting the shared memory it refers to, to avoid dangling reference
    mServerProxy.clear();
    mServerProxy.clear();
    if (mCblk != NULL) {
    releaseCblk();
        mCblk->~audio_track_cblk_t();   // destroy our shared-structure.
        if (mClient == 0) {
            free(mCblk);
        }
    }
    mCblkMemory.clear();    // free the shared memory before releasing the heap it belongs to
    mCblkMemory.clear();    // free the shared memory before releasing the heap it belongs to
    if (mClient != 0) {
    if (mClient != 0) {
        // Client destructor must run with AudioFlinger client mutex locked
        // Client destructor must run with AudioFlinger client mutex locked
@@ -549,6 +544,12 @@ AudioFlinger::PlaybackThread::Track::Track(
        return;
        return;
    }
    }


    if (!thread->isTrackAllowed_l(channelMask, format, sessionId, uid)) {
        ALOGE("%s(%d): no more tracks available", __func__, mId);
        releaseCblk(); // this makes the track invalid.
        return;
    }

    if (sharedBuffer == 0) {
    if (sharedBuffer == 0) {
        mAudioTrackServerProxy = new AudioTrackServerProxy(mCblk, mBuffer, frameCount,
        mAudioTrackServerProxy = new AudioTrackServerProxy(mCblk, mBuffer, frameCount,
                mFrameSize, !isExternalTrack(), sampleRate);
                mFrameSize, !isExternalTrack(), sampleRate);
@@ -558,10 +559,6 @@ AudioFlinger::PlaybackThread::Track::Track(
    }
    }
    mServerProxy = mAudioTrackServerProxy;
    mServerProxy = mAudioTrackServerProxy;


    if (!thread->isTrackAllowed_l(channelMask, format, sessionId, uid)) {
        ALOGE("%s(%d): no more tracks available", __func__, mId);
        return;
    }
    // only allocate a fast track index if we were able to allocate a normal track name
    // only allocate a fast track index if we were able to allocate a normal track name
    if (flags & AUDIO_OUTPUT_FLAG_FAST) {
    if (flags & AUDIO_OUTPUT_FLAG_FAST) {
        // FIXME: Not calling framesReadyIsCalledByMultipleThreads() exposes a potential
        // FIXME: Not calling framesReadyIsCalledByMultipleThreads() exposes a potential