From be406ff3538e2cfe1e7724dd1c6f16e2cf18d668 Mon Sep 17 00:00:00 2001 From: WarmUpTill <19472752+WarmUpTill@users.noreply.github.com> Date: Mon, 4 May 2026 21:20:12 +0200 Subject: [PATCH] sched --- plugins/schedule/macro-schedule.cpp | 13 ++++++++----- plugins/schedule/macro-schedule.hpp | 3 --- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/schedule/macro-schedule.cpp b/plugins/schedule/macro-schedule.cpp index 39dc9d5b..fa4c6530 100644 --- a/plugins/schedule/macro-schedule.cpp +++ b/plugins/schedule/macro-schedule.cpp @@ -23,6 +23,8 @@ static std::atomic schedulerRunning{false}; static std::mutex schedulerWaitMutex; static std::condition_variable schedulerWaitCV; +static void initScheduler(); +static void cleanupScheduler(); static void saveEntries(obs_data_t *obj); static void loadEntries(obs_data_t *obj); static bool setup(); @@ -32,9 +34,10 @@ static bool setup() { AddSaveStep(saveEntries); AddLoadStep(loadEntries); - AddFinishedLoadingStep(InitScheduler); + AddStartStep(initScheduler); + AddStopStep(cleanupScheduler); AddPluginCleanupStep([]() { - CleanupScheduler(); + cleanupScheduler(); scheduleEntries.clear(); }); AddMacroExportExtension( @@ -479,7 +482,7 @@ static void checkAndFireEntries() } } -void InitScheduler() +static void initScheduler() { if (schedulerRunning.exchange(true)) { return; // already running @@ -489,13 +492,13 @@ void InitScheduler() checkAndFireEntries(); std::unique_lock lock(schedulerWaitMutex); schedulerWaitCV.wait_for( - lock, std::chrono::seconds(10), + lock, std::chrono::seconds(1), []() { return !schedulerRunning.load(); }); } }); } -void CleanupScheduler() +static void cleanupScheduler() { schedulerRunning = false; schedulerWaitCV.notify_all(); diff --git a/plugins/schedule/macro-schedule.hpp b/plugins/schedule/macro-schedule.hpp index 9c0763e1..d2aa2241 100644 --- a/plugins/schedule/macro-schedule.hpp +++ b/plugins/schedule/macro-schedule.hpp @@ -77,7 +77,4 @@ private: std::deque &GetScheduleEntries(); -void InitScheduler(); -void CleanupScheduler(); - } // namespace advss