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

Commit c9a59dd3 authored by Wonsik Kim's avatar Wonsik Kim Committed by Android (Google) Code Review
Browse files

Merge "CCodec: protect C2OMXNode::mBufferIdsInUse" into qt-dev

parents 03517c59 a261e381
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -287,7 +287,7 @@ status_t C2OMXNode::emptyBuffer(
        return UNKNOWN_ERROR;
    }

    (void)mBufferIdsInUse.emplace(index, buffer);
    mBufferIdsInUse.lock()->emplace(index, buffer);
    return OK;
}

@@ -327,13 +327,19 @@ void C2OMXNode::onInputBufferDone(c2_cntr64_t index) {
        ALOGD("Buffer source not set (index=%llu)", index.peekull());
        return;
    }
    auto it = mBufferIdsInUse.find(index.peeku());
    if (it == mBufferIdsInUse.end()) {

    int32_t bufferId = 0;
    {
        decltype(mBufferIdsInUse)::Locked bufferIds(mBufferIdsInUse);
        auto it = bufferIds->find(index.peeku());
        if (it == bufferIds->end()) {
            ALOGV("Untracked input index %llu (maybe already removed)", index.peekull());
            return;
        }
    (void)mBufferSource->onInputBufferEmptied(it->second, -1);
    (void)mBufferIdsInUse.erase(it);
        bufferId = it->second;
        (void)bufferIds->erase(it);
    }
    (void)mBufferSource->onInputBufferEmptied(bufferId, -1);
}

}  // namespace android
+3 −2
Original line number Diff line number Diff line
@@ -20,9 +20,10 @@
#include <atomic>

#include <android/IOMXBufferSource.h>
#include <codec2/hidl/client.h>
#include <media/stagefright/foundation/Mutexed.h>
#include <media/IOMX.h>
#include <media/OMXBuffer.h>
#include <codec2/hidl/client.h>

namespace android {

@@ -111,7 +112,7 @@ private:
    c2_cntr64_t mPrevInputTimestamp; // input timestamp for previous frame
    c2_cntr64_t mPrevCodecTimestamp; // adjusted (codec) timestamp for previous frame

    std::map<uint64_t, buffer_id> mBufferIdsInUse;
    Mutexed<std::map<uint64_t, buffer_id>> mBufferIdsInUse;
};

}  // namespace android