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

Commit 3cfb02fe authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Camera: Bump the preview frame spacer thread priority" into main

parents b98871fa 3132f061
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -257,3 +257,13 @@ flag {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    namespace: "camera_platform"
    name: "bump_preview_frame_space_priority"
    description: "Increase the PreviewFrameSpacer thread priority"
    bug: "355665306"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+24 −0
Original line number Diff line number Diff line
@@ -18,10 +18,16 @@
#define ATRACE_TAG ATRACE_TAG_CAMERA
//#define LOG_NDEBUG 0

#include <com_android_internal_camera_flags.h>

#include <utils/Log.h>

#include "PreviewFrameSpacer.h"
#include "Camera3OutputStream.h"
#include "utils/SchedulingPolicyUtils.h"
#include "utils/Utils.h"

namespace flags = com::android::internal::camera::flags;

namespace android {

@@ -129,6 +135,24 @@ void PreviewFrameSpacer::queueBufferToClientLocked(
    mLastCameraReadoutTime = bufferHolder.readoutTimestamp;
}

status_t PreviewFrameSpacer::run(const char* name, int32_t priority, size_t stack) {
    auto ret = Thread::run(name, priority, stack);
    if (flags::bump_preview_frame_space_priority()) {
        // Boost priority of the preview frame spacer thread to SCHED_FIFO.
        pid_t previewFrameSpacerTid = getTid();
        auto res = SchedulingPolicyUtils::requestPriorityDirect(getpid(), previewFrameSpacerTid,
                RunThreadWithRealtimePriority::kRequestThreadPriority);
        if (res != OK) {
            ALOGW("Can't set realtime priority for preview frame spacer thread: %s (%d)",
                    strerror(-res), res);
        } else {
            ALOGV("Set real time priority for preview frame spacer thread (tid %d)",
                    previewFrameSpacerTid);
        }
    }
    return ret;
}

}; // namespace camera3

}; // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ class PreviewFrameSpacer : public Thread {

    bool threadLoop() override;
    void requestExit() override;
    status_t run(const char* name, int32_t priority = PRIORITY_DEFAULT, size_t stack = 0) override;

  private:
    // structure holding cached preview buffer info