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

Commit 7f16a338 authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Update ZSL result container

The implemetation defined ZSL processor currently
relies on the deprecated 'libutils' Vector for storing
the result metadata. The 'do_destroy' method within the
vector implementation will try to reinterpret cast an
internal void storage pointer to 'CameraMetadata' which
can trigger CFI.
Avoid possible CFI asserts and switch the container to
the now recommended 'std::vector'.

Bug: 135535544
Test: Camera CTS
Change-Id: Ie66d170ab06148f6e5a4669cf1325e13bcc22dcc
parent 4106a42a
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -172,7 +172,7 @@ ZslProcessor::ZslProcessor(
    mBufferQueueDepth = mFrameListDepth + 1;
    mBufferQueueDepth = mFrameListDepth + 1;


    mZslQueue.insertAt(0, mBufferQueueDepth);
    mZslQueue.insertAt(0, mBufferQueueDepth);
    mFrameList.insertAt(0, mFrameListDepth);
    mFrameList.resize(mFrameListDepth);
    sp<CaptureSequencer> captureSequencer = mSequencer.promote();
    sp<CaptureSequencer> captureSequencer = mSequencer.promote();
    if (captureSequencer != 0) captureSequencer->setZslProcessor(this);
    if (captureSequencer != 0) captureSequencer->setZslProcessor(this);
}
}
@@ -208,7 +208,7 @@ void ZslProcessor::onResultAvailable(const CaptureResult &result) {
    // Corresponding buffer has been cleared. No need to push into mFrameList
    // Corresponding buffer has been cleared. No need to push into mFrameList
    if (timestamp <= mLatestClearedBufferTimestamp) return;
    if (timestamp <= mLatestClearedBufferTimestamp) return;


    mFrameList.editItemAt(mFrameListHead) = result.mMetadata;
    mFrameList[mFrameListHead] = result.mMetadata;
    mFrameListHead = (mFrameListHead + 1) % mFrameListDepth;
    mFrameListHead = (mFrameListHead + 1) % mFrameListDepth;
}
}


@@ -671,7 +671,7 @@ status_t ZslProcessor::clearZslQueueLocked() {
void ZslProcessor::clearZslResultQueueLocked() {
void ZslProcessor::clearZslResultQueueLocked() {
    mFrameList.clear();
    mFrameList.clear();
    mFrameListHead = 0;
    mFrameListHead = 0;
    mFrameList.insertAt(0, mFrameListDepth);
    mFrameList.resize(mFrameListDepth);
}
}


void ZslProcessor::dump(int fd, const Vector<String16>& /*args*/) const {
void ZslProcessor::dump(int fd, const Vector<String16>& /*args*/) const {
+1 −1
Original line number Original line Diff line number Diff line
@@ -125,7 +125,7 @@ class ZslProcessor :
    static const int32_t kDefaultMaxPipelineDepth = 4;
    static const int32_t kDefaultMaxPipelineDepth = 4;
    size_t mBufferQueueDepth;
    size_t mBufferQueueDepth;
    size_t mFrameListDepth;
    size_t mFrameListDepth;
    Vector<CameraMetadata> mFrameList;
    std::vector<CameraMetadata> mFrameList;
    size_t mFrameListHead;
    size_t mFrameListHead;


    ZslPair mNextPair;
    ZslPair mNextPair;