diff --git a/ci/test_browser_submodule.py b/ci/test_browser_submodule.py new file mode 100644 index 0000000000..8e58863215 --- /dev/null +++ b/ci/test_browser_submodule.py @@ -0,0 +1,70 @@ +#!/usr/bin/env -S uv run --script +"""plugins/obs-browser must point at a commit that carries the /W4 shadowing fixes. + + uv run python -m unittest ci/test_browser_submodule.py + +The MSVC ``/W4`` ratchet (#2626) reports ``browser-app.cpp``'s shadowing locals in +the app build, which no PR path compiles. Those two fixes live in the submodule +(obs-rust/obs-browser#15), so the product build only becomes clean once this +checkout's pointer is at that commit or a descendant of it. A pointer that moves +back to an older submodule commit silently reintroduces the C4456/C4457 findings. +""" + +from __future__ import annotations + +import subprocess +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parent.parent +SUBMODULE = "plugins/obs-browser" +# obs-rust/obs-browser#15: rename the browser-app locals that hide a parameter +# and a local (C4457 `frame`, C4456 `args`) for obs-studio#2626. +WARNING_SHADOWING_FIX = "b9c5db137711717bc02cdd265801ad26f270bd66" +# obs-rust/obs-browser#16: rename browser-client.cpp's shadowing `name` (C4456) and +# `channels` (C4458) locals, found in the same app-lane build. +WARNING_SHADOWING_FIX_CLIENT = "96e724b2c948c8500a263320520f971f3f6565c2" +# obs-rust/obs-browser#17: rename the panel locals that hide a class member +# (C4458 `script` in browser-panel-client.cpp, `url` in browser-panel.cpp). +WARNING_SHADOWING_FIX_PANEL = "463e16b468ba607dfea2cc8bfcc1a0204b441ed3" + + +def git(*args: str, cwd: Path = ROOT) -> subprocess.CompletedProcess: + return subprocess.run(["git", *args], cwd=cwd, capture_output=True, text=True, check=False) + + +class BrowserSubmoduleTest(unittest.TestCase): + def _assert_pointer_at_least(self, commit: str, what: str) -> None: + tree = git("ls-tree", "HEAD", SUBMODULE).stdout.split() + self.assertEqual(tree[:2], ["160000", "commit"], f"{SUBMODULE} is not a submodule") + pointer = tree[2] + if pointer == commit: + return + sub = ROOT / SUBMODULE + if not (sub / ".git").exists(): + self.skipTest(f"{SUBMODULE} is not checked out; cannot check ancestry of {pointer}") + has = git("merge-base", "--is-ancestor", commit, pointer, cwd=sub) + if has.returncode != 0: + known = git("cat-file", "-e", f"{commit}^{{commit}}", cwd=sub).returncode == 0 + shallow = git("rev-parse", "--is-shallow-repository", cwd=sub).stdout.strip() == "true" + if not known and shallow: + # A shallow checkout may stop above the fix, so a miss here proves nothing. + self.skipTest(f"{SUBMODULE} history is shallow; cannot check ancestry of {pointer[:9]}") + self.assertEqual( + has.returncode, + 0, + f"{SUBMODULE} points at {pointer[:9]}, which lacks {what} ({commit[:9]})", + ) + + def test_pointer_keeps_the_browser_app_renames(self) -> None: + self._assert_pointer_at_least(WARNING_SHADOWING_FIX, "the browser-app shadowing renames (#15)") + + def test_pointer_keeps_the_browser_client_renames(self) -> None: + self._assert_pointer_at_least(WARNING_SHADOWING_FIX_CLIENT, "the browser-client shadowing renames (#16)") + + def test_pointer_keeps_the_panel_renames(self) -> None: + self._assert_pointer_at_least(WARNING_SHADOWING_FIX_PANEL, "the panel shadowing renames (#17)") + + +if __name__ == "__main__": + unittest.main() diff --git a/ci/test_msvc_warning_level.py b/ci/test_msvc_warning_level.py new file mode 100644 index 0000000000..6dbb00892a --- /dev/null +++ b/ci/test_msvc_warning_level.py @@ -0,0 +1,189 @@ +#!/usr/bin/env -S uv run --script +"""The MSVC build compiles at /W4 and does not hand /WX to the linker (#2626). + + uv run python -m unittest ci/test_msvc_warning_level.py + +`/WX` is not a compile flag this file sets: `CMAKE_COMPILE_WARNING_AS_ERROR` +in `cmake/common/compiler_common.cmake` makes CMake pass it to `cl.exe` +(#516). The `add_link_options(/WX)` block was dead — `link.exe` ignores +`/WX` — so it is gone and only the compile-time setting carries the intent. +The warning level itself is `/W4`, the strictest level `cl.exe` has. +""" + +from __future__ import annotations + +import re +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parent.parent +WINDOWS = ROOT / "cmake" / "windows" / "compilerconfig.cmake" +COMMON = ROOT / "cmake" / "common" / "compiler_common.cmake" + + +def call_tokens(text: str, name: str) -> list[str]: + """Every whitespace-separated argument of each `name(...)` call.""" + calls = re.findall(rf"{name}\(([^)]*)\)", text, re.S) + if not calls: + raise AssertionError(f"no {name}( call") + return [token for body in calls for token in body.split()] + + +class MsvcWarningLevelTest(unittest.TestCase): + def setUp(self) -> None: + self.text = WINDOWS.read_text(encoding="utf-8") + + def test_compile_options_request_w4(self) -> None: + options = call_tokens(self.text, "add_compile_options") + self.assertIn("/W4", options) + self.assertNotIn("/W3", options) + + def test_no_w3_anywhere(self) -> None: + self.assertIsNone(re.search(r"(? None: + self.assertNotIn("/WX", call_tokens(self.text, "add_link_options")) + + def test_wx_comes_from_the_compile_time_setting(self) -> None: + common = COMMON.read_text(encoding="utf-8") + self.assertIn("set(CMAKE_COMPILE_WARNING_AS_ERROR ON)", common) + self.assertNotIn("/WX", call_tokens(self.text, "add_compile_options")) + + +HELPERS = ROOT / "cmake" / "common" / "helpers_common.cmake" + +# Every product C++ target that compiles a translation unit including +# libobs/graphics/vec{2,3,4}.h, libobs/util/profiler.h or +# frontend/api/obs-frontend-api.h, and so reports C4201 at /W4. The warnings come +# from the headers, not from the target's own code, and the nameless unions in +# them are legal C11 (6.7.2.1p13) consumed from C, so #2626 decided a per-target +# exemption for exactly these targets rather than renaming the types (an API +# break) or disabling C4201 for every C++ target. +C4201_TARGETS = { + "aja-output-ui": "plugins/aja-output-ui/CMakeLists.txt", + "coreaudio-encoder": "plugins/coreaudio-encoder/CMakeLists.txt", + "decklink": "plugins/decklink/CMakeLists.txt", + "decklink-output-ui": "plugins/decklink-output-ui/CMakeLists.txt", + "frontend-tools": "plugins/frontend-tools/CMakeLists.txt", + "libobs-d3d11": "libobs-d3d11/CMakeLists.txt", + "obs-studio": "frontend/CMakeLists.txt", + "obs-browser": "plugins/CMakeLists.txt", + "obs-vst": "plugins/obs-vst/CMakeLists.txt", + "obs-websocket": "plugins/CMakeLists.txt", + "win-dshow": "plugins/win-dshow/CMakeLists.txt", +} + + +class MsvcNamelessUnionExemptionTest(unittest.TestCase): + """C4201 is exempted per target, for the C++ targets that include those headers.""" + + def test_helper_is_cxx_and_msvc_scoped(self) -> None: + text = HELPERS.read_text(encoding="utf-8") + self.assertIn("function(obs_msvc_exempt_c4201 target)", text) + helper = text.split("function(obs_msvc_exempt_c4201 target)", 1)[1].split("endfunction()", 1)[0] + self.assertIn("/wd4201", helper) + self.assertIn("COMPILE_LANG_AND_ID:CXX,MSVC", helper) + + def test_helper_is_a_no_op_when_the_module_is_disabled(self) -> None: + """ENABLE_BROWSER=OFF / ENABLE_WEBSOCKET=OFF leave no target to exempt.""" + text = HELPERS.read_text(encoding="utf-8") + helper = text.split("function(obs_msvc_exempt_c4201 target)", 1)[1].split("endfunction()", 1)[0] + guard = helper.find("if(NOT TARGET ${target})") + self.assertNotEqual(guard, -1, "the helper must tolerate a target the config did not create") + self.assertLess(guard, helper.find("target_compile_options"), "return before touching the target") + + def test_no_blanket_exemption_in_the_msvc_config(self) -> None: + windows = WINDOWS.read_text(encoding="utf-8") + self.assertIsNone( + re.search(r"(? None: + # The child architecture build configures win-capture/graphics-hook (and + # friends) without cmake/common/helpers_common.cmake, so an + # obs_msvc_exempt_c4201() call there fails configuration. + hook = (ROOT / "plugins" / "win-capture" / "graphics-hook" / "CMakeLists.txt").read_text(encoding="utf-8") + self.assertNotIn("obs_msvc_exempt_c4201", hook) + self.assertIn("/wd4201", hook) + child = (ROOT / "cmake" / "windows" / "architecture.cmake").read_text(encoding="utf-8") + self.assertIn("add_subdirectory(plugins/win-capture/graphics-hook)", child) + + def test_generated_wrapper_and_padded_queue_exemptions(self) -> None: + obslua = (ROOT / "shared" / "obs-scripting" / "obslua" / "CMakeLists.txt").read_text(encoding="utf-8") + for flag in ("/wd4100", "/wd4189"): + self.assertIn(flag, obslua, "the SWIG-generated wrapper is not edited by hand") + decklink = (ROOT / "plugins" / "decklink" / "CMakeLists.txt").read_text(encoding="utf-8") + self.assertIn("/wd4324", decklink, "FrameQueue pads for false-sharing avoidance") + + def test_each_product_cxx_target_opts_in(self) -> None: + missing = [] + for target, relative in sorted(C4201_TARGETS.items()): + body = (ROOT / relative).read_text(encoding="utf-8") + if f"obs_msvc_exempt_c4201({target})" not in body: + missing.append(f"{relative}: {target}") + self.assertEqual(missing, []) + + +class MsvcDeadInternalFunctionExemptionTest(unittest.TestCase): + """C4505 is exempted only for the obs-browser helper target (#2626).""" + + def helper(self) -> str: + text = HELPERS.read_text(encoding="utf-8") + self.assertIn("function(obs_msvc_exempt_c4505 target)", text) + return text.split("function(obs_msvc_exempt_c4505 target)", 1)[1].split("endfunction()", 1)[0] + + def test_helper_is_cxx_and_msvc_scoped(self) -> None: + helper = self.helper() + self.assertIn("/wd4505", helper) + self.assertIn("COMPILE_LANG_AND_ID:CXX,MSVC", helper) + + def test_helper_is_a_no_op_when_the_module_is_disabled(self) -> None: + helper = self.helper() + guard = helper.find("if(NOT TARGET ${target})") + self.assertNotEqual(guard, -1, "the helper must tolerate a target the config did not create") + self.assertLess(guard, helper.find("target_compile_options"), "return before touching the target") + + def test_only_the_obs_browser_helper_opts_in(self) -> None: + # The dead static is `SetHighDPIv2Scaling()` in the obs-browser + # submodule, so the exemption belongs to that target and nowhere else; + # deleting the function is an obs-rust/obs-browser change. + body = (ROOT / "plugins" / "CMakeLists.txt").read_text(encoding="utf-8") + self.assertIn("obs_msvc_exempt_c4505(obs-browser-helper)", body) + self.assertEqual(body.count("obs_msvc_exempt_c4505("), 1) + windows = WINDOWS.read_text(encoding="utf-8") + self.assertIsNone( + re.search(r"(? None: + text = OUTPUTS.read_text(encoding="utf-8") + block = text.split("set_source_files_properties(", 1)[1].split("\n)", 1)[0] + self.assertIn("librtmp/rtmp.c", block) + self.assertRegex( + block, + r"COMPILE_LANG_AND_ID:C,MSVC>:/wd4244;/wd4245;/wd4456;/wd4702;/wd4706>", + "librtmp needs C4244, C4245, C4456, C4702 and C4706 at /W4, scoped to the C language", + ) + + def test_libdshowcapture_exempts_its_shadowed_locals_on_msvc_cxx(self) -> None: + text = DSHOW.read_text(encoding="utf-8") + self.assertRegex( + text, + r"COMPILE_LANG_AND_ID:CXX,MSVC>:/wd4244;/wd4456;/wd4458>", + "device.cpp:483 and encoder.cpp/output-filter.cpp/ElgatoUVCDevice.cpp " + "are vendored; C4244/C4456/C4458 stay suppressed", + ) + + +if __name__ == "__main__": + unittest.main() diff --git a/ci/test_websocket_submodule.py b/ci/test_websocket_submodule.py index 30f1866afc..4bef441eb7 100644 --- a/ci/test_websocket_submodule.py +++ b/ci/test_websocket_submodule.py @@ -21,6 +21,12 @@ # obs-rust/obs-websocket#22: Stop() reads the drain predicate under the session # mutex and bounds the wait (obs-studio#2713). BOUNDED_SESSION_DRAIN = "3253206ff1ba62213936f4e9458e0ebf5eb421ea" +# obs-rust/obs-websocket#24: rename the two inner errorCode locals in onMessage +# (C4456) for the MSVC /W4 ratchet (obs-studio#2626), which the app build reports. +WARNING_SHADOWING_FIX = "960b99e702f116f9cc80ff6b2d3741dc917b7d87" +# obs-rust/obs-websocket#25: the structured binding in Json.cpp's +# obs_data_set_json_array hides the function's own `key` parameter (C4457). +WARNING_JSON_BINDING_FIX = "c2366e8d2c212be569a4fce6687d8a3fb7c6be70" # Upstream commits without the fix that stale checkouts have committed (#492, #496). KNOWN_BAD = {"073a294cd0646fa1744b0ebf3293bfa63a869b50"} @@ -59,6 +65,12 @@ def test_pointer_keeps_the_bounded_parser(self): def test_pointer_keeps_the_bounded_session_drain(self): self._assert_pointer_at_least(BOUNDED_SESSION_DRAIN, "the bounded session drain (#2713)") + def test_pointer_keeps_the_warning_renames(self): + self._assert_pointer_at_least(WARNING_SHADOWING_FIX, "the /W4 shadowing renames (#24)") + + def test_pointer_keeps_the_json_binding_rename(self): + self._assert_pointer_at_least(WARNING_JSON_BINDING_FIX, "the Json.cpp binding rename (#25)") + class SessionDrainShapeTest(unittest.TestCase): """Stop() must read the drain predicate under the session mutex and bound the wait.""" diff --git a/cmake/common/helpers_common.cmake b/cmake/common/helpers_common.cmake index 3ecafcb260..abaa730f55 100644 --- a/cmake/common/helpers_common.cmake +++ b/cmake/common/helpers_common.cmake @@ -96,6 +96,39 @@ function(target_disable target) set_property(GLOBAL APPEND PROPERTY OBS_MODULES_DISABLED ${target}) endfunction() +# obs_msvc_exempt_c4201: Disable C4201 on one C++ target (MSVC /W4, #2626) +# +# /W4 reports C4201 "nameless struct/union" for the unions in +# libobs/graphics/vec{2,3,4}.h, libobs/util/profiler.h and +# frontend/api/obs-frontend-api.h. They are legal C11 (6.7.2.1p13) and consumed +# from C, so naming them is an API break; #2626 therefore decided on a +# per-target exemption, only for the C++ targets that include those headers and +# never as a blanket /wd4201 for every C++ target. +function(obs_msvc_exempt_c4201 target) + # The module options (ENABLE_BROWSER, ENABLE_WEBSOCKET, ...) make a submodule's + # CMakeLists return before add_library, so the target exists only when that + # module is actually built; nothing to exempt otherwise. + if(NOT TARGET ${target}) + return() + endif() + target_compile_options(${target} PRIVATE $<$:/wd4201>) +endfunction() + +# obs_msvc_exempt_c4505: Disable C4505 on one C++ target (MSVC /W4, #2626) +# +# /W4 reports C4505 "unreferenced function with internal linkage has been +# removed" for the static SetHighDPIv2Scaling() in the obs-browser submodule's +# obs-browser-page-main.cpp. That function is dead in obs-browser, not in this +# tree: deleting it belongs to an obs-rust/obs-browser change, so until that +# lands the target gets the same per-target exemption properties-view already +# uses, and never a blanket /wd4505 for every C++ target. +function(obs_msvc_exempt_c4505 target) + if(NOT TARGET ${target}) + return() + endif() + target_compile_options(${target} PRIVATE $<$:/wd4505>) +endfunction() + # _handle_generator_expression_dependency: Helper function to yield dependency from a generator expression function(_handle_generator_expression_dependency library) set(oneValueArgs FOUND_VAR) diff --git a/cmake/windows/compilerconfig.cmake b/cmake/windows/compilerconfig.cmake index b2620ce19a..e060111765 100644 --- a/cmake/windows/compilerconfig.cmake +++ b/cmake/windows/compilerconfig.cmake @@ -65,7 +65,7 @@ if(CMAKE_CXX_STANDARD GREATER_EQUAL 20) endif() add_compile_options( - /W3 + /W4 /utf-8 /Brepro /permissive- @@ -97,7 +97,3 @@ add_link_options( /DEBUG /Brepro ) - -if(CMAKE_COMPILE_WARNING_AS_ERROR) - add_link_options(/WX) -endif() diff --git a/deps/libcaption/CMakeLists.txt b/deps/libcaption/CMakeLists.txt index 9b462979d9..e7fa94c127 100644 --- a/deps/libcaption/CMakeLists.txt +++ b/deps/libcaption/CMakeLists.txt @@ -39,6 +39,12 @@ target_compile_options( $<$:-Wno-cast-qual> $<$:-Wno-comma> $<$:-Wno-pedantic> + # MSVC /W4 (#2626): vendored upstream C stays vendored, with its own + # suppressions instead of edits (the #516 vendored-code exemption). + $<$:/wd4244> + $<$:/wd4701> + $<$:/wd4702> + $<$:/wd4703> ) set_target_properties(caption PROPERTIES FOLDER deps POSITION_INDEPENDENT_CODE TRUE) diff --git a/deps/libdshowcapture/CMakeLists.txt b/deps/libdshowcapture/CMakeLists.txt index 2e04053129..bdda77d184 100644 --- a/deps/libdshowcapture/CMakeLists.txt +++ b/deps/libdshowcapture/CMakeLists.txt @@ -40,4 +40,16 @@ target_include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/src/external/capture-device-support/Library") target_compile_definitions(libdshowcapture INTERFACE _UP_WINDOWS=1) -target_compile_options(libdshowcapture INTERFACE /wd4005 /wd4018) + +# /wd4005 and /wd4018 are the vendored-code suppressions this library has always +# carried. The MSVC /W4-only C4244/C4456/C4458 below belong to the same exempt set +# (#2626, #516): src/source/device.cpp:483 shadows its `defaultMT` local, +# src/source/encoder.cpp / output-filter.cpp shadow the class members `config` +# and `pin`, and external/capture-device-support/Library/ElgatoUVCDevice.cpp:218 +# stores an int into a uint8_t. Fixing them would mean editing the vendored +# submodule, so the warnings are suppressed for the consumers that compile these +# sources (win-dshow, obs-virtualcam-module). +target_compile_options( + libdshowcapture + INTERFACE /wd4005 /wd4018 $<$:/wd4244;/wd4456;/wd4458> +) diff --git a/deps/w32-pthreads/CMakeLists.txt b/deps/w32-pthreads/CMakeLists.txt index 257e75249d..dd22906e29 100644 --- a/deps/w32-pthreads/CMakeLists.txt +++ b/deps/w32-pthreads/CMakeLists.txt @@ -10,6 +10,21 @@ target_sources( target_compile_definitions(w32-pthreads PRIVATE __CLEANUP_C PTW32_BUILD) +# MSVC /W4 (#2626): vendored pthreads-win32 keeps its own suppressions rather +# than source edits (the #516 vendored-code exemption): C4324 alignment +# padding, C4057 indirection of a volatile LONG64/size_t pair in the MCS lock, +# C4310 a truncating constant cast, C4456 a shadowed local, C4702 the +# unreachable path after its own assert. +target_compile_options( + w32-pthreads + PRIVATE + $<$:/wd4057> + $<$:/wd4702> + $<$:/wd4310> + $<$:/wd4324> + $<$:/wd4456> +) + target_include_directories(w32-pthreads PUBLIC "$") configure_file(cmake/windows/obs-module.rc.in w32-pthreads.rc) diff --git a/frontend/CMakeLists.txt b/frontend/CMakeLists.txt index a4a446fda8..13210103ec 100644 --- a/frontend/CMakeLists.txt +++ b/frontend/CMakeLists.txt @@ -30,6 +30,7 @@ endif() add_executable(obs-studio) add_executable(OBS::studio ALIAS obs-studio) +obs_msvc_exempt_c4201(obs-studio) include(cmake/sources.cmake) diff --git a/frontend/OBSApp.cpp.hpp b/frontend/OBSApp.cpp.hpp index af20339235..049ab28727 100644 --- a/frontend/OBSApp.cpp.hpp +++ b/frontend/OBSApp.cpp.hpp @@ -631,9 +631,9 @@ bool OBSApp::InitGlobalConfig() return userConfigResult; } -bool OBSApp::InitUserConfig(std::filesystem::path &userConfigLocation, uint32_t lastVersion) +bool OBSApp::InitUserConfig(std::filesystem::path &configLocation, uint32_t lastVersion) { - const std::string userConfigFile = userConfigLocation.u8string() + "/" OBS_CONFIG_DIRECTORY "/user.ini"; + const std::string userConfigFile = configLocation.u8string() + "/" OBS_CONFIG_DIRECTORY "/user.ini"; int errorCode = userConfig.Open(userConfigFile.c_str(), CONFIG_OPEN_ALWAYS); diff --git a/frontend/OBSApp.hpp b/frontend/OBSApp.hpp index 097883e83a..3b30fa541e 100644 --- a/frontend/OBSApp.hpp +++ b/frontend/OBSApp.hpp @@ -110,7 +110,7 @@ class OBSApp : public QApplication { void InitCrashHandler(); void MigrateLegacySettings(uint32_t lastVersion); - bool InitUserConfig(std::filesystem::path &userConfigLocation, uint32_t lastVersion); + bool InitUserConfig(std::filesystem::path &configLocation, uint32_t lastVersion); void InitUserConfigDefaults(); bool InitLocale(); diff --git a/frontend/OBSApp_Themes.cpp.hpp b/frontend/OBSApp_Themes.cpp.hpp index 8984a8285e..a6a4f221b9 100644 --- a/frontend/OBSApp_Themes.cpp.hpp +++ b/frontend/OBSApp_Themes.cpp.hpp @@ -239,7 +239,8 @@ static bool ParseMath(CFParser &cfp, QStringList &values, vectormultiviewLayout = multiviewLayout; - this->drawLabel = drawLabel; - this->drawSafeArea = drawSafeArea; + this->multiviewLayout = layout; + this->drawLabel = showLabel; + this->drawSafeArea = showSafeArea; struct obs_video_info ovi; obs_get_video_info(&ovi); diff --git a/frontend/components/Multiview.hpp b/frontend/components/Multiview.hpp index c7382bdeb1..a6194f467a 100644 --- a/frontend/components/Multiview.hpp +++ b/frontend/components/Multiview.hpp @@ -21,7 +21,7 @@ class Multiview { public: Multiview(); ~Multiview(); - void Update(MultiviewLayout multiviewLayout, bool drawLabel, bool drawSafeArea); + void Update(MultiviewLayout layout, bool showLabel, bool showSafeArea); void Render(uint32_t cx, uint32_t cy); OBSSource GetSourceByPosition(int x, int y); diff --git a/frontend/components/OBSAdvAudioCtrl.cpp.hpp b/frontend/components/OBSAdvAudioCtrl.cpp.hpp index f400da9119..347d4ae555 100644 --- a/frontend/components/OBSAdvAudioCtrl.cpp.hpp +++ b/frontend/components/OBSAdvAudioCtrl.cpp.hpp @@ -389,10 +389,10 @@ void OBSAdvAudioCtrl::volumeChanged(double db) std::bind(undo_redo, std::placeholders::_1, val), uuid, uuid, true); } -void OBSAdvAudioCtrl::percentChanged(int percent) +void OBSAdvAudioCtrl::percentChanged(int newPercent) { float prev = obs_source_get_volume(source); - float val = (float)percent / 100.0f; + float val = (float)newPercent / 100.0f; obs_source_set_volume(source, val); diff --git a/frontend/components/OBSAdvAudioCtrl.hpp b/frontend/components/OBSAdvAudioCtrl.hpp index e194088a4f..c00c50bb09 100644 --- a/frontend/components/OBSAdvAudioCtrl.hpp +++ b/frontend/components/OBSAdvAudioCtrl.hpp @@ -81,7 +81,7 @@ public slots: void SetSourceName(QString newName); void volumeChanged(double db); - void percentChanged(int percent); + void percentChanged(int newPercent); void downmixMonoChanged(bool checked); void balanceChanged(int val); void syncOffsetChanged(int milliseconds); diff --git a/frontend/components/SourceToolbar.cpp.hpp b/frontend/components/SourceToolbar.cpp.hpp index 48b148361e..6c816776b9 100644 --- a/frontend/components/SourceToolbar.cpp.hpp +++ b/frontend/components/SourceToolbar.cpp.hpp @@ -30,8 +30,8 @@ void SourceToolbar::SetUndoProperties(obs_source_t *source, bool repeatable) return; } std::string scene_uuid = obs_source_get_uuid(currentSceneSource); - auto undo_redo = [scene_uuid = std::move(scene_uuid), main](const std::string &data) { - OBSDataAutoRelease settings = obs_data_create_from_json(data.c_str()); + auto undo_redo = [scene_uuid = std::move(scene_uuid), main](const std::string &settingsJson) { + OBSDataAutoRelease settings = obs_data_create_from_json(settingsJson.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(settings, "undo_suuid")); obs_source_reset_settings(source, settings); diff --git a/frontend/components/SourceTree.cpp.hpp b/frontend/components/SourceTree.cpp.hpp index b3541b1452..60ffb484c9 100644 --- a/frontend/components/SourceTree.cpp.hpp +++ b/frontend/components/SourceTree.cpp.hpp @@ -162,9 +162,9 @@ void SourceTree::dropEvent(QDropEvent *event) bool dropOnCollapsed = false; if (dropGroup) { - obs_data_t *data = obs_sceneitem_get_private_settings(dropGroup); - dropOnCollapsed = obs_data_get_bool(data, "collapsed"); - obs_data_release(data); + obs_data_t *privateSettings = obs_sceneitem_get_private_settings(dropGroup); + dropOnCollapsed = obs_data_get_bool(privateSettings, "collapsed"); + obs_data_release(privateSettings); } if (indicator == QAbstractItemView::BelowItem || indicator == QAbstractItemView::OnItem || @@ -378,8 +378,8 @@ void SourceTree::dropEvent(QDropEvent *event) using updateScene_t = decltype(updateScene); - auto preUpdateScene = [](void *data, obs_scene_t *) { - (*static_cast(data))(); + auto preUpdateScene = [](void *updateFn, obs_scene_t *) { + (*static_cast(updateFn))(); }; ignoreReorder = true; diff --git a/frontend/components/SourceTreeItem.cpp.hpp b/frontend/components/SourceTreeItem.cpp.hpp index df900a9ec4..434156bdec 100644 --- a/frontend/components/SourceTreeItem.cpp.hpp +++ b/frontend/components/SourceTreeItem.cpp.hpp @@ -185,8 +185,8 @@ void SourceTreeItem::ReconnectSignals() /* --------------------------------------------------------- */ - auto removeItem = [](void *data, calldata_t *cd) { - SourceTreeItem *this_ = static_cast(data); + auto removeItem = [](void *handler_data, calldata_t *cd) { + SourceTreeItem *this_ = static_cast(handler_data); OBSSceneItem curItem = (obs_sceneitem_t *)calldata_ptr(cd, "item"); OBSScene curScene = (obs_scene_t *)calldata_ptr(cd, "scene"); @@ -199,8 +199,8 @@ void SourceTreeItem::ReconnectSignals() } }; - auto itemVisible = [](void *data, calldata_t *cd) { - SourceTreeItem *this_ = static_cast(data); + auto itemVisible = [](void *handler_data, calldata_t *cd) { + SourceTreeItem *this_ = static_cast(handler_data); obs_sceneitem_t *curItem = (obs_sceneitem_t *)calldata_ptr(cd, "item"); bool visible = calldata_bool(cd, "visible"); @@ -209,8 +209,8 @@ void SourceTreeItem::ReconnectSignals() } }; - auto itemLocked = [](void *data, calldata_t *cd) { - SourceTreeItem *this_ = static_cast(data); + auto itemLocked = [](void *handler_data, calldata_t *cd) { + SourceTreeItem *this_ = static_cast(handler_data); obs_sceneitem_t *curItem = (obs_sceneitem_t *)calldata_ptr(cd, "item"); bool locked = calldata_bool(cd, "locked"); @@ -219,8 +219,8 @@ void SourceTreeItem::ReconnectSignals() } }; - auto itemSelect = [](void *data, calldata_t *cd) { - SourceTreeItem *this_ = static_cast(data); + auto itemSelect = [](void *handler_data, calldata_t *cd) { + SourceTreeItem *this_ = static_cast(handler_data); obs_sceneitem_t *curItem = (obs_sceneitem_t *)calldata_ptr(cd, "item"); if (curItem == this_->sceneitem) { @@ -228,8 +228,8 @@ void SourceTreeItem::ReconnectSignals() } }; - auto itemDeselect = [](void *data, calldata_t *cd) { - SourceTreeItem *this_ = static_cast(data); + auto itemDeselect = [](void *handler_data, calldata_t *cd) { + SourceTreeItem *this_ = static_cast(handler_data); obs_sceneitem_t *curItem = (obs_sceneitem_t *)calldata_ptr(cd, "item"); if (curItem == this_->sceneitem) { @@ -237,8 +237,8 @@ void SourceTreeItem::ReconnectSignals() } }; - auto reorderGroup = [](void *data, calldata_t *) { - SourceTreeItem *this_ = static_cast(data); + auto reorderGroup = [](void *handler_data, calldata_t *) { + SourceTreeItem *this_ = static_cast(handler_data); QMetaObject::invokeMethod(this_->tree, &SourceTree::ReorderItems); }; @@ -262,8 +262,8 @@ void SourceTreeItem::ReconnectSignals() /* --------------------------------------------------------- */ - auto removeSource = [](void *data, calldata_t *) { - SourceTreeItem *this_ = static_cast(data); + auto removeSource = [](void *handler_data, calldata_t *) { + SourceTreeItem *this_ = static_cast(handler_data); this_->DisconnectSignals(); this_->sceneitem = nullptr; QMetaObject::invokeMethod(this_->tree, &SourceTree::RefreshItems); @@ -300,7 +300,7 @@ void SourceTreeItem::enterEvent(QEnterEvent *event) OBSBasicPreview *preview = OBSBasicPreview::Get(); - std::lock_guard lock(preview->selectMutex); + std::lock_guard select_lock(preview->selectMutex); preview->hoveredPreviewItems.clear(); preview->hoveredPreviewItems.push_back(sceneitem); } @@ -311,7 +311,7 @@ void SourceTreeItem::leaveEvent(QEvent *event) OBSBasicPreview *preview = OBSBasicPreview::Get(); - std::lock_guard lock(preview->selectMutex); + std::lock_guard select_lock(preview->selectMutex); preview->hoveredPreviewItems.clear(); } @@ -407,8 +407,8 @@ void SourceTreeItem::ExitEditModeInternal(bool save) QSignalBlocker sourcesSignalBlocker(this); std::string prevName(obs_source_get_name(source)); std::string scene_uuid = obs_source_get_uuid(main->GetCurrentSceneSource()); - auto undo = [scene_uuid, prevName, main](const std::string &data) { - OBSSourceAutoRelease source = obs_get_source_by_uuid(data.c_str()); + auto undo = [scene_uuid, prevName, main](const std::string &uuid) { + OBSSourceAutoRelease source = obs_get_source_by_uuid(uuid.c_str()); obs_source_set_name(source, prevName.c_str()); OBSSourceAutoRelease scene_source = obs_get_source_by_uuid(scene_uuid.c_str()); @@ -417,8 +417,8 @@ void SourceTreeItem::ExitEditModeInternal(bool save) std::string editedName = newName; - auto redo = [scene_uuid, main, editedName](const std::string &data) { - OBSSourceAutoRelease source = obs_get_source_by_uuid(data.c_str()); + auto redo = [scene_uuid, main, editedName](const std::string &uuid) { + OBSSourceAutoRelease source = obs_get_source_by_uuid(uuid.c_str()); obs_source_set_name(source, editedName.c_str()); OBSSourceAutoRelease scene_source = obs_get_source_by_uuid(scene_uuid.c_str()); @@ -528,9 +528,9 @@ void SourceTreeItem::Update(bool force) ConfigurePlatformSourceItemWidget(expand); boxLayout->insertWidget(0, expand); - OBSDataAutoRelease data = obs_sceneitem_get_private_settings(sceneitem); + OBSDataAutoRelease privData = obs_sceneitem_get_private_settings(sceneitem); expand->blockSignals(true); - expand->setChecked(obs_data_get_bool(data, "collapsed")); + expand->setChecked(obs_data_get_bool(privData, "collapsed")); expand->blockSignals(false); connect(expand, &QPushButton::toggled, this, &SourceTreeItem::ExpandClicked); @@ -543,9 +543,9 @@ void SourceTreeItem::Update(bool force) void SourceTreeItem::ExpandClicked(bool checked) { - OBSDataAutoRelease data = obs_sceneitem_get_private_settings(sceneitem); + OBSDataAutoRelease privData = obs_sceneitem_get_private_settings(sceneitem); - obs_data_set_bool(data, "collapsed", checked); + obs_data_set_bool(privData, "collapsed", checked); if (!checked) { tree->GetStm()->ExpandGroup(sceneitem); diff --git a/frontend/components/SourceTreeModel.cpp.hpp b/frontend/components/SourceTreeModel.cpp.hpp index 667e6b8a04..c504b91621 100644 --- a/frontend/components/SourceTreeModel.cpp.hpp +++ b/frontend/components/SourceTreeModel.cpp.hpp @@ -332,8 +332,8 @@ void SourceTreeModel::GroupSelectedItems(QModelIndexList &indices) main->undo_s.push_disabled(); - for (obs_sceneitem_t *item : item_order) { - obs_sceneitem_select(item, false); + for (obs_sceneitem_t *groupItem : item_order) { + obs_sceneitem_select(groupItem, false); } hasGroups = true; diff --git a/frontend/components/VolumeControl.cpp.hpp b/frontend/components/VolumeControl.cpp.hpp index 43c7cbe811..1626cf31c4 100644 --- a/frontend/components/VolumeControl.cpp.hpp +++ b/frontend/components/VolumeControl.cpp.hpp @@ -226,13 +226,13 @@ void VolumeControl::obsSourceDestroy(void *data, calldata_t *) Qt::QueuedConnection); } -void VolumeControl::setLayoutVertical(bool vertical) +void VolumeControl::setLayoutVertical(bool verticalLayout) { QBoxLayout *newLayout = new QBoxLayout(QBoxLayout::TopToBottom); newLayout->setContentsMargins(0, 0, 0, 0); newLayout->setSpacing(0); - if (vertical) { + if (verticalLayout) { setMaximumWidth(110); setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); @@ -502,17 +502,17 @@ void VolumeControl::renameSource() QAction *action = reinterpret_cast(sender()); OBSSource source = action->property("source").value(); - std::string uuid = obs_source_get_uuid(source); + std::string sourceUuid = obs_source_get_uuid(source); OBSBasic *main = OBSBasic::Get(); // Defer the rename dialog to avoid blocking the UI thread while the context menu is closing, which can cause issues on some platforms - QTimer::singleShot(0, main, [main, uuid]() { + QTimer::singleShot(0, main, [main, sourceUuid]() { if (!main) { return; } - OBSSourceAutoRelease source = obs_get_source_by_uuid(uuid.c_str()); + OBSSourceAutoRelease source = obs_get_source_by_uuid(sourceUuid.c_str()); if (!source) { return; } @@ -544,19 +544,20 @@ void VolumeControl::renameSource() continue; } - std::string prevName(obs_source_get_name(source)); - auto undo = [prevName](const std::string &data) { - OBSSourceAutoRelease source = obs_get_source_by_uuid(data.c_str()); - obs_source_set_name(source, prevName.c_str()); + std::string nameToRestore(obs_source_get_name(source)); + auto undo = [nameToRestore](const std::string &undoUuid) { + OBSSourceAutoRelease source = obs_get_source_by_uuid(undoUuid.c_str()); + obs_source_set_name(source, nameToRestore.c_str()); }; std::string editedName = name; - auto redo = [editedName](const std::string &data) { - OBSSourceAutoRelease source = obs_get_source_by_uuid(data.c_str()); + auto redo = [editedName](const std::string &redoUuid) { + OBSSourceAutoRelease source = obs_get_source_by_uuid(redoUuid.c_str()); obs_source_set_name(source, editedName.c_str()); }; - main->undo_s.add_action(QTStr("Undo.Rename").arg(name.c_str()), undo, redo, uuid, uuid); + main->undo_s.add_action(QTStr("Undo.Rename").arg(name.c_str()), undo, redo, sourceUuid, + sourceUuid); obs_source_set_name(source, name.c_str()); break; @@ -855,8 +856,8 @@ void VolumeControl::updateText() bool muted = obs_source_muted(source); const char *accTextLookup = muted ? "VolControl.SliderMuted" : "VolControl.SliderUnmuted"; - QString sourceName = obs_source_get_name(source); - QString accText = QTStr(accTextLookup).arg(sourceName); + QString sourceLabel = obs_source_get_name(source); + QString accText = QTStr(accTextLookup).arg(sourceLabel); slider->setAccessibleName(accText); } diff --git a/frontend/components/VolumeName.cpp.hpp b/frontend/components/VolumeName.cpp.hpp index bd05ea544c..125a16310d 100644 --- a/frontend/components/VolumeName.cpp.hpp +++ b/frontend/components/VolumeName.cpp.hpp @@ -148,11 +148,11 @@ void VolumeName::paintEvent(QPaintEvent *) QRect contentRect = style()->subElementRect(QStyle::SE_PushButtonContents, &opt, this); int paddingRight = opt.rect.right() - contentRect.right(); - int indicatorWidth = style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this); + int arrowWidth = style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this); QStyleOption arrowOpt = opt; - QRect arrowRect(opt.rect.right() - indicatorWidth - paddingRight / 2, - opt.rect.center().y() - indicatorWidth / 2, indicatorWidth, indicatorWidth); + QRect arrowRect(opt.rect.right() - arrowWidth - paddingRight / 2, opt.rect.center().y() - arrowWidth / 2, + arrowWidth, arrowWidth); arrowOpt.rect = arrowRect; painter.drawPrimitive(QStyle::PE_IndicatorArrowDown, arrowOpt); diff --git a/frontend/components/VolumeSlider.cpp.hpp b/frontend/components/VolumeSlider.cpp.hpp index 23a1f6789d..af4e47c2de 100644 --- a/frontend/components/VolumeSlider.cpp.hpp +++ b/frontend/components/VolumeSlider.cpp.hpp @@ -29,7 +29,7 @@ void VolumeSlider::paintEvent(QPaintEvent *event) } QPainter painter(this); - QColor tickColor(91, 98, 115, 255); + QColor tickMarkColor(91, 98, 115, 255); obs_fader_conversion_t fader_db_to_def = obs_fader_db_to_def(fad); @@ -51,7 +51,7 @@ void VolumeSlider::paintEvent(QPaintEvent *event) float tickValue = fader_db_to_def(db); float xPos = groove.left() + (tickValue * sliderWidth) + (handle.width() / 2); - painter.fillRect(xPos, yPos, 1, tickLength, tickColor); + painter.fillRect(xPos, yPos, 1, tickLength, tickMarkColor); } } @@ -68,7 +68,7 @@ void VolumeSlider::paintEvent(QPaintEvent *event) float yPos = groove.height() + groove.top() - (tickValue * sliderHeight) - (handle.height() / 2); - painter.fillRect(xPos, yPos, tickLength, 1, tickColor); + painter.fillRect(xPos, yPos, tickLength, 1, tickMarkColor); } } diff --git a/frontend/dialogs/OBSBasicAdvAudio.cpp.hpp b/frontend/dialogs/OBSBasicAdvAudio.cpp.hpp index 3461768d3d..1a91f30c02 100644 --- a/frontend/dialogs/OBSBasicAdvAudio.cpp.hpp +++ b/frontend/dialogs/OBSBasicAdvAudio.cpp.hpp @@ -84,8 +84,8 @@ inline void OBSBasicAdvAudio::AddAudioSource(obs_source_t *source) InsertQObjectByName(controls, control); - for (auto control : controls) { - control->ShowAudioControl(ui->mainLayout); + for (auto *ctrl : controls) { + ctrl->ShowAudioControl(ui->mainLayout); } } diff --git a/frontend/dialogs/OBSBasicFilters.cpp.hpp b/frontend/dialogs/OBSBasicFilters.cpp.hpp index 261d76d804..4a148d2528 100644 --- a/frontend/dialogs/OBSBasicFilters.cpp.hpp +++ b/frontend/dialogs/OBSBasicFilters.cpp.hpp @@ -546,22 +546,22 @@ void OBSBasicFilters::AddNewFilter(const char *id) obs_data_set_string(uwrapper, "fname", obs_source_get_name(filter)); obs_data_set_string(uwrapper, "suuid", parent_uuid.c_str()); - auto undo = [scene_uuid](const std::string &data) { + auto undo = [scene_uuid](const std::string &json) { OBSSourceAutoRelease ssource = obs_get_source_by_uuid(scene_uuid.c_str()); OBSBasic::Get()->SetCurrentScene(ssource.Get(), true); - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + OBSDataAutoRelease dat = obs_data_create_from_json(json.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "suuid")); OBSSourceAutoRelease filter = obs_source_get_filter_by_name(source, obs_data_get_string(dat, "fname")); obs_source_filter_remove(source, filter); }; - auto redo = [scene_uuid](const std::string &data) { + auto redo = [scene_uuid](const std::string &json) { OBSSourceAutoRelease ssource = obs_get_source_by_uuid(scene_uuid.c_str()); OBSBasic::Get()->SetCurrentScene(ssource.Get(), true); - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + OBSDataAutoRelease dat = obs_data_create_from_json(json.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "undo_uuid")); OBSSourceAutoRelease filter = obs_load_source(dat); obs_source_filter_add(source, filter); @@ -1067,11 +1067,11 @@ void OBSBasicFilters::delete_filter(OBSSource filter) obs_data_set_string(wrapper, "undo_uuid", parent_uuid.c_str()); std::string scene_uuid = obs_source_get_uuid(OBSBasic::Get()->GetCurrentSceneSource()); - auto undo = [scene_uuid](const std::string &data) { + auto undo = [scene_uuid](const std::string &json) { OBSSourceAutoRelease ssource = obs_get_source_by_uuid(scene_uuid.c_str()); OBSBasic::Get()->SetCurrentScene(ssource.Get(), true); - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + OBSDataAutoRelease dat = obs_data_create_from_json(json.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "undo_uuid")); OBSSourceAutoRelease filter = obs_load_source(dat); obs_source_filter_add(source, filter); @@ -1080,11 +1080,11 @@ void OBSBasicFilters::delete_filter(OBSSource filter) OBSDataAutoRelease rwrapper = obs_data_create(); obs_data_set_string(rwrapper, "fname", obs_source_get_name(filter)); obs_data_set_string(rwrapper, "suuid", parent_uuid.c_str()); - auto redo = [scene_uuid](const std::string &data) { + auto redo = [scene_uuid](const std::string &json) { OBSSourceAutoRelease ssource = obs_get_source_by_uuid(scene_uuid.c_str()); OBSBasic::Get()->SetCurrentScene(ssource.Get(), true); - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + OBSDataAutoRelease dat = obs_data_create_from_json(json.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "suuid")); OBSSourceAutoRelease filter = obs_source_get_filter_by_name(source, obs_data_get_string(dat, "fname")); obs_source_filter_remove(source, filter); diff --git a/frontend/dialogs/OBSBasicProperties.cpp.hpp b/frontend/dialogs/OBSBasicProperties.cpp.hpp index 43ad01b0dc..d6b5fbb921 100644 --- a/frontend/dialogs/OBSBasicProperties.cpp.hpp +++ b/frontend/dialogs/OBSBasicProperties.cpp.hpp @@ -267,8 +267,8 @@ void OBSBasicProperties::on_buttonBox_clicked(QAbstractButton *button) std::string scene_uuid = obs_source_get_uuid(main->GetCurrentSceneSource()); - auto undo_redo = [scene_uuid](const std::string &data) { - OBSDataAutoRelease settings = obs_data_create_from_json(data.c_str()); + auto undo_redo = [scene_uuid](const std::string &json) { + OBSDataAutoRelease settings = obs_data_create_from_json(json.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(settings, "undo_uuid")); obs_source_reset_settings(source, settings); diff --git a/frontend/dialogs/OBSBasicSourceSelect.cpp.hpp b/frontend/dialogs/OBSBasicSourceSelect.cpp.hpp index f4d263542f..77d64ec208 100644 --- a/frontend/dialogs/OBSBasicSourceSelect.cpp.hpp +++ b/frontend/dialogs/OBSBasicSourceSelect.cpp.hpp @@ -713,12 +713,12 @@ void OBSBasicSourceSelect::createNew() return; } - OBSSource newSource = createResult.value(); - if (strcmp(obs_source_get_id(newSource), "group") == 0) { + OBSSource createdSource = createResult.value(); + if (strcmp(obs_source_get_id(createdSource), "group") == 0) { return; } - std::optional addResult = setupExistingSource(obs_source_get_uuid(newSource), visible, false); + std::optional addResult = setupExistingSource(obs_source_get_uuid(createdSource), visible, false); if (!addResult.has_value()) { return; } @@ -727,10 +727,10 @@ void OBSBasicSourceSelect::createNew() OBSBasic *main = reinterpret_cast(App()->GetMainWindow()); std::string sceneUuid = obs_source_get_uuid(main->GetCurrentSceneSource()); - auto undo = [sceneUuid](const std::string &data) { + auto undo = [sceneUuid](const std::string &uuid) { OBSBasic *main = OBSBasic::Get(); - OBSSourceAutoRelease source = obs_get_source_by_uuid(data.c_str()); + OBSSourceAutoRelease source = obs_get_source_by_uuid(uuid.c_str()); obs_source_remove(source); OBSSourceAutoRelease sceneSource = obs_get_source_by_uuid(sceneUuid.c_str()); @@ -742,13 +742,13 @@ void OBSBasicSourceSelect::createNew() obs_data_set_string(wrapper, "name", newName.c_str()); obs_data_set_bool(wrapper, "visible", visible); - auto redo = [sceneUuid](const std::string &data) { + auto redo = [sceneUuid](const std::string &uuid) { OBSBasic *main = OBSBasic::Get(); OBSSourceAutoRelease sceneSource = obs_get_source_by_uuid(sceneUuid.c_str()); main->SetCurrentScene(sceneSource.Get(), true); - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + OBSDataAutoRelease dat = obs_data_create_from_json(uuid.c_str()); std::optional createResult = setupNewSource(NULL, obs_data_get_string(dat, "id"), obs_data_get_string(dat, "name")); @@ -769,9 +769,9 @@ void OBSBasicSourceSelect::createNew() obs_sceneitem_set_id(item, static_cast(obs_data_get_int(dat, "item_id"))); }; undo_s.add_action(QTStr("Undo.Add").arg(QString::fromStdString(newName)), undo, redo, - std::string(obs_source_get_uuid(newSource)), std::string(obs_data_get_json(wrapper))); + std::string(obs_source_get_uuid(createdSource)), std::string(obs_data_get_json(wrapper))); - main->CreatePropertiesWindow(newSource); + main->CreatePropertiesWindow(createdSource); close(); } @@ -800,8 +800,8 @@ void OBSBasicSourceSelect::addExisting(const std::string &uuid, bool visible) OBSScene scene = obs_scene_from_source(sceneSource); OBSSceneItem item; - auto cb = [](obs_scene_t *, obs_sceneitem_t *sceneitem, void *data) { - OBSSceneItem &last = *static_cast(data); + auto cb = [](obs_scene_t *, obs_sceneitem_t *sceneitem, void *handler_data) { + OBSSceneItem &last = *static_cast(handler_data); last = sceneitem; return true; }; diff --git a/frontend/dialogs/OBSBasicTransform.cpp.hpp b/frontend/dialogs/OBSBasicTransform.cpp.hpp index 2f3ef35b58..98fdc198b2 100644 --- a/frontend/dialogs/OBSBasicTransform.cpp.hpp +++ b/frontend/dialogs/OBSBasicTransform.cpp.hpp @@ -114,11 +114,11 @@ OBSBasicTransform::~OBSBasicTransform() { OBSDataAutoRelease wrapper = obs_scene_save_transform_states(main->GetCurrentScene(), false); - auto undo_redo = [](const std::string &data) { - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + auto undo_redo = [](const std::string &json) { + OBSDataAutoRelease dat = obs_data_create_from_json(json.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "scene_uuid")); OBSBasic::Get()->SetCurrentScene(source.Get(), true); - obs_scene_load_transform_states(data.c_str()); + obs_scene_load_transform_states(json.c_str()); }; std::string redo_data(obs_data_get_json(wrapper)); diff --git a/frontend/dialogs/OBSBasicVCamConfig.cpp.hpp b/frontend/dialogs/OBSBasicVCamConfig.cpp.hpp index 6d571e03c1..d9dd9bd348 100644 --- a/frontend/dialogs/OBSBasicVCamConfig.cpp.hpp +++ b/frontend/dialogs/OBSBasicVCamConfig.cpp.hpp @@ -65,8 +65,8 @@ void OBSBasicVCamConfig::OutputTypeChanged() using AddSource_t = decltype(AddSource); obs_enum_sources( - [](void *data, obs_source_t *source) { - auto &AddSource = *static_cast(data); + [](void *handler_data, obs_source_t *source) { + auto &AddSource = *static_cast(handler_data); if (!obs_source_removed(source)) { AddSource(source); } diff --git a/frontend/importers/sl.cpp.hpp b/frontend/importers/sl.cpp.hpp index 6b5a06db46..1e3c0c343b 100644 --- a/frontend/importers/sl.cpp.hpp +++ b/frontend/importers/sl.cpp.hpp @@ -272,7 +272,7 @@ static int attempt_import(const Json &root, const string &name, Json &res) double vol = source["volume"].number_value(); bool muted = source["muted"].bool_value(); - string name = source["name"].string_value(); + string source_name = source["name"].string_value(); int monitoring = (int)source["monitoringType"].int_value(); Json::object out_hotkeys = Json::object{}; @@ -288,9 +288,9 @@ static int attempt_import(const Json &root, const string &name, Json &res) } int copy = 1; - string out_name = name; + string out_name = source_name; while (sl_source_name_exists(out_sources, out_name)) { - out_name = name + "(" + to_string(copy++) + ")"; + out_name = source_name + "(" + to_string(copy++) + ")"; } string sl_id = source["id"].string_value(); @@ -325,7 +325,7 @@ static int attempt_import(const Json &root, const string &name, Json &res) Json in_settings = scene["settings"]; - string name = scene["name"].string_value(); + string imported_scene_name = scene["name"].string_value(); Json::object out_hotkeys = Json::object{}; get_hotkey_bindings(out_hotkeys, hotkey_items, ""); @@ -340,9 +340,9 @@ static int attempt_import(const Json &root, const string &name, Json &res) } int copy = 1; - string out_name = name; + string out_name = imported_scene_name; while (sl_source_name_exists(out_sources, out_name)) { - out_name = name + "(" + to_string(copy++) + ")"; + out_name = imported_scene_name + "(" + to_string(copy++) + ")"; } if (scene_name.empty()) { @@ -372,16 +372,16 @@ static int attempt_import(const Json &root, const string &name, Json &res) Json in_settings = transition["settings"]; int duration = transition["duration"].int_value(); - string name = transition["name"].string_value(); + string imported_transition_name = transition["name"].string_value(); string id = transition["id"].string_value(); if (id == t_id) { - transition_name = name; + transition_name = imported_transition_name; } out_transitions.push_back(Json::object{{"id", transition["type"]}, {"settings", in_settings}, - {"name", name}, + {"name", imported_transition_name}, {"duration", duration}}); } diff --git a/frontend/importers/xsplit.cpp.hpp b/frontend/importers/xsplit.cpp.hpp index 0874451a24..1e81a4c81c 100644 --- a/frontend/importers/xsplit.cpp.hpp +++ b/frontend/importers/xsplit.cpp.hpp @@ -329,10 +329,10 @@ static void parse_items(QDomNode &item, Json::array &items, Json::array &sources QDomNode el = doc.documentElement(); QDomNamedNodeMap o_attr = el.attributes(); - QString name = o_attr.namedItem("wndname").nodeValue(); + QString window_name = o_attr.namedItem("wndname").nodeValue(); QString exec = o_attr.namedItem("imagename").nodeValue(); - QString res = name = "::" + exec; + QString res = window_name = "::" + exec; source["id"] = "game_capture"; settings["window"] = res.toStdString(); @@ -353,8 +353,8 @@ static void parse_items(QDomNode &item, Json::array &items, Json::array &sources } } else if (type == 11) { QString id = attr.namedItem("item").nodeValue(); - Json source = get_source_with_id(id.toStdString(), sources); - name = source["name"].string_value(); + Json linked_source = get_source_with_id(id.toStdString(), sources); + name = linked_source["name"].string_value(); goto skip; } diff --git a/frontend/oauth/AuthListener.cpp.hpp b/frontend/oauth/AuthListener.cpp.hpp index 6cf987c976..e83af41f60 100644 --- a/frontend/oauth/AuthListener.cpp.hpp +++ b/frontend/oauth/AuthListener.cpp.hpp @@ -33,9 +33,9 @@ quint16 AuthListener::GetPort() return server ? server->serverPort() : 0; } -void AuthListener::SetState(QString state) +void AuthListener::SetState(QString newState) { - this->state = state; + this->state = newState; } void AuthListener::NewConnection() diff --git a/frontend/oauth/AuthListener.hpp b/frontend/oauth/AuthListener.hpp index 65bcf540ec..d27f6ae94d 100644 --- a/frontend/oauth/AuthListener.hpp +++ b/frontend/oauth/AuthListener.hpp @@ -20,5 +20,5 @@ class AuthListener : public QObject { public: explicit AuthListener(QObject *parent = 0); quint16 GetPort(); - void SetState(QString state); + void SetState(QString newState); }; diff --git a/frontend/obs-main.cpp.hpp b/frontend/obs-main.cpp.hpp index 9effc9dbf2..8cfd78c244 100644 --- a/frontend/obs-main.cpp.hpp +++ b/frontend/obs-main.cpp.hpp @@ -144,20 +144,20 @@ static inline void LogStringChunk(fstream &logFile, char *str, int log_level) timeString += ": "; while (*nextLine) { - char *nextLine = strchr(str, '\n'); - if (!nextLine) { + char *lineEnd = strchr(str, '\n'); + if (!lineEnd) { break; } - if (nextLine != str && nextLine[-1] == '\r') { - nextLine[-1] = 0; + if (lineEnd != str && lineEnd[-1] == '\r') { + lineEnd[-1] = 0; } else { - nextLine[0] = 0; + lineEnd[0] = 0; } LogString(logFile, timeString.c_str(), str, log_level); - nextLine++; - str = nextLine; + lineEnd++; + str = lineEnd; } LogString(logFile, timeString.c_str(), str, log_level); diff --git a/frontend/settings/OBSBasicSettings.cpp.hpp b/frontend/settings/OBSBasicSettings.cpp.hpp index bc6b651efc..f2754169ed 100644 --- a/frontend/settings/OBSBasicSettings.cpp.hpp +++ b/frontend/settings/OBSBasicSettings.cpp.hpp @@ -716,8 +716,8 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) LoadColorFormats(); LoadFormats(); - auto ReloadAudioSources = [](void *data, calldata_t *param) { - auto settings = static_cast(data); + auto ReloadAudioSources = [](void *handler_data, calldata_t *param) { + auto settings = static_cast(handler_data); auto source = static_cast(calldata_ptr(param, "source")); if (!source) { @@ -735,14 +735,14 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) hotkeyConflictIcon = QIcon::fromTheme("obs", QIcon(":/res/images/warning.svg")); - auto ReloadHotkeys = [](void *data, calldata_t *) { - auto settings = static_cast(data); + auto ReloadHotkeys = [](void *handler_data, calldata_t *) { + auto settings = static_cast(handler_data); QMetaObject::invokeMethod(settings, &OBSBasicSettings::ReloadHotkeys, OBS_INVALID_HOTKEY_ID); }; hotkeyRegistered.Connect(obs_get_signal_handler(), "hotkey_register", ReloadHotkeys, this); - auto ReloadHotkeysIgnore = [](void *data, calldata_t *param) { - auto settings = static_cast(data); + auto ReloadHotkeysIgnore = [](void *handler_data, calldata_t *param) { + auto settings = static_cast(handler_data); auto key = static_cast(calldata_ptr(param, "key")); QMetaObject::invokeMethod(settings, &OBSBasicSettings::ReloadHotkeys, obs_hotkey_get_id(key)); }; @@ -1759,7 +1759,7 @@ void OBSBasicSettings::LoadSimpleOutputSettings() const char *streamAudioEnc = config_get_string(main->Config(), "SimpleOutput", "StreamAudioEncoder"); int audioBitrate = config_get_uint(main->Config(), "SimpleOutput", "ABitrate"); bool advanced = config_get_bool(main->Config(), "SimpleOutput", "UseAdvanced"); - const char *preset = config_get_string(main->Config(), "SimpleOutput", "Preset"); + const char *preset_value = config_get_string(main->Config(), "SimpleOutput", "Preset"); const char *qsvPreset = config_get_string(main->Config(), "SimpleOutput", "QSVPreset"); const char *nvPreset = config_get_string(main->Config(), "SimpleOutput", "NVENCPreset2"); const char *amdPreset = config_get_string(main->Config(), "SimpleOutput", "AMDPreset"); @@ -1781,7 +1781,7 @@ void OBSBasicSettings::LoadSimpleOutputSettings() ui->simpleOutRecTrack5->setChecked(tracks & (1 << 4)); ui->simpleOutRecTrack6->setChecked(tracks & (1 << 5)); - curPreset = preset; + curPreset = preset_value; curQSVPreset = qsvPreset; curNVENCPreset = nvPreset; curAMDPreset = amdPreset; @@ -1930,9 +1930,9 @@ void OBSBasicSettings::LoadAdvOutputStreamingSettings() ui->advOutMultiTrack6->setChecked(audioMixes & (1 << 5)); obs_service_t *service_obj = main->GetService(); - const char *protocol = nullptr; - protocol = obs_service_get_protocol(service_obj); - SwapMultiTrack(protocol); + const char *service_protocol = nullptr; + service_protocol = obs_service_get_protocol(service_obj); + SwapMultiTrack(service_protocol); } OBSPropertiesView *OBSBasicSettings::CreateEncoderPropertyView(const char *encoder, const char *path, bool changed) @@ -1947,9 +1947,10 @@ OBSPropertiesView *OBSBasicSettings::CreateEncoderPropertyView(const char *encod const std::filesystem::path jsonFilePath = currentProfile.path / std::filesystem::u8path(path); if (!jsonFilePath.empty()) { - obs_data_t *data = obs_data_create_from_json_file_safe(jsonFilePath.u8string().c_str(), "bak"); - obs_data_apply(settings, data); - obs_data_release(data); + obs_data_t *saved_settings = + obs_data_create_from_json_file_safe(jsonFilePath.u8string().c_str(), "bak"); + obs_data_apply(settings, saved_settings); + obs_data_release(saved_settings); } } @@ -2485,32 +2486,32 @@ void OBSBasicSettings::LoadAudioSources() auto handler = obs_source_get_signal_handler(source); audioSourceSignals.emplace_back( handler, "push_to_mute_changed", - [](void *data, calldata_t *param) { - auto checkBox = static_cast(data); + [](void *handler_data, calldata_t *param) { + auto checkBox = static_cast(handler_data); bool enabled = calldata_bool(param, "enabled"); QMetaObject::invokeMethod(checkBox, &SilentUpdateCheckBox::setCheckedSilently, enabled); }, ptmCB); audioSourceSignals.emplace_back( handler, "push_to_mute_delay", - [](void *data, calldata_t *param) { - auto spinBox = static_cast(data); + [](void *handler_data, calldata_t *param) { + auto spinBox = static_cast(handler_data); auto delay = static_cast(calldata_int(param, "delay")); QMetaObject::invokeMethod(spinBox, &SilentUpdateSpinBox::setValueSilently, delay); }, ptmSB); audioSourceSignals.emplace_back( handler, "push_to_talk_changed", - [](void *data, calldata_t *param) { - auto checkBox = static_cast(data); + [](void *handler_data, calldata_t *param) { + auto checkBox = static_cast(handler_data); bool enabled = calldata_bool(param, "enabled"); QMetaObject::invokeMethod(checkBox, &SilentUpdateCheckBox::setCheckedSilently, enabled); }, pttCB); audioSourceSignals.emplace_back( handler, "push_to_talk_delay", - [](void *data, calldata_t *param) { - auto spinBox = static_cast(data); + [](void *handler_data, calldata_t *param) { + auto spinBox = static_cast(handler_data); auto delay = static_cast(calldata_int(param, "delay")); QMetaObject::invokeMethod(spinBox, &SilentUpdateSpinBox::setValueSilently, delay); }, @@ -2533,8 +2534,8 @@ void OBSBasicSettings::LoadAudioSources() using AddSource_t = decltype(AddSource); obs_enum_sources( - [](void *data, obs_source_t *source) { - auto &AddSource = *static_cast(data); + [](void *handler_data, obs_source_t *source) { + auto &AddSource = *static_cast(handler_data); if (!obs_source_removed(source)) { AddSource(source); } @@ -2937,8 +2938,8 @@ void OBSBasicSettings::LoadHotkeySettings(obs_hotkey_id ignoreKey) using keys_t = map>; keys_t keys; obs_enum_hotkey_bindings( - [](void *data, size_t, obs_hotkey_binding_t *binding) { - auto &keys = *static_cast(data); + [](void *handler_data, size_t, obs_hotkey_binding_t *binding) { + auto &keys = *static_cast(handler_data); keys[obs_hotkey_binding_get_hotkey_id(binding)].emplace_back( obs_hotkey_binding_get_key_combination(binding)); @@ -3081,17 +3082,17 @@ void OBSBasicSettings::LoadHotkeySettings(obs_hotkey_id ignoreKey) }); }; - auto data = make_tuple(RegisterHotkey, std::move(keys), ignoreKey, this); - using data_t = decltype(data); + auto hotkey_enum_data = make_tuple(RegisterHotkey, std::move(keys), ignoreKey, this); + using data_t = decltype(hotkey_enum_data); obs_enum_hotkeys( - [](void *data, obs_hotkey_id id, obs_hotkey_t *key) { - data_t &d = *static_cast(data); + [](void *handler_data, obs_hotkey_id id, obs_hotkey_t *key) { + data_t &d = *static_cast(handler_data); if (id != get<2>(d)) { LayoutHotkey(get<3>(d), id, key, get<0>(d), get<1>(d)); } return true; }, - &data); + &hotkey_enum_data); for (auto keyId : pairIds) { auto data1 = pairLabels.find(keyId); @@ -3887,9 +3888,9 @@ void OBSBasicSettings::SaveHotkeySettings() OBSDataArrayAutoRelease array = obs_hotkey_save(hw.id); OBSBasic::MarkSavedHotkeys(array); - OBSDataAutoRelease data = obs_data_create(); - obs_data_set_array(data, "bindings", array); - const char *json = obs_data_get_json(data); + OBSDataAutoRelease bindings_data = obs_data_create(); + obs_data_set_array(bindings_data, "bindings", array); + const char *json = obs_data_get_json(bindings_data); config_set_string(config, "Hotkeys", hw.name.c_str(), json); } } @@ -4633,12 +4634,12 @@ void OBSBasicSettings::SearchHotkeys(const QString &text, obs_key_combination_t ui->hotkeyScrollArea->ensureVisible(0, 0); QLayoutItem *hotkeysItem = ui->hotkeyFormLayout->itemAt(0); - QWidget *hotkeys = hotkeysItem->widget(); - if (!hotkeys) { + QWidget *hotkeys_widget = hotkeysItem->widget(); + if (!hotkeys_widget) { return; } - QFormLayout *hotkeysLayout = qobject_cast(hotkeys->layout()); + QFormLayout *hotkeysLayout = qobject_cast(hotkeys_widget->layout()); hotkeysLayout->setEnabled(false); QString needle = text.toLower(); @@ -5151,7 +5152,7 @@ extern const char *get_simple_output_encoder(const char *encoder); void OBSBasicSettings::SimpleStreamingEncoderChanged() { QString encoder = ui->simpleOutStrEncoder->currentData().toString(); - QString preset; + QString selected_preset; const char *defaultPreset = nullptr; ui->simpleOutAdvanced->setVisible(true); @@ -5165,7 +5166,7 @@ void OBSBasicSettings::SimpleStreamingEncoderChanged() ui->simpleOutPreset->addItem("quality", "quality"); defaultPreset = "balanced"; - preset = curQSVPreset; + selected_preset = curQSVPreset; } else if (encoder == SIMPLE_ENCODER_NVENC || encoder == SIMPLE_ENCODER_NVENC_HEVC || encoder == SIMPLE_ENCODER_NVENC_AV1) { @@ -5177,14 +5178,14 @@ void OBSBasicSettings::SimpleStreamingEncoderChanged() obs_property_t *p = obs_properties_get(props, isFFmpegEncoder ? "preset2" : "preset"); size_t num = obs_property_list_item_count(p); for (size_t i = 0; i < num; i++) { - const char *name = obs_property_list_item_name(p, i); + const char *preset_name = obs_property_list_item_name(p, i); const char *val = obs_property_list_item_string(p, i); - ui->simpleOutPreset->addItem(QT_UTF8(name), val); + ui->simpleOutPreset->addItem(QT_UTF8(preset_name), val); } defaultPreset = "default"; - preset = curNVENCPreset; + selected_preset = curNVENCPreset; } else if (encoder == SIMPLE_ENCODER_AMD || encoder == SIMPLE_ENCODER_AMD_HEVC) { ui->simpleOutPreset->addItem("Speed", "speed"); @@ -5192,7 +5193,7 @@ void OBSBasicSettings::SimpleStreamingEncoderChanged() ui->simpleOutPreset->addItem("Quality", "quality"); defaultPreset = "balanced"; - preset = curAMDPreset; + selected_preset = curAMDPreset; } else if (encoder == SIMPLE_ENCODER_APPLE_H264 #ifdef ENABLE_HEVC || encoder == SIMPLE_ENCODER_APPLE_HEVC @@ -5210,7 +5211,7 @@ void OBSBasicSettings::SimpleStreamingEncoderChanged() ui->simpleOutPreset->addItem("High Quality", "highQuality"); defaultPreset = "balanced"; - preset = curAMDAV1Preset; + selected_preset = curAMDAV1Preset; } else { #define PRESET_STR(val) QString(Str("Basic.Settings.Output.EncoderPreset." val)).arg(val) @@ -5232,10 +5233,10 @@ void OBSBasicSettings::SimpleStreamingEncoderChanged() } defaultPreset = "veryfast"; - preset = curPreset; + selected_preset = curPreset; } - int idx = ui->simpleOutPreset->findData(QVariant(preset)); + int idx = ui->simpleOutPreset->findData(QVariant(selected_preset)); if (idx == -1) { idx = ui->simpleOutPreset->findData(QVariant(defaultPreset)); } @@ -5361,9 +5362,9 @@ void OBSBasicSettings::AdvReplayBufferChanged() currentProfile.path / std::filesystem::u8path("recordEncoder.json"); if (!jsonFilePath.empty()) { - OBSDataAutoRelease data = + OBSDataAutoRelease saved_settings = obs_data_create_from_json_file_safe(jsonFilePath.u8string().c_str(), "bak"); - obs_data_apply(settings, data); + obs_data_apply(settings, saved_settings); } } diff --git a/frontend/settings/OBSBasicSettings.hpp b/frontend/settings/OBSBasicSettings.hpp index f262482f71..74fe6eea1f 100644 --- a/frontend/settings/OBSBasicSettings.hpp +++ b/frontend/settings/OBSBasicSettings.hpp @@ -352,8 +352,8 @@ private slots: bool ServiceAndACodecCompatible(); bool ServiceSupportsCodecCheck(); - inline bool AllowsMultiTrack(const char *protocol); - void SwapMultiTrack(const char *protocol); + inline bool AllowsMultiTrack(const char *protocol_name); + void SwapMultiTrack(const char *protocol_name); private slots: void on_theme_activated(int idx); diff --git a/frontend/settings/OBSBasicSettings_Stream.cpp.hpp b/frontend/settings/OBSBasicSettings_Stream.cpp.hpp index a6eac3f857..9290073ff4 100644 --- a/frontend/settings/OBSBasicSettings_Stream.cpp.hpp +++ b/frontend/settings/OBSBasicSettings_Stream.cpp.hpp @@ -294,16 +294,16 @@ void OBSBasicSettings::LoadStream1Settings() #define SRT_PROTOCOL "srt" #define RIST_PROTOCOL "rist" -bool OBSBasicSettings::AllowsMultiTrack(const char *protocol) +bool OBSBasicSettings::AllowsMultiTrack(const char *protocol_name) { - return astrcmpi_n(protocol, SRT_PROTOCOL, strlen(SRT_PROTOCOL)) == 0 || - astrcmpi_n(protocol, RIST_PROTOCOL, strlen(RIST_PROTOCOL)) == 0; + return astrcmpi_n(protocol_name, SRT_PROTOCOL, strlen(SRT_PROTOCOL)) == 0 || + astrcmpi_n(protocol_name, RIST_PROTOCOL, strlen(RIST_PROTOCOL)) == 0; } -void OBSBasicSettings::SwapMultiTrack(const char *protocol) +void OBSBasicSettings::SwapMultiTrack(const char *protocol_name) { - if (protocol) { - if (AllowsMultiTrack(protocol)) { + if (protocol_name) { + if (AllowsMultiTrack(protocol_name)) { ui->advStreamTrackWidget->setCurrentWidget(ui->streamMultiTracks); } else { ui->advStreamTrackWidget->setCurrentWidget(ui->streamSingleTracks); @@ -394,12 +394,12 @@ void OBSBasicSettings::SaveStream1Settings() auto oldMultitrackVideoSetting = config_get_bool(main->Config(), "Stream1", "EnableMultitrackVideo"); if (!IsCustomService()) { - OBSDataAutoRelease settings = obs_data_create(); - obs_data_set_string(settings, "service", QT_TO_UTF8(ui->service->currentText())); + OBSDataAutoRelease probe_settings = obs_data_create(); + obs_data_set_string(probe_settings, "service", QT_TO_UTF8(ui->service->currentText())); OBSServiceAutoRelease temp_service = - obs_service_create_private("rtmp_common", "auto config query service", settings); - settings = obs_service_get_settings(temp_service); - auto available = obs_data_has_user_value(settings, "multitrack_video_configuration_url"); + obs_service_create_private("rtmp_common", "auto config query service", probe_settings); + probe_settings = obs_service_get_settings(temp_service); + auto available = obs_data_has_user_value(probe_settings, "multitrack_video_configuration_url"); if (available) { SaveCheckBox(ui->enableMultitrackVideo, "Stream1", "EnableMultitrackVideo"); @@ -793,9 +793,9 @@ QString OBSBasicSettings::FindProtocol() obs_data_set_string(settings, "service", QT_TO_UTF8(ui->service->currentText())); obs_property_modified(services, settings); - const char *protocol = obs_data_get_string(settings, "protocol"); - if (protocol && *protocol) { - return QT_UTF8(protocol); + const char *protocol_name = obs_data_get_string(settings, "protocol"); + if (protocol_name && *protocol_name) { + return QT_UTF8(protocol_name); } } @@ -1872,55 +1872,55 @@ void OBSBasicSettings::ResetEncoders(bool streamOnly) /* Find fallback encoders */ if (!lastAdvVideoEnc.isEmpty()) { - int idx = ui->advOutEncoder->findData(lastAdvVideoEnc); - if (idx == -1) { + int encoder_idx = ui->advOutEncoder->findData(lastAdvVideoEnc); + if (encoder_idx == -1) { lastAdvVideoEnc = get_adv_fallback(lastAdvVideoEnc); ui->advOutEncoder->setProperty("changed", QVariant(true)); OutputsChanged(); } - idx = ui->advOutEncoder->findData(lastAdvVideoEnc); + encoder_idx = ui->advOutEncoder->findData(lastAdvVideoEnc); s2.unblock(); - ui->advOutEncoder->setCurrentIndex(idx); + ui->advOutEncoder->setCurrentIndex(encoder_idx); } if (!lastAdvAudioEnc.isEmpty()) { - int idx = ui->advOutAEncoder->findData(lastAdvAudioEnc); - if (idx == -1) { + int encoder_idx = ui->advOutAEncoder->findData(lastAdvAudioEnc); + if (encoder_idx == -1) { lastAdvAudioEnc = get_adv_audio_fallback(lastAdvAudioEnc); ui->advOutAEncoder->setProperty("changed", QVariant(true)); OutputsChanged(); } - idx = ui->advOutAEncoder->findData(lastAdvAudioEnc); + encoder_idx = ui->advOutAEncoder->findData(lastAdvAudioEnc); s4.unblock(); - ui->advOutAEncoder->setCurrentIndex(idx); + ui->advOutAEncoder->setCurrentIndex(encoder_idx); } if (!lastVideoEnc.isEmpty()) { - int idx = ui->simpleOutStrEncoder->findData(lastVideoEnc); - if (idx == -1) { + int encoder_idx = ui->simpleOutStrEncoder->findData(lastVideoEnc); + if (encoder_idx == -1) { lastVideoEnc = get_simple_fallback(lastVideoEnc); ui->simpleOutStrEncoder->setProperty("changed", QVariant(true)); OutputsChanged(); } - idx = ui->simpleOutStrEncoder->findData(lastVideoEnc); + encoder_idx = ui->simpleOutStrEncoder->findData(lastVideoEnc); s1.unblock(); - ui->simpleOutStrEncoder->setCurrentIndex(idx); + ui->simpleOutStrEncoder->setCurrentIndex(encoder_idx); } if (!lastAudioEnc.isEmpty()) { - int idx = ui->simpleOutStrAEncoder->findData(lastAudioEnc); - if (idx == -1) { + int encoder_idx = ui->simpleOutStrAEncoder->findData(lastAudioEnc); + if (encoder_idx == -1) { lastAudioEnc = (lastAudioEnc == "opus") ? "aac" : "opus"; ui->simpleOutStrAEncoder->setProperty("changed", QVariant(true)); OutputsChanged(); } - idx = ui->simpleOutStrAEncoder->findData(lastAudioEnc); + encoder_idx = ui->simpleOutStrAEncoder->findData(lastAudioEnc); s3.unblock(); - ui->simpleOutStrAEncoder->setCurrentIndex(idx); + ui->simpleOutStrAEncoder->setCurrentIndex(encoder_idx); } } diff --git a/frontend/settings/OBSHotkeyWidget.cpp.hpp b/frontend/settings/OBSHotkeyWidget.cpp.hpp index 877b044e7a..0af2ff2a3d 100644 --- a/frontend/settings/OBSHotkeyWidget.cpp.hpp +++ b/frontend/settings/OBSHotkeyWidget.cpp.hpp @@ -221,8 +221,8 @@ void OBSHotkeyWidget::HandleChangedBindings(obs_hotkey_id id_) using LoadBindings_t = decltype(&LoadBindings); obs_enum_hotkey_bindings( - [](void *data, size_t, obs_hotkey_binding_t *binding) { - auto LoadBindings = *static_cast(data); + [](void *handler_data, size_t, obs_hotkey_binding_t *binding) { + auto LoadBindings = *static_cast(handler_data); LoadBindings(binding); return true; }, diff --git a/frontend/utility/AdvancedOutput.cpp.hpp b/frontend/utility/AdvancedOutput.cpp.hpp index 4320b4ee8b..ed60188ded 100644 --- a/frontend/utility/AdvancedOutput.cpp.hpp +++ b/frontend/utility/AdvancedOutput.cpp.hpp @@ -567,8 +567,8 @@ inline std::optional AdvancedOutput::VodTrackMixerIdx(obs_service_t *ser vodTrackEnabled = enableForCustomServer ? vodTrackEnabled : false; } else { OBSDataAutoRelease settings = obs_service_get_settings(service); - const char *service = obs_data_get_string(settings, "service"); - if (!ServiceSupportsVodTrack(service)) { + const char *service_name = obs_data_get_string(settings, "service"); + if (!ServiceSupportsVodTrack(service_name)) { vodTrackEnabled = false; } } @@ -709,21 +709,21 @@ bool AdvancedOutput::StartStreaming(obs_service_t *service) SetOutputNetworkOptions(main->Config(), settings); obs_data_set_bool(settings, "dyn_bitrate", enableDynBitrate); - auto streamOutput = StreamingOutput(); // shadowing is sort of bad, but also convenient + auto streamOutputRef = StreamingOutput(); - obs_output_update(streamOutput, settings); + obs_output_update(streamOutputRef, settings); if (!reconnect) { maxRetries = 0; } - obs_output_set_delay(streamOutput, useDelay ? delaySec : 0, preserveDelay ? OBS_OUTPUT_DELAY_PRESERVE : 0); + obs_output_set_delay(streamOutputRef, useDelay ? delaySec : 0, preserveDelay ? OBS_OUTPUT_DELAY_PRESERVE : 0); - obs_output_set_reconnect_settings(streamOutput, maxRetries, retryDelay); + obs_output_set_reconnect_settings(streamOutputRef, maxRetries, retryDelay); if (is_rtmp) { SetupVodTrack(service); } - if (obs_output_start(streamOutput)) { + if (obs_output_start(streamOutputRef)) { bool dumpStarted = false; if (multitrackVideo && multitrackVideoActive) { dumpStarted = multitrackVideo->StartedStreaming(); @@ -737,7 +737,7 @@ bool AdvancedOutput::StartStreaming(obs_service_t *service) multitrackVideoActive = false; } - const char *error = obs_output_get_last_error(streamOutput); + const char *error = obs_output_get_last_error(streamOutputRef); bool hasLastError = error && *error; if (hasLastError) { lastError = error; @@ -745,7 +745,7 @@ bool AdvancedOutput::StartStreaming(obs_service_t *service) lastError = string(); } - const char *type = obs_output_get_id(streamOutput); + const char *type = obs_output_get_id(streamOutputRef); blog(LOG_WARNING, "Stream output type '%s' failed to start!%s%s", type, hasLastError ? " Last Error: " : "", hasLastError ? error : ""); return false; diff --git a/frontend/utility/CrashHandler.cpp.hpp b/frontend/utility/CrashHandler.cpp.hpp index 5abfeec77a..17d90b19ac 100644 --- a/frontend/utility/CrashHandler.cpp.hpp +++ b/frontend/utility/CrashHandler.cpp.hpp @@ -125,13 +125,13 @@ void CrashHandler::checkCrashState() { bool currentSentinelFound = false; - std::filesystem::path crashSentinelPath = crashSentinelFile_.parent_path(); + std::filesystem::path sentinel_dir = crashSentinelFile_.parent_path(); - if (!ensure_crash_sentinel_dir(crashSentinelPath)) { + if (!ensure_crash_sentinel_dir(sentinel_dir)) { return; } - for (const auto &entry : std::filesystem::directory_iterator(crashSentinelPath)) { + for (const auto &entry : std::filesystem::directory_iterator(sentinel_dir)) { if (entry.is_directory()) { continue; } @@ -268,14 +268,14 @@ void CrashHandler::applicationShutdownHandler() noexcept return; } - const std::filesystem::path crashSentinelPath = crashSentinelFile_.parent_path(); + const std::filesystem::path sentinel_dir = crashSentinelFile_.parent_path(); - if (!std::filesystem::exists(crashSentinelPath)) { - blog(LOG_ERROR, "Crash sentinel location '%s' does not exist", crashSentinelPath.u8string().c_str()); + if (!std::filesystem::exists(sentinel_dir)) { + blog(LOG_ERROR, "Crash sentinel location '%s' does not exist", sentinel_dir.u8string().c_str()); return; } - for (const auto &entry : std::filesystem::directory_iterator(crashSentinelPath)) { + for (const auto &entry : std::filesystem::directory_iterator(sentinel_dir)) { if (entry.is_directory()) { continue; } diff --git a/frontend/utility/SimpleOutput.cpp.hpp b/frontend/utility/SimpleOutput.cpp.hpp index bf8156be27..58ecc5bd90 100644 --- a/frontend/utility/SimpleOutput.cpp.hpp +++ b/frontend/utility/SimpleOutput.cpp.hpp @@ -717,23 +717,23 @@ bool SimpleOutput::StartStreaming(obs_service_t *service) SetOutputNetworkOptions(main->Config(), settings); obs_data_set_bool(settings, "dyn_bitrate", enableDynBitrate); - auto streamOutput = StreamingOutput(); // shadowing is sort of bad, but also convenient + auto streamOutputRef = StreamingOutput(); - obs_output_update(streamOutput, settings); + obs_output_update(streamOutputRef, settings); if (!reconnect) { maxRetries = 0; } - obs_output_set_delay(streamOutput, useDelay ? delaySec : 0, preserveDelay ? OBS_OUTPUT_DELAY_PRESERVE : 0); + obs_output_set_delay(streamOutputRef, useDelay ? delaySec : 0, preserveDelay ? OBS_OUTPUT_DELAY_PRESERVE : 0); - obs_output_set_reconnect_settings(streamOutput, maxRetries, retryDelay); + obs_output_set_reconnect_settings(streamOutputRef, maxRetries, retryDelay); if (!multitrackVideo || !multitrackVideoActive) { SetupVodTrack(service); } - if (obs_output_start(streamOutput)) { + if (obs_output_start(streamOutputRef)) { bool dumpStarted = false; if (multitrackVideo && multitrackVideoActive) { dumpStarted = multitrackVideo->StartedStreaming(); @@ -747,7 +747,7 @@ bool SimpleOutput::StartStreaming(obs_service_t *service) multitrackVideoActive = false; } - const char *error = obs_output_get_last_error(streamOutput); + const char *error = obs_output_get_last_error(streamOutputRef); bool hasLastError = error && *error; if (hasLastError) { lastError = error; @@ -755,7 +755,7 @@ bool SimpleOutput::StartStreaming(obs_service_t *service) lastError = string(); } - const char *type = obs_output_get_id(streamOutput); + const char *type = obs_output_get_id(streamOutputRef); blog(LOG_WARNING, "Stream output type '%s' failed to start!%s%s", type, hasLastError ? " Last Error: " : "", hasLastError ? error : ""); return false; diff --git a/frontend/utility/ThumbnailItem.cpp.hpp b/frontend/utility/ThumbnailItem.cpp.hpp index de259a5a94..9cf46531b8 100644 --- a/frontend/utility/ThumbnailItem.cpp.hpp +++ b/frontend/utility/ThumbnailItem.cpp.hpp @@ -87,9 +87,9 @@ QPixmap ThumbnailItem::getPixmap() const return pixmap; } -void ThumbnailItem::setPixmap(QPixmap pixmap) +void ThumbnailItem::setPixmap(QPixmap newPixmap) { - this->pixmap = std::move(pixmap); + this->pixmap = std::move(newPixmap); emit pixmapUpdated(this->pixmap); } @@ -164,9 +164,9 @@ bool ThumbnailItem::update() return false; } - QPixmap pixmap; + QPixmap blank_pixmap; if (this->pixmap.isNull()) { - this->pixmap = pixmap; + this->pixmap = blank_pixmap; } if (source) { diff --git a/frontend/utility/ThumbnailItem.hpp b/frontend/utility/ThumbnailItem.hpp index 2f4ee50e51..774061e2a7 100644 --- a/frontend/utility/ThumbnailItem.hpp +++ b/frontend/utility/ThumbnailItem.hpp @@ -47,7 +47,7 @@ class ThumbnailItem : public QObject { bool update(); [[nodiscard]] QPixmap getPixmap() const; - void setPixmap(QPixmap pixmap); + void setPixmap(QPixmap newPixmap); [[nodiscard]] bool isDefaultPixmap() const { return isDefaultPixmap_; } [[nodiscard]] bool isValid() const diff --git a/frontend/utility/ThumbnailManager.cpp.hpp b/frontend/utility/ThumbnailManager.cpp.hpp index 33e5a24910..1f7a3a36a9 100644 --- a/frontend/utility/ThumbnailManager.cpp.hpp +++ b/frontend/utility/ThumbnailManager.cpp.hpp @@ -251,9 +251,9 @@ void ThumbnailManager::deleteItemById(const std::string &uuid) QPointer item = entry->second; if (item && !item->isDefaultPixmap()) { - std::string uuid = item->getUuid(); + std::string item_uuid = item->getUuid(); QPixmap pixmap = item->getPixmap(); - addItemToCache(uuid, pixmap); + addItemToCache(item_uuid, pixmap); } thumbnailList.erase(uuid); diff --git a/frontend/utility/ThumbnailView.cpp.hpp b/frontend/utility/ThumbnailView.cpp.hpp index 17a9adf53a..03b7ee4e1d 100644 --- a/frontend/utility/ThumbnailView.cpp.hpp +++ b/frontend/utility/ThumbnailView.cpp.hpp @@ -39,12 +39,12 @@ ThumbnailView::ThumbnailView(QObject *parent, const QPointer &ite } } -void ThumbnailView::setEnabled(bool enabled) +void ThumbnailView::setEnabled(bool newEnabled) { - if (this->enabled != enabled) { - this->enabled = enabled; + if (this->enabled != newEnabled) { + this->enabled = newEnabled; - emit enabledChanged(enabled); + emit enabledChanged(newEnabled); } } @@ -57,9 +57,9 @@ void ThumbnailView::requestUpdate() emit updateRequested(uuid); } -void ThumbnailView::setPixmap(QPixmap pixmap) +void ThumbnailView::setPixmap(QPixmap newPixmap) { - this->pixmap = std::move(pixmap); + this->pixmap = std::move(newPixmap); emit updated(this->pixmap); } diff --git a/frontend/utility/ThumbnailView.hpp b/frontend/utility/ThumbnailView.hpp index 093b364eba..eae013af86 100644 --- a/frontend/utility/ThumbnailView.hpp +++ b/frontend/utility/ThumbnailView.hpp @@ -40,7 +40,7 @@ class ThumbnailView : public QObject { [[nodiscard]] QPixmap getPixmap() const { return pixmap; } [[nodiscard]] bool isEnabled() const { return enabled; } - void setEnabled(bool enabled); + void setEnabled(bool newEnabled); void requestUpdate(); @@ -50,5 +50,5 @@ class ThumbnailView : public QObject { void updateRequested(std::string &uuid); public slots: - void setPixmap(QPixmap pixmap); + void setPixmap(QPixmap newPixmap); }; diff --git a/frontend/utility/audio-encoders.cpp.hpp b/frontend/utility/audio-encoders.cpp.hpp index 96e150362f..10fecfdd0a 100644 --- a/frontend/utility/audio-encoders.cpp.hpp +++ b/frontend/utility/audio-encoders.cpp.hpp @@ -164,12 +164,12 @@ static void PopulateBitrateLists() id); } - ostringstream ss; + ostringstream bitrate_list; for (auto &bitrate : encoderBitrates[encoder]) { - ss << "\n " << setw(3) << bitrate << " kbit/s"; + bitrate_list << "\n " << setw(3) << bitrate << " kbit/s"; } - blog(LOG_DEBUG, "%s (%s) encoder bitrates:%s", EncoderName(id), id, ss.str().c_str()); + blog(LOG_DEBUG, "%s (%s) encoder bitrates:%s", EncoderName(id), id, bitrate_list.str().c_str()); } if (encoderBitrates.empty() && fallbackBitrates.empty()) { diff --git a/frontend/utility/platform-windows.cpp.hpp b/frontend/utility/platform-windows.cpp.hpp index d29b5f6262..67c76471cc 100644 --- a/frontend/utility/platform-windows.cpp.hpp +++ b/frontend/utility/platform-windows.cpp.hpp @@ -963,7 +963,7 @@ bool UseNativeComboBoxPopup() return false; } -static HRESULT SaveJxrImage(LPCWSTR path, uint8_t *pixels, uint32_t cx, uint32_t cy, IWICBitmapFrameEncode *frameEncode, +static HRESULT SaveJxrImage(uint8_t *pixels, uint32_t cx, uint32_t cy, IWICBitmapFrameEncode *frameEncode, IPropertyBag2 *options) { wchar_t lossless[] = L"Lossless"; @@ -1053,7 +1053,7 @@ static HRESULT SaveJxr(LPCWSTR path, uint8_t *pixels, uint32_t cx, uint32_t cy) return hr; } - hr = SaveJxrImage(path, pixels, cx, cy, frameEncode.Get(), options.Get()); + hr = SaveJxrImage(pixels, cx, cy, frameEncode.Get(), options.Get()); if (FAILED(hr)) { return hr; } diff --git a/frontend/utility/win-dll-blocklist.c.h b/frontend/utility/win-dll-blocklist.c.h index d61846b259..559a036f4f 100644 --- a/frontend/utility/win-dll-blocklist.c.h +++ b/frontend/utility/win-dll-blocklist.c.h @@ -363,7 +363,17 @@ void install_dll_blocklist_hook(void) DetourTransactionBegin(); - if (DetourAttach((PVOID *)&ntMap, NtMapViewOfSection_hook) != NO_ERROR) { + /* Detours stores hooks as data pointers, and a cast from a function + * pointer to a data pointer is C4152 at /W4 even when it is explicit. + * Copy the address through a union instead, the way GET_DBGHELP_IMPORT + * (libobs/obs-win-crash-handler.c.h) does for GetProcAddress. No code is + * generated for the copy. */ + union { + fn_NtMapViewOfSection fn; + PVOID obj; + } detour = {NtMapViewOfSection_hook}; + + if (DetourAttach((PVOID *)&ntMap, detour.obj) != NO_ERROR) { DetourTransactionAbort(); } else { DetourTransactionCommit(); diff --git a/frontend/widgets/OBSBasic.cpp.hpp b/frontend/widgets/OBSBasic.cpp.hpp index e34f5f649f..caab64c751 100644 --- a/frontend/widgets/OBSBasic.cpp.hpp +++ b/frontend/widgets/OBSBasic.cpp.hpp @@ -775,22 +775,22 @@ void OBSBasic::InitOBSCallbacks() signalHandlers.emplace_back(obs_get_signal_handler(), "source_device_busy", OBSBasic::SourceDeviceBusy, this); signalHandlers.emplace_back( obs_get_signal_handler(), "hotkey_background_status_changed", - [](void *data, calldata_t *) { - QMetaObject::invokeMethod(static_cast(data), + [](void *handler_data, calldata_t *) { + QMetaObject::invokeMethod(static_cast(handler_data), &OBSBasic::NotifyHotkeyBackgroundStatus, Qt::QueuedConnection); }, this); signalHandlers.emplace_back( obs_get_signal_handler(), "source_filter_add", - [](void *data, calldata_t *) { - QMetaObject::invokeMethod(static_cast(data), &OBSBasic::UpdateEditMenu, + [](void *handler_data, calldata_t *) { + QMetaObject::invokeMethod(static_cast(handler_data), &OBSBasic::UpdateEditMenu, Qt::QueuedConnection); }, this); signalHandlers.emplace_back( obs_get_signal_handler(), "source_filter_remove", - [](void *data, calldata_t *) { - QMetaObject::invokeMethod(static_cast(data), &OBSBasic::UpdateEditMenu, + [](void *handler_data, calldata_t *) { + QMetaObject::invokeMethod(static_cast(handler_data), &OBSBasic::UpdateEditMenu, Qt::QueuedConnection); }, this); diff --git a/frontend/widgets/OBSBasic.hpp b/frontend/widgets/OBSBasic.hpp index bd93e92afb..6f324cd34e 100644 --- a/frontend/widgets/OBSBasic.hpp +++ b/frontend/widgets/OBSBasic.hpp @@ -1120,7 +1120,7 @@ private slots: void DisableRelativeCoordinates(bool disable); void CreateDefaultScene(bool firstStart); void Save(SceneCollection &collection); - void LoadData(obs_data_t *data, SceneCollection &collection); + void LoadData(obs_data_t *collectionData, SceneCollection &collection); void Load(SceneCollection &collection); void ClearSceneData(); diff --git a/frontend/widgets/OBSBasicPreview.cpp.hpp b/frontend/widgets/OBSBasicPreview.cpp.hpp index c2a627cbf9..24b0b5ea3c 100644 --- a/frontend/widgets/OBSBasicPreview.cpp.hpp +++ b/frontend/widgets/OBSBasicPreview.cpp.hpp @@ -348,16 +348,20 @@ bool OBSBasicPreview::SelectedAtPos(const vec2 &pos) } struct HandleFindData { - const vec2 &pos; - const float radius; + /* parent_xform is 16-byte aligned (vec4 carries the SIMD type), so it + * leads the struct: every other member then lands at its natural offset + * and the size stays a multiple of the alignment, with no padding to + * warn about (C4324). */ matrix4 parent_xform; + const vec2 &pos; OBSSceneItem item; - ItemHandle handle = ItemHandle::None; - float angle = 0.0f; vec2 rotatePoint; vec2 offsetPoint; + const float radius; + ItemHandle handle = ItemHandle::None; + float angle = 0.0f; float angleOffset = 0.0f; HandleFindData(const HandleFindData &) = delete; @@ -372,12 +376,12 @@ struct HandleFindData { inline HandleFindData(const HandleFindData &hfd, obs_sceneitem_t *parent) : pos(hfd.pos), - radius(hfd.radius), item(hfd.item), - handle(hfd.handle), - angle(hfd.angle), rotatePoint(hfd.rotatePoint), - offsetPoint(hfd.offsetPoint) + offsetPoint(hfd.offsetPoint), + radius(hfd.radius), + handle(hfd.handle), + angle(hfd.angle) { obs_sceneitem_get_draw_transform(parent, &parent_xform); } @@ -508,15 +512,15 @@ void OBSBasicPreview::GetStretchHandleData(const vec2 &pos, bool ignoreGroup) float scale = main->previewScale / main->GetDevicePixelRatio(); vec2 scaled_pos = pos; vec2_divf(&scaled_pos, &scaled_pos, scale); - HandleFindData data(scaled_pos, scale); - obs_scene_enum_items(scene, FindHandleAtPos, &data); + HandleFindData findData(scaled_pos, scale); + obs_scene_enum_items(scene, FindHandleAtPos, &findData); - stretchItem = std::move(data.item); - stretchHandle = data.handle; + stretchItem = std::move(findData.item); + stretchHandle = findData.handle; - rotateAngle = data.angle; - rotatePoint = data.rotatePoint; - offsetPoint = data.offsetPoint; + rotateAngle = findData.angle; + rotatePoint = findData.rotatePoint; + offsetPoint = findData.offsetPoint; if (stretchHandle != ItemHandle::None) { matrix4 boxTransform; @@ -657,12 +661,12 @@ void OBSBasicPreview::mousePressEvent(QMouseEvent *event) if (altDown || shiftDown || ctrlDown) { vec2 s; - SceneFindBoxData data(s, s); + SceneFindBoxData findData(s, s); - obs_scene_enum_items(main->GetCurrentScene(), FindSelected, &data); + obs_scene_enum_items(main->GetCurrentScene(), FindSelected, &findData); std::lock_guard lock(selectMutex); - selectedItems = data.sceneItems; + selectedItems = findData.sceneItems; } vec2_set(&startPos, x, y); @@ -859,12 +863,12 @@ void OBSBasicPreview::mouseReleaseEvent(QMouseEvent *event) OBSDataAutoRelease rwrapper = obs_scene_save_transform_states(main->GetCurrentScene(), true); - auto undo_redo = [](const std::string &data) { - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + auto undo_redo = [](const std::string &jsonStr) { + OBSDataAutoRelease dat = obs_data_create_from_json(jsonStr.c_str()); OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "scene_uuid")); OBSBasic::Get()->SetCurrentScene(source.Get(), true); - obs_scene_load_transform_states(data.c_str()); + obs_scene_load_transform_states(jsonStr.c_str()); }; if (wrapper && rwrapper) { @@ -1308,7 +1312,7 @@ static bool FindItemsInBox(obs_scene_t * /* scene */, obs_sceneitem_t *item, voi return true; } -void OBSBasicPreview::BoxItems(const vec2 &startPos, const vec2 &pos) +void OBSBasicPreview::BoxItems(const vec2 &boxStart, const vec2 &pos) { OBSBasic *main = OBSBasic::Get(); @@ -1321,11 +1325,11 @@ void OBSBasicPreview::BoxItems(const vec2 &startPos, const vec2 &pos) setCursor(Qt::CrossCursor); } - SceneFindBoxData data(startPos, pos); - obs_scene_enum_items(scene, FindItemsInBox, &data); + SceneFindBoxData findData(boxStart, pos); + obs_scene_enum_items(scene, FindItemsInBox, &findData); std::lock_guard lock(selectMutex); - hoveredPreviewItems = data.sceneItems; + hoveredPreviewItems = findData.sceneItems; } vec3 OBSBasicPreview::CalculateStretchPos(const vec3 &tl, const vec3 &br) @@ -1797,10 +1801,10 @@ void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event) if (!mouseMoved && hoveredPreviewItems.size() > 0) { mousePos = pos; - OBSBasic *main = OBSBasic::Get(); - float scale = main->GetDevicePixelRatio(); - float x = qtPos.x() - main->previewX / scale; - float y = qtPos.y() - main->previewY / scale; + OBSBasic *obsBasic = OBSBasic::Get(); + float scale = obsBasic->GetDevicePixelRatio(); + float x = qtPos.x() - obsBasic->previewX / scale; + float y = qtPos.y() - obsBasic->previewY / scale; vec2_set(&startPos, x, y); updateCursor = true; } @@ -2640,16 +2644,16 @@ void OBSBasicPreview::DrawSpacingHelpers() OBSBasic *main = OBSBasic::Get(); vec2 s; - SceneFindBoxData data(s, s); + SceneFindBoxData findData(s, s); OBSScene scene = main->GetCurrentScene(); - obs_scene_enum_items(scene, FindSelected, &data); + obs_scene_enum_items(scene, FindSelected, &findData); - if (data.sceneItems.size() != 1) { + if (findData.sceneItems.size() != 1) { return; } - OBSSceneItem item = data.sceneItems[0]; + OBSSceneItem item = findData.sceneItems[0]; if (!item) { return; } diff --git a/frontend/widgets/OBSBasicPreview.hpp b/frontend/widgets/OBSBasicPreview.hpp index ff86d41d5c..f52d0acbd0 100644 --- a/frontend/widgets/OBSBasicPreview.hpp +++ b/frontend/widgets/OBSBasicPreview.hpp @@ -123,7 +123,7 @@ class OBSBasicPreview : public OBSQTDisplay { static void SnapItemMovement(vec2 &offset); void MoveItems(const vec2 &pos); - void BoxItems(const vec2 &startPos, const vec2 &pos); + void BoxItems(const vec2 &boxStart, const vec2 &pos); void ProcessClick(const vec2 &pos); diff --git a/frontend/widgets/OBSBasicStatusBar.cpp.hpp b/frontend/widgets/OBSBasicStatusBar.cpp.hpp index 4d1df02def..8da68b2f7d 100644 --- a/frontend/widgets/OBSBasicStatusBar.cpp.hpp +++ b/frontend/widgets/OBSBasicStatusBar.cpp.hpp @@ -255,12 +255,12 @@ void OBSBasicStatusBar::UpdateStreamTime() { totalStreamSeconds++; - int seconds = totalStreamSeconds % 60; + int secondsPart = totalStreamSeconds % 60; int totalMinutes = totalStreamSeconds / 60; int minutes = totalMinutes % 60; int hours = totalMinutes / 60; - QString text = QString::asprintf("%02d:%02d:%02d", hours, minutes, seconds); + QString text = QString::asprintf("%02d:%02d:%02d", hours, minutes, secondsPart); statusWidget->ui->streamTime->setText(text); if (streamOutput && !statusWidget->ui->streamTime->isEnabled()) { statusWidget->ui->streamTime->setDisabled(false); @@ -315,12 +315,12 @@ void OBSBasicStatusBar::UpdateRecordTime() void OBSBasicStatusBar::UpdateRecordTimeLabel() { - int seconds = totalRecordSeconds % 60; + int secondsPart = totalRecordSeconds % 60; int totalMinutes = totalRecordSeconds / 60; int minutes = totalMinutes % 60; int hours = totalMinutes / 60; - QString text = QString::asprintf("%02d:%02d:%02d", hours, minutes, seconds); + QString text = QString::asprintf("%02d:%02d:%02d", hours, minutes, secondsPart); if (os_atomic_load_bool(&recording_paused)) { text += QStringLiteral(" (PAUSED)"); } @@ -415,7 +415,7 @@ void OBSBasicStatusBar::OBSOutputReconnectSuccess(void *data, calldata_t *) QMetaObject::invokeMethod(statusBar, &OBSBasicStatusBar::ReconnectSuccess); } -void OBSBasicStatusBar::Reconnect(int seconds) +void OBSBasicStatusBar::Reconnect(int timeoutSeconds) { OBSBasic *main = qobject_cast(parent()); @@ -423,7 +423,7 @@ void OBSBasicStatusBar::Reconnect(int seconds) main->SysTrayNotify(QTStr("Basic.SystemTray.Message.Reconnecting"), QSystemTrayIcon::Warning); } - reconnectTimeout = seconds; + reconnectTimeout = timeoutSeconds; if (streamOutput) { OBSOutput output = OBSGetStrongRef(streamOutput); diff --git a/frontend/widgets/OBSBasicStatusBar.hpp b/frontend/widgets/OBSBasicStatusBar.hpp index 3fefa1cb52..9dac06230f 100644 --- a/frontend/widgets/OBSBasicStatusBar.hpp +++ b/frontend/widgets/OBSBasicStatusBar.hpp @@ -89,7 +89,7 @@ public slots: void showMessage(const QString &message, int timeout = 0); private slots: - void Reconnect(int seconds); + void Reconnect(int timeoutSeconds); void ReconnectSuccess(); void UpdateStatusBar(); void UpdateCurrentFPS(); diff --git a/frontend/widgets/OBSBasic_ContextToolbar.cpp.hpp b/frontend/widgets/OBSBasic_ContextToolbar.cpp.hpp index 60fee3d6b5..9dbd819ef2 100644 --- a/frontend/widgets/OBSBasic_ContextToolbar.cpp.hpp +++ b/frontend/widgets/OBSBasic_ContextToolbar.cpp.hpp @@ -208,8 +208,8 @@ void OBSBasic::UpdateContextBar(bool force) if (toolbar->GetSource() == source) { updateNeeded = false; } - } else if (MediaControls *toolbar = dynamic_cast(la->widget())) { - if (toolbar->GetSource() == source) { + } else if (MediaControls *mediaControls = dynamic_cast(la->widget())) { + if (mediaControls->GetSource() == source) { updateNeeded = false; } } diff --git a/frontend/widgets/OBSBasic_DeviceBusy.cpp.hpp b/frontend/widgets/OBSBasic_DeviceBusy.cpp.hpp index cc1f2fe926..d11410e346 100644 --- a/frontend/widgets/OBSBasic_DeviceBusy.cpp.hpp +++ b/frontend/widgets/OBSBasic_DeviceBusy.cpp.hpp @@ -67,22 +67,22 @@ void OBSBasic::ShowDeviceBusy(OBSWeakSource weak, QString device, QString holder (canForce ? QTStr("Basic.DeviceBusy.ForceExplain").arg(holder) : QTStr("Basic.DeviceBusy.Wait")); source = nullptr; - QMessageBox box(this); - box.setIcon(QMessageBox::Warning); - box.setWindowTitle(QTStr("Basic.DeviceBusy.Title")); - box.setText(text); - QPushButton *force = canForce ? box.addButton(QTStr("Basic.DeviceBusy.Force"), QMessageBox::AcceptRole) + QMessageBox messageBox(this); + messageBox.setIcon(QMessageBox::Warning); + messageBox.setWindowTitle(QTStr("Basic.DeviceBusy.Title")); + messageBox.setText(text); + QPushButton *force = canForce ? messageBox.addButton(QTStr("Basic.DeviceBusy.Force"), QMessageBox::AcceptRole) : nullptr; - box.addButton(canForce ? QMessageBox::Cancel : QMessageBox::Ok); + messageBox.addButton(canForce ? QMessageBox::Cancel : QMessageBox::Ok); if (force) { - box.setDefaultButton(force); + messageBox.setDefaultButton(force); } busyDevicePopups.insert(device); - box.exec(); + messageBox.exec(); busyDevicePopups.remove(device); - if (!force || box.clickedButton() != force) { + if (!force || messageBox.clickedButton() != force) { return; } diff --git a/frontend/widgets/OBSBasic_Dropfiles.cpp.hpp b/frontend/widgets/OBSBasic_Dropfiles.cpp.hpp index cfdba8a266..95b3266d60 100644 --- a/frontend/widgets/OBSBasic_Dropfiles.cpp.hpp +++ b/frontend/widgets/OBSBasic_Dropfiles.cpp.hpp @@ -100,7 +100,7 @@ void OBSBasic::AddDropURL(QUrl url, QString &name, obs_data_t *settings, const o obs_data_set_string(settings, "url", QT_TO_UTF8(url.url())); } -void OBSBasic::AddDropSource(const char *data, DropType image) +void OBSBasic::AddDropSource(const char *droppedValue, DropType image) { OBSBasic *main = OBSBasic::Get(); OBSDataAutoRelease settings = obs_data_create(); @@ -112,33 +112,33 @@ void OBSBasic::AddDropSource(const char *data, DropType image) switch (image) { case DropType_RawText: - obs_data_set_string(settings, "text", data); + obs_data_set_string(settings, "text", droppedValue); type = GetPlatformTextSourceId(); break; case DropType_Text: - SetPlatformTextFileSettings(settings, data, name); + SetPlatformTextFileSettings(settings, droppedValue, name); type = GetPlatformTextSourceId(); break; case DropType_Image: - obs_data_set_string(settings, "file", data); - name = QUrl::fromLocalFile(QString(data)).fileName(); + obs_data_set_string(settings, "file", droppedValue); + name = QUrl::fromLocalFile(QString(droppedValue)).fileName(); type = "image_source"; break; case DropType_Media: - obs_data_set_string(settings, "local_file", data); - name = QUrl::fromLocalFile(QString(data)).fileName(); + obs_data_set_string(settings, "local_file", droppedValue); + name = QUrl::fromLocalFile(QString(droppedValue)).fileName(); type = "ffmpeg_source"; break; case DropType_Html: obs_data_set_bool(settings, "is_local_file", true); - obs_data_set_string(settings, "local_file", data); + obs_data_set_string(settings, "local_file", droppedValue); obs_data_set_int(settings, "width", ovi.base_width); obs_data_set_int(settings, "height", ovi.base_height); - name = QUrl::fromLocalFile(QString(data)).fileName(); + name = QUrl::fromLocalFile(QString(droppedValue)).fileName(); type = "browser_source"; break; case DropType_Url: - AddDropURL(QUrl(data), name, settings, ovi); + AddDropURL(QUrl(droppedValue), name, settings, ovi); type = "browser_source"; break; } @@ -167,11 +167,11 @@ void OBSBasic::AddDropSource(const char *data, DropType image) OBSSourceAutoRelease scene = obs_get_source_by_uuid(sceneUUID.c_str()); OBSBasic::Get()->SetCurrentScene(scene.Get(), true); }; - auto redo = [sceneUUID, sourceName, type](const std::string &data) { + auto redo = [sceneUUID, sourceName, type](const std::string &jsonText) { OBSSourceAutoRelease scene = obs_get_source_by_uuid(sceneUUID.c_str()); OBSBasic::Get()->SetCurrentScene(scene.Get(), true); - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + OBSDataAutoRelease dat = obs_data_create_from_json(jsonText.c_str()); OBSSourceAutoRelease source = obs_load_source(dat); obs_scene_add(obs_scene_from_source(scene), source.Get()); }; diff --git a/frontend/widgets/OBSBasic_Hotkeys.cpp.hpp b/frontend/widgets/OBSBasic_Hotkeys.cpp.hpp index bb7482b1a7..8467ff8c51 100644 --- a/frontend/widgets/OBSBasic_Hotkeys.cpp.hpp +++ b/frontend/widgets/OBSBasic_Hotkeys.cpp.hpp @@ -179,8 +179,8 @@ void OBSBasic::CreateHotkeys() }; #define MAKE_CALLBACK(pred, method, log_action) \ - [](void *data, obs_hotkey_pair_id, obs_hotkey_t *, bool pressed) { \ - OBSBasic &basic = *static_cast(data); \ + [](void *handler_data, obs_hotkey_pair_id, obs_hotkey_t *, bool pressed) { \ + OBSBasic &basic = *static_cast(handler_data); \ if ((pred) && pressed) { \ blog(LOG_INFO, log_action " due to hotkey"); \ method(); \ @@ -199,8 +199,8 @@ void OBSBasic::CreateHotkeys() this, this); LoadHotkeyPair(streamingHotkeys, "OBSBasic.StartStreaming", "OBSBasic.StopStreaming"); - auto cb = [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { - OBSBasic &basic = *static_cast(data); + auto cb = [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + OBSBasic &basic = *static_cast(handler_data); if (basic.outputHandler->StreamingActive() && pressed) { basic.ForceStopStreaming(); } @@ -260,8 +260,8 @@ void OBSBasic::CreateHotkeys() this, this); LoadHotkeyPair(replayBufHotkeys, "OBSBasic.StartReplayBuffer", "OBSBasic.StopReplayBuffer"); - auto replayBufferCallback = [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { - OBSBasic *basic = static_cast(data); + auto replayBufferCallback = [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + OBSBasic *basic = static_cast(handler_data); if (basic->outputHandler->ReplayBufferActive() && pressed) { blog(LOG_INFO, "Saving replay buffer due to hotkey"); basic->ReplayBufferSave(); @@ -324,9 +324,9 @@ void OBSBasic::CreateHotkeys() LoadHotkeyPair(contextBarHotkeys, "OBSBasic.ShowContextBar", "OBSBasic.HideContextBar"); #undef MAKE_CALLBACK - auto transition = [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + auto transition = [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { if (pressed) { - QMetaObject::invokeMethod(static_cast(data), &OBSBasic::TransitionClicked, + QMetaObject::invokeMethod(static_cast(handler_data), &OBSBasic::TransitionClicked, Qt::QueuedConnection); } }; @@ -334,9 +334,9 @@ void OBSBasic::CreateHotkeys() transitionHotkey = obs_hotkey_register_frontend("OBSBasic.Transition", Str("Transition"), transition, this); LoadHotkey(transitionHotkey, "OBSBasic.Transition"); - auto resetStats = [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + auto resetStats = [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { if (pressed) { - QMetaObject::invokeMethod(static_cast(data), &OBSBasic::ResetStatsHotkey, + QMetaObject::invokeMethod(static_cast(handler_data), &OBSBasic::ResetStatsHotkey, Qt::QueuedConnection); } }; @@ -345,9 +345,9 @@ void OBSBasic::CreateHotkeys() obs_hotkey_register_frontend("OBSBasic.ResetStats", Str("Basic.Stats.ResetStats"), resetStats, this); LoadHotkey(statsHotkey, "OBSBasic.ResetStats"); - auto screenshot = [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + auto screenshot = [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { if (pressed) { - QMetaObject::invokeMethod(static_cast(data), &OBSBasic::Screenshot, + QMetaObject::invokeMethod(static_cast(handler_data), &OBSBasic::Screenshot, Qt::QueuedConnection, nullptr); } }; @@ -355,10 +355,10 @@ void OBSBasic::CreateHotkeys() screenshotHotkey = obs_hotkey_register_frontend("OBSBasic.Screenshot", Str("Screenshot"), screenshot, this); LoadHotkey(screenshotHotkey, "OBSBasic.Screenshot"); - auto screenshotSource = [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + auto screenshotSource = [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { if (pressed) { - QMetaObject::invokeMethod(static_cast(data), &OBSBasic::ScreenshotSelectedSource, - Qt::QueuedConnection); + QMetaObject::invokeMethod(static_cast(handler_data), + &OBSBasic::ScreenshotSelectedSource, Qt::QueuedConnection); } }; diff --git a/frontend/widgets/OBSBasic_Projectors.cpp.hpp b/frontend/widgets/OBSBasic_Projectors.cpp.hpp index e7c042dc66..2aa03f10e7 100644 --- a/frontend/widgets/OBSBasic_Projectors.cpp.hpp +++ b/frontend/widgets/OBSBasic_Projectors.cpp.hpp @@ -68,15 +68,15 @@ void OBSBasic::LoadSavedProjectors(obs_data_array_t *array) size_t num = obs_data_array_count(array); for (size_t i = 0; i < num; i++) { - OBSDataAutoRelease data = obs_data_array_item(array, i); + OBSDataAutoRelease projectorData = obs_data_array_item(array, i); SavedProjectorInfo info = {}; - info.monitor = obs_data_get_int(data, "monitor"); - info.type = static_cast(obs_data_get_int(data, "type")); - info.geometry = std::string(obs_data_get_string(data, "geometry")); - info.name = std::string(obs_data_get_string(data, "name")); - info.alwaysOnTop = obs_data_get_bool(data, "alwaysOnTop"); - info.alwaysOnTopOverridden = obs_data_get_bool(data, "alwaysOnTopOverridden"); + info.monitor = obs_data_get_int(projectorData, "monitor"); + info.type = static_cast(obs_data_get_int(projectorData, "type")); + info.geometry = std::string(obs_data_get_string(projectorData, "geometry")); + info.name = std::string(obs_data_get_string(projectorData, "name")); + info.alwaysOnTop = obs_data_get_bool(projectorData, "alwaysOnTop"); + info.alwaysOnTopOverridden = obs_data_get_bool(projectorData, "alwaysOnTopOverridden"); OpenSavedProjector(&info); } diff --git a/frontend/widgets/OBSBasic_Recording.cpp.hpp b/frontend/widgets/OBSBasic_Recording.cpp.hpp index 5bdc086b7e..b60dc72e55 100644 --- a/frontend/widgets/OBSBasic_Recording.cpp.hpp +++ b/frontend/widgets/OBSBasic_Recording.cpp.hpp @@ -95,11 +95,11 @@ void OBSBasic::AutoRemux(QString input, bool no_show) output += "mp4"; } - OBSRemux *remux = new OBSRemux(QT_TO_UTF8(path), this, true); + OBSRemux *remuxDialog = new OBSRemux(QT_TO_UTF8(path), this, true); if (!no_show) { - remux->show(); + remuxDialog->show(); } - remux->AutoRemux(input, output); + remuxDialog->AutoRemux(input, output); } void OBSBasic::StartRecording() diff --git a/frontend/widgets/OBSBasic_SceneCollections.cpp.hpp b/frontend/widgets/OBSBasic_SceneCollections.cpp.hpp index 50a01db52c..f33dfab9ad 100644 --- a/frontend/widgets/OBSBasic_SceneCollections.cpp.hpp +++ b/frontend/widgets/OBSBasic_SceneCollections.cpp.hpp @@ -170,10 +170,10 @@ void OBSBasic::SetupDuplicateSceneCollection(const std::string &collectionName) obs_data_array_enum( sources, - [](obs_data_t *data, void *) -> void { + [](obs_data_t *sourceData, void *) -> void { const char *uuid = os_generate_uuid(); - obs_data_set_string(data, "uuid", uuid); + obs_data_set_string(sourceData, "uuid", uuid); bfree((void *)uuid); }, @@ -660,9 +660,9 @@ void OBSBasic::on_actionExportSceneCollection_triggered() OBSDataVector sourceItems; obs_data_array_enum( sources, - [](obs_data_t *data, void *vector) -> void { + [](obs_data_t *sourceData, void *vector) -> void { OBSDataVector &sourceItems{*static_cast(vector)}; - sourceItems.push_back(data); + sourceItems.push_back(sourceData); }, &sourceItems); @@ -831,8 +831,8 @@ void OBSBasic::Save(SceneCollection &collection) using FilterAudioSources_t = decltype(FilterAudioSources); OBSDataArrayAutoRelease sourcesArray = obs_save_sources_filtered( - [](void *data, obs_source_t *source) { - auto &func = *static_cast(data); + [](void *handler_data, obs_source_t *source) { + auto &func = *static_cast(handler_data); return func(source); }, static_cast(&FilterAudioSources)); @@ -1121,9 +1121,9 @@ void OBSBasic::Load(SceneCollection &collection) lastOutputResolution.reset(); collection.setMigrationResolution(0, 0); - obs_data_t *data = obs_data_create_from_json_file_safe(collection.getFilePathString().c_str(), "bak"); + obs_data_t *collectionData = obs_data_create_from_json_file_safe(collection.getFilePathString().c_str(), "bak"); - if (!data) { + if (!collectionData) { disableSaving--; const std::filesystem::path filePath = collection.getFilePath(); @@ -1152,10 +1152,10 @@ void OBSBasic::Load(SceneCollection &collection) return; } - LoadData(data, collection); + LoadData(collectionData, collection); } -void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) +void OBSBasic::LoadData(obs_data_t *collectionData, SceneCollection &collection) { ClearSceneData(); ClearContextBar(); @@ -1176,23 +1176,23 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) QApplication::sendPostedEvents(nullptr); - OBSDataAutoRelease modulesObj = obs_data_get_obj(data, "modules"); + OBSDataAutoRelease modulesObj = obs_data_get_obj(collectionData, "modules"); if (api) { api->on_preload(modulesObj); } /* Keep a reference to "modules" data so plugins that are not loaded do * not have their collection specific data lost. */ - collectionModuleData = obs_data_get_obj(data, "modules"); + collectionModuleData = obs_data_get_obj(collectionData, "modules"); - OBSDataArrayAutoRelease sceneOrder = obs_data_get_array(data, "scene_order"); - OBSDataArrayAutoRelease sources = obs_data_get_array(data, "sources"); - OBSDataArrayAutoRelease groups = obs_data_get_array(data, "groups"); - OBSDataArrayAutoRelease transitionsData = obs_data_get_array(data, "transitions"); - OBSDataArrayAutoRelease collection_canvases = obs_data_get_array(data, "canvases"); - const char *sceneName = obs_data_get_string(data, "current_scene"); - const char *programSceneName = obs_data_get_string(data, "current_program_scene"); - const char *transitionName = obs_data_get_string(data, "current_transition"); + OBSDataArrayAutoRelease sceneOrder = obs_data_get_array(collectionData, "scene_order"); + OBSDataArrayAutoRelease sources = obs_data_get_array(collectionData, "sources"); + OBSDataArrayAutoRelease groups = obs_data_get_array(collectionData, "groups"); + OBSDataArrayAutoRelease transitionsData = obs_data_get_array(collectionData, "transitions"); + OBSDataArrayAutoRelease collection_canvases = obs_data_get_array(collectionData, "canvases"); + const char *sceneName = obs_data_get_string(collectionData, "current_scene"); + const char *programSceneName = obs_data_get_string(collectionData, "current_program_scene"); + const char *transitionName = obs_data_get_string(collectionData, "current_transition"); if (!opt_starting_scene.empty()) { programSceneName = opt_starting_scene.c_str(); @@ -1201,7 +1201,7 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) } } - int newDuration = obs_data_get_int(data, "transition_duration"); + int newDuration = obs_data_get_int(collectionData, "transition_duration"); if (!newDuration) { newDuration = 300; } @@ -1212,9 +1212,9 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) const char *curSceneCollection = config_get_string(App()->GetUserConfig(), "Basic", "SceneCollection"); - obs_data_set_default_string(data, "name", curSceneCollection); + obs_data_set_default_string(collectionData, "name", curSceneCollection); - const char *name = obs_data_get_string(data, "name"); + const char *name = obs_data_get_string(collectionData, "name"); OBSSourceAutoRelease curScene; OBSSourceAutoRelease curProgramScene; obs_source_t *curTransition; @@ -1223,12 +1223,12 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) name = curSceneCollection; } - LoadAudioDevice(DESKTOP_AUDIO_1.data(), 1, data); - LoadAudioDevice(DESKTOP_AUDIO_2.data(), 2, data); - LoadAudioDevice(AUX_AUDIO_1.data(), 3, data); - LoadAudioDevice(AUX_AUDIO_2.data(), 4, data); - LoadAudioDevice(AUX_AUDIO_3.data(), 5, data); - LoadAudioDevice(AUX_AUDIO_4.data(), 6, data); + LoadAudioDevice(DESKTOP_AUDIO_1.data(), 1, collectionData); + LoadAudioDevice(DESKTOP_AUDIO_2.data(), 2, collectionData); + LoadAudioDevice(AUX_AUDIO_1.data(), 3, collectionData); + LoadAudioDevice(AUX_AUDIO_2.data(), 4, collectionData); + LoadAudioDevice(AUX_AUDIO_3.data(), 5, collectionData); + LoadAudioDevice(AUX_AUDIO_4.data(), 6, collectionData); if (collection_canvases) { canvases = OBS::Canvas::LoadCanvases(collection_canvases); @@ -1243,8 +1243,8 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) bool resetVideo = false; obs_video_info ovi; - int64_t version = obs_data_get_int(data, "version"); - OBSDataAutoRelease res = obs_data_get_obj(data, "resolution"); + int64_t version = obs_data_get_int(collectionData, "version"); + OBSDataAutoRelease res = obs_data_get_obj(collectionData, "resolution"); OBS::Rect collectionSize{}; @@ -1279,8 +1279,8 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) backupFilePath.replace_extension(".json.v1"); if (!std::filesystem::exists(backupFilePath)) { - bool success = obs_data_save_json_pretty_safe(data, backupFilePath.u8string().c_str(), - "tmp", nullptr); + bool success = obs_data_save_json_pretty_safe( + collectionData, backupFilePath.u8string().c_str(), "tmp", nullptr); if (!success) { blog(LOG_WARNING, @@ -1292,7 +1292,7 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) } else if (version < 2) { collection.setCoordinateMode(SceneCoordinateMode::Absolute); } else { - OBSDataAutoRelease migrationResolution = obs_data_get_obj(data, "migration_resolution"); + OBSDataAutoRelease migrationResolution = obs_data_get_obj(collectionData, "migration_resolution"); if (migrationResolution) { collection.setMigrationResolution(obs_data_get_int(migrationResolution, "x"), @@ -1335,7 +1335,8 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) LoadSceneListOrder(sceneOrder); } - curTransition = FindSavedTransition(transitionName, obs_data_get_string(data, "current_transition_id")); + curTransition = + FindSavedTransition(transitionName, obs_data_get_string(collectionData, "current_transition_id")); SetTransitionDuration(newDuration); SetTransition(curTransition); @@ -1347,8 +1348,8 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) /* if the starting scene command line parameter is bad at all, * fall back to original settings */ if (!opt_starting_scene.empty() && (!curScene || !curProgramScene)) { - sceneName = obs_data_get_string(data, "current_scene"); - programSceneName = obs_data_get_string(data, "current_program_scene"); + sceneName = obs_data_get_string(collectionData, "current_scene"); + programSceneName = obs_data_get_string(collectionData, "current_program_scene"); opt_starting_scene.clear(); goto retryScene; } @@ -1375,7 +1376,7 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) bool projectorSave = config_get_bool(App()->GetUserConfig(), "BasicWindow", "SaveProjectors"); if (projectorSave) { - OBSDataArrayAutoRelease savedProjectors = obs_data_get_array(data, "saved_projectors"); + OBSDataArrayAutoRelease savedProjectors = obs_data_get_array(collectionData, "saved_projectors"); if (savedProjectors) { LoadSavedProjectors(savedProjectors); @@ -1388,21 +1389,21 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) config_set_string(App()->GetUserConfig(), "Basic", "SceneCollection", collection.getName().c_str()); config_set_string(App()->GetUserConfig(), "Basic", "SceneCollectionFile", collection.getFileName().c_str()); - OBSDataArrayAutoRelease quickTransitionData = obs_data_get_array(data, "quick_transitions"); + OBSDataArrayAutoRelease quickTransitionData = obs_data_get_array(collectionData, "quick_transitions"); LoadQuickTransitions(quickTransitionData); RefreshQuickTransitions(); - bool previewLocked = obs_data_get_bool(data, "preview_locked"); + bool previewLocked = obs_data_get_bool(collectionData, "preview_locked"); ui->preview->SetLocked(previewLocked); ui->actionLockPreview->setChecked(previewLocked); /* ---------------------- */ - bool fixedScaling = obs_data_get_bool(data, "scaling_enabled"); - int scalingLevel = (int)obs_data_get_int(data, "scaling_level"); - float scrollOffX = (float)obs_data_get_double(data, "scaling_off_x"); - float scrollOffY = (float)obs_data_get_double(data, "scaling_off_y"); + bool fixedScaling = obs_data_get_bool(collectionData, "scaling_enabled"); + int scalingLevel = (int)obs_data_get_int(collectionData, "scaling_level"); + float scrollOffX = (float)obs_data_get_double(collectionData, "scaling_off_x"); + float scrollOffY = (float)obs_data_get_double(collectionData, "scaling_off_y"); if (fixedScaling) { ui->preview->SetScalingLevel(scalingLevel); @@ -1413,7 +1414,7 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) emit ui->preview->DisplayResized(); if (vcamEnabled) { - OBSDataAutoRelease obj = obs_data_get_obj(data, "virtual-camera"); + OBSDataAutoRelease obj = obs_data_get_obj(collectionData, "virtual-camera"); vcamConfig.type = (VCamOutputType)obs_data_get_int(obj, "type2"); if (vcamConfig.type == VCamOutputType::Invalid) { @@ -1446,7 +1447,7 @@ void OBSBasic::LoadData(obs_data_t *data, SceneCollection &collection) api->on_load(modulesObj); } - obs_data_release(data); + obs_data_release(collectionData); if (!opt_starting_scene.empty()) { opt_starting_scene.clear(); @@ -1716,8 +1717,8 @@ void OBSBasic::on_actionShowMissingFiles_triggered() { obs_missing_files_t *files = obs_missing_files_create(); - auto cb_sources = [](void *data, obs_source_t *source) { - missing_files_list_add_source(data, source); + auto cb_sources = [](void *handler_data, obs_source_t *source) { + missing_files_list_add_source(handler_data, source); return true; }; diff --git a/frontend/widgets/OBSBasic_SceneItems.cpp.hpp b/frontend/widgets/OBSBasic_SceneItems.cpp.hpp index 16d2203b6f..fe460cccf8 100644 --- a/frontend/widgets/OBSBasic_SceneItems.cpp.hpp +++ b/frontend/widgets/OBSBasic_SceneItems.cpp.hpp @@ -561,8 +561,8 @@ void OBSBasic::CreateSourcePopupMenu(int idx, bool preview) delete deinterlaceMenu; OBSSceneItem sceneItem; - obs_source_t *source; - uint32_t flags; + obs_source_t *source = nullptr; + uint32_t flags = 0; bool isAsyncVideo = false; bool hasAudio = false; bool hasVideo = false; diff --git a/frontend/widgets/OBSBasic_Scenes.cpp.hpp b/frontend/widgets/OBSBasic_Scenes.cpp.hpp index c1f0873b27..b314004806 100644 --- a/frontend/widgets/OBSBasic_Scenes.cpp.hpp +++ b/frontend/widgets/OBSBasic_Scenes.cpp.hpp @@ -52,9 +52,9 @@ obs_data_array_t *OBSBasic::SaveSceneListOrder() obs_data_array_t *sceneOrder = obs_data_array_create(); for (int i = 0; i < ui->scenes->count(); i++) { - OBSDataAutoRelease data = obs_data_create(); - obs_data_set_string(data, "name", QT_TO_UTF8(ui->scenes->item(i)->text())); - obs_data_array_push_back(sceneOrder, data); + OBSDataAutoRelease orderData = obs_data_create(); + obs_data_set_string(orderData, "name", QT_TO_UTF8(ui->scenes->item(i)->text())); + obs_data_array_push_back(sceneOrder, orderData); } return sceneOrder; @@ -80,8 +80,8 @@ void OBSBasic::LoadSceneListOrder(obs_data_array_t *array) size_t num = obs_data_array_count(array); for (size_t i = 0; i < num; i++) { - OBSDataAutoRelease data = obs_data_array_item(array, i); - const char *name = obs_data_get_string(data, "name"); + OBSDataAutoRelease itemData = obs_data_array_item(array, i); + const char *name = obs_data_get_string(itemData, "name"); ReorderItemByName(ui->scenes, name, (int)i); } @@ -103,10 +103,10 @@ void OBSBasic::AddScene(OBSSource source) obs_hotkey_register_source( source, "OBSBasic.SelectScene", Str("Basic.Hotkeys.SelectScene"), - [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { OBSBasic *main = OBSBasic::Get(); - auto potential_source = static_cast(data); + auto potential_source = static_cast(handler_data); OBSSourceAutoRelease source = obs_source_get_ref(potential_source); if (source && pressed) { main->SetCurrentScene(source.Get()); @@ -146,8 +146,8 @@ void OBSBasic::AddScene(OBSSource source) SaveProject(); if (!disableSaving) { - obs_source_t *source = obs_scene_get_source(scene); - blog(LOG_INFO, "User added scene '%s'", obs_source_get_name(source)); + obs_source_t *sceneSource = obs_scene_get_source(scene); + blog(LOG_INFO, "User added scene '%s'", obs_source_get_name(sceneSource)); OBSProjector::UpdateMultiviewProjectors(); } @@ -267,33 +267,34 @@ void OBSBasic::DuplicateSelectedScene() continue; } - obs_source_t *source = obs_get_source_by_name(name.c_str()); - if (source) { + obs_source_t *existingSource = obs_get_source_by_name(name.c_str()); + if (existingSource) { OBSMessageBox::warning(this, QTStr("NameExists.Title"), QTStr("NameExists.Text")); - obs_source_release(source); + obs_source_release(existingSource); continue; } OBSSceneAutoRelease scene = obs_scene_duplicate(curScene, name.c_str(), OBS_SCENE_DUP_REFS); - source = obs_scene_get_source(scene); - SetCurrentScene(source, true); + existingSource = obs_scene_get_source(scene); + SetCurrentScene(existingSource, true); - auto undo = [](const std::string &data) { - OBSSourceAutoRelease source = obs_get_source_by_name(data.c_str()); + auto undo = [](const std::string &sceneName) { + OBSSourceAutoRelease source = obs_get_source_by_name(sceneName.c_str()); obs_source_remove(source); }; - auto redo = [this, name](const std::string &data) { - OBSSourceAutoRelease source = obs_get_source_by_name(data.c_str()); + auto redo = [this, name](const std::string &sceneName) { + OBSSourceAutoRelease source = obs_get_source_by_name(sceneName.c_str()); obs_scene_t *scene = obs_scene_from_source(source); scene = obs_scene_duplicate(scene, name.c_str(), OBS_SCENE_DUP_REFS); source = obs_scene_get_source(scene); SetCurrentScene(source.Get(), true); }; - undo_s.add_action(QTStr("Undo.Scene.Duplicate").arg(obs_source_get_name(source)), undo, redo, - obs_source_get_name(source), obs_source_get_name(obs_scene_get_source(curScene))); + undo_s.add_action(QTStr("Undo.Scene.Duplicate").arg(obs_source_get_name(existingSource)), undo, redo, + obs_source_get_name(existingSource), + obs_source_get_name(obs_scene_get_source(curScene))); break; } @@ -460,13 +461,13 @@ void OBSBasic::RemoveSelectedScene() RemoveSceneAndReleaseNested(source); }; - OBSDataAutoRelease data = obs_data_create(); - obs_data_set_array(data, "sources_in_deleted_scene", sources_in_deleted_scene); - obs_data_set_array(data, "scene_used_in_other_scenes", scene_used_in_other_scenes); - obs_data_set_int(data, "index", ui->scenes->currentRow()); + OBSDataAutoRelease undoData = obs_data_create(); + obs_data_set_array(undoData, "sources_in_deleted_scene", sources_in_deleted_scene); + obs_data_set_array(undoData, "scene_used_in_other_scenes", scene_used_in_other_scenes); + obs_data_set_int(undoData, "index", ui->scenes->currentRow()); const char *scene_name = obs_source_get_name(source); - undo_s.add_action(QTStr("Undo.Delete").arg(scene_name), undo, redo, obs_data_get_json(data), scene_name); + undo_s.add_action(QTStr("Undo.Delete").arg(scene_name), undo, redo, obs_data_get_json(undoData), scene_name); /* --------------------------- */ /* remove */ @@ -609,21 +610,22 @@ void OBSBasic::on_scenes_customContextMenuRequested(const QPoint &pos) QAction *multiviewAction = popup.addAction(QTStr("ShowInMultiview")); OBSSource source = GetCurrentSceneSource(); - OBSDataAutoRelease data = obs_source_get_private_settings(source); + OBSDataAutoRelease privateSettings = obs_source_get_private_settings(source); - obs_data_set_default_bool(data, "show_in_multiview", true); - bool show = obs_data_get_bool(data, "show_in_multiview"); + obs_data_set_default_bool(privateSettings, "show_in_multiview", true); + bool show = obs_data_get_bool(privateSettings, "show_in_multiview"); multiviewAction->setCheckable(true); multiviewAction->setChecked(show); - auto showInMultiview = [](OBSData data) { - bool show = obs_data_get_bool(data, "show_in_multiview"); - obs_data_set_bool(data, "show_in_multiview", !show); + auto showInMultiview = [](OBSData settingsData) { + bool show = obs_data_get_bool(settingsData, "show_in_multiview"); + obs_data_set_bool(settingsData, "show_in_multiview", !show); OBSProjector::UpdateMultiviewProjectors(); }; - connect(multiviewAction, &QAction::triggered, multiviewAction, std::bind(showInMultiview, data.Get())); + connect(multiviewAction, &QAction::triggered, multiviewAction, + std::bind(showInMultiview, privateSettings.Get())); copyFilters->setEnabled(obs_source_filter_count(source) > 0); } @@ -687,24 +689,24 @@ void OBSBasic::on_actionAddScene_triggered() return; } - OBSSourceAutoRelease source = obs_get_source_by_name(name.c_str()); - if (source) { + OBSSourceAutoRelease existingSource = obs_get_source_by_name(name.c_str()); + if (existingSource) { OBSMessageBox::warning(this, QTStr("NameExists.Title"), QTStr("NameExists.Text")); on_actionAddScene_triggered(); return; } - auto undo_fn = [](const std::string &data) { - obs_source_t *t = obs_get_source_by_name(data.c_str()); + auto undo_fn = [](const std::string &sceneName) { + obs_source_t *t = obs_get_source_by_name(sceneName.c_str()); if (t) { obs_source_remove(t); obs_source_release(t); } }; - auto redo_fn = [this](const std::string &data) { - OBSSceneAutoRelease scene = obs_scene_create(data.c_str()); + auto redo_fn = [this](const std::string &sceneName) { + OBSSceneAutoRelease scene = obs_scene_create(sceneName.c_str()); obs_source_t *source = obs_scene_get_source(scene); SetCurrentScene(source, true); }; diff --git a/frontend/widgets/OBSBasic_Service.cpp.hpp b/frontend/widgets/OBSBasic_Service.cpp.hpp index 1448af85ab..c229c155e0 100644 --- a/frontend/widgets/OBSBasic_Service.cpp.hpp +++ b/frontend/widgets/OBSBasic_Service.cpp.hpp @@ -31,20 +31,20 @@ void OBSBasic::SaveService() const std::filesystem::path jsonFilePath = currentProfile.path / std::filesystem::u8path(OBSServiceFileName); - OBSDataAutoRelease data = obs_data_create(); + OBSDataAutoRelease serviceData = obs_data_create(); OBSDataAutoRelease settings = obs_service_get_settings(service); - obs_data_set_string(data, "type", obs_service_get_type(service)); - obs_data_set_obj(data, "settings", settings); + obs_data_set_string(serviceData, "type", obs_service_get_type(service)); + obs_data_set_obj(serviceData, "settings", settings); - if (!obs_data_save_json_safe(data, jsonFilePath.u8string().c_str(), "tmp", "bak")) { + if (!obs_data_save_json_safe(serviceData, jsonFilePath.u8string().c_str(), "tmp", "bak")) { blog(LOG_WARNING, "Failed to save service"); } } bool OBSBasic::LoadService() { - OBSDataAutoRelease data; + OBSDataAutoRelease serviceData; try { const OBSProfile ¤tProfile = GetCurrentProfile(); @@ -52,9 +52,9 @@ bool OBSBasic::LoadService() const std::filesystem::path jsonFilePath = currentProfile.path / std::filesystem::u8path(OBSServiceFileName); - data = obs_data_create_from_json_file_safe(jsonFilePath.u8string().c_str(), "bak"); + serviceData = obs_data_create_from_json_file_safe(jsonFilePath.u8string().c_str(), "bak"); - if (!data) { + if (!serviceData) { return false; } } catch (const std::invalid_argument &error) { @@ -63,11 +63,11 @@ bool OBSBasic::LoadService() } const char *type; - obs_data_set_default_string(data, "type", "rtmp_common"); - type = obs_data_get_string(data, "type"); + obs_data_set_default_string(serviceData, "type", "rtmp_common"); + type = obs_data_get_string(serviceData, "type"); - OBSDataAutoRelease settings = obs_data_get_obj(data, "settings"); - OBSDataAutoRelease hotkey_data = obs_data_get_obj(data, "hotkeys"); + OBSDataAutoRelease settings = obs_data_get_obj(serviceData, "settings"); + OBSDataAutoRelease hotkey_data = obs_data_get_obj(serviceData, "hotkeys"); service = obs_service_create(type, "default_service", settings, hotkey_data); obs_service_release(service); diff --git a/frontend/widgets/OBSBasic_Streaming.cpp.hpp b/frontend/widgets/OBSBasic_Streaming.cpp.hpp index d3fd8ffdfb..3032026213 100644 --- a/frontend/widgets/OBSBasic_Streaming.cpp.hpp +++ b/frontend/widgets/OBSBasic_Streaming.cpp.hpp @@ -418,10 +418,11 @@ void OBSBasic::StreamActionTriggered() return; } - Auth *auth = GetAuth(); + Auth *currentAuth = GetAuth(); - auto action = (auth && auth->external()) ? StreamSettingsAction::ContinueStream - : UIValidation::StreamSettingsConfirmation(this, service); + auto action = (currentAuth && currentAuth->external()) + ? StreamSettingsAction::ContinueStream + : UIValidation::StreamSettingsConfirmation(this, service); switch (action) { case StreamSettingsAction::ContinueStream: break; @@ -440,7 +441,7 @@ void OBSBasic::StreamActionTriggered() OBSDataAutoRelease settings = obs_service_get_settings(service); bwtest = obs_data_get_bool(settings, "bwtest"); // Disable confirmation if this is going to open broadcast setup - if (auth && auth->broadcastFlow() && !broadcastReady && !broadcastActive) { + if (currentAuth && currentAuth->broadcastFlow() && !broadcastReady && !broadcastActive) { confirm = false; } } diff --git a/frontend/widgets/OBSBasic_StudioMode.cpp.hpp b/frontend/widgets/OBSBasic_StudioMode.cpp.hpp index 658526eee1..5da09d7c38 100644 --- a/frontend/widgets/OBSBasic_StudioMode.cpp.hpp +++ b/frontend/widgets/OBSBasic_StudioMode.cpp.hpp @@ -240,7 +240,7 @@ void OBSBasic::SetPreviewProgramMode(bool enabled) "-------------------"); } else { OBSSource actualProgramScene = OBSGetStrongRef(programScene); - OBSSource currentScene = GetCurrentSceneSource(); + OBSSource currentSceneSource = GetCurrentSceneSource(); struct studio_mode_exit_ops ops = {}; ops.param = this; ops.select_scene = [](void *param, void *scene) { @@ -260,7 +260,7 @@ void OBSBasic::SetPreviewProgramMode(bool enabled) ops.scene_changed = [](void *param) { static_cast(param)->OnEvent(OBS_FRONTEND_EVENT_SCENE_CHANGED); }; - studio_mode_exit_switch(&ops, actualProgramScene.Get(), currentScene.Get()); + studio_mode_exit_switch(&ops, actualProgramScene.Get(), currentSceneSource.Get()); delete programOptions; delete program; @@ -365,14 +365,15 @@ void OBSBasic::UpdatePreviewProgramIndicators() QString preview = QTStr("StudioMode.PreviewSceneName").arg(QT_UTF8(obs_source_get_name(GetCurrentSceneSource()))); - QString program = QTStr("StudioMode.ProgramSceneName").arg(QT_UTF8(obs_source_get_name(GetProgramSource()))); + QString programText = + QTStr("StudioMode.ProgramSceneName").arg(QT_UTF8(obs_source_get_name(GetProgramSource()))); if (ui->previewLabel->text() != preview) { ui->previewLabel->setText(preview); } - if (programLabel && programLabel->text() != program) { - programLabel->setText(program); + if (programLabel && programLabel->text() != programText) { + programLabel->setText(programText); } } @@ -384,14 +385,14 @@ OBSSource OBSBasic::GetProgramSource() void OBSBasic::ProgramViewContextMenuRequested() { QMenu popup(this); - QPointer studioProgramProjector; + QPointer programProjectorMenu; - studioProgramProjector = new QMenu(QTStr("Projector.Open.Program")); - AddProjectorMenuMonitors(studioProgramProjector, this, &OBSBasic::OpenStudioProgramProjector); - studioProgramProjector->addSeparator(); - studioProgramProjector->addAction(QTStr("Projector.Window"), this, &OBSBasic::OpenStudioProgramWindow); + programProjectorMenu = new QMenu(QTStr("Projector.Open.Program")); + AddProjectorMenuMonitors(programProjectorMenu, this, &OBSBasic::OpenStudioProgramProjector); + programProjectorMenu->addSeparator(); + programProjectorMenu->addAction(QTStr("Projector.Window"), this, &OBSBasic::OpenStudioProgramWindow); - popup.addMenu(studioProgramProjector); + popup.addMenu(programProjectorMenu); popup.addSeparator(); popup.addAction(QTStr("Screenshot.StudioProgram"), this, &OBSBasic::ScreenshotProgram); diff --git a/frontend/widgets/OBSBasic_Transitions.cpp.hpp b/frontend/widgets/OBSBasic_Transitions.cpp.hpp index 54443a3847..f11a7a7208 100644 --- a/frontend/widgets/OBSBasic_Transitions.cpp.hpp +++ b/frontend/widgets/OBSBasic_Transitions.cpp.hpp @@ -89,8 +89,8 @@ void OBSBasic::AddQuickTransitionHotkey(QuickTransition *qt) dstr_printf(hotkeyId, "OBSBasic.QuickTransition.%d", qt->id); hotkeyName = QTStr("QuickTransitions.HotkeyName").arg(TransitionsQuickTransitionText(qt)); - auto quickTransition = [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { - int id = (int)(uintptr_t)data; + auto quickTransition = [](void *handler_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { + int id = (int)(uintptr_t)handler_data; OBSBasic *main = OBSBasic::Get(); if (pressed) { @@ -126,18 +126,18 @@ void OBSBasic::RemoveQuickTransitionHotkey(QuickTransition *qt) void OBSBasic::InitTransition(obs_source_t *transition) { - auto onTransitionStart = [](void *data, calldata_t *) { - OBSBasic *window = (OBSBasic *)data; + auto onTransitionStart = [](void *handler_data, calldata_t *) { + OBSBasic *window = (OBSBasic *)handler_data; QMetaObject::invokeMethod(window, &OBSBasic::TransitionStarted, Qt::QueuedConnection); }; - auto onTransitionStop = [](void *data, calldata_t *) { - OBSBasic *window = (OBSBasic *)data; + auto onTransitionStop = [](void *handler_data, calldata_t *) { + OBSBasic *window = (OBSBasic *)handler_data; QMetaObject::invokeMethod(window, &OBSBasic::TransitionStopped, Qt::QueuedConnection); }; - auto onTransitionFullStop = [](void *data, calldata_t *) { - OBSBasic *window = (OBSBasic *)data; + auto onTransitionFullStop = [](void *handler_data, calldata_t *) { + OBSBasic *window = (OBSBasic *)handler_data; QMetaObject::invokeMethod(window, &OBSBasic::TransitionFullyStopped, Qt::QueuedConnection); }; @@ -168,12 +168,12 @@ void OBSBasic::LoadQuickTransitions(obs_data_array_t *array) quickTransitionIdCounter = 1; for (size_t i = 0; i < count; i++) { - OBSDataAutoRelease data = obs_data_array_item(array, i); - OBSDataArrayAutoRelease hotkeys = obs_data_get_array(data, "hotkeys"); - const char *name = obs_data_get_string(data, "name"); - int duration = obs_data_get_int(data, "duration"); - int id = obs_data_get_int(data, "id"); - bool toBlack = obs_data_get_bool(data, "fade_to_black"); + OBSDataAutoRelease itemData = obs_data_array_item(array, i); + OBSDataArrayAutoRelease hotkeys = obs_data_get_array(itemData, "hotkeys"); + const char *name = obs_data_get_string(itemData, "name"); + int duration = obs_data_get_int(itemData, "duration"); + int id = obs_data_get_int(itemData, "id"); + bool toBlack = obs_data_get_bool(itemData, "fade_to_black"); if (id) { obs_source_t *source = FindTransition(name); @@ -198,17 +198,17 @@ obs_data_array_t *OBSBasic::SaveQuickTransitions() obs_data_array_t *array = obs_data_array_create(); for (QuickTransition &qt : quickTransitions) { - OBSDataAutoRelease data = obs_data_create(); + OBSDataAutoRelease entryData = obs_data_create(); OBSDataArrayAutoRelease hotkeys = obs_hotkey_save(qt.hotkey); MarkSavedHotkeys(hotkeys); - obs_data_set_string(data, "name", obs_source_get_name(qt.source)); - obs_data_set_int(data, "duration", qt.duration); - obs_data_set_array(data, "hotkeys", hotkeys); - obs_data_set_int(data, "id", qt.id); - obs_data_set_bool(data, "fade_to_black", qt.fadeToBlack); + obs_data_set_string(entryData, "name", obs_source_get_name(qt.source)); + obs_data_set_int(entryData, "duration", qt.duration); + obs_data_set_array(entryData, "hotkeys", hotkeys); + obs_data_set_int(entryData, "id", qt.id); + obs_data_set_bool(entryData, "fade_to_black", qt.fadeToBlack); - obs_data_array_push_back(array, data); + obs_data_array_push_back(array, entryData); } return array; @@ -323,13 +323,13 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force, bool quickTransit programScene = OBSGetWeakRef(source); if (!force && !black) { - OBSSource lastScene = OBSGetStrongRef(lastProgramScene); + OBSSource previousScene = OBSGetStrongRef(lastProgramScene); - if (!sceneDuplicationMode && lastScene == source) { + if (!sceneDuplicationMode && previousScene == source) { return; } - if (swapScenesMode && lastScene && lastScene != GetCurrentSceneSource()) { + if (swapScenesMode && previousScene && previousScene != GetCurrentSceneSource()) { swapScene = lastProgramScene; swapPreviewScene = OBSGetWeakRef(GetCurrentSceneSource()); } @@ -656,7 +656,7 @@ void OBSBasic::on_transitionProps_clicked() return; } - auto properties = [&]() { + auto openSourceProperties = [&]() { CreatePropertiesWindow(source); }; @@ -667,7 +667,7 @@ void OBSBasic::on_transitionProps_clicked() menu.addAction(action); action = new QAction(QTStr("Properties"), &menu); - connect(action, &QAction::triggered, this, properties); + connect(action, &QAction::triggered, this, openSourceProperties); menu.addAction(action); menu.exec(QCursor::pos()); @@ -895,12 +895,12 @@ QMenu *OBSBasic::CreatePerSceneTransitionMenu() OBSSource scene = GetCurrentSceneSource(); QMenu *menu = new QMenu(QTStr("TransitionOverride")); - OBSDataAutoRelease data = obs_source_get_private_settings(scene); + OBSDataAutoRelease privateSettings = obs_source_get_private_settings(scene); - obs_data_set_default_int(data, "transition_duration", 300); + obs_data_set_default_int(privateSettings, "transition_duration", 300); - const char *curTransition = obs_data_get_string(data, "transition"); - int curDuration = (int)obs_data_get_int(data, "transition_duration"); + const char *curTransition = obs_data_get_string(privateSettings, "transition"); + int curDuration = (int)obs_data_get_int(privateSettings, "transition_duration"); QSpinBox *duration = new QSpinBox(menu); duration->setMinimum(50); @@ -912,12 +912,12 @@ QMenu *OBSBasic::CreatePerSceneTransitionMenu() auto setTransition = [this](QAction *action) { std::string uuid = action->property("transition_uuid").toString().toStdString(); OBSSource scene = GetCurrentSceneSource(); - OBSDataAutoRelease data = obs_source_get_private_settings(scene); + OBSDataAutoRelease privateSettings = obs_source_get_private_settings(scene); auto transitionIter = transitions.find(uuid); OBSSource transition; if (uuid.empty()) { - obs_data_set_string(data, "transition", ""); + obs_data_set_string(privateSettings, "transition", ""); return; } @@ -929,15 +929,15 @@ QMenu *OBSBasic::CreatePerSceneTransitionMenu() if (transition) { const char *name = obs_source_get_name(transition); - obs_data_set_string(data, "transition", name); + obs_data_set_string(privateSettings, "transition", name); } }; auto setDuration = [this](int duration) { OBSSource scene = GetCurrentSceneSource(); - OBSDataAutoRelease data = obs_source_get_private_settings(scene); + OBSDataAutoRelease privateSettings = obs_source_get_private_settings(scene); - obs_data_set_int(data, "transition_duration", duration); + obs_data_set_int(privateSettings, "transition_duration", duration); }; connect(duration, &QSpinBox::valueChanged, this, setDuration); @@ -1007,12 +1007,12 @@ void OBSBasic::PasteShowHideTransition(obs_sceneitem_t *item, bool show, obs_sou int64_t sceneItemId = obs_sceneitem_get_id(item); std::string sceneUUID = obs_source_get_uuid(obs_scene_get_source(obs_sceneitem_get_scene(item))); - auto undo_redo = [sceneUUID, sceneItemId, show](const std::string &data) { + auto undo_redo = [sceneUUID, sceneItemId, show](const std::string &undoJson) { OBSSourceAutoRelease source = obs_get_source_by_uuid(sceneUUID.c_str()); obs_scene_t *scene = obs_scene_from_source(source); obs_sceneitem_t *i = obs_scene_find_sceneitem_by_id(scene, sceneItemId); if (i) { - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + OBSDataAutoRelease dat = obs_data_create_from_json(undoJson.c_str()); obs_sceneitem_transition_load(i, dat, show); } }; @@ -1089,8 +1089,8 @@ QMenu *OBSBasic::CreateVisibilityTransitionMenu(bool visible) .arg(QString::number(count)); } - auto undo_redo = [](const std::string &data) { - OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str()); + auto undo_redo = [](const std::string &undoJson) { + OBSDataAutoRelease dat = obs_data_create_from_json(undoJson.c_str()); visibility_transition_restore(dat); }; main->undo_s.add_action(text, undo_redo, undo_redo, obs_data_get_json(undo_data), @@ -1262,11 +1262,11 @@ void OBSBasic::AddQuickTransitionId(int id) button->setMenu(buttonMenu); connect(button, &QAbstractButton::clicked, this, &OBSBasic::QuickTransitionClicked); - QVBoxLayout *programLayout = reinterpret_cast(programOptions->layout()); + QVBoxLayout *optionsLayout = reinterpret_cast(programOptions->layout()); int idx = 3; for (;; idx++) { - QLayoutItem *item = programLayout->itemAt(idx); + QLayoutItem *item = optionsLayout->itemAt(idx); if (!item) { break; } @@ -1277,7 +1277,7 @@ void OBSBasic::AddQuickTransitionId(int id) } } - programLayout->insertWidget(idx, button); + optionsLayout->insertWidget(idx, button); } void OBSBasic::AddQuickTransition() @@ -1318,10 +1318,10 @@ void OBSBasic::ClearQuickTransitions() return; } - QVBoxLayout *programLayout = reinterpret_cast(programOptions->layout()); + QVBoxLayout *optionsLayout = reinterpret_cast(programOptions->layout()); for (int idx = 0;; idx++) { - QLayoutItem *item = programLayout->itemAt(idx); + QLayoutItem *item = optionsLayout->itemAt(idx); if (!item) { break; } @@ -1405,10 +1405,10 @@ void OBSBasic::ClearQuickTransitionWidgets() return; } - QVBoxLayout *programLayout = reinterpret_cast(programOptions->layout()); + QVBoxLayout *optionsLayout = reinterpret_cast(programOptions->layout()); for (int idx = 0;; idx++) { - QLayoutItem *item = programLayout->itemAt(idx); + QLayoutItem *item = optionsLayout->itemAt(idx); if (!item) { break; } @@ -1452,10 +1452,10 @@ void OBSBasic::EnableTransitionWidgets(bool enable) return; } - QVBoxLayout *programLayout = reinterpret_cast(programOptions->layout()); + QVBoxLayout *optionsLayout = reinterpret_cast(programOptions->layout()); for (int idx = 0;; idx++) { - QLayoutItem *item = programLayout->itemAt(idx); + QLayoutItem *item = optionsLayout->itemAt(idx); if (!item) { break; } @@ -1538,9 +1538,9 @@ OBSSource OBSBasic::GetOverrideTransition(OBSSource source) return nullptr; } - OBSDataAutoRelease data = obs_source_get_private_settings(source); + OBSDataAutoRelease privateSettings = obs_source_get_private_settings(source); - const char *trOverrideName = obs_data_get_string(data, "transition"); + const char *trOverrideName = obs_data_get_string(privateSettings, "transition"); OBSSource trOverride = nullptr; @@ -1557,10 +1557,10 @@ int OBSBasic::GetOverrideTransitionDuration(OBSSource source) return 300; } - OBSDataAutoRelease data = obs_source_get_private_settings(source); - obs_data_set_default_int(data, "transition_duration", 300); + OBSDataAutoRelease privateSettings = obs_source_get_private_settings(source); + obs_data_set_default_int(privateSettings, "transition_duration", 300); - return (int)obs_data_get_int(data, "transition_duration"); + return (int)obs_data_get_int(privateSettings, "transition_duration"); } int OBSBasic::GetTransitionDuration() diff --git a/frontend/widgets/OBSProjector.cpp.hpp b/frontend/widgets/OBSProjector.cpp.hpp index def412f727..a9e9358434 100644 --- a/frontend/widgets/OBSProjector.cpp.hpp +++ b/frontend/widgets/OBSProjector.cpp.hpp @@ -440,9 +440,9 @@ void OBSProjector::ResizeToContent() resize(newX, newY); } -void OBSProjector::AlwaysOnTopToggled(bool isAlwaysOnTop) +void OBSProjector::AlwaysOnTopToggled(bool alwaysOnTop) { - SetIsAlwaysOnTop(isAlwaysOnTop, true); + SetIsAlwaysOnTop(alwaysOnTop, true); } void OBSProjector::closeEvent(QCloseEvent *event) @@ -461,12 +461,12 @@ bool OBSProjector::IsAlwaysOnTopOverridden() const return isAlwaysOnTopOverridden; } -void OBSProjector::SetIsAlwaysOnTop(bool isAlwaysOnTop, bool isOverridden) +void OBSProjector::SetIsAlwaysOnTop(bool alwaysOnTop, bool isOverridden) { - this->isAlwaysOnTop = isAlwaysOnTop; + this->isAlwaysOnTop = alwaysOnTop; this->isAlwaysOnTopOverridden = isOverridden; - SetAlwaysOnTop(this, isAlwaysOnTop); + SetAlwaysOnTop(this, alwaysOnTop); } void OBSProjector::ScreenRemoved(QScreen *screen) diff --git a/frontend/widgets/OBSProjector.hpp b/frontend/widgets/OBSProjector.hpp index 7f9cd4a4a1..c3b9c48b46 100644 --- a/frontend/widgets/OBSProjector.hpp +++ b/frontend/widgets/OBSProjector.hpp @@ -64,5 +64,5 @@ private slots: bool IsAlwaysOnTop() const; bool IsAlwaysOnTopOverridden() const; - void SetIsAlwaysOnTop(bool isAlwaysOnTop, bool isOverridden); + void SetIsAlwaysOnTop(bool alwaysOnTop, bool isOverridden); }; diff --git a/frontend/wizards/AutoConfig.cpp.hpp b/frontend/wizards/AutoConfig.cpp.hpp index 6d15e7be1f..e57c6809b0 100644 --- a/frontend/wizards/AutoConfig.cpp.hpp +++ b/frontend/wizards/AutoConfig.cpp.hpp @@ -169,8 +169,8 @@ AutoConfig::AutoConfig(QWidget *parent) : QWizard(parent) /* Newer generations of NVENC have a high enough quality to * bitrate ratio that if NVENC is available, it makes sense to * just always prefer hardware encoding by default */ - bool preferHardware = nvencAvailable || appleAvailable || os_get_physical_cores() <= 4; - streamPage->ui->preferHardware->setChecked(preferHardware); + bool preferHardwareEncoding = nvencAvailable || appleAvailable || os_get_physical_cores() <= 4; + streamPage->ui->preferHardware->setChecked(preferHardwareEncoding); } setOptions(QWizard::WizardOptions()); @@ -204,19 +204,19 @@ void AutoConfig::TestHardwareEncoding() } } -bool AutoConfig::CanTestServer(const char *server) +bool AutoConfig::CanTestServer(const char *serverAddress) { if (!testRegions || (regionUS && regionEU && regionAsia && regionOther)) { return true; } if (service == Service::Twitch) { - if (astrcmp_n(server, "US West:", 8) == 0 || astrcmp_n(server, "US East:", 8) == 0 || - astrcmp_n(server, "US Central:", 11) == 0) { + if (astrcmp_n(serverAddress, "US West:", 8) == 0 || astrcmp_n(serverAddress, "US East:", 8) == 0 || + astrcmp_n(serverAddress, "US Central:", 11) == 0) { return regionUS; - } else if (astrcmp_n(server, "EU:", 3) == 0) { + } else if (astrcmp_n(serverAddress, "EU:", 3) == 0) { return regionEU; - } else if (astrcmp_n(server, "Asia:", 5) == 0) { + } else if (astrcmp_n(serverAddress, "Asia:", 5) == 0) { return regionAsia; } else if (regionOther) { return true; diff --git a/frontend/wizards/AutoConfig.hpp b/frontend/wizards/AutoConfig.hpp index 92fa568f98..53e0f8c188 100644 --- a/frontend/wizards/AutoConfig.hpp +++ b/frontend/wizards/AutoConfig.hpp @@ -104,7 +104,7 @@ class AutoConfig : public QWizard { int specificFPSDen = 0; void TestHardwareEncoding(); - bool CanTestServer(const char *server); + bool CanTestServer(const char *serverAddress); virtual void done(int result) override; diff --git a/frontend/wizards/AutoConfigStreamPage.cpp.hpp b/frontend/wizards/AutoConfigStreamPage.cpp.hpp index 09f3eebdf1..7c8c84ba69 100644 --- a/frontend/wizards/AutoConfigStreamPage.cpp.hpp +++ b/frontend/wizards/AutoConfigStreamPage.cpp.hpp @@ -165,10 +165,11 @@ bool AutoConfigStreamPage::validatePage() auto postData = constructGoLivePost(QString::fromStdString(wiz->key), std::nullopt, std::nullopt, false, canvases); - OBSDataAutoRelease service_settings = obs_service_get_settings(service); + OBSDataAutoRelease multitrack_service_settings = obs_service_get_settings(service); auto multitrack_video_name = QTStr("Basic.Settings.Stream.MultitrackVideoLabel"); - if (obs_data_has_user_value(service_settings, "multitrack_video_name")) { - multitrack_video_name = obs_data_get_string(service_settings, "multitrack_video_name"); + if (obs_data_has_user_value(multitrack_service_settings, "multitrack_video_name")) { + multitrack_video_name = + obs_data_get_string(multitrack_service_settings, "multitrack_video_name"); } try { @@ -200,9 +201,9 @@ bool AutoConfigStreamPage::validatePage() continue; } - int bitrate = 0; - it->get_to(bitrate); - multitrackVideoBitrate += bitrate; + int endpoint_bitrate = 0; + it->get_to(endpoint_bitrate); + multitrackVideoBitrate += endpoint_bitrate; } if (multitrackVideoBitrate > 0) { diff --git a/frontend/wizards/AutoConfigTestPage.cpp.hpp b/frontend/wizards/AutoConfigTestPage.cpp.hpp index 85f067d450..05e923db95 100644 --- a/frontend/wizards/AutoConfigTestPage.cpp.hpp +++ b/frontend/wizards/AutoConfigTestPage.cpp.hpp @@ -284,13 +284,13 @@ void AutoConfigTestPage::TestBandwidthThread() using on_started_t = decltype(on_started); using on_stopped_t = decltype(on_stopped); - auto pre_on_started = [](void *data, calldata_t *) { - on_started_t &on_started = *static_cast(data); + auto pre_on_started = [](void *handler_data, calldata_t *) { + on_started_t &on_started = *static_cast(handler_data); on_started(); }; - auto pre_on_stopped = [](void *data, calldata_t *) { - on_stopped_t &on_stopped = *static_cast(data); + auto pre_on_stopped = [](void *handler_data, calldata_t *) { + on_stopped_t &on_stopped = *static_cast(handler_data); on_stopped(); }; @@ -524,8 +524,8 @@ bool AutoConfigTestPage::TestSoftwareEncoding() using on_stopped_t = decltype(on_stopped); - auto pre_on_stopped = [](void *data, calldata_t *) { - on_stopped_t &on_stopped = *static_cast(data); + auto pre_on_stopped = [](void *handler_data, calldata_t *) { + on_stopped_t &on_stopped = *static_cast(handler_data); on_stopped(); }; @@ -565,7 +565,7 @@ bool AutoConfigTestPage::TestSoftwareEncoding() /* -----------------------------------*/ /* perform tests */ - vector results; + vector testResults; int i = 0; int count = 1; @@ -578,7 +578,7 @@ bool AutoConfigTestPage::TestSoftwareEncoding() } /* no need for more than 3 tests max */ - if (results.size() >= 3) { + if (testResults.size() >= 3) { return true; } @@ -636,7 +636,7 @@ bool AutoConfigTestPage::TestSoftwareEncoding() int skipped = (int)video_output_get_skipped_frames(obs_get_video()); if (force || skipped <= 10) { - results.emplace_back(cx, cy, fps_num, fps_den); + testResults.emplace_back(cx, cy, fps_num, fps_den); } return !cancel; @@ -716,19 +716,19 @@ bool AutoConfigTestPage::TestSoftwareEncoding() int minArea = 960 * 540 + 1000; - if (!wiz->specificFPSNum && wiz->preferHighFPS && results.size() > 1) { - Result &result1 = results[0]; - Result &result2 = results[1]; + if (!wiz->specificFPSNum && wiz->preferHighFPS && testResults.size() > 1) { + Result &result1 = testResults[0]; + Result &result2 = testResults[1]; if (result1.fps_num == 30 && result2.fps_num == 60) { int nextArea = result2.cx * result2.cy; if (nextArea >= minArea) { - results.erase(results.begin()); + testResults.erase(testResults.begin()); } } } - Result result = results.front(); + Result result = testResults.front(); wiz->idealResolutionCX = result.cx; wiz->idealResolutionCY = result.cy; wiz->idealFPSNum = result.fps_num; @@ -762,7 +762,7 @@ void AutoConfigTestPage::FindIdealHardwareResolution() int baseCY = wiz->baseResolutionCY; CalcBaseRes(baseCX, baseCY); - vector results; + vector testResults; int pcores = os_get_physical_cores(); int maxDataRate; @@ -777,7 +777,7 @@ void AutoConfigTestPage::FindIdealHardwareResolution() return; } - if (results.size() >= 3) { + if (testResults.size() >= 3) { return; } @@ -812,7 +812,7 @@ void AutoConfigTestPage::FindIdealHardwareResolution() force = true; } if (force || wiz->idealBitrate >= minBitrate) { - results.emplace_back(cx, cy, fps_num, fps_den); + testResults.emplace_back(cx, cy, fps_num, fps_den); } }; @@ -843,19 +843,19 @@ void AutoConfigTestPage::FindIdealHardwareResolution() int minArea = 960 * 540 + 1000; - if (!wiz->specificFPSNum && wiz->preferHighFPS && results.size() > 1) { - Result &result1 = results[0]; - Result &result2 = results[1]; + if (!wiz->specificFPSNum && wiz->preferHighFPS && testResults.size() > 1) { + Result &result1 = testResults[0]; + Result &result2 = testResults[1]; if (result1.fps_num == 30 && result2.fps_num == 60) { int nextArea = result2.cx * result2.cy; if (nextArea >= minArea) { - results.erase(results.begin()); + testResults.erase(testResults.begin()); } } } - Result result = results.front(); + Result result = testResults.front(); wiz->idealResolutionCX = result.cx; wiz->idealResolutionCY = result.cy; wiz->idealFPSNum = result.fps_num; diff --git a/libobs-d3d11/CMakeLists.txt b/libobs-d3d11/CMakeLists.txt index 55d92854be..d1c6fdee29 100644 --- a/libobs-d3d11/CMakeLists.txt +++ b/libobs-d3d11/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.28...3.30) add_library(libobs-d3d11 MODULE) add_library(OBS::libobs-d3d11 ALIAS libobs-d3d11) +obs_msvc_exempt_c4201(libobs-d3d11) # Unity group (BUILD.md): build/d3d11.core+.hpp.cpp #includes the # implementation files (d3d11-foo.cpp.hpp) behind one precompiled header. diff --git a/libobs-d3d11/d3d11-rebuild.cpp.hpp b/libobs-d3d11/d3d11-rebuild.cpp.hpp index 5d5de32d77..0a886d88e8 100644 --- a/libobs-d3d11/d3d11-rebuild.cpp.hpp +++ b/libobs-d3d11/d3d11-rebuild.cpp.hpp @@ -34,10 +34,10 @@ void gs_index_buffer::Rebuild(ID3D11Device *dev) void gs_texture_2d::RebuildSharedTextureFallback() { - static const gs_color_format format = GS_BGRA; - static const DXGI_FORMAT dxgi_format_resource = ConvertGSTextureFormatResource(format); - static const DXGI_FORMAT dxgi_format_view = ConvertGSTextureFormatView(format); - static const DXGI_FORMAT dxgi_format_view_linear = ConvertGSTextureFormatViewLinear(format); + static const gs_color_format tex_format = GS_BGRA; + static const DXGI_FORMAT dxgi_format_resource = ConvertGSTextureFormatResource(tex_format); + static const DXGI_FORMAT dxgi_format_view = ConvertGSTextureFormatView(tex_format); + static const DXGI_FORMAT dxgi_format_view_linear = ConvertGSTextureFormatViewLinear(tex_format); td = {}; td.Width = 2; @@ -308,10 +308,10 @@ void gs_timer_range::Rebuild(ID3D11Device *dev) void gs_texture_3d::RebuildSharedTextureFallback() { - static const gs_color_format format = GS_BGRA; - static const DXGI_FORMAT dxgi_format_resource = ConvertGSTextureFormatResource(format); - static const DXGI_FORMAT dxgi_format_view = ConvertGSTextureFormatView(format); - static const DXGI_FORMAT dxgi_format_view_linear = ConvertGSTextureFormatViewLinear(format); + static const gs_color_format tex_format = GS_BGRA; + static const DXGI_FORMAT dxgi_format_resource = ConvertGSTextureFormatResource(tex_format); + static const DXGI_FORMAT dxgi_format_view = ConvertGSTextureFormatView(tex_format); + static const DXGI_FORMAT dxgi_format_view_linear = ConvertGSTextureFormatViewLinear(tex_format); td = {}; td.Width = 2; diff --git a/libobs-d3d11/d3d11-subsystem.cpp.hpp b/libobs-d3d11/d3d11-subsystem.cpp.hpp index baa03eee8e..5a35ffabad 100644 --- a/libobs-d3d11/d3d11-subsystem.cpp.hpp +++ b/libobs-d3d11/d3d11-subsystem.cpp.hpp @@ -1188,11 +1188,11 @@ gs_monitor_color_info gs_device::GetMonitorColorInfo(HMONITOR hMonitor) } } - ComPtr adapter; + ComPtr dxgi_adapter; ComPtr output; ComPtr output6; - for (UINT adapterIndex = 0; SUCCEEDED(factory1->EnumAdapters(adapterIndex, &adapter)); ++adapterIndex) { - for (UINT outputIndex = 0; SUCCEEDED(adapter->EnumOutputs(outputIndex, &output)); ++outputIndex) { + for (UINT adapterIndex = 0; SUCCEEDED(factory1->EnumAdapters(adapterIndex, &dxgi_adapter)); ++adapterIndex) { + for (UINT outputIndex = 0; SUCCEEDED(dxgi_adapter->EnumOutputs(outputIndex, &output)); ++outputIndex) { DXGI_OUTPUT_DESC1 desc1; if (SUCCEEDED(output->QueryInterface(&output6)) && SUCCEEDED(output6->GetDesc1(&desc1)) && (desc1.Monitor == hMonitor)) { diff --git a/libobs-d3d11/d3d11-texture2d.cpp.hpp b/libobs-d3d11/d3d11-texture2d.cpp.hpp index 522928dd2c..def26abc69 100644 --- a/libobs-d3d11/d3d11-texture2d.cpp.hpp +++ b/libobs-d3d11/d3d11-texture2d.cpp.hpp @@ -17,7 +17,7 @@ #include "libobs-d3d11/build/d3d11.pch.hpp" -void gs_texture_2d::InitSRD(std::vector &srd) +void gs_texture_2d::InitSRD(std::vector &subresource_data) { uint32_t rowSizeBytes = width * gs_get_format_bpp(format); uint32_t texSizeBytes = height * rowSizeBytes / 8; @@ -40,7 +40,7 @@ void gs_texture_2d::InitSRD(std::vector &srd) newSRD.pSysMem = data[curTex++].data(); newSRD.SysMemPitch = newRowSize; newSRD.SysMemSlicePitch = newTexSize; - srd.push_back(newSRD); + subresource_data.push_back(newSRD); newRowSize /= 2; newTexSize /= 4; @@ -48,7 +48,7 @@ void gs_texture_2d::InitSRD(std::vector &srd) } } -void gs_texture_2d::BackupTexture(const uint8_t *const *data) +void gs_texture_2d::BackupTexture(const uint8_t *const *plane_data) { uint32_t textures = type == GS_TEXTURE_CUBE ? 6 : 1; uint32_t bbp = gs_get_format_bpp(format); @@ -61,7 +61,7 @@ void gs_texture_2d::BackupTexture(const uint8_t *const *data) for (uint32_t lv = 0; lv < levels; lv++) { uint32_t i = levels * t + lv; - if (!data[i]) { + if (!plane_data[i]) { break; } @@ -69,7 +69,7 @@ void gs_texture_2d::BackupTexture(const uint8_t *const *data) std::vector &subData = this->data[i]; subData.resize(texSize); - memcpy(&subData[0], data[i], texSize); + memcpy(&subData[0], plane_data[i], texSize); if (w > 1) { w /= 2; @@ -97,7 +97,7 @@ void gs_texture_2d::GetSharedHandle(IDXGIResource *dxgi_res) } } -void gs_texture_2d::InitTexture(const uint8_t *const *data) +void gs_texture_2d::InitTexture(const uint8_t *const *plane_data) { HRESULT hr; @@ -130,12 +130,12 @@ void gs_texture_2d::InitTexture(const uint8_t *const *data) td.MiscFlags |= D3D11_RESOURCE_MISC_SHARED; } - if (data) { - BackupTexture(data); + if (plane_data) { + BackupTexture(plane_data); InitSRD(srd); } - hr = device->device->CreateTexture2D(&td, data ? srd.data() : NULL, texture.Assign()); + hr = device->device->CreateTexture2D(&td, plane_data ? srd.data() : NULL, texture.Assign()); if (FAILED(hr)) { throw HRError("Failed to create 2D texture", hr); } @@ -340,18 +340,18 @@ gs_texture_2d::gs_texture_2d(gs_device_t *device, uint32_t handle, bool ntHandle texture->GetDesc(&td); - const gs_color_format format = ConvertDXGITextureFormat(td.Format); + const gs_color_format tex_format = ConvertDXGITextureFormat(td.Format); this->type = GS_TEXTURE_2D; - this->format = format; + this->format = tex_format; this->levels = 1; this->device = device; this->width = td.Width; this->height = td.Height; - this->dxgiFormatResource = ConvertGSTextureFormatResource(format); - this->dxgiFormatView = ConvertGSTextureFormatView(format); - this->dxgiFormatViewLinear = ConvertGSTextureFormatViewLinear(format); + this->dxgiFormatResource = ConvertGSTextureFormatResource(tex_format); + this->dxgiFormatView = ConvertGSTextureFormatView(tex_format); + this->dxgiFormatViewLinear = ConvertGSTextureFormatViewLinear(tex_format); InitResourceView(); } @@ -363,18 +363,18 @@ gs_texture_2d::gs_texture_2d(gs_device_t *device, ID3D11Texture2D *obj) texture->GetDesc(&td); - const gs_color_format format = ConvertDXGITextureFormat(td.Format); + const gs_color_format tex_format = ConvertDXGITextureFormat(td.Format); this->type = GS_TEXTURE_2D; - this->format = format; + this->format = tex_format; this->levels = 1; this->device = device; this->width = td.Width; this->height = td.Height; - this->dxgiFormatResource = ConvertGSTextureFormatResource(format); - this->dxgiFormatView = ConvertGSTextureFormatView(format); - this->dxgiFormatViewLinear = ConvertGSTextureFormatViewLinear(format); + this->dxgiFormatResource = ConvertGSTextureFormatResource(tex_format); + this->dxgiFormatView = ConvertGSTextureFormatView(tex_format); + this->dxgiFormatViewLinear = ConvertGSTextureFormatViewLinear(tex_format); InitResourceView(); } diff --git a/libobs-d3d11/d3d11-texture3d.cpp.hpp b/libobs-d3d11/d3d11-texture3d.cpp.hpp index 21cc20cca8..ab0f1c9f23 100644 --- a/libobs-d3d11/d3d11-texture3d.cpp.hpp +++ b/libobs-d3d11/d3d11-texture3d.cpp.hpp @@ -17,7 +17,7 @@ #include "libobs-d3d11/build/d3d11.pch.hpp" -void gs_texture_3d::InitSRD(std::vector &srd) +void gs_texture_3d::InitSRD(std::vector &subresource_data) { uint32_t rowSizeBits = width * gs_get_format_bpp(format); uint32_t sliceSizeBytes = height * rowSizeBits / 8; @@ -35,14 +35,14 @@ void gs_texture_3d::InitSRD(std::vector &srd) newSRD.pSysMem = data[level].data(); newSRD.SysMemPitch = newRowSize; newSRD.SysMemSlicePitch = newSlizeSize; - srd.push_back(newSRD); + subresource_data.push_back(newSRD); newRowSize /= 2; newSlizeSize /= 4; } } -void gs_texture_3d::BackupTexture(const uint8_t *const *data) +void gs_texture_3d::BackupTexture(const uint8_t *const *plane_data) { this->data.resize(levels); @@ -52,7 +52,7 @@ void gs_texture_3d::BackupTexture(const uint8_t *const *data) const uint32_t bbp = gs_get_format_bpp(format); for (uint32_t i = 0; i < levels; i++) { - if (!data[i]) { + if (!plane_data[i]) { break; } @@ -60,7 +60,7 @@ void gs_texture_3d::BackupTexture(const uint8_t *const *data) this->data[i].resize(texSize); std::vector &subData = this->data[i]; - memcpy(&subData[0], data[i], texSize); + memcpy(&subData[0], plane_data[i], texSize); if (w > 1) { w /= 2; @@ -90,7 +90,7 @@ void gs_texture_3d::GetSharedHandle(IDXGIResource *dxgi_res) } } -void gs_texture_3d::InitTexture(const uint8_t *const *data) +void gs_texture_3d::InitTexture(const uint8_t *const *plane_data) { HRESULT hr; @@ -114,12 +114,12 @@ void gs_texture_3d::InitTexture(const uint8_t *const *data) td.MiscFlags |= D3D11_RESOURCE_MISC_SHARED; } - if (data) { - BackupTexture(data); + if (plane_data) { + BackupTexture(plane_data); InitSRD(srd); } - hr = device->device->CreateTexture3D(&td, data ? srd.data() : NULL, texture.Assign()); + hr = device->device->CreateTexture3D(&td, plane_data ? srd.data() : NULL, texture.Assign()); if (FAILED(hr)) { throw HRError("Failed to create 3D texture", hr); } @@ -217,19 +217,19 @@ gs_texture_3d::gs_texture_3d(gs_device_t *device, uint32_t handle) texture->GetDesc(&td); - const gs_color_format format = ConvertDXGITextureFormat(td.Format); + const gs_color_format tex_format = ConvertDXGITextureFormat(td.Format); this->type = GS_TEXTURE_3D; - this->format = format; + this->format = tex_format; this->levels = 1; this->device = device; this->width = td.Width; this->height = td.Height; this->depth = td.Depth; - this->dxgiFormatResource = ConvertGSTextureFormatResource(format); - this->dxgiFormatView = ConvertGSTextureFormatView(format); - this->dxgiFormatViewLinear = ConvertGSTextureFormatViewLinear(format); + this->dxgiFormatResource = ConvertGSTextureFormatResource(tex_format); + this->dxgiFormatView = ConvertGSTextureFormatView(tex_format); + this->dxgiFormatViewLinear = ConvertGSTextureFormatViewLinear(tex_format); InitResourceView(); } diff --git a/libobs-d3d11/d3d11-vertexbuffer.cpp.hpp b/libobs-d3d11/d3d11-vertexbuffer.cpp.hpp index 02ccb83d3e..5628633ad9 100644 --- a/libobs-d3d11/d3d11-vertexbuffer.cpp.hpp +++ b/libobs-d3d11/d3d11-vertexbuffer.cpp.hpp @@ -73,7 +73,7 @@ UINT gs_vertex_buffer::MakeBufferList(gs_vertex_shader *shader, ID3D11Buffer **b return numBuffers; } -void gs_vertex_buffer::InitBuffer(const size_t elementSize, const size_t numVerts, void *array, ID3D11Buffer **buffer) +void gs_vertex_buffer::InitBuffer(const size_t elementSize, const size_t num_verts, void *array, ID3D11Buffer **buffer) { D3D11_BUFFER_DESC bd; D3D11_SUBRESOURCE_DATA srd; @@ -85,7 +85,7 @@ void gs_vertex_buffer::InitBuffer(const size_t elementSize, const size_t numVert bd.Usage = dynamic ? D3D11_USAGE_DYNAMIC : D3D11_USAGE_DEFAULT; bd.CPUAccessFlags = dynamic ? D3D11_CPU_ACCESS_WRITE : 0; bd.BindFlags = D3D11_BIND_VERTEX_BUFFER; - bd.ByteWidth = UINT(elementSize * numVerts); + bd.ByteWidth = UINT(elementSize * num_verts); srd.pSysMem = array; hr = device->device->CreateBuffer(&bd, &srd, buffer); diff --git a/libobs-opengl/gl-shaderparser.c.h b/libobs-opengl/gl-shaderparser.c.h index 5e27ae53ad..2870629255 100644 --- a/libobs-opengl/gl-shaderparser.c.h +++ b/libobs-opengl/gl-shaderparser.c.h @@ -40,7 +40,7 @@ static inline size_t sp_getsampler(struct gl_shader_parser *glsp, struct cf_toke return i; } - return -1; + return (size_t)-1; } static inline int cmp_type(const char *name, const size_t name_len, const char *type, const size_t type_len) diff --git a/libobs-opengl/gl-windows.c.h b/libobs-opengl/gl-windows.c.h index f3d30ae3a9..1e1f9ab98d 100644 --- a/libobs-opengl/gl-windows.c.h +++ b/libobs-opengl/gl-windows.c.h @@ -384,6 +384,8 @@ static bool create_dummy_window(struct gl_platform *plat) static bool init_default_swap(struct gl_platform *plat, gs_device_t *device, int pixel_format, PIXELFORMATDESCRIPTOR *pfd) { + UNUSED_PARAMETER(device); + if (!gl_setpixelformat(plat->window.hdc, pixel_format, pfd)) return false; @@ -586,6 +588,9 @@ extern void gl_getclientsize(const struct gs_swap_chain *swap, uint32_t *width, EXPORT bool device_is_monitor_hdr(gs_device_t *device, void *monitor) { + UNUSED_PARAMETER(device); + UNUSED_PARAMETER(monitor); + return false; } diff --git a/libobs/CMakeLists.txt b/libobs/CMakeLists.txt index ee806f85a3..b2d03120b7 100644 --- a/libobs/CMakeLists.txt +++ b/libobs/CMakeLists.txt @@ -31,6 +31,20 @@ include(cmake/sources.cmake) set_target_properties(libobs-objects PROPERTIES POSITION_INDEPENDENT_CODE TRUE) target_sources(libobs-objects PRIVATE ${LIBOBS_SOURCES}) +# MSVC /W4 (#2626): uthash's HASH_* macros end in uthash_fatal -> exit(-1), +# whose non-returning path makes MSVC report C4702 "unreachable code" at the +# closing brace of every HASH_ADD/HASH_ITER use (obs.c.h, obs-data.c.h, +# obs-hotkey.c.h, ...). The C oracle already suppresses C4702 for the same +# macros in its own build script, so this follows the vendored-code exemption +# (#516) instead of editing uthash or sprinkling pragmas in first-party code. +# Every C target needs it: the ported groups are also compiled by the +# C-reference library, which has its own compile options. +# +# Do not name a crate here: ci/test_tier2_proof_inputs.py treats any crate name +# mentioned in a cmake or CMakeLists.txt file as a Tier 2 root. +foreach(target libobs-objects ${OBS_LIBOBS_C_TARGETS}) + target_compile_options(${target} PRIVATE $<$:/wd4702>) +endforeach() obs_libobs_add_c_sources(${LIBOBS_PORTED_SOURCES}) # MSVC warns about INFINITY (a standard library macro) in obs-audio-controls.c # (#870; was a pragma in the file). diff --git a/libobs/audio-monitoring/win32/wasapi-output.c.h b/libobs/audio-monitoring/win32/wasapi-output.c.h index e34f1dd2dd..c76345cbcc 100644 --- a/libobs/audio-monitoring/win32/wasapi-output.c.h +++ b/libobs/audio-monitoring/win32/wasapi-output.c.h @@ -426,7 +426,6 @@ void audio_monitor_reset(struct audio_monitor *monitor) ReleaseSRWLockExclusive(&monitor->playback_mutex); if (success) { - obs_source_t *source = monitor->source; audio_monitor_free(monitor); *monitor = new_monitor; audio_monitor_init_final(monitor); diff --git a/libobs/callback/proc.c.h b/libobs/callback/proc.c.h index accfe37081..86a0a7ef97 100644 --- a/libobs/callback/proc.c.h +++ b/libobs/callback/proc.c.h @@ -111,7 +111,10 @@ bool proc_handler_call(proc_handler_t *handler, const char *name, calldata_t *pa pthread_mutex_lock(&handler->mutex); struct proc_info *info = getproc(handler, name); - struct proc_info info_copy; + /* Copied under the lock only when `info` is set, and used only after the + * `!info` early return; MSVC cannot correlate the two: C4701 at /W4. + * Zero-initializing cannot be observed. */ + struct proc_info info_copy = {0}; if (info) info_copy = *info; pthread_mutex_unlock(&handler->mutex); diff --git a/libobs/graphics/libnsgif/gif-frame.c.h b/libobs/graphics/libnsgif/gif-frame.c.h index 39213bae66..bdc5d14be0 100644 --- a/libobs/graphics/libnsgif/gif-frame.c.h +++ b/libobs/graphics/libnsgif/gif-frame.c.h @@ -154,7 +154,10 @@ static nsgif_error nsgif_frame__decode_complex( nsgif_error ret = NSGIF_OK; uint32_t clip_x = nsgif_frame__clip(offset_x, width, canvas->width); uint32_t clip_y = nsgif_frame__clip(offset_y, height, canvas->height); - const uint8_t *uncompressed; + /* Set by lzw_decode() (through the pointer) before the first read, so + * this initializer is never observed; MSVC cannot see that lzw_decode + * writes it and reports C4701/C4703 at /W4. */ + const uint8_t *uncompressed = NULL; uint32_t available = 0; uint8_t step = 24; uint32_t skip = 0; diff --git a/libobs/obs-module.c.h b/libobs/obs-module.c.h index 8c172b5933..7df732cf07 100644 --- a/libobs/obs-module.c.h +++ b/libobs/obs-module.c.h @@ -521,13 +521,18 @@ static void load_all_callback(void *param, const struct obs_module_info2 *info) blog(LOG_DEBUG, "Failed to load module file '%s', incompatible version", info->bin_path); break; } - if (route & OBS_MODULE_LOAD_RULES_DISABLE) + if (route & OBS_MODULE_LOAD_RULES_DISABLE) { obs_create_disabled_module(&disabled_module, info->bin_path, info->data_path, (enum obs_module_load_state)state); - if ((route & OBS_MODULE_LOAD_RULES_CORE_CONTINUES) && obs_module_load_rules_is_core(info->type)) { - disabled_module->module_type = info->type; - blog(LOG_WARNING, "Core module '%s' could not be opened, continuing without it", info->name); - return; + /* CORE_CONTINUES is only returned together with DISABLE + * (obs_module_load_rules_open_route()), so this is the module + * that carries the type. Keeping the two in one branch also + * shows the compiler the variable is set before its use. */ + if ((route & OBS_MODULE_LOAD_RULES_CORE_CONTINUES) && obs_module_load_rules_is_core(info->type)) { + disabled_module->module_type = info->type; + blog(LOG_WARNING, "Core module '%s' could not be opened, continuing without it", info->name); + return; + } } if (route & OBS_MODULE_LOAD_RULES_FAIL) goto load_failure; @@ -537,11 +542,14 @@ static void load_all_callback(void *param, const struct obs_module_info2 *info) route = obs_module_load_rules_init_route(obs_init_module(module), &state); if (route & OBS_MODULE_LOAD_RULES_FREE) free_module(module); - if (route & OBS_MODULE_LOAD_RULES_DISABLE) + if (route & OBS_MODULE_LOAD_RULES_DISABLE) { obs_create_disabled_module(&disabled_module, info->bin_path, info->data_path, (enum obs_module_load_state)state); - if (route & OBS_MODULE_LOAD_RULES_KEEP_TYPE) - disabled_module->module_type = info->type; + /* KEEP_TYPE likewise comes only with DISABLE + * (obs_module_load_rules_init_route()). */ + if (route & OBS_MODULE_LOAD_RULES_KEEP_TYPE) + disabled_module->module_type = info->type; + } if (route & OBS_MODULE_LOAD_RULES_SET_TYPE) module->module_type = info->type; diff --git a/libobs/obs-output.c.h b/libobs/obs-output.c.h index 76c7d43f02..26457c85bb 100644 --- a/libobs/obs-output.c.h +++ b/libobs/obs-output.c.h @@ -1530,7 +1530,10 @@ static bool add_caption(struct obs_output *output, struct encoder_packet *out) struct encoder_packet backup = *out; sei_t sei; uint8_t *data = NULL; - size_t size; + /* Only set when the packet carries a caption; reading it without + * a caption is guarded below. Starting at zero silences MSVC's C4701 + * "potentially uninitialized" at /W4 without changing behavior. */ + size_t size = 0; long ref = 1; bool avc = false; bool hevc = false; diff --git a/libobs/obs-scene-item-audio-actions.c.h b/libobs/obs-scene-item-audio-actions.c.h index b2236ac267..b2519f53dd 100644 --- a/libobs/obs-scene-item-audio-actions.c.h +++ b/libobs/obs-scene-item-audio-actions.c.h @@ -49,7 +49,9 @@ void apply_scene_item_audio_actions(struct obs_scene_item *item, float *buf, uin bool apply_scene_item_volume(struct obs_scene_item *item, float *buf, uint64_t ts, size_t sample_rate) { bool actions_pending; - struct item_action action; + /* Set only when an action is pending, and read under the same guard: + * C4701 at /W4. Zero-initializing cannot be observed. */ + struct item_action action = {0}; pthread_mutex_lock(&item->actions_mutex); diff --git a/libobs/obs-scene.c.h b/libobs/obs-scene.c.h index f66902f1e5..b4ecd17eb1 100644 --- a/libobs/obs-scene.c.h +++ b/libobs/obs-scene.c.h @@ -18,7 +18,11 @@ #include "libobs/build/libobs.pch.h" -const struct obs_source_info group_info; +/* Forward declaration: the definition (with its initializer) is at + * the bottom of this file. `extern` keeps MSVC from reading this as a + * tentative definition and warning C4132 "const object should be + * initialized" at /W4. */ +extern const struct obs_source_info group_info; static void resize_group(obs_sceneitem_t *group, bool scene_resize); static void resize_scene(obs_scene_t *scene); diff --git a/libobs/obs-source.c.h b/libobs/obs-source.c.h index 09645efef6..a48ac63a2d 100644 --- a/libobs/obs-source.c.h +++ b/libobs/obs-source.c.h @@ -4903,7 +4903,10 @@ static void apply_audio_actions(obs_source_t *source, size_t channels, size_t sa * stay here. */ static void apply_audio_volume(obs_source_t *source, uint32_t mixers, size_t channels, size_t sample_rate) { - struct audio_action action; + /* Set only when an action is pending, and read under the same guard; + * MSVC's flow analysis cannot carry that across the branch: C4701 at + * /W4. Zero-initializing cannot be observed, the read is guarded. */ + struct audio_action action = {0}; bool actions_pending; float vol; diff --git a/libobs/obs-win-crash-handler.c.h b/libobs/obs-win-crash-handler.c.h index 00b70b5995..1d87bf45de 100644 --- a/libobs/obs-win-crash-handler.c.h +++ b/libobs/obs-win-crash-handler.c.h @@ -99,16 +99,20 @@ static inline void exception_handler_data_free(struct exception_handler_data *da FreeLibrary(data->dbghelp); } -static inline void *get_proc(HMODULE module, const char *func) -{ - return (void *)GetProcAddress(module, func); -} - -#define GET_DBGHELP_IMPORT(target, str) \ - do { \ - data->target = get_proc(data->dbghelp, str); \ - if (!data->target) \ - return false; \ +/* GetProcAddress returns a FARPROC and the typed members are function pointers: + * a cast between the two is C4152 at /W4. Copy the address through a union + * instead, the way LOAD_MODULE_SYMBOL (libobs/obs-module.c.h) does for + * os_dlsym. No code is generated for the copy. */ +#define GET_DBGHELP_IMPORT(target, str) \ + do { \ + union { \ + FARPROC proc; \ + __typeof__(data->target) fn; \ + } _sym; \ + _sym.proc = GetProcAddress(data->dbghelp, str); \ + data->target = _sym.fn; \ + if (!data->target) \ + return false; \ } while (false) static inline bool get_dbghelp_imports(struct exception_handler_data *data) @@ -295,7 +299,11 @@ static inline void get_module_name(struct exception_handler_data *data, struct m static inline bool walk_stack(struct exception_handler_data *data, HANDLE thread, struct stack_trace *trace) { struct module_info module_info = {0}; - DWORD64 func_offset; + /* sym_from_addr fills this through a pointer, so MSVC's flow analysis + * cannot see that the read below is guarded by its return value: C4701 + * at /W4. Starting it at zero costs nothing and cannot be observed, + * because it is only printed when that call succeeded. */ + DWORD64 func_offset = 0; char sym_name[256]; char *p; @@ -513,12 +521,10 @@ static LONG CALLBACK exception_handler(PEXCEPTION_POINTERS exception) inside_handler = true; handle_exception(&data, exception); + /* bcrash is OBS_NORETURN (libobs/util/base.h), so the cleanup, the + * inside_handler reset and the return that used to follow it were dead + * statements - C4702 at /W4. Nothing is leaked: the process is gone. */ bcrash("%s", data.str.array); - exception_handler_data_free(&data); - - inside_handler = false; - - return EXCEPTION_CONTINUE_SEARCH; } void initialize_crash_handler(void) diff --git a/libobs/obs-windows.c.h b/libobs/obs-windows.c.h index 560e200547..902a2d33ad 100644 --- a/libobs/obs-windows.c.h +++ b/libobs/obs-windows.c.h @@ -1115,14 +1115,29 @@ static void reset_win32_symbol_paths(void) if (!funcs_initialized) { HMODULE mod; + /* GetProcAddress yields a FARPROC and the members are function + * pointers: casting between them is C4152 at /W4. Copy each + * address through a union of that member's own type instead (as + * LOAD_MODULE_SYMBOL does), one union per member because the two + * prototypes differ and a shared union would be C4113. */ + union { + FARPROC proc; + __typeof__(sym_initialize_w) fn; + } sym_initialize; + union { + FARPROC proc; + __typeof__(sym_set_search_path_w) fn; + } sym_search_path; funcs_initialized = true; mod = LoadLibraryW(L"DbgHelp"); if (!mod) return; - sym_initialize_w = (void *)GetProcAddress(mod, "SymInitializeW"); - sym_set_search_path_w = (void *)GetProcAddress(mod, "SymSetSearchPathW"); + sym_initialize.proc = GetProcAddress(mod, "SymInitializeW"); + sym_initialize_w = sym_initialize.fn; + sym_search_path.proc = GetProcAddress(mod, "SymSetSearchPathW"); + sym_set_search_path_w = sym_search_path.fn; if (!sym_initialize_w || !sym_set_search_path_w) { FreeLibrary(mod); return; @@ -1308,9 +1323,17 @@ struct winrt_exports { void (*winrt_capture_thread_stop)(); }; +/* os_dlsym returns a void *, and assigning it straight to a function-pointer + * member is C4152 at /W4, so copy the address through a union, the way + * GRAPHICS_IMPORT (libobs/graphics/graphics-imports.c.h) does. */ #define WINRT_IMPORT(func) \ do { \ - exports->func = os_dlsym(module, #func); \ + union { \ + void *obj; \ + __typeof__(exports->func) fn; \ + } _sym; \ + _sym.obj = os_dlsym(module, #func); \ + exports->func = _sym.fn; \ if (!exports->func) { \ success = false; \ blog(LOG_ERROR, \ diff --git a/libobs/util/platform-windows.c.h b/libobs/util/platform-windows.c.h index f70e664d3d..62e224bebc 100644 --- a/libobs/util/platform-windows.c.h +++ b/libobs/util/platform-windows.c.h @@ -1010,7 +1010,16 @@ static inline void rtl_get_ver(struct win_version_info *ver) return; NTSTATUS(WINAPI * get_ver) - (RTL_OSVERSIONINFOEXW *) = (void *)GetProcAddress(ntdll, "RtlGetVersion"); + (RTL_OSVERSIONINFOEXW *); + /* GetProcAddress yields a FARPROC and `get_ver` is a function pointer: + * casting between them through a void * is C4152 at /W4. Copy the address + * through a union instead, the way LOAD_MODULE_SYMBOL does for os_dlsym. */ + union { + FARPROC proc; + __typeof__(get_ver) fn; + } sym; + sym.proc = GetProcAddress(ntdll, "RtlGetVersion"); + get_ver = sym.fn; if (!get_ver) { return; } diff --git a/libobs/util/windows/window-helpers.c.h b/libobs/util/windows/window-helpers.c.h index 2fd3a26cd5..96d1470d24 100644 --- a/libobs/util/windows/window-helpers.c.h +++ b/libobs/util/windows/window-helpers.c.h @@ -70,11 +70,11 @@ bool ms_check_window_property_setting(obs_properties_t *ppts, obs_property_t *p, } for (;;) { - const char *val = obs_property_list_item_string(p, i++); - if (!val) + const char *item_val = obs_property_list_item_string(p, i++); + if (!item_val) break; - if (strcmp(val, cur_val) == 0) { + if (strcmp(item_val, cur_val) == 0) { match = true; break; } diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 64697897c0..6bcba36c79 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -22,6 +22,13 @@ macro(check_obs_browser) message(FATAL_ERROR "Required submodule 'obs-browser' not available.") else() add_core_module(obs-browser) + # The submodule's C++ sources include libobs/graphics/vec{2,3,4}.h and + # libobs/util/profiler.h, whose nameless unions C4201 flags; the target is + # defined by the submodule's own CMakeLists, so the exemption is applied + # here (#2626). + obs_msvc_exempt_c4201(obs-browser) + # obs-browser-page-main.cpp's dead static function, C4505 (#2626). + obs_msvc_exempt_c4505(obs-browser-helper) endif() else() add_custom_target(obs-browser) @@ -34,6 +41,9 @@ macro(check_obs_websocket) message(FATAL_ERROR "Required submodule 'obs-websocket' not available.") else() add_core_module(obs-websocket) + # Same C4201 exemption as obs-browser: the target comes from the submodule + # (#2626). + obs_msvc_exempt_c4201(obs-websocket) endif() endmacro() diff --git a/plugins/aja-output-ui/AJAOutputUI.cpp.hpp b/plugins/aja-output-ui/AJAOutputUI.cpp.hpp index f527de0d9d..7f616f4b1d 100644 --- a/plugins/aja-output-ui/AJAOutputUI.cpp.hpp +++ b/plugins/aja-output-ui/AJAOutputUI.cpp.hpp @@ -27,9 +27,9 @@ void AJAOutputUI::SetupPropertiesView() } obs_data_t *settings = obs_data_create(); - OBSData data = load_settings(kProgramPropsFilename); - if (data) { - obs_data_apply(settings, data); + OBSData settings_data = load_settings(kProgramPropsFilename); + if (settings_data) { + obs_data_apply(settings, settings_data); } else { // apply default settings obs_data_set_default_int(settings, kUIPropOutput.id, static_cast(IOSelection::Invalid)); @@ -76,9 +76,9 @@ void AJAOutputUI::SetupPreviewPropertiesView() obs_data_t *settings = obs_data_create(); - OBSData data = load_settings(kPreviewPropsFilename); - if (data) { - obs_data_apply(settings, data); + OBSData settings_data = load_settings(kPreviewPropsFilename); + if (settings_data) { + obs_data_apply(settings, settings_data); } else { // apply default settings obs_data_set_default_int(settings, kUIPropOutput.id, static_cast(IOSelection::Invalid)); @@ -224,9 +224,9 @@ void AJAOutputUI::SetupMiscPropertiesView() } obs_data_t *settings = obs_data_create(); - OBSData data = load_settings(kMiscPropsFilename); - if (data) { - obs_data_apply(settings, data); + OBSData settings_data = load_settings(kMiscPropsFilename); + if (settings_data) { + obs_data_apply(settings, settings_data); } miscPropertiesView = new OBSPropertiesView(settings, this, (PropertiesReloadCallback)create_misc_props_ui, diff --git a/plugins/aja-output-ui/CMakeLists.txt b/plugins/aja-output-ui/CMakeLists.txt index a236793482..fec1747f9a 100644 --- a/plugins/aja-output-ui/CMakeLists.txt +++ b/plugins/aja-output-ui/CMakeLists.txt @@ -22,6 +22,7 @@ endif() add_library(aja-output-ui MODULE) add_library(OBS::aja-output-ui ALIAS aja-output-ui) +obs_msvc_exempt_c4201(aja-output-ui) target_sources(aja-output-ui PRIVATE build/aja-output-ui.core+.hpp.cpp aja-ui-main.h AJAOutputUI.h) diff --git a/plugins/aja-output-ui/aja-ui-main.cpp.hpp b/plugins/aja-output-ui/aja-ui-main.cpp.hpp index e2036b9a6b..94d4256309 100644 --- a/plugins/aja-output-ui/aja-ui-main.cpp.hpp +++ b/plugins/aja-output-ui/aja-ui-main.cpp.hpp @@ -165,9 +165,9 @@ void preview_output_toggle() } } -void populate_misc_device_list(obs_property_t *list, aja::CardManager *cardManager, NTV2DeviceID &firstDeviceID) +void populate_misc_device_list(obs_property_t *list, aja::CardManager *card_manager, NTV2DeviceID &firstDeviceID) { - for (const auto &iter : *cardManager) { + for (const auto &iter : *card_manager) { if (!iter.second) { continue; } @@ -202,11 +202,11 @@ bool on_misc_device_selected(void *data, obs_properties_t *props, obs_property_t if (!cardID || !cardID[0]) { return false; } - aja::CardManager *cardManager = (aja::CardManager *)data; - if (!cardManager) { + aja::CardManager *card_manager_local = (aja::CardManager *)data; + if (!card_manager_local) { return false; } - auto cardEntry = cardManager->GetCardEntry(cardID); + auto cardEntry = card_manager_local->GetCardEntry(cardID); if (!cardEntry) { return false; } @@ -267,11 +267,11 @@ bool on_multi_view_toggle(void *data, obs_properties_t *, obs_property_t *, obs_ if (!cardID || !cardID[0]) { return false; } - aja::CardManager *cardManager = (aja::CardManager *)data; - if (!cardManager) { + aja::CardManager *card_manager_local = (aja::CardManager *)data; + if (!card_manager_local) { return false; } - CNTV2Card *card = cardManager->GetCard(cardID); + CNTV2Card *card = card_manager_local->GetCard(cardID); if (!card) { return false; } diff --git a/plugins/coreaudio-encoder/CMakeLists.txt b/plugins/coreaudio-encoder/CMakeLists.txt index decf7a6fe0..540adcc247 100644 --- a/plugins/coreaudio-encoder/CMakeLists.txt +++ b/plugins/coreaudio-encoder/CMakeLists.txt @@ -9,6 +9,7 @@ endif() add_library(coreaudio-encoder MODULE) add_library(OBS::coreaudio-encoder ALIAS coreaudio-encoder) +obs_msvc_exempt_c4201(coreaudio-encoder) # SDK types and deleters belong to one host; the Windows imports/functions # must share a translation unit with the encoder that calls them. diff --git a/plugins/decklink-captions/decklink-captions.cpp.hpp b/plugins/decklink-captions/decklink-captions.cpp.hpp index 233b4014c4..7c9ab8930d 100644 --- a/plugins/decklink-captions/decklink-captions.cpp.hpp +++ b/plugins/decklink-captions/decklink-captions.cpp.hpp @@ -46,7 +46,8 @@ DecklinkCaptionsUI::DecklinkCaptionsUI(QWidget *parent) : QDialog(parent), ui(ne ui->source->blockSignals(true); ui->source->addItem(QStringLiteral("")); ui->source->setCurrentIndex(0); - obs_enum_sources([](void *data, obs_source_t *source) { return (*static_cast(data))(source); }, &cb); + obs_enum_sources([](void *cbData, obs_source_t *source) { return (*static_cast(cbData))(source); }, + &cb); ui->source->blockSignals(false); } @@ -60,12 +61,12 @@ void DecklinkCaptionsUI::on_source_currentIndexChanged(int) captions->start(); } -static void caption_callback(void * /* param */, obs_source_t * /* source */, const struct obs_source_cea_708 *captions) +static void caption_callback(void * /* param */, obs_source_t * /* source */, const struct obs_source_cea_708 *cea708) { obs_output *output = obs_frontend_get_streaming_output(); if (output) { if (obs_frontend_streaming_active() && obs_output_active(output)) { - obs_output_caption(output, captions); + obs_output_caption(output, cea708); } obs_output_release(output); } diff --git a/plugins/decklink-output-ui/CMakeLists.txt b/plugins/decklink-output-ui/CMakeLists.txt index c270c1be52..571ed0c57d 100644 --- a/plugins/decklink-output-ui/CMakeLists.txt +++ b/plugins/decklink-output-ui/CMakeLists.txt @@ -12,6 +12,7 @@ endif() add_library(decklink-output-ui MODULE) add_library(OBS::decklink-output-ui ALIAS decklink-output-ui) +obs_msvc_exempt_c4201(decklink-output-ui) if(NOT TARGET OBS::properties-view) add_subdirectory("${CMAKE_SOURCE_DIR}/shared/properties-view" "${CMAKE_BINARY_DIR}/shared/properties-view") diff --git a/plugins/decklink-output-ui/DecklinkOutputUI.cpp.hpp b/plugins/decklink-output-ui/DecklinkOutputUI.cpp.hpp index 65905cd439..b807697d91 100644 --- a/plugins/decklink-output-ui/DecklinkOutputUI.cpp.hpp +++ b/plugins/decklink-output-ui/DecklinkOutputUI.cpp.hpp @@ -28,9 +28,9 @@ void DecklinkOutputUI::SetupPropertiesView() obs_data_t *settings = obs_data_create(); - OBSData data = load_settings(); - if (data) { - obs_data_apply(settings, data); + OBSData settingsData = load_settings(); + if (settingsData) { + obs_data_apply(settings, settingsData); } propertiesView = new OBSPropertiesView(settings, "decklink_output", @@ -64,9 +64,9 @@ void DecklinkOutputUI::SetupPreviewPropertiesView() obs_data_t *settings = obs_data_create(); - OBSData data = load_preview_settings(); - if (data) { - obs_data_apply(settings, data); + OBSData previewSettingsData = load_preview_settings(); + if (previewSettingsData) { + obs_data_apply(settings, previewSettingsData); } previewPropertiesView = new OBSPropertiesView(settings, "decklink_output", diff --git a/plugins/decklink/CMakeLists.txt b/plugins/decklink/CMakeLists.txt index 95d3a556e5..1a01c48b12 100644 --- a/plugins/decklink/CMakeLists.txt +++ b/plugins/decklink/CMakeLists.txt @@ -7,6 +7,11 @@ endif() add_library(decklink MODULE) add_library(OBS::decklink ALIAS decklink) +obs_msvc_exempt_c4201(decklink) +# MSVC /W4 (#2626): FrameQueue pads its nodes to a cache line so producers and +# consumers do not share one (decklink-device-instance.hpp), so the padding +# C4324 reports there is the intent, not slack in a struct layout. +target_compile_options(decklink PRIVATE $<$:/wd4324>) add_library(decklink-sdk INTERFACE) add_library(Decklink::SDK ALIAS decklink-sdk) diff --git a/plugins/decklink/DecklinkOutput.cpp.hpp b/plugins/decklink/DecklinkOutput.cpp.hpp index 2be7e9dd60..8b90f81f53 100644 --- a/plugins/decklink/DecklinkOutput.cpp.hpp +++ b/plugins/decklink/DecklinkOutput.cpp.hpp @@ -94,10 +94,10 @@ void DeckLinkOutput::WriteAudio(audio_data *frames) instance->WriteAudio(frames); } -void DeckLinkOutput::SetSize(int width, int height) +void DeckLinkOutput::SetSize(int newWidth, int newHeight) { - this->width = width; - this->height = height; + this->width = newWidth; + this->height = newHeight; } int DeckLinkOutput::GetWidth() diff --git a/plugins/decklink/OBSVideoFrame.cpp.hpp b/plugins/decklink/OBSVideoFrame.cpp.hpp index 2d42b47bdd..02dee3178c 100644 --- a/plugins/decklink/OBSVideoFrame.cpp.hpp +++ b/plugins/decklink/OBSVideoFrame.cpp.hpp @@ -30,14 +30,14 @@ HRESULT OBSVideoFrame::SetTimecode(BMDTimecodeFormat format, IDeckLinkTimecode * HRESULT OBSVideoFrame::SetTimecodeFromComponents(BMDTimecodeFormat format, uint8_t hours, uint8_t minutes, uint8_t seconds, - uint8_t frames, BMDTimecodeFlags flags) + uint8_t frames, BMDTimecodeFlags timecodeFlags) { UNUSED_PARAMETER(format); UNUSED_PARAMETER(hours); UNUSED_PARAMETER(minutes); UNUSED_PARAMETER(seconds); UNUSED_PARAMETER(frames); - UNUSED_PARAMETER(flags); + UNUSED_PARAMETER(timecodeFlags); return 0; } diff --git a/plugins/decklink/decklink-device-instance.cpp.hpp b/plugins/decklink/decklink-device-instance.cpp.hpp index cbf2ff10a1..9ed9b5b4d6 100644 --- a/plugins/decklink/decklink-device-instance.cpp.hpp +++ b/plugins/decklink/decklink-device-instance.cpp.hpp @@ -227,7 +227,7 @@ void DeckLinkDeviceInstance::HandleVideoFrame(IDeckLinkVideoInputFrame *videoFra } } } - currentFrame.trc = trc; + currentFrame.trc = static_cast(trc); obs_source_output_video2(static_cast(decklink)->GetSource(), ¤tFrame); } @@ -580,12 +580,12 @@ bool DeckLinkDeviceInstance::StartOutput(DeckLinkDeviceMode *mode_) /* No conversion when create didn't find the device or mode: not HDR (#2144). */ const struct video_scale_info *conversion = obs_output_get_video_conversion(decklinkOutput->GetOutput()); const bool enable_hdr = source_hdr && conversion && conversion->colorspace == VIDEO_CS_2100_PQ; - BMDPixelFormat pixelFormat = enable_hdr ? bmdFormat10BitRGBXLE : bmdFormat8BitBGRA; + const BMDPixelFormat outputPixelFormat = enable_hdr ? bmdFormat10BitRGBXLE : bmdFormat8BitBGRA; const int64_t minimumPrerollFrames = std::max(device->GetMinimumPrerollFrames(), INT64_C(3)); for (int64_t i = 0; i < minimumPrerollFrames; ++i) { ComPtr decklinkOutputFrame; HRESULT result = output_->CreateVideoFrame(decklinkOutput->GetWidth(), decklinkOutput->GetHeight(), - rowSize, pixelFormat, bmdFrameFlagDefault, + rowSize, outputPixelFormat, bmdFrameFlagDefault, &decklinkOutputFrame); if (result != S_OK) { blog(LOG_ERROR, "failed to create video frame 0x%X", result); diff --git a/plugins/decklink/decklink-output.cpp.hpp b/plugins/decklink/decklink-output.cpp.hpp index 7973392c3e..cf91ca7dd2 100644 --- a/plugins/decklink/decklink-output.cpp.hpp +++ b/plugins/decklink/decklink-output.cpp.hpp @@ -222,10 +222,10 @@ static bool decklink_output_device_changed(obs_properties_t *props, obs_property struct obs_video_info ovi; if (obs_get_video_info(&ovi)) { - for (DeckLinkDeviceMode *mode : modes) { - if (mode->IsEqualFrameRate(ovi.fps_num, ovi.fps_den)) { - obs_property_list_add_int(modeList, mode->GetName().c_str(), - mode->GetId()); + for (DeckLinkDeviceMode *deviceMode : modes) { + if (deviceMode->IsEqualFrameRate(ovi.fps_num, ovi.fps_den)) { + obs_property_list_add_int(modeList, deviceMode->GetName().c_str(), + deviceMode->GetId()); } } } diff --git a/plugins/decklink/decklink-source.cpp.hpp b/plugins/decklink/decklink-source.cpp.hpp index 0666356715..dde2b868de 100644 --- a/plugins/decklink/decklink-source.cpp.hpp +++ b/plugins/decklink/decklink-source.cpp.hpp @@ -171,8 +171,8 @@ static bool decklink_device_changed(obs_properties_t *props, obs_property_t *lis const std::vector &modes = device->GetInputModes(); - for (DeckLinkDeviceMode *mode : modes) { - obs_property_list_add_int(modeList, mode->GetName().c_str(), mode->GetId()); + for (DeckLinkDeviceMode *deviceMode : modes) { + obs_property_list_add_int(modeList, deviceMode->GetName().c_str(), deviceMode->GetId()); } if (device->GetMaxChannel() >= 8) { diff --git a/plugins/frontend-tools/CMakeLists.txt b/plugins/frontend-tools/CMakeLists.txt index a50ddf3fd4..6b79be8848 100644 --- a/plugins/frontend-tools/CMakeLists.txt +++ b/plugins/frontend-tools/CMakeLists.txt @@ -13,6 +13,7 @@ endif() add_library(frontend-tools MODULE) add_library(OBS::frontend-tools ALIAS frontend-tools) +obs_msvc_exempt_c4201(frontend-tools) if(NOT TARGET OBS::properties-view) add_subdirectory("${CMAKE_SOURCE_DIR}/shared/properties-view" "${CMAKE_BINARY_DIR}/shared/properties-view") diff --git a/plugins/frontend-tools/captions-mssapi-stream.cpp.hpp b/plugins/frontend-tools/captions-mssapi-stream.cpp.hpp index 795fa30d63..3346ee7153 100644 --- a/plugins/frontend-tools/captions-mssapi-stream.cpp.hpp +++ b/plugins/frontend-tools/captions-mssapi-stream.cpp.hpp @@ -138,6 +138,7 @@ STDMETHODIMP CaptionStream::Read(void *data, ULONG bytes, ULONG *read_bytes) STDMETHODIMP CaptionStream::Write(const void *, ULONG bytes, ULONG *) { debugfunc("data, %lu, written_bytes", bytes); + UNUSED_PARAMETER(bytes); return STG_E_INVALIDFUNCTION; } @@ -163,6 +164,7 @@ STDMETHODIMP CaptionStream::Seek(LARGE_INTEGER move, DWORD origin, ULARGE_INTEGE STDMETHODIMP CaptionStream::SetSize(ULARGE_INTEGER new_size) { debugfunc("%llu", new_size); + UNUSED_PARAMETER(new_size); return STG_E_INVALIDFUNCTION; } @@ -201,6 +203,7 @@ STDMETHODIMP CaptionStream::CopyTo(IStream *stream, ULARGE_INTEGER bytes, ULARGE STDMETHODIMP CaptionStream::Commit(DWORD commit_flags) { debugfunc("%lx", commit_flags); + UNUSED_PARAMETER(commit_flags); /* TODO? */ return S_OK; } @@ -214,6 +217,9 @@ STDMETHODIMP CaptionStream::Revert(void) STDMETHODIMP CaptionStream::LockRegion(ULARGE_INTEGER offset, ULARGE_INTEGER size, DWORD type) { debugfunc("%llu, %llu, %ld", offset, size, type); + UNUSED_PARAMETER(offset); + UNUSED_PARAMETER(size); + UNUSED_PARAMETER(type); /* TODO? */ return STG_E_INVALIDFUNCTION; } @@ -221,6 +227,9 @@ STDMETHODIMP CaptionStream::LockRegion(ULARGE_INTEGER offset, ULARGE_INTEGER siz STDMETHODIMP CaptionStream::UnlockRegion(ULARGE_INTEGER offset, ULARGE_INTEGER size, DWORD type) { debugfunc("%llu, %llu, %ld", offset, size, type); + UNUSED_PARAMETER(offset); + UNUSED_PARAMETER(size); + UNUSED_PARAMETER(type); /* TODO? */ return STG_E_INVALIDFUNCTION; } @@ -347,18 +356,18 @@ STDMETHODIMP CaptionStream::GetBufferInfo(SPAUDIOBUFFERINFO *buf_info_) return S_OK; } -STDMETHODIMP CaptionStream::GetDefaultFormat(GUID *format, WAVEFORMATEX **co_mem_wfex_out) +STDMETHODIMP CaptionStream::GetDefaultFormat(GUID *format_guid, WAVEFORMATEX **co_mem_wfex_out) { debugfunc("format, co_mem_wfex_out"); - if (!format || !co_mem_wfex_out) { + if (!format_guid || !co_mem_wfex_out) { return E_POINTER; } - void *wfex = CoTaskMemAlloc(sizeof(format)); - memcpy(wfex, &format, sizeof(format)); + void *wfex = CoTaskMemAlloc(sizeof(format_guid)); + memcpy(wfex, &format_guid, sizeof(format_guid)); - *format = SPDFID_WaveFormatEx; + *format_guid = SPDFID_WaveFormatEx; *co_mem_wfex_out = (WAVEFORMATEX *)wfex; return S_OK; } diff --git a/plugins/frontend-tools/captions.cpp.hpp b/plugins/frontend-tools/captions.cpp.hpp index 649e48aaf1..791d2502c5 100644 --- a/plugins/frontend-tools/captions.cpp.hpp +++ b/plugins/frontend-tools/captions.cpp.hpp @@ -71,7 +71,8 @@ CaptionsDialog::CaptionsDialog(QWidget *parent) : QDialog(parent), ui(new Ui_Cap ui->source->blockSignals(true); ui->source->addItem(QStringLiteral("")); ui->source->setCurrentIndex(0); - obs_enum_sources([](void *data, obs_source_t *source) { return (*static_cast(data))(source); }, &cb); + obs_enum_sources([](void *cb_data, obs_source_t *source) { return (*static_cast(cb_data))(source); }, + &cb); ui->source->blockSignals(false); for (auto &ht : captions->handler_types) { @@ -96,13 +97,13 @@ CaptionsDialog::CaptionsDialog(QWidget *parent) : QDialog(parent), ui(new Ui_Cap bool set_language = false; ui->language->blockSignals(true); - for (int idx = 0; idx < (int)locales.size(); idx++) { - locale_info &locale = locales[idx]; + for (int locale_idx = 0; locale_idx < (int)locales.size(); locale_idx++) { + locale_info &locale = locales[locale_idx]; ui->language->addItem(locale.name->array, (int)locale.id); if (locale.id == captions->lang_id) { - ui->language->setCurrentIndex(idx); + ui->language->setCurrentIndex(locale_idx); set_language = true; } } @@ -239,8 +240,8 @@ void obs_captions::start() captions_handler *h = pair->second.create(caption_text, lang_name); handler.reset(h); - OBSSource s = OBSGetStrongRef(source); - obs_source_add_audio_capture_callback(s, audio_capture, nullptr); + OBSSource capture_source = OBSGetStrongRef(source); + obs_source_add_audio_capture_callback(capture_source, audio_capture, nullptr); } catch (std::string text) { QWidget *window = (QWidget *)obs_frontend_get_main_window(); diff --git a/plugins/nv-filters/nvidia-audiofx-filter.c.h b/plugins/nv-filters/nvidia-audiofx-filter.c.h index a53e43677f..1a7b69b1e0 100644 --- a/plugins/nv-filters/nvidia-audiofx-filter.c.h +++ b/plugins/nv-filters/nvidia-audiofx-filter.c.h @@ -362,13 +362,13 @@ static void *nvidia_audio_initialize(void *data) goto failure; } bool updated_string = ng->sdk_version >= MIN_ARM_AFX_SDK_VERSION; - NvAFX_Status err = NvAFX_GetU32(ng->handle[0], - updated_string ? NVAFX_PARAM_NUM_SAMPLES_PER_INPUT_FRAME - : NVAFX_PARAM_NUM_INPUT_SAMPLES_PER_FRAME, - &ng->num_samples_per_frame); - if (err != NVAFX_STATUS_SUCCESS) { + NvAFX_Status samples_err = NvAFX_GetU32(ng->handle[0], + updated_string ? NVAFX_PARAM_NUM_SAMPLES_PER_INPUT_FRAME + : NVAFX_PARAM_NUM_INPUT_SAMPLES_PER_FRAME, + &ng->num_samples_per_frame); + if (samples_err != NVAFX_STATUS_SUCCESS) { do_log(LOG_ERROR, "NvAFX_GetU32() failed to get the number of samples per frame, error %i", - err); + samples_err); goto failure; } if (ng->num_samples_per_frame != NVAFX_FRAME_SIZE) { @@ -832,6 +832,7 @@ static obs_properties_t *nvidia_audio_properties(void *data) S_METHOD_NVAFX_DEREVERB_DENOISER); obs_property_t *slider = obs_properties_add_float_slider(ppts, S_NVAFX_INTENSITY, TEXT_NVAFX_INTENSITY, 0.0f, 1.0f, 0.01f); + UNUSED_PARAMETER(slider); obs_properties_add_bool(ppts, S_NVAFX_VAD, TEXT_NVAFX_VAD); obs_property_set_modified_callback2(method, nvidia_audio_method_modified, ng); diff --git a/plugins/nv-filters/nvidia-videofx-filter.c.h b/plugins/nv-filters/nvidia-videofx-filter.c.h index 1f531ef515..c1c8f867e3 100644 --- a/plugins/nv-filters/nvidia-videofx-filter.c.h +++ b/plugins/nv-filters/nvidia-videofx-filter.c.h @@ -379,6 +379,8 @@ static void nvvfx_filter_reset(void *data, calldata_t *calldata) struct nvvfx_data *filter = (struct nvvfx_data *)data; NvCV_Status vfxErr; + UNUSED_PARAMETER(calldata); + os_atomic_set_bool(&filter->processing_stop, true); // [A] first destroy if (filter->handle) { @@ -870,6 +872,7 @@ static void nvvfx_filter_render(void *data, gs_effect_t *effect, bool has_blur) const uint32_t target_flags = obs_source_get_output_flags(target); const uint32_t parent_flags = obs_source_get_output_flags(parent); + UNUSED_PARAMETER(parent_flags); bool custom_draw = (target_flags & OBS_SOURCE_CUSTOM_DRAW) != 0; bool async = (target_flags & OBS_SOURCE_ASYNC) != 0; @@ -1048,6 +1051,7 @@ static obs_properties_t *nvvfx_filter_properties(void *data) if (filter->filter_id != S_FX_AIGS) { obs_property_t *strength = obs_properties_add_float_slider(props, S_STRENGTH, TEXT_MODE_BLUR_STRENGTH, 0, 1, 0.05); + UNUSED_PARAMETER(strength); } else { obs_property_t *mode = obs_properties_add_list(props, S_MODE, TEXT_MODE, OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); @@ -1057,6 +1061,7 @@ static obs_properties_t *nvvfx_filter_properties(void *data) obs_property_list_add_int(mode, TEXT_MODE_PERF_CHAIR, S_MODE_PERF_CHAIR); obs_property_t *threshold = obs_properties_add_float_slider(props, S_THRESHOLDFX, TEXT_MODE_THRESHOLD, 0, 1, 0.05); + UNUSED_PARAMETER(threshold); obs_property_t *partial = obs_properties_add_int_slider(props, S_PROCESSING, TEXT_PROCESSING, 1, 4, 1); obs_property_set_long_description(partial, TEXT_PROCESSING_HINT); } diff --git a/plugins/obs-browser b/plugins/obs-browser index 434cc38501..463e16b468 160000 --- a/plugins/obs-browser +++ b/plugins/obs-browser @@ -1 +1 @@ -Subproject commit 434cc3850178072ba41a49582b7538852315aca4 +Subproject commit 463e16b468ba607dfea2cc8bfcc1a0204b441ed3 diff --git a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c.h b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c.h index 8e55b8218b..457217bb10 100644 --- a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c.h +++ b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c.h @@ -661,7 +661,10 @@ static void *ffmpeg_mux_io_thread(void *data) // ffmpeg, then we flush the chunk. next_seek_position is the actual // offset we should seek to when we write the chunk. uint64_t current_seek_position = 0; - uint64_t next_seek_position; + // want_seek is only raised next to the assignment below, so the read in + // the write path is always dominated by it; cl.exe cannot see that across + // the chunk-flush branch, so the declaration carries the zero (#2626). + uint64_t next_seek_position = 0; for (;;) { // Wait for ffmpeg to write data to the buffer diff --git a/plugins/obs-ffmpeg/obs-amf-test/obs-amf-test.cpp.hpp b/plugins/obs-ffmpeg/obs-amf-test/obs-amf-test.cpp.hpp index 45cf3498fa..0e2a6d1422 100644 --- a/plugins/obs-ffmpeg/obs-amf-test/obs-amf-test.cpp.hpp +++ b/plugins/obs-ffmpeg/obs-amf-test/obs-amf-test.cpp.hpp @@ -151,8 +151,8 @@ try { while (get_adapter_caps(factory, idx++)) ; - for (auto &[idx, caps] : adapter_info) { - printf("[%u]\n", idx); + for (auto &[caps_index, caps] : adapter_info) { + printf("[%u]\n", caps_index); printf("is_amd=%s\n", caps.is_amd ? "true" : "false"); printf("supports_avc=%s\n", caps.supports_avc ? "true" : "false"); printf("supports_hevc=%s\n", caps.supports_hevc ? "true" : "false"); diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-formats.h b/plugins/obs-ffmpeg/obs-ffmpeg-formats.h index 89263d4199..e73183c643 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-formats.h +++ b/plugins/obs-ffmpeg/obs-ffmpeg-formats.h @@ -112,7 +112,4 @@ static inline enum audio_format convert_ffmpeg_sample_format(enum AVSampleFormat default: return AUDIO_FORMAT_16BIT; } - - /* shouldn't get here */ - return AUDIO_FORMAT_16BIT; } diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c.h b/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c.h index 39520afec5..cd783215f0 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c.h +++ b/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c.h @@ -1131,7 +1131,7 @@ static void ffmpeg_mpegts_stop_internal(void *data, uint64_t ts, bool signal) cmd->ts = ts; bool have_to_join = false; - pthread_t to_join; + pthread_t to_join = {0}; os_atomic_set_bool(&stream->abort_connect, true); diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-srt.h b/plugins/obs-ffmpeg/obs-ffmpeg-srt.h index 74fcaa4d58..ecb9af2793 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-srt.h +++ b/plugins/obs-ffmpeg/obs-ffmpeg-srt.h @@ -426,7 +426,10 @@ static int libsrt_set_options_pre(URLContext *h, SRTSOCKET fd) if (s->linger >= 0) { struct linger lin; - lin.l_linger = s->linger; + /* struct linger::l_linger is u_short on Windows; the value is + * only used when l_onoff is set, and the cast keeps the existing + * (already truncating) assignment explicit. */ + lin.l_linger = (u_short)s->linger; lin.l_onoff = lin.l_linger > 0 ? 1 : 0; if (libsrt_setsockopt(h, fd, SRTO_LINGER, "SRTO_LINGER", &lin, sizeof(lin)) < 0) { s->last_error.srt_error_code = srt_getlasterror(NULL); @@ -504,7 +507,8 @@ static int libsrt_setup(URLContext *h, const char *uri) return AVERROR(EIO); } la.sin_family = AF_INET; - la.sin_port = htons(port); + /* port is bounded to [1, 65535] by the check after av_url_split */ + la.sin_port = htons((u_short)port); inet_pton(AF_INET, s->localip, &la.sin_addr.s_addr); } diff --git a/plugins/obs-ffmpeg/texture-amf.cpp.hpp b/plugins/obs-ffmpeg/texture-amf.cpp.hpp index c3e8c3b3ff..00d36becd7 100644 --- a/plugins/obs-ffmpeg/texture-amf.cpp.hpp +++ b/plugins/obs-ffmpeg/texture-amf.cpp.hpp @@ -467,13 +467,13 @@ static inline int get_preset(amf_base *enc, const char *preset) static inline void refresh_throughput_caps(amf_base *enc, const char *&preset) { AMF_RESULT res = AMF_OK; - AMFCapsPtr caps; + AMFCapsPtr amf_caps; set_opt(QUALITY_PRESET, get_preset(enc, preset)); - res = enc->amf_encoder->GetCaps(&caps); + res = enc->amf_encoder->GetCaps(&amf_caps); if (res == AMF_OK) { - caps->GetProperty(get_opt_name(CAP_MAX_THROUGHPUT), &enc->max_throughput); - caps->GetProperty(get_opt_name(CAP_REQUESTED_THROUGHPUT), &enc->requested_throughput); + amf_caps->GetProperty(get_opt_name(CAP_MAX_THROUGHPUT), &enc->max_throughput); + amf_caps->GetProperty(get_opt_name(CAP_REQUESTED_THROUGHPUT), &enc->requested_throughput); } } @@ -542,7 +542,7 @@ static void convert_to_encoder_packet(amf_base *enc, AMFDataPtr &data, encoder_p enc->packet_data = AMFBufferPtr(data); data->GetProperty(L"PTS", &packet->pts); - const wchar_t *get_output_type; + const wchar_t *get_output_type = NULL; switch (enc->codec) { case amf_codec_type::AVC: get_output_type = AMF_VIDEO_ENCODER_OUTPUT_DATA_TYPE; @@ -653,6 +653,8 @@ static void roi_cb(void *param, obs_encoder_roi *roi) static void create_roi(amf_base *enc, AMFSurface *amf_surf) { + UNUSED_PARAMETER(amf_surf); + uint32_t mb_size = 16; /* H.264 is always 16x16 */ if (enc->codec == amf_codec_type::HEVC || enc->codec == amf_codec_type::AV1) { mb_size = 64; /* AMF HEVC & AV1 use 64x64 blocks */ @@ -663,9 +665,10 @@ static void create_roi(amf_base *enc, AMFSurface *amf_surf) if (!enc->roi_map) { AMFContext1Ptr context1(enc->amf_context); - AMF_RESULT res = context1->AllocSurfaceEx(AMF_MEMORY_HOST, AMF_SURFACE_GRAY32, mb_width, mb_height, - AMF_SURFACE_USAGE_DEFAULT | AMF_SURFACE_USAGE_LINEAR, - AMF_MEMORY_CPU_DEFAULT, &enc->roi_map); + AMF_RESULT res = context1->AllocSurfaceEx( + AMF_MEMORY_HOST, AMF_SURFACE_GRAY32, mb_width, mb_height, + (AMF_SURFACE_USAGE)(AMF_SURFACE_USAGE_DEFAULT | AMF_SURFACE_USAGE_LINEAR), + (AMF_MEMORY_CPU_ACCESS)(AMF_MEMORY_CPU_DEFAULT), &enc->roi_map); if (res != AMF_OK) { warn("Failed allocating surface for ROI map!"); @@ -832,7 +835,6 @@ try { throw amf_error("CreateSurfaceFromDX11Native failed", res); } - int64_t last_ts = convert_to_amf_ts(enc, pts - 1); int64_t cur_ts = convert_to_amf_ts(enc, pts); amf_surf->SetPts(cur_ts); @@ -937,7 +939,6 @@ try { throw amf_error("CreateSurfaceFromHostNative failed", res); } - int64_t last_ts = convert_to_amf_ts(enc, frame->pts - 1); int64_t cur_ts = convert_to_amf_ts(enc, frame->pts); amf_surf->SetPts(cur_ts); @@ -1308,6 +1309,8 @@ static const char *amf_avc_get_name(void *) static inline int get_avc_preset(amf_base *enc, const char *preset) { + UNUSED_PARAMETER(enc); + if (astrcmpi(preset, "quality") == 0) { return AMF_VIDEO_ENCODER_QUALITY_PRESET_QUALITY; } else if (astrcmpi(preset, "speed") == 0) { @@ -1649,13 +1652,13 @@ static void amf_avc_create_internal(amf_base *enc, obs_data_t *settings) throw "Failed to create encoder"; } - AMFCapsPtr caps; - res = enc->amf_encoder->GetCaps(&caps); + AMFCapsPtr amf_caps; + res = enc->amf_encoder->GetCaps(&amf_caps); if (res == AMF_OK) { - caps->GetProperty(AMF_VIDEO_ENCODER_CAP_BFRAMES, &enc->bframes_supported); - caps->GetProperty(AMF_VIDEO_ENCODER_CAP_MAX_THROUGHPUT, &enc->max_throughput); - caps->GetProperty(AMF_VIDEO_ENCODER_CAP_REQUESTED_THROUGHPUT, &enc->requested_throughput); - caps->GetProperty(AMF_VIDEO_ENCODER_CAP_ROI, &enc->roi_supported); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_CAP_BFRAMES, &enc->bframes_supported); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_CAP_MAX_THROUGHPUT, &enc->max_throughput); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_CAP_REQUESTED_THROUGHPUT, &enc->requested_throughput); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_CAP_ROI, &enc->roi_supported); } const char *preset = obs_data_get_string(settings, "preset"); @@ -1808,6 +1811,8 @@ static const char *amf_hevc_get_name(void *) static inline int get_hevc_preset(amf_base *enc, const char *preset) { + UNUSED_PARAMETER(enc); + if (astrcmpi(preset, "balanced") == 0) { return AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_BALANCED; } else if (astrcmpi(preset, "speed") == 0) { @@ -2040,12 +2045,12 @@ static void amf_hevc_create_internal(amf_base *enc, obs_data_t *settings) throw "Failed to create encoder"; } - AMFCapsPtr caps; - res = enc->amf_encoder->GetCaps(&caps); + AMFCapsPtr amf_caps; + res = enc->amf_encoder->GetCaps(&amf_caps); if (res == AMF_OK) { - caps->GetProperty(AMF_VIDEO_ENCODER_HEVC_CAP_MAX_THROUGHPUT, &enc->max_throughput); - caps->GetProperty(AMF_VIDEO_ENCODER_HEVC_CAP_REQUESTED_THROUGHPUT, &enc->requested_throughput); - caps->GetProperty(AMF_VIDEO_ENCODER_HEVC_CAP_ROI, &enc->roi_supported); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_HEVC_CAP_MAX_THROUGHPUT, &enc->max_throughput); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_HEVC_CAP_REQUESTED_THROUGHPUT, &enc->requested_throughput); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_HEVC_CAP_ROI, &enc->roi_supported); } const bool is10bit = enc->amf_format == AMF_SURFACE_P010; @@ -2084,8 +2089,8 @@ static void amf_hevc_create_internal(amf_base *enc, obs_data_t *settings) md->whitePoint[1] = amf_hdr_primary(329, 1000); md->minMasteringLuminance = 0; md->maxMasteringLuminance = amf_make_lum(hdr_nominal_peak_level); - md->maxContentLightLevel = hdr_nominal_peak_level; - md->maxFrameAverageLightLevel = hdr_nominal_peak_level; + md->maxContentLightLevel = (amf_uint16)hdr_nominal_peak_level; + md->maxFrameAverageLightLevel = (amf_uint16)hdr_nominal_peak_level; set_hevc_property(enc, INPUT_HDR_METADATA, buf); } @@ -2219,6 +2224,8 @@ static const char *amf_av1_get_name(void *) static inline int get_av1_preset(amf_base *enc, const char *preset) { + UNUSED_PARAMETER(enc); + if (astrcmpi(preset, "highquality") == 0) { return AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_HIGH_QUALITY; } else if (astrcmpi(preset, "quality") == 0) { @@ -2467,12 +2474,12 @@ static void amf_av1_create_internal(amf_base *enc, obs_data_t *settings) throw "Failed to create encoder"; } - AMFCapsPtr caps; - AMF_RESULT res = enc->amf_encoder->GetCaps(&caps); + AMFCapsPtr amf_caps; + AMF_RESULT res = enc->amf_encoder->GetCaps(&amf_caps); if (res == AMF_OK) { - caps->GetProperty(AMF_VIDEO_ENCODER_AV1_CAP_BFRAMES, &enc->bframes_supported); - caps->GetProperty(AMF_VIDEO_ENCODER_AV1_CAP_MAX_THROUGHPUT, &enc->max_throughput); - caps->GetProperty(AMF_VIDEO_ENCODER_AV1_CAP_REQUESTED_THROUGHPUT, &enc->requested_throughput); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_AV1_CAP_BFRAMES, &enc->bframes_supported); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_AV1_CAP_MAX_THROUGHPUT, &enc->max_throughput); + amf_caps->GetProperty(AMF_VIDEO_ENCODER_AV1_CAP_REQUESTED_THROUGHPUT, &enc->requested_throughput); /* For some reason there's no specific CAP for AV1, but should always be supported */ enc->roi_supported = true; } diff --git a/plugins/obs-filters/cube-lut.c.h b/plugins/obs-filters/cube-lut.c.h index ed22fa4683..ee34e03578 100644 --- a/plugins/obs-filters/cube-lut.c.h +++ b/plugins/obs-filters/cube-lut.c.h @@ -80,7 +80,7 @@ void *load_cube_file(const char *const path, uint32_t *const width, struct vec3 FILE *const file = os_fopen(path, "rb"); if (file) { - float red, green, blue; + float red = 0.0f, green = 0.0f, blue = 0.0f; unsigned width_1d = 0; unsigned width_3d = 0; diff --git a/plugins/obs-nvenc/nvenc-d3d11.c.h b/plugins/obs-nvenc/nvenc-d3d11.c.h index 158e8f4af4..7bedc61292 100644 --- a/plugins/obs-nvenc/nvenc-d3d11.c.h +++ b/plugins/obs-nvenc/nvenc-d3d11.c.h @@ -23,6 +23,8 @@ typedef HRESULT(WINAPI *CREATEDXGIFACTORY1PROC)(REFIID, void **); bool d3d11_init(struct nvenc_data *enc, obs_data_t *settings) { + UNUSED_PARAMETER(settings); + HMODULE dxgi = get_lib(enc, "DXGI.dll"); HMODULE d3d11 = get_lib(enc, "D3D11.dll"); CREATEDXGIFACTORY1PROC create_dxgi; diff --git a/plugins/obs-nvenc/nvenc.c.h b/plugins/obs-nvenc/nvenc.c.h index 5db7dfd882..7703f860f1 100644 --- a/plugins/obs-nvenc/nvenc.c.h +++ b/plugins/obs-nvenc/nvenc.c.h @@ -306,7 +306,7 @@ static bool init_encoder_base(struct nvenc_data *enc, obs_data_t *settings) * checkbox and the Enhanced Broadcasting override both write the key. * When the key is absent, the preset may still enable lookahead. */ const bool lookahead_explicit = enc->props.data && obs_data_has_user_value(enc->props.data, "lookahead"); - const bool use_profile_lookahead = config->rcParams.enableLookahead; + const bool use_profile_lookahead = config->rcParams.enableLookahead != 0; bool lookahead = nv_get_cap(enc, NV_ENC_CAPS_SUPPORT_LOOKAHEAD) && nvenc_lookahead_enabled(use_profile_lookahead, lookahead_explicit, enc->props.lookahead); diff --git a/plugins/obs-nvenc/obs-nvenc-test/obs-nvenc-test.cpp.hpp b/plugins/obs-nvenc/obs-nvenc-test/obs-nvenc-test.cpp.hpp index 2469848582..58ee84fca0 100644 --- a/plugins/obs-nvenc/obs-nvenc-test/obs-nvenc-test.cpp.hpp +++ b/plugins/obs-nvenc/obs-nvenc-test/obs-nvenc-test.cpp.hpp @@ -377,11 +377,11 @@ static bool get_adapter_caps(int adapter_idx, codec_caps_map &caps, device_info preset_config.version = NV_ENC_PRESET_CONFIG_VER; preset_config.presetCfg.version = NV_ENC_CONFIG_VER; - NVENCSTATUS res = nv.nvEncGetEncodePresetConfigEx(nvSession.ptr, *guid, NV_ENC_PRESET_P7_GUID, - NV_ENC_TUNING_INFO_ULTRA_HIGH_QUALITY, - &preset_config); + NVENCSTATUS preset_status = nv.nvEncGetEncodePresetConfigEx(nvSession.ptr, *guid, NV_ENC_PRESET_P7_GUID, + NV_ENC_TUNING_INFO_ULTRA_HIGH_QUALITY, + &preset_config); - device_info.caps[codec_name]["uhq"] = res == NV_ENC_SUCCESS ? 1 : 0; + device_info.caps[codec_name]["uhq"] = preset_status == NV_ENC_SUCCESS ? 1 : 0; caps[codec_name]["uhq"] = std::max(device_info.caps[codec_name]["uhq"], caps[codec_name]["uhq"]); #endif } diff --git a/plugins/obs-outputs/CMakeLists.txt b/plugins/obs-outputs/CMakeLists.txt index 36d28e381f..7f11fd4da0 100644 --- a/plugins/obs-outputs/CMakeLists.txt +++ b/plugins/obs-outputs/CMakeLists.txt @@ -98,7 +98,14 @@ target_include_directories( # Vendored librtmp (C89 code that casts away const throughout) is not ported # or edited here; -Wcast-qual, -Wshadow and -Wpedantic (its __FUNCTION__ use; -# obs-rust/obs-studio#516, #2623) cover our own sources. +# obs-rust/obs-studio#516, #2623) cover our own sources. The same exemption +# covers the MSVC /W4-only classes librtmp trips (#2626): C4244 the +# `MD5_u32plus` state shifted down into its `unsigned char` digest in md5.c, +# C4245 an int stored in SOCKET/uint8_t, C4456 its shadowed loop counter `i`, +# C4706 its `while ((s = ...))` assignment conditions, and C4702 the tail it +# leaves unreachable after its own error exits. These are per-source options: the +# Visual Studio generator does honour them, which the 2026-10-28 app-lane runs +# on this branch show (the C4245/C4456/C4706 findings stop being reported). set_source_files_properties( librtmp/amf.c librtmp/cencode.c @@ -109,7 +116,7 @@ set_source_files_properties( librtmp/rtmp.c PROPERTIES COMPILE_OPTIONS - "$<$:-Wno-cast-qual;-Wno-shadow;-Wno-pedantic;-Wno-missing-prototypes;-Wno-strict-prototypes>" + "$<$:-Wno-cast-qual;-Wno-shadow;-Wno-pedantic;-Wno-missing-prototypes;-Wno-strict-prototypes>;$<$:/wd4244;/wd4245;/wd4456;/wd4702;/wd4706>" ) target_compile_options( diff --git a/plugins/obs-outputs/mp4-mux.c.h b/plugins/obs-outputs/mp4-mux.c.h index bd7105c0fd..3590d1be7c 100644 --- a/plugins/obs-outputs/mp4-mux.c.h +++ b/plugins/obs-outputs/mp4-mux.c.h @@ -592,7 +592,7 @@ static inline void mp4_write_visual_sample_entry(struct mp4_mux *mux, obs_encode s_write(s, compressor_name, sizeof(compressor_name)); // compressorname s_wb16(s, 0x0018); // depth - s_wb16(s, -1); // pre_defined + s_wb16(s, 0xFFFF); // pre_defined } /// 12.1.6 Content light level @@ -894,7 +894,7 @@ static inline void mp4_write_audio_sample_entry(struct mp4_mux *mux, struct mp4_ s_wb32(s, is_pcm ? track->sample_size : 0); // constBytesPerAudioPacket s_wb32(s, is_pcm ? 1 : 0); // constLPCMFramesPerAudioPacket } else { - s_wb16(s, channels); // channelcount + s_wb16(s, (uint16_t)channels); // channelcount /* OBS FLAC is currently always 16-bit, ALAC always 24, this may change in the future and should be * handled differently then. @@ -1558,7 +1558,7 @@ static size_t mp4_write_sgpd_aac(struct mp4_mux *mux) s_wb32(s, 1); // entry_count // AudioRollRecoveryEntry - s_wb16(s, -1); // roll_distance + s_wb16(s, 0xFFFF); // roll_distance return write_box_size(s, start); } @@ -2908,7 +2908,10 @@ void mp4_mux_destroy(struct mp4_mux *mux) bool mp4_mux_submit_packet(struct mp4_mux *mux, struct encoder_packet *pkt) { struct mp4_track *track = NULL; - struct encoder_packet parsed_packet; + /* Every branch below fills this except one: a video packet whose track + * codec matches no parse arm. Zero-init keeps that path well defined + * (MSVC reports C4701 at /W4 because it cannot prove a branch ran). */ + struct encoder_packet parsed_packet = {0}; enum obs_encoder_type type = pkt->type; bool fragment_ready = mux->next_frag_pts > 0; diff --git a/plugins/obs-outputs/net-if-host-windows.c.h b/plugins/obs-outputs/net-if-host-windows.c.h index 8e47f4c5d9..3358a847d0 100644 --- a/plugins/obs-outputs/net-if-host-windows.c.h +++ b/plugins/obs-outputs/net-if-host-windows.c.h @@ -20,6 +20,8 @@ void netif_host_addr_to_string(char *dest, struct sockaddr_storage *byte_address bool netif_host_str_to_addr(struct sockaddr_storage *out, int *addr_len, const char *addr, bool ipv6) { + UNUSED_PARAMETER(ipv6); + int ret = WSAStringToAddressA((LPSTR)addr, out->ss_family, NULL, (LPSOCKADDR)out, addr_len); if (ret == SOCKET_ERROR) warn("Could not parse address, error code: %d", GetLastError()); diff --git a/plugins/obs-outputs/rtmp-av1.c.h b/plugins/obs-outputs/rtmp-av1.c.h index 5878e8166a..3f2dd9c03c 100644 --- a/plugins/obs-outputs/rtmp-av1.c.h +++ b/plugins/obs-outputs/rtmp-av1.c.h @@ -250,18 +250,18 @@ static int parse_color_config(AV1SequenceParameters *seq_params, Av1GetBitContex if (seq_params->profile == FF_PROFILE_AV1_PROFESSIONAL && high_bitdepth) twelve_bit = av1_get_bits(gb, 1); - seq_params->bitdepth = 8 + (high_bitdepth * 2) + (twelve_bit * 2); + seq_params->bitdepth = (uint8_t)(8 + (high_bitdepth * 2) + (twelve_bit * 2)); if (seq_params->profile == FF_PROFILE_AV1_HIGH) seq_params->monochrome = 0; else - seq_params->monochrome = av1_get_bits(gb, 1); + seq_params->monochrome = (uint8_t)av1_get_bits(gb, 1); - seq_params->color_description_present_flag = av1_get_bits(gb, 1); + seq_params->color_description_present_flag = (uint8_t)av1_get_bits(gb, 1); if (seq_params->color_description_present_flag) { - seq_params->color_primaries = av1_get_bits(gb, 8); - seq_params->transfer_characteristics = av1_get_bits(gb, 8); - seq_params->matrix_coefficients = av1_get_bits(gb, 8); + seq_params->color_primaries = (uint8_t)av1_get_bits(gb, 8); + seq_params->transfer_characteristics = (uint8_t)av1_get_bits(gb, 8); + seq_params->matrix_coefficients = (uint8_t)av1_get_bits(gb, 8); } else { seq_params->color_primaries = 2; seq_params->transfer_characteristics = 2; @@ -269,7 +269,7 @@ static int parse_color_config(AV1SequenceParameters *seq_params, Av1GetBitContex } if (seq_params->monochrome) { - seq_params->color_range = av1_get_bits(gb, 1); + seq_params->color_range = (uint8_t)av1_get_bits(gb, 1); seq_params->chroma_subsampling_x = 1; seq_params->chroma_subsampling_y = 1; seq_params->chroma_sample_position = 0; @@ -279,7 +279,7 @@ static int parse_color_config(AV1SequenceParameters *seq_params, Av1GetBitContex seq_params->chroma_subsampling_x = 0; seq_params->chroma_subsampling_y = 0; } else { - seq_params->color_range = av1_get_bits(gb, 1); + seq_params->color_range = (uint8_t)av1_get_bits(gb, 1); if (seq_params->profile == FF_PROFILE_AV1_MAIN) { seq_params->chroma_subsampling_x = 1; @@ -289,9 +289,9 @@ static int parse_color_config(AV1SequenceParameters *seq_params, Av1GetBitContex seq_params->chroma_subsampling_y = 0; } else { if (twelve_bit) { - seq_params->chroma_subsampling_x = av1_get_bits(gb, 1); + seq_params->chroma_subsampling_x = (uint8_t)av1_get_bits(gb, 1); if (seq_params->chroma_subsampling_x) - seq_params->chroma_subsampling_y = av1_get_bits(gb, 1); + seq_params->chroma_subsampling_y = (uint8_t)av1_get_bits(gb, 1); else seq_params->chroma_subsampling_y = 0; } else { @@ -300,7 +300,7 @@ static int parse_color_config(AV1SequenceParameters *seq_params, Av1GetBitContex } } if (seq_params->chroma_subsampling_x && seq_params->chroma_subsampling_y) - seq_params->chroma_sample_position = av1_get_bits(gb, 2); + seq_params->chroma_sample_position = (uint8_t)av1_get_bits(gb, 2); } skip_bits(gb, 1); // separate_uv_delta_q @@ -325,13 +325,13 @@ static int parse_sequence_header(AV1SequenceParameters *seq_params, const uint8_ memset(seq_params, 0, sizeof(*seq_params)); - seq_params->profile = av1_get_bits(&gb, 3); + seq_params->profile = (uint8_t)av1_get_bits(&gb, 3); skip_bits(&gb, 1); // still_picture reduced_still_picture_header = av1_get_bits(&gb, 1); if (reduced_still_picture_header) { - seq_params->level = av1_get_bits(&gb, 5); + seq_params->level = (uint8_t)av1_get_bits(&gb, 5); seq_params->tier = 0; } else { int initial_display_delay_present_flag, operating_points_cnt_minus_1; @@ -381,8 +381,8 @@ static int parse_sequence_header(AV1SequenceParameters *seq_params, const uint8_ } if (i == 0) { - seq_params->level = seq_level_idx; - seq_params->tier = seq_tier; + seq_params->level = (uint8_t)seq_level_idx; + seq_params->tier = (uint8_t)seq_tier; } } } @@ -449,7 +449,10 @@ size_t obs_parse_av1_header(uint8_t **header, const uint8_t *data, size_t size) } // AV1S init - AV1SequenceParameters seq_params; + /* Filled by parse_sequence_header() in the AV1_OBU_SEQUENCE_HEADER case, + * which the !nb_seq guard below makes mandatory; MSVC cannot see that + * through the switch and reports C4701 at /W4. */ + AV1SequenceParameters seq_params = {0}; int nb_seq = 0, seq_size = 0, meta_size = 0; const uint8_t *seq = 0, *meta = 0; diff --git a/plugins/obs-outputs/rtmp-hevc.c.h b/plugins/obs-outputs/rtmp-hevc.c.h index e09ba2d3e9..1bcf942cad 100644 --- a/plugins/obs-outputs/rtmp-hevc.c.h +++ b/plugins/obs-outputs/rtmp-hevc.c.h @@ -258,13 +258,13 @@ uint8_t *ff_nal_unit_extract_rbsp(uint8_t *dst, const uint8_t *src, int src_len, static int hvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, uint8_t nal_type, int ps_array_completeness, HVCCNALUnitArray *array) { - s_wb16(&array->nalUnit, nal_size); + s_wb16(&array->nalUnit, (uint16_t)nal_size); s_write(&array->nalUnit, nal_buf, nal_size); array->NAL_unit_type = nal_type; array->numNalus++; if (nal_type == OBS_HEVC_NAL_VPS || nal_type == OBS_HEVC_NAL_SPS || nal_type == OBS_HEVC_NAL_PPS) - array->array_completeness = ps_array_completeness; + array->array_completeness = (uint8_t)ps_array_completeness; return 0; } @@ -272,7 +272,7 @@ static int hvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, uint8_t static void nal_unit_parse_header(HevcGetBitContext *gb, uint8_t *nal_type) { skip_bits(gb, 1); // forbidden_zero_bit - *nal_type = get_bits(gb, 6); + *nal_type = (uint8_t)get_bits(gb, 6); get_bits(gb, 9); } @@ -297,17 +297,17 @@ static void hvcc_parse_ptl(HevcGetBitContext *gb, HEVCDecoderConfigurationRecord uint8_t sub_layer_profile_present_flag[7]; // max sublayers uint8_t sub_layer_level_present_flag[7]; // max sublayers - general_ptl.profile_space = get_bits(gb, 2); - general_ptl.tier_flag = get_bits(gb, 1); - general_ptl.profile_idc = get_bits(gb, 5); + general_ptl.profile_space = (uint8_t)get_bits(gb, 2); + general_ptl.tier_flag = (uint8_t)get_bits(gb, 1); + general_ptl.profile_idc = (uint8_t)get_bits(gb, 5); general_ptl.profile_compatibility_flags = get_bits_long(gb, 32); general_ptl.constraint_indicator_flags = get_bits64(gb, 48); - general_ptl.level_idc = get_bits(gb, 8); + general_ptl.level_idc = (uint8_t)get_bits(gb, 8); hvcc_update_ptl(hvcc, &general_ptl); for (i = 0; i < max_sub_layers_minus1; i++) { - sub_layer_profile_present_flag[i] = get_bits(gb, 1); - sub_layer_level_present_flag[i] = get_bits(gb, 1); + sub_layer_profile_present_flag[i] = (uint8_t)get_bits(gb, 1); + sub_layer_level_present_flag[i] = (uint8_t)get_bits(gb, 1); } // skip the rest @@ -332,7 +332,7 @@ static int hvcc_parse_vps(HevcGetBitContext *gb, HEVCDecoderConfigurationRecord unsigned int vps_max_sub_layers_minus1; skip_bits(gb, 12); vps_max_sub_layers_minus1 = get_bits(gb, 3); - hvcc->numTemporalLayers = max_u8(hvcc->numTemporalLayers, vps_max_sub_layers_minus1 + 1); + hvcc->numTemporalLayers = max_u8(hvcc->numTemporalLayers, (uint8_t)(vps_max_sub_layers_minus1 + 1)); skip_bits(gb, 17); hvcc_parse_ptl(gb, hvcc, vps_max_sub_layers_minus1); return 0; @@ -377,9 +377,9 @@ static int parse_rps(HevcGetBitContext *gb, unsigned int rps_idx, unsigned int n for (i = 0; i <= num_delta_pocs[rps_idx - 1]; i++) { uint8_t use_delta_flag = 0; - uint8_t used_by_curr_pic_flag = get_bits(gb, 1); + uint8_t used_by_curr_pic_flag = (uint8_t)get_bits(gb, 1); if (!used_by_curr_pic_flag) - use_delta_flag = get_bits(gb, 1); + use_delta_flag = (uint8_t)get_bits(gb, 1); if (used_by_curr_pic_flag || use_delta_flag) num_delta_pocs[rps_idx]++; @@ -433,11 +433,11 @@ static int skip_hrd_parameters(HevcGetBitContext *gb, uint8_t cprms_present_flag uint8_t vcl_hrd_parameters_present_flag = 0; if (cprms_present_flag) { - nal_hrd_parameters_present_flag = get_bits(gb, 1); - vcl_hrd_parameters_present_flag = get_bits(gb, 1); + nal_hrd_parameters_present_flag = (uint8_t)get_bits(gb, 1); + vcl_hrd_parameters_present_flag = (uint8_t)get_bits(gb, 1); if (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag) { - sub_pic_hrd_params_present_flag = get_bits(gb, 1); + sub_pic_hrd_params_present_flag = (uint8_t)get_bits(gb, 1); if (sub_pic_hrd_params_present_flag) get_bits(gb, 19); @@ -454,15 +454,15 @@ static int skip_hrd_parameters(HevcGetBitContext *gb, uint8_t cprms_present_flag unsigned int cpb_cnt_minus1 = 0; uint8_t low_delay_hrd_flag = 0; uint8_t fixed_pic_rate_within_cvs_flag = 0; - uint8_t fixed_pic_rate_general_flag = get_bits(gb, 1); + uint8_t fixed_pic_rate_general_flag = (uint8_t)get_bits(gb, 1); if (!fixed_pic_rate_general_flag) - fixed_pic_rate_within_cvs_flag = get_bits(gb, 1); + fixed_pic_rate_within_cvs_flag = (uint8_t)get_bits(gb, 1); if (fixed_pic_rate_within_cvs_flag) get_ue_golomb_long(gb); else - low_delay_hrd_flag = get_bits(gb, 1); + low_delay_hrd_flag = (uint8_t)get_bits(gb, 1); if (!low_delay_hrd_flag) { cpb_cnt_minus1 = get_ue_golomb_long(gb); @@ -532,7 +532,7 @@ static void hvcc_parse_vui(HevcGetBitContext *gb, HEVCDecoderConfigurationRecord min_spatial_segmentation_idc = get_ue_golomb_long(gb); hvcc->min_spatial_segmentation_idc = - min_u16(hvcc->min_spatial_segmentation_idc, min_spatial_segmentation_idc); + min_u16(hvcc->min_spatial_segmentation_idc, (uint16_t)min_spatial_segmentation_idc); get_ue_golomb_long(gb); // max_bytes_per_pic_denom get_ue_golomb_long(gb); // max_bits_per_min_cu_denom @@ -549,15 +549,15 @@ static int hvcc_parse_sps(HevcGetBitContext *gb, HEVCDecoderConfigurationRecord get_bits(gb, 4); // sps_video_parameter_set_id sps_max_sub_layers_minus1 = get_bits(gb, 3); - hvcc->numTemporalLayers = max_u8(hvcc->numTemporalLayers, sps_max_sub_layers_minus1 + 1); + hvcc->numTemporalLayers = max_u8(hvcc->numTemporalLayers, (uint8_t)(sps_max_sub_layers_minus1 + 1)); - hvcc->temporalIdNested = get_bits(gb, 1); + hvcc->temporalIdNested = (uint8_t)get_bits(gb, 1); hvcc_parse_ptl(gb, hvcc, sps_max_sub_layers_minus1); get_ue_golomb_long(gb); // sps_seq_parameter_set_id - hvcc->chromaFormat = get_ue_golomb_long(gb); + hvcc->chromaFormat = (uint8_t)get_ue_golomb_long(gb); if (hvcc->chromaFormat == 3) get_bits(gb, 1); // separate_colour_plane_flag @@ -572,8 +572,8 @@ static int hvcc_parse_sps(HevcGetBitContext *gb, HEVCDecoderConfigurationRecord get_ue_golomb_long(gb); // conf_win_bottom_offset } - hvcc->bitDepthLumaMinus8 = get_ue_golomb_long(gb); - hvcc->bitDepthChromaMinus8 = get_ue_golomb_long(gb); + hvcc->bitDepthLumaMinus8 = (uint8_t)get_ue_golomb_long(gb); + hvcc->bitDepthChromaMinus8 = (uint8_t)get_ue_golomb_long(gb); log2_max_pic_order_cnt_lsb_minus4 = get_ue_golomb_long(gb); /* sps_sub_layer_ordering_info_present_flag */ @@ -660,8 +660,8 @@ static int hvcc_parse_pps(HevcGetBitContext *gb, HEVCDecoderConfigurationRecord get_bits(gb, 4); - tiles_enabled_flag = get_bits(gb, 1); - entropy_coding_sync_enabled_flag = get_bits(gb, 1); + tiles_enabled_flag = (uint8_t)get_bits(gb, 1); + entropy_coding_sync_enabled_flag = (uint8_t)get_bits(gb, 1); if (entropy_coding_sync_enabled_flag && tiles_enabled_flag) hvcc->parallelismType = 0; // mixed-type parallel decoding diff --git a/plugins/obs-outputs/rtmp-windows.c.h b/plugins/obs-outputs/rtmp-windows.c.h index 90a1213f9c..4590e8b342 100644 --- a/plugins/obs-outputs/rtmp-windows.c.h +++ b/plugins/obs-outputs/rtmp-windows.c.h @@ -5,7 +5,7 @@ static void fatal_sock_shutdown(struct rtmp_stream *stream) { closesocket(stream->rtmp.m_sb.sb_socket); - stream->rtmp.m_sb.sb_socket = -1; + stream->rtmp.m_sb.sb_socket = INVALID_SOCKET; stream->write_buf_len = 0; os_event_signal(stream->buffer_space_available_event); } @@ -107,7 +107,7 @@ static bool socket_event(struct rtmp_stream *stream, bool *can_write, uint64_t l return true; } -static void ideal_send_backlog_event(struct rtmp_stream *stream, bool *can_write) +static void ideal_send_backlog_event(struct rtmp_stream *stream) { ULONG ideal_send_backlog; int ret; @@ -304,7 +304,7 @@ static inline void socket_thread_windows_internal(struct rtmp_stream *stream) } else if (status == WAIT_OBJECT_0 + 2) { /* Ideal send backlog event */ - ideal_send_backlog_event(stream, &can_write); + ideal_send_backlog_event(stream); ResetEvent(send_backlog_event); idealsendbacklognotify(stream->rtmp.m_sb.sb_socket, &send_backlog_overlapped, NULL); diff --git a/plugins/obs-qsv11/QSV_Encoder_Internal.cpp.hpp b/plugins/obs-qsv11/QSV_Encoder_Internal.cpp.hpp index b972fcec72..9c1e55ece1 100644 --- a/plugins/obs-qsv11/QSV_Encoder_Internal.cpp.hpp +++ b/plugins/obs-qsv11/QSV_Encoder_Internal.cpp.hpp @@ -553,8 +553,8 @@ mfxStatus QSV_Encoder_Internal::GetVideoParam(enum qsv_codec codec) opt.Header.BufferId = MFX_EXTBUFF_CODING_OPTION_SPSPPS; opt.Header.BufferSz = sizeof(mfxExtCodingOptionSPSPPS); - std::vector extendedBuffers; - extendedBuffers.reserve(2); + std::vector param_ext_buffers; + param_ext_buffers.reserve(2); opt.SPSBuffer = m_SPSBuffer; opt.PPSBuffer = m_PPSBuffer; @@ -568,13 +568,13 @@ mfxStatus QSV_Encoder_Internal::GetVideoParam(enum qsv_codec codec) opt_vps.VPSBuffer = m_VPSBuffer; opt_vps.VPSBufSize = 1024; - extendedBuffers.push_back((mfxExtBuffer *)&opt_vps); + param_ext_buffers.push_back((mfxExtBuffer *)&opt_vps); } - extendedBuffers.push_back((mfxExtBuffer *)&opt); + param_ext_buffers.push_back((mfxExtBuffer *)&opt); - m_parameter.ExtParam = extendedBuffers.data(); - m_parameter.NumExtParam = (mfxU16)extendedBuffers.size(); + m_parameter.ExtParam = param_ext_buffers.data(); + m_parameter.NumExtParam = (mfxU16)param_ext_buffers.size(); mfxStatus sts = m_pmfxENC->GetVideoParam(&m_parameter); MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts); diff --git a/plugins/obs-qsv11/common_utils_windows.cpp.hpp b/plugins/obs-qsv11/common_utils_windows.cpp.hpp index 143562a008..e2b25a7c9b 100644 --- a/plugins/obs-qsv11/common_utils_windows.cpp.hpp +++ b/plugins/obs-qsv11/common_utils_windows.cpp.hpp @@ -7,6 +7,7 @@ mfxStatus Initialize(mfxVersion ver, mfxSession *pSession, mfxFrameAllocator *pmfxAllocator, mfxHDL *deviceHandle, bool bCreateSharedHandles, enum qsv_codec codec, void **data) { + UNUSED_PARAMETER(ver); UNUSED_PARAMETER(codec); UNUSED_PARAMETER(data); @@ -147,7 +148,7 @@ static bool enum_luids(void *param, uint32_t idx, uint64_t luid) return true; } -void check_adapters(struct adapter_info *adapters, size_t *adapter_count) +void check_adapters(struct adapter_info *adapter_info_list, size_t *adapter_count_out) { char *test_exe = os_get_executable_path_ptr("obs-qsv-test.exe"); struct dstr cmd = {0}; @@ -199,15 +200,15 @@ void check_adapters(struct adapter_info *adapters, size_t *adapter_count) config_adapter_count = config_num_sections(config); - if (config_adapter_count < *adapter_count) { - *adapter_count = config_adapter_count; + if (config_adapter_count < *adapter_count_out) { + *adapter_count_out = config_adapter_count; } - for (size_t i = 0; i < *adapter_count; i++) { + for (size_t i = 0; i < *adapter_count_out; i++) { char section[16]; snprintf(section, sizeof(section), "%d", (int)i); - struct adapter_info *adapter = &adapters[i]; + struct adapter_info *adapter = &adapter_info_list[i]; adapter->is_intel = config_get_bool(config, section, "is_intel"); adapter->is_dgpu = config_get_bool(config, section, "is_dgpu"); adapter->supports_av1 = config_get_bool(config, section, "supports_av1"); diff --git a/plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp.hpp b/plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp.hpp index 6c2b127d70..2daa26fa6c 100644 --- a/plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp.hpp +++ b/plugins/obs-qsv11/obs-qsv-test/obs-qsv-test.cpp.hpp @@ -168,7 +168,9 @@ try { MFXSetConfigFilterProperty(cfg, (const mfxU8 *)"mfxImplDescription.Impl", impl); mfxSession m_session = nullptr; - mfxStatus sts = MFXCreateSession(loader, 0, &m_session); + // A session that failed to open is simply null: the probe below then + // reports no adapters and the close is skipped, so the status is not used. + (void)MFXCreateSession(loader, 0, &m_session); uint32_t idx = 0; while (get_adapter_caps(factory, loader, m_session, idx++) == true) @@ -180,8 +182,8 @@ try { MFXUnload(loader); - for (auto &[idx, caps] : adapter_info) { - printf("[%u]\n", idx); + for (auto &[caps_index, caps] : adapter_info) { + printf("[%u]\n", caps_index); printf("is_intel=%s\n", caps.is_intel ? "true" : "false"); printf("is_dgpu=%s\n", caps.is_dgpu ? "true" : "false"); printf("supports_av1=%s\n", caps.supports_av1 ? "true" : "false"); diff --git a/plugins/obs-qsv11/obs-qsv11.c.h b/plugins/obs-qsv11/obs-qsv11.c.h index 58e443f3b6..bd9aa14cbe 100644 --- a/plugins/obs-qsv11/obs-qsv11.c.h +++ b/plugins/obs-qsv11/obs-qsv11.c.h @@ -570,8 +570,8 @@ static void update_params(struct obs_qsv *obsqsv, obs_data_t *settings) obsqsv->params.MaxDisplayMasteringLuminance = hdr_nominal_peak_level * 10000; obsqsv->params.MinDisplayMasteringLuminance = 0; - obsqsv->params.MaxContentLightLevel = hdr_nominal_peak_level; - obsqsv->params.MaxPicAverageLightLevel = hdr_nominal_peak_level; + obsqsv->params.MaxContentLightLevel = (mfxU16)hdr_nominal_peak_level; + obsqsv->params.MaxPicAverageLightLevel = (mfxU16)hdr_nominal_peak_level; } /* internal convenience parameter, overrides rate control param @@ -629,9 +629,9 @@ static void update_params(struct obs_qsv *obsqsv, obs_data_t *settings) if (obsqsv->codec == QSV_CODEC_AV1) { actual_cqp *= 4; } - obsqsv->params.nQPI = actual_cqp; - obsqsv->params.nQPP = actual_cqp; - obsqsv->params.nQPB = actual_cqp; + obsqsv->params.nQPI = (mfxU16)actual_cqp; + obsqsv->params.nQPP = (mfxU16)actual_cqp; + obsqsv->params.nQPB = (mfxU16)actual_cqp; } obsqsv->params.nTargetBitRate = (mfxU16)target_bitrate; obsqsv->params.nMaxBitRate = (mfxU16)max_bitrate; diff --git a/plugins/obs-text/gdiplus/obs-text.cpp.hpp b/plugins/obs-text/gdiplus/obs-text.cpp.hpp index ed04226190..1d34736312 100644 --- a/plugins/obs-text/gdiplus/obs-text.cpp.hpp +++ b/plugins/obs-text/gdiplus/obs-text.cpp.hpp @@ -276,7 +276,7 @@ struct TextSource { void GetStringFormat(StringFormat &format); void RemoveNewlinePadding(const StringFormat &format, RectF &box); void CalculateTextSizes(const StringFormat &format, RectF &bounding_box, SIZE &text_size); - void RenderOutlineText(Graphics &graphics, const GraphicsPath &path, const Brush &brush); + void RenderOutlineText(Graphics &graphics_target, const GraphicsPath &path, const Brush &brush); void RenderText(); void LoadFileText(); void TransformText(); @@ -538,7 +538,7 @@ void TextSource::CalculateTextSizes(const StringFormat &format, RectF &bounding_ bounding_box.Height = temp_box.Height; } -void TextSource::RenderOutlineText(Graphics &graphics, const GraphicsPath &path, const Brush &brush) +void TextSource::RenderOutlineText(Graphics &graphics_target, const GraphicsPath &path, const Brush &brush) { DWORD outline_rgba = calc_color(outline_color, outline_opacity); Status stat; @@ -547,10 +547,10 @@ void TextSource::RenderOutlineText(Graphics &graphics, const GraphicsPath &path, stat = pen.SetLineJoin(LineJoinRound); warn_stat("pen.SetLineJoin"); - stat = graphics.DrawPath(&pen, &path); + stat = graphics_target.DrawPath(&pen, &path); warn_stat("graphics.DrawPath"); - stat = graphics.FillPath(&brush, &path); + stat = graphics_target.FillPath(&brush, &path); warn_stat("graphics.FillPath"); } @@ -720,7 +720,7 @@ inline void TextSource::Update(obs_data_t *s) const char *valign_str = obs_data_get_string(s, S_VALIGN); uint32_t new_color = obs_data_get_uint32(s, S_COLOR); uint32_t new_opacity = obs_data_get_uint32(s, S_OPACITY); - bool gradient = obs_data_get_bool(s, S_GRADIENT); + bool new_gradient = obs_data_get_bool(s, S_GRADIENT); uint32_t new_color2 = obs_data_get_uint32(s, S_GRADIENT_COLOR); uint32_t new_opacity2 = obs_data_get_uint32(s, S_GRADIENT_OPACITY); float new_grad_dir = (float)obs_data_get_double(s, S_GRADIENT_DIR); @@ -791,7 +791,7 @@ inline void TextSource::Update(obs_data_t *s) text_transform = new_text_transform; antialiasing = new_antialiasing; - if (!gradient) { + if (!new_gradient) { color2 = color; opacity2 = opacity; } diff --git a/plugins/obs-vst/CMakeLists.txt b/plugins/obs-vst/CMakeLists.txt index 8348e4763b..0a3db9fe8b 100644 --- a/plugins/obs-vst/CMakeLists.txt +++ b/plugins/obs-vst/CMakeLists.txt @@ -8,6 +8,7 @@ endif() add_library(obs-vst MODULE) add_library(OBS::vst ALIAS obs-vst) +obs_msvc_exempt_c4201(obs-vst) find_package(Qt6 REQUIRED Widgets) diff --git a/plugins/obs-websocket b/plugins/obs-websocket index 777071b5db..c2366e8d2c 160000 --- a/plugins/obs-websocket +++ b/plugins/obs-websocket @@ -1 +1 @@ -Subproject commit 777071b5db3dc3cf0fd62f3cea5a2a3ac7992af2 +Subproject commit c2366e8d2c212be569a4fce6687d8a3fb7c6be70 diff --git a/plugins/text-freetype2/find-font.c.h b/plugins/text-freetype2/find-font.c.h index fffc4c380b..bc65c10bd2 100644 --- a/plugins/text-freetype2/find-font.c.h +++ b/plugins/text-freetype2/find-font.c.h @@ -292,8 +292,8 @@ void build_font_path_info(FT_Face face, FT_Long idx, const char *path) if (!family) continue; - for (size_t i = 0; i < family_names.num; i++) { - if (astrcmpi(family_names.array[i], family) == 0) { + for (size_t existing = 0; existing < family_names.num; existing++) { + if (astrcmpi(family_names.array[existing], family) == 0) { bfree(family); family = NULL; break; diff --git a/plugins/win-capture/game-capture.c.h b/plugins/win-capture/game-capture.c.h index 26815e6ac8..eb22cd2640 100644 --- a/plugins/win-capture/game-capture.c.h +++ b/plugins/win-capture/game-capture.c.h @@ -1761,15 +1761,15 @@ static void game_capture_tick(void *data, float seconds) ms_get_window_class(&gc->class, gc->window); } signal_handler_t *sh = obs_source_get_signal_handler(gc->source); - calldata_t data = {0}; + calldata_t cd = {0}; - calldata_set_ptr(&data, "source", gc->source); - calldata_set_string(&data, "title", gc->title.array); - calldata_set_string(&data, "class", gc->class.array); - calldata_set_string(&data, "executable", gc->executable.array); + calldata_set_ptr(&cd, "source", gc->source); + calldata_set_string(&cd, "title", gc->title.array); + calldata_set_string(&cd, "class", gc->class.array); + calldata_set_string(&cd, "executable", gc->executable.array); - signal_handler_signal(sh, "hooked", &data); - calldata_free(&data); + signal_handler_signal(sh, "hooked", &cd); + calldata_free(&cd); if (gc->audio_source) { reconfigure_audio_source(gc->audio_source, gc->window); diff --git a/plugins/win-capture/graphics-hook/CMakeLists.txt b/plugins/win-capture/graphics-hook/CMakeLists.txt index 5073134195..a0ca65fa60 100644 --- a/plugins/win-capture/graphics-hook/CMakeLists.txt +++ b/plugins/win-capture/graphics-hook/CMakeLists.txt @@ -25,6 +25,12 @@ add_library(graphics-hook MODULE) # batches (cmake/common/unity.cmake). set_property(TARGET graphics-hook PROPERTY OBS_DISABLE_UNITY_BUILD ON) add_library(OBS::graphics-hook ALIAS graphics-hook) +# MSVC /W4 (#2626): this target is also configured by the child architecture +# build (cmake/windows/architecture.cmake), which does not include +# cmake/common/helpers_common.cmake, so the C4201 exemption is written inline +# here instead of through the per-target helper. d3d10-capture.cpp.hpp's state +# is an anonymous union over two struct overlays by design. +target_compile_options(graphics-hook PRIVATE $<$:/wd4201>) target_sources( graphics-hook diff --git a/plugins/win-capture/graphics-hook/d3d11-capture.cpp.hpp b/plugins/win-capture/graphics-hook/d3d11-capture.cpp.hpp index e9683ebb9a..2e42e42bd9 100644 --- a/plugins/win-capture/graphics-hook/d3d11-capture.cpp.hpp +++ b/plugins/win-capture/graphics-hook/d3d11-capture.cpp.hpp @@ -15,7 +15,7 @@ struct d3d11_data { struct shtex_data *shtex_info; ID3D11Texture2D *texture; HANDLE handle; - }; + } shtex; /* shared memory */ struct { ID3D11Texture2D *copy_surfaces[NUM_BUFFERS]; @@ -25,8 +25,8 @@ struct d3d11_data { struct shmem_data *shmem_info; int cur_tex; int copy_wait; - }; - }; + } shmem; + } u; }; static struct d3d11_data data = {}; @@ -36,16 +36,16 @@ void d3d11_free(void) capture_free(); if (data.using_shtex) { - if (data.texture) { - data.texture->Release(); + if (data.u.shtex.texture) { + data.u.shtex.texture->Release(); } } else { for (size_t i = 0; i < NUM_BUFFERS; i++) { - if (data.copy_surfaces[i]) { - if (data.texture_mapped[i]) { - data.context->Unmap(data.copy_surfaces[i], 0); + if (data.u.shmem.copy_surfaces[i]) { + if (data.u.shmem.texture_mapped[i]) { + data.context->Unmap(data.u.shmem.copy_surfaces[i], 0); } - data.copy_surfaces[i]->Release(); + data.u.shmem.copy_surfaces[i]->Release(); } } } @@ -146,7 +146,7 @@ static bool d3d11_shmem_init_buffers(size_t idx) { bool success; - success = create_d3d11_stage_surface(&data.copy_surfaces[idx]); + success = create_d3d11_stage_surface(&data.u.shmem.copy_surfaces[idx]); if (!success) { hlog("d3d11_shmem_init_buffers: failed to create copy surface"); return false; @@ -156,7 +156,7 @@ static bool d3d11_shmem_init_buffers(size_t idx) D3D11_MAPPED_SUBRESOURCE map = {}; HRESULT hr; - hr = data.context->Map(data.copy_surfaces[idx], 0, D3D11_MAP_READ, 0, &map); + hr = data.context->Map(data.u.shmem.copy_surfaces[idx], 0, D3D11_MAP_READ, 0, &map); if (FAILED(hr)) { hlog_hr("d3d11_shmem_init_buffers: failed to get " "pitch", @@ -164,8 +164,8 @@ static bool d3d11_shmem_init_buffers(size_t idx) return false; } - data.pitch = map.RowPitch; - data.context->Unmap(data.copy_surfaces[idx], 0); + data.u.shmem.pitch = map.RowPitch; + data.context->Unmap(data.u.shmem.copy_surfaces[idx], 0); } return true; @@ -180,7 +180,8 @@ static bool d3d11_shmem_init(HWND window) return false; } } - if (!capture_init_shmem(&data.shmem_info, window, data.cx, data.cy, data.pitch, data.format, false)) { + if (!capture_init_shmem(&data.u.shmem.shmem_info, window, data.cx, data.cy, data.u.shmem.pitch, data.format, + false)) { return false; } @@ -194,14 +195,14 @@ static bool d3d11_shtex_init(HWND window) data.using_shtex = true; - success = create_d3d11_tex(data.cx, data.cy, &data.texture, &data.handle); + success = create_d3d11_tex(data.cx, data.cy, &data.u.shtex.texture, &data.u.shtex.handle); if (!success) { hlog("d3d11_shtex_init: failed to create texture"); return false; } - if (!capture_init_shtex(&data.shtex_info, window, data.cx, data.cy, data.format, false, - (uintptr_t)data.handle)) { + if (!capture_init_shtex(&data.u.shtex.shtex_info, window, data.cx, data.cy, data.format, false, + (uintptr_t)data.u.shtex.handle)) { return false; } @@ -246,8 +247,8 @@ static inline void d3d11_copy_texture(ID3D11Resource *dst, ID3D11Resource *src) static inline void d3d11_shtex_capture(ID3D11Resource *backbuffer) { - if (data.texture) { - d3d11_copy_texture(data.texture, backbuffer); + if (data.u.shtex.texture) { + d3d11_copy_texture(data.u.shtex.texture, backbuffer); } } @@ -256,12 +257,12 @@ static void d3d11_shmem_capture_copy(int i) D3D11_MAPPED_SUBRESOURCE map; HRESULT hr; - if (data.texture_ready[i]) { - data.texture_ready[i] = false; + if (data.u.shmem.texture_ready[i]) { + data.u.shmem.texture_ready[i] = false; - hr = data.context->Map(data.copy_surfaces[i], 0, D3D11_MAP_READ, 0, &map); + hr = data.context->Map(data.u.shmem.copy_surfaces[i], 0, D3D11_MAP_READ, 0, &map); if (SUCCEEDED(hr)) { - data.texture_mapped[i] = true; + data.u.shmem.texture_mapped[i] = true; shmem_copy_data(i, map.pData); } } @@ -271,23 +272,23 @@ static inline void d3d11_shmem_capture(ID3D11Resource *backbuffer) { int next_tex; - next_tex = (data.cur_tex + 1) % NUM_BUFFERS; + next_tex = (data.u.shmem.cur_tex + 1) % NUM_BUFFERS; d3d11_shmem_capture_copy(next_tex); - if (data.copy_wait < NUM_BUFFERS - 1) { - data.copy_wait++; + if (data.u.shmem.copy_wait < NUM_BUFFERS - 1) { + data.u.shmem.copy_wait++; } else { - if (shmem_texture_data_lock(data.cur_tex)) { - data.context->Unmap(data.copy_surfaces[data.cur_tex], 0); - data.texture_mapped[data.cur_tex] = false; - shmem_texture_data_unlock(data.cur_tex); + if (shmem_texture_data_lock(data.u.shmem.cur_tex)) { + data.context->Unmap(data.u.shmem.copy_surfaces[data.u.shmem.cur_tex], 0); + data.u.shmem.texture_mapped[data.u.shmem.cur_tex] = false; + shmem_texture_data_unlock(data.u.shmem.cur_tex); } - d3d11_copy_texture(data.copy_surfaces[data.cur_tex], backbuffer); - data.texture_ready[data.cur_tex] = true; + d3d11_copy_texture(data.u.shmem.copy_surfaces[data.u.shmem.cur_tex], backbuffer); + data.u.shmem.texture_ready[data.u.shmem.cur_tex] = true; } - data.cur_tex = next_tex; + data.u.shmem.cur_tex = next_tex; } void d3d11_capture(void *swap_ptr, void *backbuffer_ptr) @@ -302,7 +303,7 @@ void d3d11_capture(void *swap_ptr, void *backbuffer_ptr) if (capture_should_init()) { d3d11_init(swap); } - if (data.handle != nullptr && capture_ready()) { + if (data.u.shtex.handle != nullptr && capture_ready()) { ID3D11Resource *backbuffer; hr = dxgi_backbuffer->QueryInterface(__uuidof(ID3D11Resource), (void **)&backbuffer); diff --git a/plugins/win-capture/graphics-hook/d3d12-capture.cpp.hpp b/plugins/win-capture/graphics-hook/d3d12-capture.cpp.hpp index 572d7b91b8..221da8bfe5 100644 --- a/plugins/win-capture/graphics-hook/d3d12-capture.cpp.hpp +++ b/plugins/win-capture/graphics-hook/d3d12-capture.cpp.hpp @@ -20,15 +20,11 @@ struct d3d12_data { ID3D11DeviceContext *context11; ID3D11On12Device *device11on12; - union { - struct { - struct shtex_data *shtex_info; - UINT backbuffer_count; - UINT cur_backbuffer; - ID3D11Texture2D *copy_tex; - HANDLE handle; - }; - }; + struct shtex_data *shtex_info; + UINT backbuffer_count; + UINT cur_backbuffer; + ID3D11Texture2D *copy_tex; + HANDLE handle; }; static struct d3d12_data data = {}; diff --git a/plugins/win-capture/graphics-hook/d3d9-patches.hpp b/plugins/win-capture/graphics-hook/d3d9-patches.hpp index 06af6814a5..7f73f37eb0 100644 --- a/plugins/win-capture/graphics-hook/d3d9-patches.hpp +++ b/plugins/win-capture/graphics-hook/d3d9-patches.hpp @@ -173,12 +173,14 @@ static inline int get_d3d9_patch(HMODULE d3d9) return -1; } -static inline uint8_t *get_d3d9_patch_addr(HMODULE d3d9, int patch) +/* The parameter used to be called `patch`, which hides a global symbol of that + * name (C4459 at /W4); `index` also matches get_d3d9_patch's return value. */ +static inline uint8_t *get_d3d9_patch_addr(HMODULE d3d9, int index) { - if (patch == -1) { + if (index == -1) { return nullptr; } uint8_t *addr = (uint8_t *)d3d9; - return addr + patch_offset[patch] + CMP_SIZE; + return addr + patch_offset[index] + CMP_SIZE; } diff --git a/plugins/win-capture/graphics-hook/gl-capture.c.h b/plugins/win-capture/graphics-hook/gl-capture.c.h index fc0c09a81c..7f074617cb 100644 --- a/plugins/win-capture/graphics-hook/gl-capture.c.h +++ b/plugins/win-capture/graphics-hook/gl-capture.c.h @@ -813,9 +813,10 @@ bool hook_gl(void) /* "life is feudal: your own" somehow uses both opengl and directx at * the same time, so blacklist it from capturing opengl */ - const char *process_name = get_process_name(); - if (_strcmpi(process_name, "yo_cm_client.exe") == 0 || _strcmpi(process_name, "cm_client.exe") == 0) { - hlog("Ignoring opengl for game: %s", process_name); + const char *process_name_local = get_process_name(); + if (_strcmpi(process_name_local, "yo_cm_client.exe") == 0 || + _strcmpi(process_name_local, "cm_client.exe") == 0) { + hlog("Ignoring opengl for game: %s", process_name_local); return true; } diff --git a/plugins/win-capture/inject-helper/inject-helper.c.h b/plugins/win-capture/inject-helper/inject-helper.c.h index fafc67d817..eedd004e49 100644 --- a/plugins/win-capture/inject-helper/inject-helper.c.h +++ b/plugins/win-capture/inject-helper/inject-helper.c.h @@ -29,7 +29,8 @@ static void load_debug_privilege(void) static inline HANDLE open_process(DWORD desired_access, bool inherit_handle, DWORD process_id) { HANDLE(WINAPI * open_process_proc)(DWORD, BOOL, DWORD); - open_process_proc = ms_get_obfuscated_func(GetModuleHandleW(L"KERNEL32"), "HxjcQrmkb|~", 0xc82efdf78201df87); + open_process_proc = (HANDLE(WINAPI *)(DWORD, BOOL, DWORD))ms_get_obfuscated_func( + GetModuleHandleW(L"KERNEL32"), "HxjcQrmkb|~", 0xc82efdf78201df87); return open_process_proc(desired_access, inherit_handle, process_id); } diff --git a/plugins/win-capture/window-capture.c.h b/plugins/win-capture/window-capture.c.h index 61d63f3066..f74631ce58 100644 --- a/plugins/win-capture/window-capture.c.h +++ b/plugins/win-capture/window-capture.c.h @@ -593,10 +593,10 @@ static void wc_hide(void *data) wc->hooked = false; signal_handler_t *sh = obs_source_get_signal_handler(wc->source); - calldata_t data = {0}; - calldata_set_ptr(&data, "source", wc->source); - signal_handler_signal(sh, "unhooked", &data); - calldata_free(&data); + calldata_t cd = {0}; + calldata_set_ptr(&cd, "source", wc->source); + signal_handler_signal(sh, "unhooked", &cd); + calldata_free(&cd); } } @@ -614,10 +614,10 @@ static void wc_tick(void *data, float seconds) wc->hooked = false; signal_handler_t *sh = obs_source_get_signal_handler(wc->source); - calldata_t data = {0}; - calldata_set_ptr(&data, "source", wc->source); - signal_handler_signal(sh, "unhooked", &data); - calldata_free(&data); + calldata_t cd = {0}; + calldata_set_ptr(&cd, "source", wc->source); + signal_handler_signal(sh, "unhooked", &cd); + calldata_free(&cd); } if (!wc->title && !wc->class) { @@ -679,10 +679,10 @@ static void wc_tick(void *data, float seconds) wc->hooked = false; signal_handler_t *sh = obs_source_get_signal_handler(wc->source); - calldata_t data = {0}; - calldata_set_ptr(&data, "source", wc->source); - signal_handler_signal(sh, "unhooked", &data); - calldata_free(&data); + calldata_t cd = {0}; + calldata_set_ptr(&cd, "source", wc->source); + signal_handler_signal(sh, "unhooked", &cd); + calldata_free(&cd); } return; } @@ -723,7 +723,7 @@ static void wc_tick(void *data, float seconds) wc->hooked = true; signal_handler_t *sh = obs_source_get_signal_handler(wc->source); - calldata_t data = {0}; + calldata_t cd = {0}; struct dstr title = {0}; struct dstr class = {0}; struct dstr executable = {0}; @@ -732,16 +732,16 @@ static void wc_tick(void *data, float seconds) ms_get_window_class(&class, wc->window); ms_get_window_exe(&executable, wc->window); - calldata_set_ptr(&data, "source", wc->source); - calldata_set_string(&data, "title", title.array); - calldata_set_string(&data, "class", class.array); - calldata_set_string(&data, "executable", executable.array); - signal_handler_signal(sh, "hooked", &data); + calldata_set_ptr(&cd, "source", wc->source); + calldata_set_string(&cd, "title", title.array); + calldata_set_string(&cd, "class", class.array); + calldata_set_string(&cd, "executable", executable.array); + signal_handler_signal(sh, "hooked", &cd); dstr_free(&title); dstr_free(&class); dstr_free(&executable); - calldata_free(&data); + calldata_free(&cd); } } @@ -761,7 +761,7 @@ static void wc_tick(void *data, float seconds) wc->hooked = true; signal_handler_t *sh = obs_source_get_signal_handler(wc->source); - calldata_t data = {0}; + calldata_t cd = {0}; struct dstr title = {0}; struct dstr class = {0}; struct dstr executable = {0}; @@ -770,16 +770,16 @@ static void wc_tick(void *data, float seconds) ms_get_window_class(&class, wc->window); ms_get_window_exe(&executable, wc->window); - calldata_set_ptr(&data, "source", wc->source); - calldata_set_string(&data, "title", title.array); - calldata_set_string(&data, "class", class.array); - calldata_set_string(&data, "executable", executable.array); - signal_handler_signal(sh, "hooked", &data); + calldata_set_ptr(&cd, "source", wc->source); + calldata_set_string(&cd, "title", title.array); + calldata_set_string(&cd, "class", class.array); + calldata_set_string(&cd, "executable", executable.array); + signal_handler_signal(sh, "hooked", &cd); dstr_free(&title); dstr_free(&class); dstr_free(&executable); - calldata_free(&data); + calldata_free(&cd); } } } diff --git a/plugins/win-dshow/CMakeLists.txt b/plugins/win-dshow/CMakeLists.txt index 8a947dd8c5..e1d75a81fd 100644 --- a/plugins/win-dshow/CMakeLists.txt +++ b/plugins/win-dshow/CMakeLists.txt @@ -5,6 +5,10 @@ find_package(FFmpeg 8.0 REQUIRED avcodec avutil) add_library(win-dshow MODULE) add_library(OBS::dshow ALIAS win-dshow) +# The C++ TUs including the libobs headers report the nameless unions C4201 at +# /W4; the same per-target exemption as the other product C++ targets (#2626). +obs_msvc_exempt_c4201(win-dshow) + if(NOT TARGET OBS::tiny-nv12-scale) add_subdirectory("${CMAKE_SOURCE_DIR}/shared/obs-tiny-nv12-scale" obs-tiny-nv12-scale) endif() diff --git a/plugins/win-wasapi/win-wasapi.cpp.hpp b/plugins/win-wasapi/win-wasapi.cpp.hpp index 1337b2d7c4..05f881a32c 100644 --- a/plugins/win-wasapi/win-wasapi.cpp.hpp +++ b/plugins/win-wasapi/win-wasapi.cpp.hpp @@ -397,11 +397,11 @@ WASAPISource::WASAPISource(obs_data_t *settings, obs_source_t *source_, SourceTy } } - auto notify = GetNotify(); - if (notify) { - notify->AddDefaultDeviceChangedCallback(this, std::bind(&WASAPISource::SetDefaultDevice, this, - std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3)); + auto notify_handler = GetNotify(); + if (notify_handler) { + notify_handler->AddDefaultDeviceChangedCallback( + this, std::bind(&WASAPISource::SetDefaultDevice, this, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3)); } Start(); @@ -451,9 +451,9 @@ void WASAPISource::Stop() WASAPISource::~WASAPISource() { - auto notify = GetNotify(); - if (notify) { - notify->RemoveDefaultDeviceChangedCallback(this); + auto notify_handler = GetNotify(); + if (notify_handler) { + notify_handler->RemoveDefaultDeviceChangedCallback(this); } // If the device is also used for monitoring, a cleanup is needed. if (sourceType == SourceType::DeviceOutput) { @@ -475,21 +475,21 @@ WASAPISource::UpdateParams WASAPISource::BuildUpdateParams(obs_data_t *settings) params.executable.clear(); if (sourceType != SourceType::Input) { const char *const window = obs_data_get_string(settings, OPT_WINDOW); - char *window_class = nullptr; - char *title = nullptr; - char *executable = nullptr; - ms_build_window_strings(window, &window_class, &title, &executable); - if (window_class) { - params.window_class = window_class; - bfree(window_class); + char *window_class_name = nullptr; + char *window_title = nullptr; + char *window_exe = nullptr; + ms_build_window_strings(window, &window_class_name, &window_title, &window_exe); + if (window_class_name) { + params.window_class = window_class_name; + bfree(window_class_name); } - if (title) { - params.title = title; - bfree(title); + if (window_title) { + params.title = window_title; + bfree(window_title); } - if (executable) { - params.executable = executable; - bfree(executable); + if (window_exe) { + params.executable = window_exe; + bfree(window_exe); } } @@ -536,15 +536,15 @@ void WASAPISource::Update(obs_data_t *settings) { UpdateParams params = BuildUpdateParams(settings); - const bool restart = (sourceType == SourceType::ProcessOutput) - ? ((priority != params.priority) || (window_class != params.window_class) || - (title != params.title) || (executable != params.executable)) - : (device_id.compare(params.device_id) != 0); + const bool should_restart = (sourceType == SourceType::ProcessOutput) + ? ((priority != params.priority) || (window_class != params.window_class) || + (title != params.title) || (executable != params.executable)) + : (device_id.compare(params.device_id) != 0); UpdateSettings(std::move(params)); LogSettings(); - if (restart) { + if (should_restart) { SetEvent(restartSignal); } } @@ -553,14 +553,14 @@ void WASAPISource::OnWindowChanged(obs_data_t *settings) { UpdateParams params = BuildUpdateParams(settings); - const bool restart = (sourceType == SourceType::ProcessOutput) - ? ((priority != params.priority) || (window_class != params.window_class) || - (title != params.title) || (executable != params.executable)) - : (device_id.compare(params.device_id) != 0); + const bool should_restart = (sourceType == SourceType::ProcessOutput) + ? ((priority != params.priority) || (window_class != params.window_class) || + (title != params.title) || (executable != params.executable)) + : (device_id.compare(params.device_id) != 0); UpdateSettings(std::move(params)); - if (restart) { + if (should_restart) { SetEvent(restartSignal); } } @@ -890,23 +890,23 @@ void WASAPISource::Initialize() signal_handler_t *sh = obs_source_get_signal_handler(source); calldata_t data = {0}; - struct dstr title = {0}; - struct dstr window_class = {0}; - struct dstr executable = {0}; + struct dstr window_title = {0}; + struct dstr window_class_name = {0}; + struct dstr window_exe = {0}; - ms_get_window_title(&title, hwnd); - ms_get_window_class(&window_class, hwnd); - ms_get_window_exe(&executable, hwnd); + ms_get_window_title(&window_title, hwnd); + ms_get_window_class(&window_class_name, hwnd); + ms_get_window_exe(&window_exe, hwnd); calldata_set_ptr(&data, "source", source); - calldata_set_string(&data, "title", title.array); - calldata_set_string(&data, "class", window_class.array); - calldata_set_string(&data, "executable", executable.array); + calldata_set_string(&data, "title", window_title.array); + calldata_set_string(&data, "class", window_class_name.array); + calldata_set_string(&data, "executable", window_exe.array); signal_handler_signal(sh, "hooked", &data); - dstr_free(&title); - dstr_free(&window_class); - dstr_free(&executable); + dstr_free(&window_title); + dstr_free(&window_class_name); + dstr_free(&window_exe); calldata_free(&data); } } diff --git a/shared/bpm/bpm.c.h b/shared/bpm/bpm.c.h index c2b6f786ed..bac2192dea 100644 --- a/shared/bpm/bpm.c.h +++ b/shared/bpm/bpm.c.h @@ -324,7 +324,7 @@ static bool process_metrics(obs_output_t *output, struct encoder_packet *out, st struct encoder_packet backup = *out; sei_t sei; uint8_t *data = NULL; - size_t size; + size_t size = 0; long ref = 1; bool avc = false; bool hevc = false; diff --git a/shared/happy-eyeballs/happy-eyeballs.c.h b/shared/happy-eyeballs/happy-eyeballs.c.h index f871d38cdf..fcfb7969a9 100644 --- a/shared/happy-eyeballs/happy-eyeballs.c.h +++ b/shared/happy-eyeballs/happy-eyeballs.c.h @@ -309,12 +309,12 @@ static void *happy_connect_worker(void *arg) } he_platform_socket_nosigpipe(args->sockfd); - if (context->bind_addr.ss_family != 0 && - bind(args->sockfd, (const struct sockaddr *)&context->bind_addr, context->bind_addr_len) < 0) { + if (context->bind_addr.ss_family != 0 && bind(args->sockfd, (const struct sockaddr *)&context->bind_addr, + he_platform_addr_len(context->bind_addr_len)) < 0) { goto failure; } - if (connect(args->sockfd, args->address->ai_addr, args->address->ai_addrlen) == 0) { + if (connect(args->sockfd, args->address->ai_addr, he_platform_addr_len(args->address->ai_addrlen)) == 0) { /* success, check if we're the winner. */ pthread_mutex_lock(&context->winner_mutex); diff --git a/shared/happy-eyeballs/hosts/posix/happy-eyeballs-platform.h b/shared/happy-eyeballs/hosts/posix/happy-eyeballs-platform.h index 254e5c798a..276496272d 100644 --- a/shared/happy-eyeballs/hosts/posix/happy-eyeballs-platform.h +++ b/shared/happy-eyeballs/hosts/posix/happy-eyeballs-platform.h @@ -62,3 +62,10 @@ static inline void he_platform_socket_nosigpipe(SOCKET fd) (void)fd; #endif } + +/* BSD sockets take the address length as a socklen_t; the resolved length is + * a size_t, so narrow it the way the call already did implicitly. */ +static inline socklen_t he_platform_addr_len(size_t len) +{ + return (socklen_t)len; +} diff --git a/shared/happy-eyeballs/hosts/windows/happy-eyeballs-platform.h b/shared/happy-eyeballs/hosts/windows/happy-eyeballs-platform.h index a8171a75c8..c4501139d4 100644 --- a/shared/happy-eyeballs/hosts/windows/happy-eyeballs-platform.h +++ b/shared/happy-eyeballs/hosts/windows/happy-eyeballs-platform.h @@ -62,3 +62,11 @@ static inline void he_platform_socket_nosigpipe(SOCKET fd) { (void)fd; } + +/* Winsock's bind()/connect() take the address length as an int, while the + * resolved length is a size_t; the conversion is the one the call already + * made implicitly, so it is spelled out here rather than at the call sites. */ +static inline int he_platform_addr_len(size_t len) +{ + return (int)len; +} diff --git a/shared/ipc-util/ipc-util/pipe-windows.c.h b/shared/ipc-util/ipc-util/pipe-windows.c.h index 285569cb78..58893e3c3b 100644 --- a/shared/ipc-util/ipc-util/pipe-windows.c.h +++ b/shared/ipc-util/ipc-util/pipe-windows.c.h @@ -131,8 +131,8 @@ static DWORD CALLBACK ipc_pipe_internal_server_thread(LPVOID param) break; } - DWORD wait = WaitForMultipleObjects(_countof(handles), handles, FALSE, INFINITE); - if (wait != WAIT_OBJECT_0) { + DWORD wait_result = WaitForMultipleObjects(_countof(handles), handles, FALSE, INFINITE); + if (wait_result != WAIT_OBJECT_0) { break; } diff --git a/shared/media-playback/media-playback/cache.c.h b/shared/media-playback/media-playback/cache.c.h index 18da3e2f49..c7d0d80d04 100644 --- a/shared/media-playback/media-playback/cache.c.h +++ b/shared/media-playback/media-playback/cache.c.h @@ -168,7 +168,7 @@ static void seek_to(mp_cache_t *c, int64_t pos) int64_t pos_ns = c->speed > 0 ? pos * 1000 * 100 / c->speed : pos * 1000; if (c->has_video) { - struct obs_source_frame *v; + struct obs_source_frame *v = NULL; for (size_t i = 0; i < c->video_frames.num; i++) { v = &c->video_frames.array[i]; @@ -187,7 +187,7 @@ static void seek_to(mp_cache_t *c, int64_t pos) } } if (c->has_audio) { - struct obs_source_audio *a; + struct obs_source_audio *a = NULL; for (size_t i = 0; i < c->audio_segments.num; i++) { a = &c->audio_segments.array[i]; new_a_idx = i; diff --git a/shared/media-playback/media-playback/decode.c.h b/shared/media-playback/media-playback/decode.c.h index ea82de2436..72996b5f94 100644 --- a/shared/media-playback/media-playback/decode.c.h +++ b/shared/media-playback/media-playback/decode.c.h @@ -138,7 +138,7 @@ static uint16_t get_max_luminance(const AVStream *stream) } } - return max_luminance; + return (uint16_t)max_luminance; } bool mp_decode_init(mp_media_t *m, enum AVMediaType type, bool hw) diff --git a/shared/media-playback/media-playback/media.c.h b/shared/media-playback/media-playback/media.c.h index 02a3f89b89..ea31ffba9e 100644 --- a/shared/media-playback/media-playback/media.c.h +++ b/shared/media-playback/media-playback/media.c.h @@ -416,7 +416,7 @@ void mp_media_next_audio(mp_media_t *m) audio.data[i] = f->data[i]; audio.samples_per_sec = f->sample_rate * m->speed / 100; - audio.speakers = convert_speaker_layout(f->ch_layout.nb_channels); + audio.speakers = convert_speaker_layout((uint8_t)f->ch_layout.nb_channels); audio.format = convert_sample_format(f->format); audio.frames = f->nb_samples; audio.timestamp = m->full_decode ? d->frame_pts diff --git a/shared/obs-inject-library/inject-library-windows.c.h b/shared/obs-inject-library/inject-library-windows.c.h index ee75a36885..ffcbd9c422 100644 --- a/shared/obs-inject-library/inject-library-windows.c.h +++ b/shared/obs-inject-library/inject-library-windows.c.h @@ -14,7 +14,7 @@ int inject_library_obf(HANDLE process, const wchar_t *dll, const char *create_re int ret = INJECT_ERROR_UNLIKELY_FAIL; DWORD last_error = 0; bool success = false; - size_t written_size; + SIZE_T written_size; DWORD thread_id; HANDLE thread = NULL; size_t size; diff --git a/shared/obs-scripting/obslua/CMakeLists.txt b/shared/obs-scripting/obslua/CMakeLists.txt index 170132e06e..326de8e8ea 100644 --- a/shared/obs-scripting/obslua/CMakeLists.txt +++ b/shared/obs-scripting/obslua/CMakeLists.txt @@ -26,6 +26,10 @@ target_compile_options( $<$:/wd4197> $<$:/wd4244> $<$:/wd4267> + # MSVC /W4 (#2626): the wrapper also leaves its IStream-style parameters + # unreferenced (C4100) and declares locals only to convert them (C4189). + $<$:/wd4100> + $<$:/wd4189> $<$:-Wno-shorten-64-to-32> $<$:-Wno-unreachable-code> $<$:-Wno-maybe-uninitialized> diff --git a/shared/properties-view/properties-view.cpp.hpp b/shared/properties-view/properties-view.cpp.hpp index 0463aeec01..f4192a26be 100644 --- a/shared/properties-view/properties-view.cpp.hpp +++ b/shared/properties-view/properties-view.cpp.hpp @@ -218,16 +218,16 @@ void OBSPropertiesView::resizeEvent(QResizeEvent *event) } template -QWidget *OBSPropertiesView::NewWidget(obs_property_t *prop, Sender *widget, void (SenderParent::*signal)(Args...)) +QWidget *OBSPropertiesView::NewWidget(obs_property_t *prop, Sender *widget_ptr, void (SenderParent::*signal)(Args...)) { const char *long_desc = obs_property_long_description(prop); - WidgetInfo *info = new WidgetInfo(this, prop, widget); - QObject::connect(widget, signal, info, &WidgetInfo::ControlChanged); + WidgetInfo *info = new WidgetInfo(this, prop, widget_ptr); + QObject::connect(widget_ptr, signal, info, &WidgetInfo::ControlChanged); children.emplace_back(info); - widget->setToolTip(QT_UTF8(long_desc)); - return widget; + widget_ptr->setToolTip(QT_UTF8(long_desc)); + return widget_ptr; } QWidget *OBSPropertiesView::AddCheckbox(obs_property_t *prop) @@ -240,10 +240,10 @@ QWidget *OBSPropertiesView::AddCheckbox(obs_property_t *prop) QCheckBox *checkbox = new QCheckBox(QT_UTF8(desc)); checkbox->setCheckState(val ? Qt::Checked : Qt::Unchecked); - QWidget *widget = NewWidget(prop, checkbox, &QCheckBox::checkStateChanged); + QWidget *widget_ptr = NewWidget(prop, checkbox, &QCheckBox::checkStateChanged); if (!long_desc) { - return widget; + return widget_ptr; } QString file = !obs_frontend_is_theme_dark() ? ":/res/images/help.svg" : ":/res/images/help_light.svg"; @@ -254,17 +254,17 @@ QWidget *OBSPropertiesView::AddCheckbox(obs_property_t *prop) qt_platform::tweak_checkbox(checkbox); - widget = new QWidget(); - QHBoxLayout *layout = new QHBoxLayout(widget); + widget_ptr = new QWidget(); + QHBoxLayout *layout = new QHBoxLayout(widget_ptr); layout->setContentsMargins(0, 0, 0, 0); layout->setAlignment(Qt::AlignLeft); layout->setSpacing(0); layout->addWidget(checkbox); layout->addWidget(help); - widget->setLayout(layout); + widget_ptr->setLayout(layout); - return widget; + return widget_ptr; } QWidget *OBSPropertiesView::AddText(obs_property_t *prop, QFormLayout *layout, QLabel *&label) @@ -272,15 +272,15 @@ QWidget *OBSPropertiesView::AddText(obs_property_t *prop, QFormLayout *layout, Q const char *name = obs_property_name(prop); const char *val = obs_data_get_string(settings, name); bool monospace = obs_property_text_monospace(prop); - obs_text_type type = obs_property_text_type(prop); + obs_text_type text_type = obs_property_text_type(prop); - if (type == OBS_TEXT_MULTILINE) { + if (text_type == OBS_TEXT_MULTILINE) { OBSPlainTextEdit *edit = new OBSPlainTextEdit(this, monospace); edit->setPlainText(QT_UTF8(val)); edit->setTabStopDistance(40); return NewWidget(prop, edit, &OBSPlainTextEdit::textChanged); - } else if (type == OBS_TEXT_PASSWORD) { + } else if (text_type == OBS_TEXT_PASSWORD) { QLayout *subLayout = new QHBoxLayout(); QLineEdit *edit = new QLineEdit(); QPushButton *show = new QPushButton(); @@ -306,7 +306,7 @@ QWidget *OBSPropertiesView::AddText(obs_property_t *prop, QFormLayout *layout, Q connect(edit, &QLineEdit::textEdited, info, &WidgetInfo::ControlChanged); return nullptr; - } else if (type == OBS_TEXT_INFO) { + } else if (text_type == OBS_TEXT_INFO) { QString desc = QT_UTF8(obs_property_description(prop)); const char *long_desc = obs_property_long_description(prop); obs_text_info_type info_type = obs_property_text_info_type(prop); @@ -391,7 +391,7 @@ void OBSPropertiesView::AddPath(obs_property_t *prop, QFormLayout *layout, QLabe void OBSPropertiesView::AddInt(obs_property_t *prop, QFormLayout *layout, QLabel **label) { - obs_number_type type = obs_property_int_type(prop); + obs_number_type int_type = obs_property_int_type(prop); QLayout *subLayout = new QHBoxLayout(); const char *name = obs_property_name(prop); @@ -415,7 +415,7 @@ void OBSPropertiesView::AddInt(obs_property_t *prop, QFormLayout *layout, QLabel WidgetInfo *info = new WidgetInfo(this, prop, spin); children.emplace_back(info); - if (type == OBS_NUMBER_SLIDER) { + if (int_type == OBS_NUMBER_SLIDER) { QSlider *slider = new SliderIgnoreScroll(); slider->setMinimum(minVal); slider->setMaximum(maxVal); @@ -439,7 +439,7 @@ void OBSPropertiesView::AddInt(obs_property_t *prop, QFormLayout *layout, QLabel void OBSPropertiesView::AddFloat(obs_property_t *prop, QFormLayout *layout, QLabel **label) { - obs_number_type type = obs_property_float_type(prop); + obs_number_type float_type = obs_property_float_type(prop); QLayout *subLayout = new QHBoxLayout(); const char *name = obs_property_name(prop); @@ -473,7 +473,7 @@ void OBSPropertiesView::AddFloat(obs_property_t *prop, QFormLayout *layout, QLab WidgetInfo *info = new WidgetInfo(this, prop, spin); children.emplace_back(info); - if (type == OBS_NUMBER_SLIDER) { + if (float_type == OBS_NUMBER_SLIDER) { DoubleSlider *slider = new DoubleSlider(); slider->setDoubleConstraints(minVal, maxVal, stepVal, val); slider->setOrientation(Qt::Horizontal); @@ -588,13 +588,13 @@ static QVariant from_obs_data_autoselect(obs_data_t *data, const char *name, obs QWidget *OBSPropertiesView::AddList(obs_property_t *prop, bool &warning) { const char *name = obs_property_name(prop); - obs_combo_type type = obs_property_list_type(prop); + obs_combo_type combo_type = obs_property_list_type(prop); obs_combo_format format = obs_property_list_format(prop); size_t count = obs_property_list_item_count(prop); QVariant value = from_obs_data(settings, name, format); - if (type == OBS_COMBO_TYPE_RADIO) { + if (combo_type == OBS_COMBO_TYPE_RADIO) { QButtonGroup *buttonGroup = new QButtonGroup(); QFormLayout *subLayout = new QFormLayout(); subLayout->setContentsMargins(0, 0, 0, 0); @@ -610,9 +610,9 @@ QWidget *OBSPropertiesView::AddList(obs_property_t *prop, bool &warning) connect(buttonGroup, &QButtonGroup::buttonClicked, info, &WidgetInfo::ControlChanged); } - QWidget *widget = new QWidget(); - widget->setLayout(subLayout); - return widget; + QWidget *widget_ptr = new QWidget(); + widget_ptr->setLayout(subLayout); + return widget_ptr; } int idx = -1; @@ -622,20 +622,20 @@ QWidget *OBSPropertiesView::AddList(obs_property_t *prop, bool &warning) AddComboItem(combo, prop, i); } - if (type == OBS_COMBO_TYPE_EDITABLE) { + if (combo_type == OBS_COMBO_TYPE_EDITABLE) { combo->setEditable(true); } combo->setMaxVisibleItems(40); combo->setToolTip(QT_UTF8(obs_property_long_description(prop))); - if (format == OBS_COMBO_FORMAT_STRING && type == OBS_COMBO_TYPE_EDITABLE) { + if (format == OBS_COMBO_FORMAT_STRING && combo_type == OBS_COMBO_TYPE_EDITABLE) { combo->lineEdit()->setText(value.toString()); } else { idx = combo->findData(value); } - if (type == OBS_COMBO_TYPE_EDITABLE) { + if (combo_type == OBS_COMBO_TYPE_EDITABLE) { return NewWidget(prop, combo, &QComboBox::editTextChanged); } @@ -1372,30 +1372,30 @@ void OBSPropertiesView::AddFrameRate(obs_property_t *prop, bool &warning, QFormL int selector_mode = obs_data_get_int(settings, "fps_selector_mode"); - auto widget = CreateFrameRateWidget(prop, warning, option, selector_mode, valid_fps, fps_ranges); - auto info = new WidgetInfo(this, prop, widget); + auto widget_ptr = CreateFrameRateWidget(prop, warning, option, selector_mode, valid_fps, fps_ranges); + auto info = new WidgetInfo(this, prop, widget_ptr); - widget->setToolTip(QT_UTF8(obs_property_long_description(prop))); + widget_ptr->setToolTip(QT_UTF8(obs_property_long_description(prop))); - widget->name = name; - widget->settings = settings; + widget_ptr->name = name; + widget_ptr->settings = settings; - widget->modeSelect->setEnabled(enabled); - widget->simpleFPS->setEnabled(enabled); - widget->fpsRange->setEnabled(enabled); - widget->numEdit->setEnabled(enabled); - widget->denEdit->setEnabled(enabled); + widget_ptr->modeSelect->setEnabled(enabled); + widget_ptr->simpleFPS->setEnabled(enabled); + widget_ptr->fpsRange->setEnabled(enabled); + widget_ptr->numEdit->setEnabled(enabled); + widget_ptr->denEdit->setEnabled(enabled); - label = widget->warningLabel = new QLabel{obs_property_description(prop)}; + label = widget_ptr->warningLabel = new QLabel{obs_property_description(prop)}; - layout->addRow(label, widget); + layout->addRow(label, widget_ptr); children.emplace_back(info); - UpdateFPSLabels(widget); + UpdateFPSLabels(widget_ptr); - auto stack = widget->modeDisplay; - auto combo = widget->modeSelect; + auto stack = widget_ptr->modeDisplay; + auto combo = widget_ptr->modeSelect; stack->setToolTip(QT_UTF8(obs_property_long_description(prop))); combo->setToolTip(QT_UTF8(obs_property_long_description(prop))); @@ -1405,40 +1405,40 @@ void OBSPropertiesView::AddFrameRate(obs_property_t *prop, bool &warning, QFormL auto idx = out_of_bounds ? stack->count() - 1 : index; stack->setCurrentIndex(idx); - if (widget->updating) { + if (widget_ptr->updating) { return; } - UpdateFPSLabels(widget); + UpdateFPSLabels(widget_ptr); emit info->ControlChanged(); }); - connect(widget->simpleFPS, &QComboBox::currentIndexChanged, info, [=](int) { - if (widget->updating) { + connect(widget_ptr->simpleFPS, &QComboBox::currentIndexChanged, info, [=](int) { + if (widget_ptr->updating) { return; } emit info->ControlChanged(); }); - connect(widget->fpsRange, &QComboBox::currentIndexChanged, info, [=](int) { - if (widget->updating) { + connect(widget_ptr->fpsRange, &QComboBox::currentIndexChanged, info, [=](int) { + if (widget_ptr->updating) { return; } - UpdateFPSLabels(widget); + UpdateFPSLabels(widget_ptr); }); - connect(widget->numEdit, &QSpinBox::valueChanged, info, [=](int) { - if (widget->updating) { + connect(widget_ptr->numEdit, &QSpinBox::valueChanged, info, [=](int) { + if (widget_ptr->updating) { return; } emit info->ControlChanged(); }); - connect(widget->denEdit, &QSpinBox::valueChanged, info, [=](int) { - if (widget->updating) { + connect(widget_ptr->denEdit, &QSpinBox::valueChanged, info, [=](int) { + if (widget_ptr->updating) { return; } @@ -1451,11 +1451,11 @@ void OBSPropertiesView::AddGroup(obs_property_t *prop, QFormLayout *layout) const char *name = obs_property_name(prop); bool val = obs_data_get_bool(settings, name); const char *desc = obs_property_description(prop); - enum obs_group_type type = obs_property_group_type(prop); + enum obs_group_type group_type = obs_property_group_type(prop); // Create GroupBox QGroupBox *groupBox = new QGroupBox(QT_UTF8(desc)); - groupBox->setCheckable(type == OBS_GROUP_CHECKABLE); + groupBox->setCheckable(group_type == OBS_GROUP_CHECKABLE); groupBox->setChecked(groupBox->isCheckable() ? val : true); groupBox->setAccessibleName("group"); groupBox->setEnabled(obs_property_enabled(prop)); @@ -1486,21 +1486,21 @@ void OBSPropertiesView::AddGroup(obs_property_t *prop, QFormLayout *layout) void OBSPropertiesView::AddProperty(obs_property_t *property, QFormLayout *layout) { const char *name = obs_property_name(property); - obs_property_type type = obs_property_get_type(property); + obs_property_type prop_type = obs_property_get_type(property); if (!obs_property_visible(property)) { return; } QLabel *label = nullptr; - QWidget *widget = nullptr; + QWidget *widget_ptr = nullptr; bool warning = false; - switch (type) { + switch (prop_type) { case OBS_PROPERTY_INVALID: return; case OBS_PROPERTY_BOOL: - widget = AddCheckbox(property); + widget_ptr = AddCheckbox(property); break; case OBS_PROPERTY_INT: AddInt(property, layout, &label); @@ -1509,13 +1509,13 @@ void OBSPropertiesView::AddProperty(obs_property_t *property, QFormLayout *layou AddFloat(property, layout, &label); break; case OBS_PROPERTY_TEXT: - widget = AddText(property, layout, label); + widget_ptr = AddText(property, layout, label); break; case OBS_PROPERTY_PATH: AddPath(property, layout, &label); break; case OBS_PROPERTY_LIST: - widget = AddList(property, warning); + widget_ptr = AddList(property, warning); break; case OBS_PROPERTY_COLOR: AddColor(property, layout, label); @@ -1524,7 +1524,7 @@ void OBSPropertiesView::AddProperty(obs_property_t *property, QFormLayout *layou AddFont(property, layout, label); break; case OBS_PROPERTY_BUTTON: - widget = AddButton(property); + widget_ptr = AddButton(property); break; case OBS_PROPERTY_EDITABLE_LIST: AddEditableList(property, layout, label); @@ -1539,11 +1539,12 @@ void OBSPropertiesView::AddProperty(obs_property_t *property, QFormLayout *layou AddColorAlpha(property, layout, label); } - if (!widget && !label) { + if (!widget_ptr && !label) { return; } - if (!label && type != OBS_PROPERTY_BOOL && type != OBS_PROPERTY_BUTTON && type != OBS_PROPERTY_GROUP) { + if (!label && prop_type != OBS_PROPERTY_BOOL && prop_type != OBS_PROPERTY_BUTTON && + prop_type != OBS_PROPERTY_GROUP) { label = new QLabel(QT_UTF8(obs_property_description(property))); } @@ -1562,12 +1563,12 @@ void OBSPropertiesView::AddProperty(obs_property_t *property, QFormLayout *layou } } - if (!widget) { + if (!widget_ptr) { return; } if (!obs_property_enabled(property)) { - widget->setEnabled(false); + widget_ptr->setEnabled(false); } QWidget *leftWidget = label; @@ -1591,11 +1592,11 @@ void OBSPropertiesView::AddProperty(obs_property_t *property, QFormLayout *layou leftWidget = newWidget; } - layout->addRow(leftWidget, widget); + layout->addRow(leftWidget, widget_ptr); if (!lastFocused.empty()) { if (lastFocused.compare(name) == 0) { - lastWidget = widget; + lastWidget = widget_ptr; } } } diff --git a/test/cmocka/CMakeLists.txt b/test/cmocka/CMakeLists.txt index f53f4d3a4f..5a0223d5aa 100644 --- a/test/cmocka/CMakeLists.txt +++ b/test/cmocka/CMakeLists.txt @@ -67,6 +67,42 @@ add_compile_options($<$:-Wno-strict- # tests (obs-rust/obs-studio#516, #2842). The macOS CI preset builds with # CMAKE_COMPILE_WARNING_AS_ERROR, so without this the lane does not compile. add_compile_options($<$:-Wno-comma>) +# The MSVC /W4 set (obs-rust/obs-studio#2626) needs the same split, and for the +# same reason: these are existing C tests, never edited to satisfy a new +# warning (obs-rust/obs-studio#516), and several of them compile libobs / +# libobs-rust sources into their own executable, so the classes the /W4 level +# adds are reported against them rather than against product code. +# C4132 a const struct the test fills in field by field +# C4201 the nameless unions in libobs/graphics/vec{2,3,4}.h and +# libobs/util/profiler.h (an API change, not a test bug) +# C4244/C4245 uint32 -> uint16 and int -> SOCKET in their fixtures, and the +# librtmp sources some of them compile +# C4310 constant truncation in their tables +# C4456/C4459 a test helper or local shadowing an outer local/global +# C4702 the non-returning uthash_fatal path at the end of every HASH_* block +# (the reason libobs-objects carries /wd4702 as well) +# C4206/C4706 the vendored librtmp classes (empty unity TU, assignment used as +# a condition); these tests compile librtmp into their own executable, +# the same reason C4244/C4245 are listed. The product target's own +# handling is a separate decision: the Visual Studio generator ignores +# its per-source COMPILE_OPTIONS. +add_compile_options( + $<$:/wd4132> + $<$:/wd4201> + $<$:/wd4206> + $<$:/wd4244> + $<$:/wd4245> + $<$:/wd4310> + $<$:/wd4456> + $<$:/wd4459> + $<$:/wd4702> + $<$:/wd4706> +) +# C4201 reaches the tests through C++ TUs too: several test executables compile +# frontend *.cpp sources against the libobs headers, and the nameless structs in +# libobs/graphics/vec{2,3,4}.h and libobs/util/profiler.h are a nonstandard C++ +# extension (C11 6.7.2.1p13 is what makes them legal C). +add_compile_options($<$:/wd4201>) # Per-test sanitizers (obs-rust/obs-studio#159). Some tests compile the code # they check with ASan/UBSan so a bug fails the test. Those flags are added