Skip to content

libobs: Move core host code behind obs-host/ capability interfaces (#1051) - #1069

Merged
zackees merged 2 commits into
masterfrom
infra/1051-libobs-host-facade
Oct 16, 2026
Merged

zackees merged 2 commits into
masterfrom
infra/1051-libobs-host-facade

Conversation

@zackees

@zackees zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member

Fixes #866. Refs #1051 (phase 4: drain host conditionals out of libobs core).

What

  • Each host capability the libobs core uses gets one interface, libobs/obs-host/<capability>.h, declared with OBS_HOST_EXTERN: plain extern with C linkage and no EXPORT, so it stays out of obs.dll's export table.
  • A host that has the capability defines it in its own OS file:
    • obs-windows.c: com, graphics-thread-hooks (WinRT and the message pump), shared-texture, module-symbols, display-clear-workaround.
    • obs-cocoa.m: graphics-thread (QoS and autorelease), module-paths, display-srgb-clear, default-monitoring-device.
  • A host that lacks it builds obs-host/noop/<capability>.c, listed in libobs/cmake/os-<os>.cmake, so no #ifdef picks between them.
  • obs.c, obs-video.c, obs-module.c, obs-display.c, obs-source.c, obs-video-gpu-encode.c and obs-internal.h now hold no host conditionals. The ratchet baseline goes from 478 to 448.
  • obs-hotkey.c keeps its one Apple conditional: two cmocka tests compile that file directly, and C tests aren't edited.

RED

677f5095f adds FacadeTest. It fails with 8 failures and 1 error: the core files still select on _WIN32/__APPLE__, and the facade doesn't exist yet.

GREEN

7ff93c40f. A new test checks every capability has a no-op, and that every os-<os>.cmake either builds the no-op or its host file defines the whole capability, never both.

Verified locally

  • Linux Tier 2 (rust/tools/linux-validate/run.sh): with ENABLE_RUST_LIBOBS OFF and ON, 256/256 cmocka tests pass, and the exported symbols are identical.
  • macOS arm64 and Windows x64 MSVC, cross-compiled from Linux with soldr's LLVM 21 and its cached SDKs (Apple 14.5, xwin):
    • All changed core files, the host file and each no-op compile cleanly.
    • With OBS's warning flags, the warnings are identical to origin/master's, so none are new.
  • The real Windows and macOS link happens in this PR's CI lanes.

obs.c, obs-video.c, obs-module.c, obs-display.c, obs-hotkey.c,
obs-source.c, obs-video-gpu-encode.c and obs-internal.h still select on
_WIN32/__APPLE__ (8 failures); libobs/obs-host.h doesn't exist (1 error).

Refs #1051
…1051)

Each host capability the libobs core uses gets one interface,
libobs/obs-host/<capability>.h, declared with OBS_HOST_EXTERN (plain
extern, C linkage, no EXPORT: libobs-internal, kept out of obs.dll's
export table). A host that has the capability defines it in its own file
(obs-windows.c: com, graphics-thread-hooks, shared-texture,
module-symbols, display-clear-workaround; obs-cocoa.m: graphics-thread,
module-paths, display-srgb-clear, default-monitoring-device). A host
that lacks it builds obs-host/noop/<capability>.c, listed in
libobs/cmake/os-<os>.cmake, so no #ifdef picks between them.

obs.c, obs-video.c, obs-module.c, obs-display.c, obs-source.c,
obs-video-gpu-encode.c and obs-internal.h now hold no host conditionals
(baseline 478 -> 448). copy_surfaces_encode is now a field on every host
(NULL unless Windows creates it); obs-internal.h is not installed.
initialize_com, uninitialize_com and reset_win32_symbol_paths become
static in obs-windows.c, and the macOS autorelease wrappers static in
obs-cocoa.m. obs-hotkey.c keeps its Apple keypad conditional: two cmocka
tests compile that file directly, and C tests are not edited, so it is
dropped from the RED list.

A new test checks every capability has a no-op and every host builds
either the no-op or a full definition, never both.

Fixes #866. Refs #1051
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

facade: libobs/obs-video.c: move 10 platform conditionals into obs-<os> files

1 participant