From 64df33152ae0c51f459e5b85c7deaaea50327dd7 Mon Sep 17 00:00:00 2001 From: tt2468 Date: Thu, 26 Aug 2021 22:46:53 -0700 Subject: [PATCH] Utils: Switch to `obs_enum_scenes()` for GetSceneList More threadsafe than `obs_frontend_get_scenes()`, not that either are in any way threadsafe. --- src/utils/Obs.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/utils/Obs.cpp b/src/utils/Obs.cpp index 85b6a807..7e9fe4aa 100644 --- a/src/utils/Obs.cpp +++ b/src/utils/Obs.cpp @@ -197,20 +197,19 @@ std::vector Utils::Obs::ListHelper::GetHotkeyNameList() std::vector Utils::Obs::ListHelper::GetSceneList() { - obs_frontend_source_list sceneList = {}; - obs_frontend_get_scenes(&sceneList); - std::vector ret; - for (size_t i = 0; i < sceneList.sources.num; i++) { - obs_source_t *scene = sceneList.sources.array[i]; + auto sceneEnumProc = [](void *param, obs_source_t *scene) { + auto ret = reinterpret_cast*>(param); + json sceneJson; sceneJson["sceneName"] = obs_source_get_name(scene); - sceneJson["sceneIndex"] = sceneList.sources.num - (i + 1); sceneJson["isGroup"] = obs_source_is_group(scene); - ret.push_back(sceneJson); - } - obs_frontend_source_list_free(&sceneList); + ret->push_back(sceneJson); + return true; + }; + + obs_enum_scenes(sceneEnumProc, &ret); return ret; } @@ -276,7 +275,7 @@ std::vector Utils::Obs::ListHelper::GetTransitionList() } struct EnumInputInfo { - std::string inputKind; + std::string inputKind; // For searching by input kind std::vector inputs; };