From 4bd8cdf5a0a29029e9b58d089b3c1f0b282b46ba Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Sun, 14 Jun 2020 14:17:03 +0200 Subject: [PATCH] move auto start/stop to gernal.cpp --- src/general.cpp | 50 ++++++++++++++++++++++++++++++++++++++++ src/scene-round-trip.cpp | 50 ---------------------------------------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/general.cpp b/src/general.cpp index a1c33d00..5e30648a 100644 --- a/src/general.cpp +++ b/src/general.cpp @@ -103,6 +103,56 @@ void SceneSwitcher::closeEvent(QCloseEvent *) obs_frontend_save(); } +void SceneSwitcher::on_autoStopScenes_currentTextChanged(const QString &text) +{ + if (loading) + return; + + std::lock_guard lock(switcher->m); + UpdateAutoStopScene(text); +} + +void SceneSwitcher::on_autoStopSceneCheckBox_stateChanged(int state) +{ + if (loading) + return; + + std::lock_guard lock(switcher->m); + if (!state) { + ui->autoStopScenes->setDisabled(true); + switcher->autoStopEnable = false; + } else { + ui->autoStopScenes->setDisabled(false); + switcher->autoStopEnable = true; + } +} + +void SceneSwitcher::UpdateAutoStopScene(const QString &name) +{ + obs_source_t *scene = obs_get_source_by_name(name.toUtf8().constData()); + obs_weak_source_t *ws = obs_source_get_weak_source(scene); + + switcher->autoStopScene = ws; + + obs_weak_source_release(ws); + obs_source_release(scene); +} + +void SwitcherData::autoStopStreamAndRecording() +{ + obs_source_t *currentSource = obs_frontend_get_current_scene(); + obs_weak_source_t *ws = obs_source_get_weak_source(currentSource); + + if (ws && autoStopScene == ws) { + if (obs_frontend_streaming_active()) + obs_frontend_streaming_stop(); + if (obs_frontend_recording_active()) + obs_frontend_recording_stop(); + } + obs_source_release(currentSource); + obs_weak_source_release(ws); +} + void SceneSwitcher::on_verboseLogging_stateChanged(int state) { if (loading) diff --git a/src/scene-round-trip.cpp b/src/scene-round-trip.cpp index 16be8ba7..93340e8b 100644 --- a/src/scene-round-trip.cpp +++ b/src/scene-round-trip.cpp @@ -89,41 +89,6 @@ void SceneSwitcher::on_sceneRoundTripRemove_clicked() delete item; } -void SceneSwitcher::on_autoStopSceneCheckBox_stateChanged(int state) -{ - if (loading) - return; - - std::lock_guard lock(switcher->m); - if (!state) { - ui->autoStopScenes->setDisabled(true); - switcher->autoStopEnable = false; - } else { - ui->autoStopScenes->setDisabled(false); - switcher->autoStopEnable = true; - } -} - -void SceneSwitcher::UpdateAutoStopScene(const QString &name) -{ - obs_source_t *scene = obs_get_source_by_name(name.toUtf8().constData()); - obs_weak_source_t *ws = obs_source_get_weak_source(scene); - - switcher->autoStopScene = ws; - - obs_weak_source_release(ws); - obs_source_release(scene); -} - -void SceneSwitcher::on_autoStopScenes_currentTextChanged(const QString &text) -{ - if (loading) - return; - - std::lock_guard lock(switcher->m); - UpdateAutoStopScene(text); -} - void SceneSwitcher::on_sceneRoundTripSave_clicked() { QString directory = QFileDialog::getSaveFileName( @@ -315,21 +280,6 @@ int SceneSwitcher::SceneRoundTripFindByData(const QString &scene1) return idx; } -void SwitcherData::autoStopStreamAndRecording() -{ - obs_source_t *currentSource = obs_frontend_get_current_scene(); - obs_weak_source_t *ws = obs_source_get_weak_source(currentSource); - - if (ws && autoStopScene == ws) { - if (obs_frontend_streaming_active()) - obs_frontend_streaming_stop(); - if (obs_frontend_recording_active()) - obs_frontend_recording_stop(); - } - obs_source_release(currentSource); - obs_weak_source_release(ws); -} - void SwitcherData::saveSceneRoundTripSwitches(obs_data_t *obj) { obs_data_array_t *sceneRoundTripArray = obs_data_array_create();