mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-23 09:45:49 -05:00
Enable plugin callbacks to be peformed after condition checks completed
Also run these callbacks before restarting the plugin. This should ensure that no outdated signals received while the plugin was stopped will trigger unexpected actions. (E.g. websocket messages that were received while the plugin was stopped)
This commit is contained in:
@@ -255,7 +255,7 @@ void SwitcherData::Thread()
|
||||
}
|
||||
}
|
||||
|
||||
ClearWebsocketMessages();
|
||||
resetForNextInterval();
|
||||
|
||||
if (match) {
|
||||
if (macroMatch) {
|
||||
@@ -308,6 +308,16 @@ void SwitcherData::setPreconditions()
|
||||
lastCursorPos = getCursorPos();
|
||||
}
|
||||
|
||||
void SwitcherData::resetForNextInterval()
|
||||
{
|
||||
// Core reset functions
|
||||
ClearWebsocketMessages();
|
||||
// Plugin reset functions
|
||||
for (const auto &func : resetForNextIntervalFuncs) {
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
bool SwitcherData::checkForMatch(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition, int &linger,
|
||||
bool &setPrevSceneAfterLinger,
|
||||
@@ -414,9 +424,20 @@ void switchPreviewScene(const OBSWeakSource &ws)
|
||||
obs_source_release(source);
|
||||
}
|
||||
|
||||
static void ResetMacros()
|
||||
{
|
||||
for (auto &m : switcher->macros) {
|
||||
m->ResetRunCount();
|
||||
m->ResetTimers();
|
||||
}
|
||||
}
|
||||
|
||||
void SwitcherData::Start()
|
||||
{
|
||||
if (!(th && th->isRunning())) {
|
||||
resetForNextInterval();
|
||||
ResetMacros();
|
||||
|
||||
stop = false;
|
||||
th = new SwitcherThread();
|
||||
th->start((QThread::Priority)threadPriority);
|
||||
@@ -441,14 +462,6 @@ void SwitcherData::Start()
|
||||
}
|
||||
}
|
||||
|
||||
void ResetMacros()
|
||||
{
|
||||
for (auto &m : switcher->macros) {
|
||||
m->ResetRunCount();
|
||||
m->ResetTimers();
|
||||
}
|
||||
}
|
||||
|
||||
void SwitcherData::Stop()
|
||||
{
|
||||
if (th && th->isRunning()) {
|
||||
@@ -462,7 +475,6 @@ void SwitcherData::Stop()
|
||||
th = nullptr;
|
||||
|
||||
writeToStatusFile("Advanced Scene Switcher stopped");
|
||||
ResetMacros();
|
||||
}
|
||||
|
||||
server.stop();
|
||||
|
||||
@@ -133,3 +133,10 @@ void SwitcherData::saveVersion(obs_data_t *obj,
|
||||
{
|
||||
obs_data_set_string(obj, "version", currentVersion.c_str());
|
||||
}
|
||||
|
||||
void SwitcherData::addResetForNextIntervalFunction(
|
||||
std::function<void()> function)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
resetForNextIntervalFuncs.emplace_back(function);
|
||||
}
|
||||
|
||||
@@ -271,6 +271,9 @@ struct SwitcherData {
|
||||
void writeToStatusFile(const QString &msg);
|
||||
|
||||
void setPreconditions();
|
||||
void resetForNextInterval();
|
||||
void addResetForNextIntervalFunction(std::function<void()>);
|
||||
std::vector<std::function<void()>> resetForNextIntervalFuncs;
|
||||
bool checkForMatch(OBSWeakSource &scene, OBSWeakSource &transition,
|
||||
int &linger, bool &setPreviousSceneAsMatch,
|
||||
bool ¯oMatch);
|
||||
|
||||
Reference in New Issue
Block a user