diff --git a/app/config/config.cpp b/app/config/config.cpp index 51dc15713..3274236e1 100644 --- a/app/config/config.cpp +++ b/app/config/config.cpp @@ -91,7 +91,7 @@ void Config::SetDefaults() SetEntryInternal(QStringLiteral("Loop"), NodeParam::kBoolean, false); SetEntryInternal(QStringLiteral("SplitClipsCopyNodes"), NodeParam::kBoolean, true); - SetEntryInternal(QStringLiteral("AutoCacheInterval"), NodeParam::kInt, 250); + SetEntryInternal(QStringLiteral("AutoCacheDelay"), NodeParam::kInt, 1000); SetEntryInternal(QStringLiteral("NodeCatColor0"), NodeParam::kColor, QVariant::fromValue(Color(0.75f, 0.75f, 0.75f))); SetEntryInternal(QStringLiteral("NodeCatColor1"), NodeParam::kColor, QVariant::fromValue(Color(0.25f, 0.25f, 0.25f))); diff --git a/app/render/previewautocacher.cpp b/app/render/previewautocacher.cpp index 7a309e467..8037b6a6f 100644 --- a/app/render/previewautocacher.cpp +++ b/app/render/previewautocacher.cpp @@ -24,6 +24,10 @@ PreviewAutoCacher::PreviewAutoCacher() : { // Set default autocache range SetPlayhead(rational()); + + delayed_requeue_timer_.setInterval(Config::Current()[QStringLiteral("AutoCacheDelay")].toInt()); + delayed_requeue_timer_.setSingleShot(true); + connect(&delayed_requeue_timer_, &QTimer::timeout, this, &PreviewAutoCacher::RequeueFrames); } RenderTicketPtr PreviewAutoCacher::GetSingleFrame(const rational &t) @@ -169,7 +173,9 @@ void PreviewAutoCacher::HashesProcessed() if (hash_tasks_.contains(watcher)) { hash_tasks_.removeOne(watcher); - RequeueFrames(); + // Restart delayed requeue timer + delayed_requeue_timer_.stop(); + delayed_requeue_timer_.start(); } // The cacher might be waiting for this job to finish @@ -595,6 +601,8 @@ void PreviewAutoCacher::TryRender() void PreviewAutoCacher::RequeueFrames() { + delayed_requeue_timer_.stop(); + if (viewer_node_ && viewer_node_->video_frame_cache()->HasInvalidatedRanges() && hash_tasks_.isEmpty() diff --git a/app/render/previewautocacher.h b/app/render/previewautocacher.h index 03898c169..99c7aec70 100644 --- a/app/render/previewautocacher.h +++ b/app/render/previewautocacher.h @@ -104,11 +104,6 @@ private: void TryRender(); - /** - * @brief Generic function called whenever the frames to render need to be (re)queued - */ - void RequeueFrames(); - /** * @brief Process all changes to internal NodeGraph copy * @@ -156,6 +151,8 @@ private: ColorManager* color_manager_; + QTimer delayed_requeue_timer_; + private slots: /** * @brief Handler for when the NodeGraph reports a video change over a certain time range @@ -202,6 +199,11 @@ private slots: void SingleFrameFinished(); + /** + * @brief Generic function called whenever the frames to render need to be (re)queued + */ + void RequeueFrames(); + }; }