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

Commit 97978fbe authored by Yin-Chia Yeh's avatar Yin-Chia Yeh
Browse files

Camera: fix offline processing VTS/CTS

Test: camera VTS test + add manual delay to webcam HAL output thread
      so there will be some requests left for offline processing
      camera CTS OfflineSessionTest
Bug: 135142453
Change-Id: If5718350707ef051f96b96da75f934089b10467d
parent 9ab6b3eb
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -182,9 +182,8 @@ void HandleImporter::freeBuffer(buffer_handle_t handle) {
    }

    Mutex::Autolock lock(mLock);
    if (mMapperV4 == nullptr && mMapperV3 == nullptr && mMapperV2 == nullptr) {
        ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__);
        return;
    if (!mInitialized) {
        initializeLocked();
    }

    if (mMapperV4 != nullptr) {
+1 −0
Original line number Diff line number Diff line
@@ -519,6 +519,7 @@ int encodeJpegYU12(
        yLines[i]  = static_cast<JSAMPROW>(py + li * inLayout.yStride);
        if(i < paddedHeight / cVSubSampling)
        {
            li = std::min(i, (inSz.height - 1) / cVSubSampling);
            crLines[i] = static_cast<JSAMPROW>(pcr + li * inLayout.cStride);
            cbLines[i] = static_cast<JSAMPROW>(pcb + li * inLayout.cStride);
        }
+1 −1
Original line number Diff line number Diff line
@@ -321,7 +321,7 @@ protected:
    const common::V1_0::helper::CameraMetadata mCameraCharacteristics;
    const std::vector<SupportedV4L2Format> mSupportedFormats;
    const CroppingType mCroppingType;
    const std::string& mCameraId;
    const std::string mCameraId;

    // Not protected by mLock, this is almost a const.
    // Setup in constructor, reset in close() after OutputThread is joined
+9 −7
Original line number Diff line number Diff line
@@ -149,10 +149,6 @@ void ExternalCameraDeviceSession::fillOfflineSessionInfo(const hidl_vec<int32_t>
    info->offlineStreams.resize(offlineStreams.size());
    info->offlineRequests.resize(offlineReqs.size());

    std::unordered_map<int32_t, uint32_t> outstandingBufs(offlineStreams.size());
    for (const auto streamId : offlineStreams) {
        outstandingBufs.insert({streamId, 0});
    }
    // Fill in offline reqs and count outstanding buffers
    for (size_t i = 0; i < offlineReqs.size(); i++) {
        info->offlineRequests[i].frameNumber = offlineReqs[i]->frameNumber;
@@ -160,14 +156,15 @@ void ExternalCameraDeviceSession::fillOfflineSessionInfo(const hidl_vec<int32_t>
        for (size_t bIdx = 0; bIdx < offlineReqs[i]->buffers.size(); bIdx++) {
            int32_t streamId = offlineReqs[i]->buffers[bIdx].streamId;
            info->offlineRequests[i].pendingStreams[bIdx] = streamId;
            outstandingBufs[streamId]++;
        }
    }

    for (size_t i = 0; i < offlineStreams.size(); i++) {
        int32_t streamId = offlineStreams[i];
        info->offlineStreams[i].id = streamId;
        info->offlineStreams[i].numOutstandingBuffers = outstandingBufs[streamId];
        // outstanding buffers are 0 since we are doing hal buffer management and
        // offline session will ask for those buffers later
        info->offlineStreams[i].numOutstandingBuffers = 0;
        const CirculatingBuffers& bufIdMap = circulatingBuffers.at(streamId);
        info->offlineStreams[i].circulatingBufferIds.resize(bufIdMap.size());
        size_t bIdx = 0;
@@ -345,7 +342,12 @@ Status ExternalCameraDeviceSession::switchToOffline(const hidl_vec<int32_t>& off
        return Status::INTERNAL_ERROR;
    }

    // No need to return session if there is no offline requests left
    if (offlineReqs.size() != 0) {
        *session = sessionImpl->getInterface();
    } else {
        *session = nullptr;
    }
    return Status::OK;
}

+198 −57

File changed.

Preview size limit exceeded, changes collapsed.