Fix previous scene not working for some sequences

If a duration for a transition is used that is longer than the scene
switcher check interval it could happen that the "incorrect" previous
scene could be chosen for uninterruptible scene sequences, as at the
time the sequence check was preformed the "previous scene" variable
was not yet updated as the transition was still ongoing.
This commit is contained in:
WarmUpTill 2021-04-24 23:57:45 +02:00 committed by WarmUpTill
parent 1310d0b3f3
commit d9dfc1913d
3 changed files with 20 additions and 7 deletions

View File

@ -479,6 +479,9 @@ void SwitcherData::Thread()
bool match = false;
OBSWeakSource scene;
OBSWeakSource transition;
// The previous scene might have changed during the linger duration,
// if a longer transition is used than the configured check interval
bool setPrevSceneAfterLinger = false;
endTime = std::chrono::high_resolution_clock::now();
@ -512,7 +515,8 @@ void SwitcherData::Thread()
if (checkPause()) {
continue;
}
match = checkForMatch(scene, transition, linger);
match = checkForMatch(scene, transition, linger,
setPrevSceneAfterLinger);
if (switcher->stop) {
break;
}
@ -536,6 +540,8 @@ void SwitcherData::Thread()
match = false;
linger = 0;
} else if (setPrevSceneAfterLinger) {
scene = previousScene;
}
}
@ -563,12 +569,14 @@ void SwitcherData::Thread()
}
bool SwitcherData::checkForMatch(OBSWeakSource &scene,
OBSWeakSource &transition, int &linger)
OBSWeakSource &transition, int &linger,
bool &setPrevSceneAfterLinger)
{
bool match = false;
if (uninterruptibleSceneSequenceActive) {
match = checkSceneSequence(scene, transition, linger);
match = checkSceneSequence(scene, transition, linger,
setPrevSceneAfterLinger);
if (match) {
return match;
}
@ -593,7 +601,8 @@ bool SwitcherData::checkForMatch(OBSWeakSource &scene,
match = checkWindowTitleSwitch(scene, transition);
break;
case round_trip_func:
match = checkSceneSequence(scene, transition, linger);
match = checkSceneSequence(scene, transition, linger,
setPrevSceneAfterLinger);
break;
case media_func:
match = checkMediaSwitch(scene, transition);

View File

@ -188,9 +188,9 @@ struct SwitcherData {
void writeToStatusFile(QString status);
bool checkForMatch(OBSWeakSource &scene, OBSWeakSource &transition,
int &linger);
int &linger, bool &setPreviousSceneAsMatch);
bool checkSceneSequence(OBSWeakSource &scene, OBSWeakSource &transition,
int &linger);
int &linger, bool &setPrevSceneAfterLinger);
bool checkIdleSwitch(OBSWeakSource &scene, OBSWeakSource &transition);
bool checkWindowTitleSwitch(OBSWeakSource &scene,
OBSWeakSource &transition);

View File

@ -180,7 +180,8 @@ void AdvSceneSwitcher::on_sceneSequenceSwitches_itemDoubleClicked(
}
bool SwitcherData::checkSceneSequence(OBSWeakSource &scene,
OBSWeakSource &transition, int &linger)
OBSWeakSource &transition, int &linger,
bool &setPrevSceneAfterLinger)
{
if (SceneSequenceSwitch::pause) {
return false;
@ -206,9 +207,12 @@ bool SwitcherData::checkSceneSequence(OBSWeakSource &scene,
if (s.activeSequence) {
scene = s.activeSequence->getScene();
transition = s.activeSequence->transition;
setPrevSceneAfterLinger =
s.activeSequence->usePreviousScene;
} else {
scene = s.getScene();
transition = s.transition;
setPrevSceneAfterLinger = s.usePreviousScene;
if (verbose) {
s.logMatch();
}