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

Commit 0d3958f7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Camera: synchronize access to mHidlMemPoolMap" into oc-mr1-dev

parents 5deda0e7 c3424df9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -97,11 +97,13 @@ hardware::Return<uint32_t> CameraHardwareInterface::registerMemory(
        ALOGE("%s: CameraHeapMemory has FD %d (expect >= 0)", __FUNCTION__, memPoolId);
        return 0;
    }
    std::lock_guard<std::mutex> lock(mHidlMemPoolMapLock);
    mHidlMemPoolMap.insert(std::make_pair(memPoolId, mem));
    return memPoolId;
}

hardware::Return<void> CameraHardwareInterface::unregisterMemory(uint32_t memId) {
    std::lock_guard<std::mutex> lock(mHidlMemPoolMapLock);
    if (mHidlMemPoolMap.count(memId) == 0) {
        ALOGE("%s: memory pool ID %d not found", __FUNCTION__, memId);
        return hardware::Void();
@@ -115,6 +117,7 @@ hardware::Return<void> CameraHardwareInterface::unregisterMemory(uint32_t memId)
hardware::Return<void> CameraHardwareInterface::dataCallback(
        DataCallbackMsg msgType, uint32_t data, uint32_t bufferIndex,
        const hardware::camera::device::V1_0::CameraFrameMetadata& metadata) {
    std::lock_guard<std::mutex> lock(mHidlMemPoolMapLock);
    if (mHidlMemPoolMap.count(data) == 0) {
        ALOGE("%s: memory pool ID %d not found", __FUNCTION__, data);
        return hardware::Void();
@@ -129,6 +132,7 @@ hardware::Return<void> CameraHardwareInterface::dataCallback(
hardware::Return<void> CameraHardwareInterface::dataCallbackTimestamp(
        DataCallbackMsg msgType, uint32_t data,
        uint32_t bufferIndex, int64_t timestamp) {
    std::lock_guard<std::mutex> lock(mHidlMemPoolMapLock);
    if (mHidlMemPoolMap.count(data) == 0) {
        ALOGE("%s: memory pool ID %d not found", __FUNCTION__, data);
        return hardware::Void();
@@ -140,6 +144,7 @@ hardware::Return<void> CameraHardwareInterface::dataCallbackTimestamp(
hardware::Return<void> CameraHardwareInterface::handleCallbackTimestamp(
        DataCallbackMsg msgType, const hidl_handle& frameData, uint32_t data,
        uint32_t bufferIndex, int64_t timestamp) {
    std::lock_guard<std::mutex> lock(mHidlMemPoolMapLock);
    if (mHidlMemPoolMap.count(data) == 0) {
        ALOGE("%s: memory pool ID %d not found", __FUNCTION__, data);
        return hardware::Void();
@@ -158,6 +163,7 @@ hardware::Return<void> CameraHardwareInterface::handleCallbackTimestampBatch(
    std::vector<android::HandleTimestampMessage> msgs;
    msgs.reserve(messages.size());

    std::lock_guard<std::mutex> lock(mHidlMemPoolMapLock);
    for (const auto& hidl_msg : messages) {
        if (mHidlMemPoolMap.count(hidl_msg.data) == 0) {
            ALOGE("%s: memory pool ID %d not found", __FUNCTION__, hidl_msg.data);
+1 −0
Original line number Diff line number Diff line
@@ -479,6 +479,7 @@ private:
    uint64_t mNextBufferId = 1;
    static const uint64_t BUFFER_ID_NO_BUFFER = 0;

    std::mutex mHidlMemPoolMapLock; // protecting mHidlMemPoolMap
    std::unordered_map<int, camera_memory_t*> mHidlMemPoolMap;
};