From c1704f21647114372a615e662d90e316df24a4f3 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Sat, 22 May 2021 19:23:55 +0200 Subject: [PATCH] Fix rapid scene switches by random tab Wait scene was not set while waiting for scene changes on the random tab. If wait scene was ever set by other means (sequence) the scene switcher would immediately wake up as the wait scene is not the expected value. --- src/advanced-scene-switcher.cpp | 8 ++++++++ src/headers/switcher-data-structs.hpp | 1 + src/switch-sequence.cpp | 2 -- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/advanced-scene-switcher.cpp b/src/advanced-scene-switcher.cpp index 96f7b640..bb0e3b32 100644 --- a/src/advanced-scene-switcher.cpp +++ b/src/advanced-scene-switcher.cpp @@ -484,6 +484,7 @@ void SwitcherData::Thread() } vblog(LOG_INFO, "try to sleep for %ld", duration.count()); + setWaitScene(); cv.wait_for(lock, duration); startTime = std::chrono::high_resolution_clock::now(); @@ -510,6 +511,7 @@ void SwitcherData::Thread() vblog(LOG_INFO, "sleep for %ld before switching scene", duration.count()); + setWaitScene(); cv.wait_for(lock, duration); if (stop) { @@ -686,6 +688,12 @@ void SwitcherData::Stop() client.disconnect(); } +void SwitcherData::setWaitScene() +{ + waitScene = obs_frontend_get_current_scene(); + obs_source_release(waitScene); +} + bool SwitcherData::sceneChangedDuringWait() { obs_source_t *currentSource = obs_frontend_get_current_scene(); diff --git a/src/headers/switcher-data-structs.hpp b/src/headers/switcher-data-structs.hpp index 7fa4864a..64f13c0e 100644 --- a/src/headers/switcher-data-structs.hpp +++ b/src/headers/switcher-data-structs.hpp @@ -192,6 +192,7 @@ struct SwitcherData { void Start(); void Stop(); + void setWaitScene(); bool sceneChangedDuringWait(); bool prioFuncsValid(); diff --git a/src/switch-sequence.cpp b/src/switch-sequence.cpp index abdb675a..fb5cfda4 100644 --- a/src/switch-sequence.cpp +++ b/src/switch-sequence.cpp @@ -440,8 +440,6 @@ void SceneSequenceSwitch::prepareUninterruptibleMatch( { int dur = delay.seconds * 1000; if (dur > 0) { - switcher->waitScene = obs_weak_source_get_source(currentScene); - obs_source_release(switcher->waitScene); linger = dur; } }