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

Commit 274a28cd authored by wangxiaobin's avatar wangxiaobin Committed by xiaobin Wang
Browse files

Camera: verify per-frame metadata when ALOGV is enabled



Validate_camera_metadata_structure need about 4% cpu on
cameraserver for each frame.
The verify in writeToParcel and acquire only print error logs.
So it's better to close the verify for normal user.

Test: Catch cpu usage and cat simpleperf of Camera APP
Bug:395005214

Change-Id: I509e54de26871c7928caa26cf2191d63c8c38634
Signed-off-by: default avatarwangxiaobin <wangxiaobin@xiaomi.corp-partner.google.com>
parent da1dca0f
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -132,10 +132,12 @@ void CameraMetadata::acquire(camera_metadata_t *buffer) {
    clear();
    mBuffer = buffer;

    IF_ALOGV() {
        ALOGE_IF(validate_camera_metadata_structure(mBuffer, /*size*/NULL) != OK,
                 "%s: Failed to validate metadata structure %p",
                 __FUNCTION__, buffer);
    }
}

void CameraMetadata::acquire(CameraMetadata &other) {
    if (mLocked) {
@@ -712,10 +714,12 @@ status_t CameraMetadata::writeToParcel(Parcel& data,

        // Not too big of a problem since receiving side does hard validation
        // Don't check the size since the compact size could be larger
        IF_ALOGV() {
            if (validate_camera_metadata_structure(metadata, /*size*/NULL) != OK) {
                ALOGW("%s: Failed to validate metadata %p before writing blob",
                       __FUNCTION__, metadata);
            }
        }

    } while(false);
    blob.release();