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

Commit ebf70f00 authored by Andy Hung's avatar Andy Hung Committed by Automerger Merge Worker
Browse files

Merge "Tracks: Fix memory leak." am: abd83bb7 am: e6c88b7c am: b8c4500c...

Merge "Tracks: Fix memory leak." am: abd83bb7 am: e6c88b7c am: b8c4500c am: 217855db am: 7c2cfed7

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



Change-Id: I7216cf82dda91fee2974b381065941d3649b9fe3
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7b93d366 7c2cfed7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ public:
                                pid_t creatorPid,
                                uid_t uid,
                                bool isOut,
                                alloc_type alloc = ALLOC_CBLK,
                                const alloc_type alloc = ALLOC_CBLK,
                                track_type type = TYPE_DEFAULT,
                                audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE,
                                std::string metricsId = {});
@@ -352,6 +352,7 @@ protected:
                                    // this could be a track type if needed later

    const wp<ThreadBase> mThread;
    const alloc_type     mAllocType;
    /*const*/ sp<Client> mClient;   // see explanation at ~TrackBase() why not const
    sp<IMemory>         mCblkMemory;
    audio_track_cblk_t* mCblk;
+6 −1
Original line number Diff line number Diff line
@@ -90,12 +90,13 @@ AudioFlinger::ThreadBase::TrackBase::TrackBase(
            pid_t creatorPid,
            uid_t clientUid,
            bool isOut,
            alloc_type alloc,
            const alloc_type alloc,
            track_type type,
            audio_port_handle_t portId,
            std::string metricsId)
    :   RefBase(),
        mThread(thread),
        mAllocType(alloc),
        mClient(client),
        mCblk(NULL),
        // mBuffer, mBufferSize
@@ -277,6 +278,10 @@ AudioFlinger::ThreadBase::TrackBase::~TrackBase()
        // relying on the automatic clear() at end of scope.
        mClient.clear();
    }
    if (mAllocType == ALLOC_LOCAL) {
        free(mBuffer);
        mBuffer = nullptr;
    }
    // flush the binder command buffer
    IPCThreadState::self()->flushCommands();
}