Loading camera/camera_platform.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -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 } } services/camera/libcameraservice/device3/PreviewFrameSpacer.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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 services/camera/libcameraservice/device3/PreviewFrameSpacer.h +1 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
camera/camera_platform.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -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 } }
services/camera/libcameraservice/device3/PreviewFrameSpacer.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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
services/camera/libcameraservice/device3/PreviewFrameSpacer.h +1 −0 Original line number Diff line number Diff line Loading @@ -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 Loading