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

Commit 6360911c authored by Leena Winterrowd's avatar Leena Winterrowd
Browse files

stagefright: ExtendedStats: Add lock in TimeBoundVector

TimedBoundVector::clear() can get called from AwesomePlayer's
seek context whereas TimeBoundVector::add() is called from
logBitrate() in MediaSource::read(). Place a lock around all
TimeBoundVector APIs to avoid data corruption due to this
potential race condition.

CRs-Fixed: 753767
Change-Id: Ie70549d606515e2c0ccd8ac6bcbf07d1d5908f36
parent b9b86dcb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -183,6 +183,7 @@ public:
        private:
            SortedVector<StatsFrameInfoWrapper> mList;
            StatsFrameInfoPool& mFrameInfoPool;
            Mutex mLock;
    };

    struct AutoProfile {
+2 −0
Original line number Diff line number Diff line
@@ -287,6 +287,7 @@ ExtendedStats::StatsFrameInfoPool::~StatsFrameInfoPool() {

/* TimeBoundVector methods */
void ExtendedStats::TimeBoundVector::add(StatsFrameInfoWrapper item) {
    Mutex::Autolock lock(mLock);
    mList.add(item);
    mCurrBoundedSum += (item.infoPtr)->size;
    mTotalSizeSum += (item.infoPtr)->size;
@@ -316,6 +317,7 @@ void ExtendedStats::TimeBoundVector::add(StatsFrameInfoWrapper item) {
}

void ExtendedStats::TimeBoundVector::clear() {
    Mutex::Autolock lock(mLock);
    for (uint32_t i = 0; i < mList.size(); i++) {
        delete mList.editItemAt(i).infoPtr;
        mList.editItemAt(i).infoPtr = 0;