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

Commit d06e4754 authored by Andy Hung's avatar Andy Hung Committed by android-build-merger
Browse files

AudioFlinger: Fix memory allocation for client-less tracks am: 1159ffd5 am:...

AudioFlinger: Fix memory allocation for client-less tracks am: 1159ffd5 am: f242b890 am: 24ef54ec am: a3581647
am: 1ce123cf

Change-Id: I414a644145a6da9c9fe4e073d97aa07dd0272267
parents ed429f11 1ce123cf
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -143,9 +143,11 @@ AudioFlinger::ThreadBase::TrackBase::TrackBase(
            return;
        }
    } else {
        // this syntax avoids calling the audio_track_cblk_t constructor twice
        mCblk = (audio_track_cblk_t *) new uint8_t[size];
        // assume mCblk != NULL
        mCblk = (audio_track_cblk_t *) malloc(size);
        if (mCblk == NULL) {
            ALOGE("not enough memory for AudioTrack size=%zu", size);
            return;
        }
    }

    // construct the shared structure in-place.
@@ -237,10 +239,9 @@ AudioFlinger::ThreadBase::TrackBase::~TrackBase()
    // delete the proxy before deleting the shared memory it refers to, to avoid dangling reference
    delete mServerProxy;
    if (mCblk != NULL) {
        if (mClient == 0) {
            delete mCblk;
        } else {
        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