Skip to content

facade: frontend/utility/*: move 18 platform conditionals behind frontend/utility/platform.hpp #883

Closed

Description

@zackees

Part of #847.

Inventory of platform conditionals in frontend/utility/* measured on origin/master. Total: 18.

Conditionals

File Line Macro What the branch does
AdvancedOutput.cpp 51 __APPLE__ translate_macvth264_encoder helper
AdvancedOutput.cpp 70 __APPLE__ apply translation to stream/record encoder ids
AdvancedOutput.cpp 724 _WIN32 read NewSocketLoop / LowLatency config
AdvancedOutput.cpp 742 _WIN32 apply new_socket_loop/low_latency to output settings
CrashHandler.cpp 79 _WIN32 localtime_s vs localtime_r
MissingFilesPathItemDelegate.cpp 140 __APPLE__ raise window (QTBUG-42661)
OBSProxyStyle.cpp 10 __APPLE__ SH_ComboBox_UseNativePopup style hint
RemuxEntryPathItemDelegate.cpp 190 __APPLE__ raise window (QTBUG-42661)
ScreenshotObj.cpp 28 _WIN32 include wincodec.h
ScreenshotObj.cpp 89 _WIN32 HDR extended colour space handling
ScreenshotObj.cpp 234 _WIN32 SaveJxrImage helper
ScreenshotObj.cpp 345 _WIN32 JXR save with wide-char path
SimpleOutput.cpp 727 _WIN32 read NewSocketLoop / LowLatency config
SimpleOutput.cpp 736 _WIN32 apply new_socket_loop/low_latency
WhatsNewInfoThread.cpp 29 __APPLE__ WHATSNEW_URL = MAC_WHATSNEW_URL
WhatsNewInfoThread.cpp 31 _WIN32 (elif) WHATSNEW_URL = WIN_WHATSNEW_URL
output-filename-reserve.c 8 _WIN32 include io.h vs unistd.h
output-filename-reserve.c 28 _WIN32 wide-char path open

Proposed facade operations

Declared in frontend/utility/platform.hpp; implemented in frontend/utility/platform-windows.cpp, platform-osx.mm, platform-x11.cpp (Linux/BSD). Names are proposals; one facade function per logical operation, moves kept small and mechanical so upstream merges stay manageable.

Facade function Implementation
platform_localtime (same single entry as the obs-main issue) windows / posix
platform_translate_encoder_id(const char *&) osx
platform_apply_output_network_options(config, settings) windows (de-duplicates AdvancedOutput/SimpleOutput)
platform_raise_dialog_window(QWidget*), platform_style_hint(...) osx
platform_save_jxr(path, pixels, ...), platform_hdr_screenshot_space(...) windows (ScreenshotObj)
platform_whatsnew_url() per platform
platform_reserve_file(path) for output-filename-reserve.c (C file: small extern "C" function in platform-*.cpp with a header the C file can include) windows / posix

Likely must stay / caveats

  • output-filename-reserve.c is plain C, so its facade function needs C linkage.
  • frontend/utility/platform.hpp itself has 4 platform conditionals (lines 27, 54, 62, 89) that guard Windows/mac-only declarations; these are the facade surface and can only be removed by declaring everything unconditionally with stubs in the other platforms' impls. Tracked here as a follow-up, not counted in this issue's N.

Test approach

Characterisation tests for platform_translate_encoder_id, platform_whatsnew_url, platform_reserve_file (temp-dir reservation test on each OS) and platform_localtime; ScreenshotObj JXR by ci-full.

RED first (failing characterisation test or facade stub), then GREEN, per docs/rust-port/testing-policy.md. Add the ci-full label since this touches shared frontend code built natively on all platforms.

Done when the listed files have no platform conditionals other than the documented exceptions, and the ratchet baseline (#848) is lowered accordingly.

Activity

  1. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Claiming: #883 (15 conditionals left on master), one small PR per facade operation:

    1. What's New URL (WhatsNewInfoThread.cpp.hpp, 2): the macOS and Windows obs_frontend_platform_whatsnew() macros set WHATSNEW_URL to their macro; the shared file keeps the three URLs and a plain default.
    2. platform_apply_output_network_options() (Simple/AdvancedOutput, 4).
    3. platform_translate_encoder_id() (AdvancedOutput, 2).
    4. platform_raise_dialog_window() and the style hint (3).
    5. output-filename-reserve (1, C linkage), then ScreenshotObj (3).

    Each PR is RED (ci/test_frontend_cmake_facade.py or a characterization test) then GREEN, with the ratchet baseline lowered. First PR today.

  2. added
    claimed
    on Oct 23, 2026
  3. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Progress: #1975 and #1976 merged; #1977, #1980 and #1984 are open (encoder ids, macOS dialog/style quirks, HDR screenshots). Together they cover 14 of the 15.

    Decision needed for the last one, output-filename-reserve.c.h (create_exclusive: _WIN32 _wopen vs POSIX open(O_EXCL), plus the matching <io.h>/<unistd.h> in its PCH). Moving it to hosts/{windows,posix}/ files means test_output_filename_reserve has to compile the host file too, which is an edit to test/cmocka/tests.d/test_output_filename_reserve.cmake (adding a source, no assertion change). Is that build-file edit OK under the "never edit existing C tests" rule? If not, I'd list this file in the ratchet's exceptions with the reason, and #883 closes with the facade done everywhere else.

  4. 7 remaining items

  5. moved this from In progress to Triage in obs-rust Multiviewon Oct 25, 2026
  6. removed
    claimed
    on Oct 25, 2026
  7. added
    P3
    size:M
    on Oct 25, 2026
  8. zackees commented on Oct 25, 2026

    @zackees
    MemberAuthor

    Decided: keep output-filename-reserve.c.h as it is and list it in ci/platform_ifdef_ratchet.py's exceptions with the reason; don't edit test/cmocka/tests.d/test_output_filename_reserve.cmake.
    Reasons:

    /ready: with the decision made, #883 closes once those three PRs and the exception land. P3, size:M.

  9. zackees commented on Oct 25, 2026

    @zackees
    MemberAuthor

    Correction: #1977, #1980 and #1984 were already merged (2026-10-23), not open as I wrote. So the only thing left here is the ratchet exception for output-filename-reserve.c.h decided above. Then this closes.

  10. zackees commented on Oct 25, 2026

    @zackees
    MemberAuthor

    /ready

  11. added
    ready
    on Oct 25, 2026
  12. zackees commented on Oct 25, 2026

    @zackees
    MemberAuthor

    Claiming: #883 (the ratchet exception for output-filename-reserve.c.h, as decided above).

  13. zackees commented on Oct 25, 2026

    @zackees
    MemberAuthor

    Closing #883. The decided exception can't be added as written, and isn't needed:

    • ci/platform_ifdef_ratchet.py accepts exceptions only for public headers. output-filename-reserve.c.h ends in .c.h, which is in IMPL_SUFFIXES, so load_exceptions rejects it ("not a header; only public headers get exceptions"). ci/platform-ifdef-exceptions.toml also says the list only shrinks.
    • The file is already held by ci/platform-ifdef-baseline.json (frontend/utility/output-filename-reserve.c.h: 1, and its PCH frontend-utility-output-filename-reserve.pch.h: 2). The ratchet fails if either count grows, so the decision "keep it as it is, don't edit the test's build file" is already enforced.

    The other 14 conditionals moved in #1975, #1976, #1977, #1980 and #1984. If the maintainer later allows adding a source to test/cmocka/tests.d/test_output_filename_reserve.cmake, the move can be its own issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3readysize:M

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions