diff --git a/forms/advanced-scene-switcher.ui b/forms/advanced-scene-switcher.ui index eb4df51e..251c958a 100644 --- a/forms/advanced-scene-switcher.ui +++ b/forms/advanced-scene-switcher.ui @@ -502,7 +502,7 @@ - + Enable verbose logging (Only needed for debugging) diff --git a/src/advanced-scene-switcher.cpp b/src/advanced-scene-switcher.cpp index ac619416..fda1cae0 100644 --- a/src/advanced-scene-switcher.cpp +++ b/src/advanced-scene-switcher.cpp @@ -191,6 +191,8 @@ SceneSwitcher::SceneSwitcher(QWidget *parent) ui->autoStopScenes->setDisabled(true); } + ui->verboseLogging->setChecked(switcher->verbose); + for (auto &scene : switcher->pauseScenesSwitches) { std::string sceneName = GetWeakSourceName(scene); QString text = QString::fromStdString(sceneName); @@ -495,10 +497,19 @@ void SwitcherData::Thread() OBSWeakSource scene; OBSWeakSource transition; std::chrono::milliseconds duration; - if (sleep > interval) + if (sleep > interval) { duration = std::chrono::milliseconds(sleep); - else + if (verbose) + blog(LOG_INFO, + "Advanced Scene Switcher sleep for %d", + sleep); + } else { duration = std::chrono::milliseconds(interval); + if (verbose) + blog(LOG_INFO, + "Advanced Scene Switcher sleep for %d", + interval); + } sleep = 0; switcher->Prune(); writeSceneInfoToFile(); @@ -613,6 +624,10 @@ void switchScene(OBSWeakSource &scene, OBSWeakSource &transition, obs_frontend_set_current_scene(source); lock.lock(); + if (switcher->verbose) + blog(LOG_INFO, + "Advanced Scene Switcher switched scene"); + obs_weak_source_release(nextTransitionWs); } obs_source_release(currentSource); diff --git a/src/executable-switch.cpp b/src/executable-switch.cpp index 0ab0000e..62f3abc3 100644 --- a/src/executable-switch.cpp +++ b/src/executable-switch.cpp @@ -189,6 +189,10 @@ void SwitcherData::checkExeSwitch(bool &match, OBSWeakSource &scene, scene = s.mScene; transition = s.mTransition; + if (verbose) + blog(LOG_INFO, + "Advanced Scene Switcher exec match"); + break; } } diff --git a/src/file-switch.cpp b/src/file-switch.cpp index 9ed4837a..81e3a782 100644 --- a/src/file-switch.cpp +++ b/src/file-switch.cpp @@ -158,6 +158,10 @@ void SwitcherData::checkFileContent(bool &match, OBSWeakSource &scene, transition = s.transition; match = true; + if (verbose) + blog(LOG_INFO, + "Advanced Scene Switcher file match"); + break; } } diff --git a/src/general.cpp b/src/general.cpp index 66151ba7..a1c33d00 100644 --- a/src/general.cpp +++ b/src/general.cpp @@ -103,6 +103,15 @@ void SceneSwitcher::closeEvent(QCloseEvent *) obs_frontend_save(); } +void SceneSwitcher::on_verboseLogging_stateChanged(int state) +{ + if (loading) + return; + + std::lock_guard lock(switcher->m); + switcher->verbose = state; +} + void SwitcherData::saveGeneralSettings(obs_data_t *obj) { obs_data_set_int(obj, "interval", switcher->interval); @@ -122,6 +131,8 @@ void SwitcherData::saveGeneralSettings(obs_data_t *obj) obs_data_set_string(obj, "autoStopSceneName", autoStopSceneName.c_str()); + obs_data_set_bool(obj, "verbose", switcher->verbose); + obs_data_set_int(obj, "priority0", switcher->functionNamesByPriority[0]); obs_data_set_int(obj, "priority1", @@ -162,6 +173,8 @@ void SwitcherData::loadGeneralSettings(obs_data_t *obj) switcher->autoStopEnable = obs_data_get_bool(obj, "autoStopEnable"); switcher->autoStopScene = GetWeakSourceByName(autoStopScene.c_str()); + switcher->verbose = obs_data_get_bool(obj, "verbose"); + obs_data_set_default_int(obj, "priority0", DEFAULT_PRIORITY_0); obs_data_set_default_int(obj, "priority1", DEFAULT_PRIORITY_1); obs_data_set_default_int(obj, "priority2", DEFAULT_PRIORITY_2); diff --git a/src/headers/advanced-scene-switcher.hpp b/src/headers/advanced-scene-switcher.hpp index 0ffbb776..d75ac46c 100644 --- a/src/headers/advanced-scene-switcher.hpp +++ b/src/headers/advanced-scene-switcher.hpp @@ -88,6 +88,8 @@ public slots: void on_autoStopSceneCheckBox_stateChanged(int state); void on_autoStopScenes_currentTextChanged(const QString &text); + void on_verboseLogging_stateChanged(int state); + void on_sceneTransitions_currentRowChanged(int idx); void on_transitionsAdd_clicked(); void on_transitionsRemove_clicked(); diff --git a/src/headers/switcher-data-structs.hpp b/src/headers/switcher-data-structs.hpp index 5b68aa81..67731df9 100644 --- a/src/headers/switcher-data-structs.hpp +++ b/src/headers/switcher-data-structs.hpp @@ -267,6 +267,7 @@ struct SwitcherData { std::condition_variable transitionCv; bool startAtLaunch = false; bool stop = false; + bool verbose = false; int interval = DEFAULT_INTERVAL; diff --git a/src/idle-switch.cpp b/src/idle-switch.cpp index 32b60392..003ba8db 100644 --- a/src/idle-switch.cpp +++ b/src/idle-switch.cpp @@ -41,6 +41,10 @@ void SwitcherData::checkIdleSwitch(bool &match, OBSWeakSource &scene, transition = idleData.transition; match = true; idleData.alreadySwitched = true; + + if (verbose) + blog(LOG_INFO, + "Advanced Scene Switcher idle match"); } else idleData.alreadySwitched = false; } diff --git a/src/media-switch.cpp b/src/media-switch.cpp index d6627044..0bf891e3 100644 --- a/src/media-switch.cpp +++ b/src/media-switch.cpp @@ -122,6 +122,10 @@ void SwitcherData::checkMediaSwitch(bool &match, OBSWeakSource &scene, ? previousScene : mediaSwitch.scene; transition = mediaSwitch.transition; + + if (verbose) + blog(LOG_INFO, + "Advanced Scene Switcher meida match"); } mediaSwitch.matched = matched; obs_source_release(source); diff --git a/src/pause-switch.cpp b/src/pause-switch.cpp index 8c41bb42..267a0e4f 100644 --- a/src/pause-switch.cpp +++ b/src/pause-switch.cpp @@ -219,6 +219,11 @@ bool SwitcherData::checkPause() } } } + + if (verbose && pause) + blog(LOG_INFO, + "Advanced Scene Switcher pause match"); + return pause; } diff --git a/src/random.cpp b/src/random.cpp index 2aaaf5d0..137f394c 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -132,6 +132,10 @@ void SwitcherData::checkRandom(bool &match, OBSWeakSource &scene, delay = (int)r.delay * 1000; match = true; lastRandomScene = r.scene; + + if (verbose) + blog(LOG_INFO, "Advanced Scene Switcher random match"); + break; } } diff --git a/src/scene-round-trip.cpp b/src/scene-round-trip.cpp index f3a9cc71..16be8ba7 100644 --- a/src/scene-round-trip.cpp +++ b/src/scene-round-trip.cpp @@ -237,6 +237,12 @@ void SwitcherData::checkSceneRoundTrip(bool &match, OBSWeakSource &scene, int dur = s.delay - interval; if (dur > 0) { waitScene = currentSource; + + if (verbose) + blog(LOG_INFO, + "Advanced Scene Switcher sequence sleep %d", + dur); + cv.wait_for(lock, std::chrono::milliseconds(dur)); } diff --git a/src/scene-transitions.cpp b/src/scene-transitions.cpp index d4868d11..c2bb0a58 100644 --- a/src/scene-transitions.cpp +++ b/src/scene-transitions.cpp @@ -162,6 +162,11 @@ void SwitcherData::setDefaultSceneTransitions() //This might cancel the current transition //There is no way to be sure when the previous transition finished obs_frontend_set_current_transition(transition); + + if (verbose) + blog(LOG_INFO, + "Advanced Scene Switcher default transition set"); + obs_source_release(transition); break; } diff --git a/src/screen-region-switch.cpp b/src/screen-region-switch.cpp index e395210b..d39fafe3 100644 --- a/src/screen-region-switch.cpp +++ b/src/screen-region-switch.cpp @@ -15,6 +15,12 @@ void SwitcherData::checkScreenRegionSwitch(bool &match, OBSWeakSource &scene, scene = s.scene; transition = s.transition; minRegionSize = regionSize; + + if (verbose) + blog(LOG_INFO, + "Advanced Scene Switcher region match"); + + break; } } } diff --git a/src/time-switch.cpp b/src/time-switch.cpp index f4aa85f8..771399c2 100644 --- a/src/time-switch.cpp +++ b/src/time-switch.cpp @@ -142,6 +142,11 @@ void SwitcherData::checkTimeSwitch(bool &match, OBSWeakSource &scene, scene = (s.usePreviousScene) ? previousScene : s.scene; transition = s.transition; match = true; + + if (verbose) + blog(LOG_INFO, + "Advanced Scene Switcher time match"); + break; } }