Skip to content

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

Closed

Description

@zackees

Part of #847.

Graphics-thread/NV12 shared-texture sync (D3D11 keyed mutex), WinRT capture init and the macOS autorelease loop live inline in the shared render loop.

Class totals: (a) movable 10, (b) stays - public header 0, (c) Rust-ported 0. Total: 10. Line numbers on origin/master.

file:line macro branch class proposed function / target
libobs/obs-video.c:27 _WIN32 include windows.h a drop; windows.h only needed for MSG/winrt, move with the functions into obs-windows.c
libobs/obs-video.c:471 _WIN32 gs_texture_acquire_sync on NV12 texture before reuse a obs_video_texture_acquire_sync(tf) (no-op on nix/mac) in obs-windows.c
libobs/obs-video.c:483 !_WIN32 non-D3D: copy Y and UV textures separately (D3D views share one texture) a obs_video_copy_planes_separately() returning bool; nix/mac return true, windows false
libobs/obs-video.c:504 _WIN32 record shared handle and release sync after texture copy a obs_video_texture_release_sync(tf) in obs-windows.c
libobs/obs-video.c:563 _WIN32 use video->copy_surfaces_encode, channel_count=1 a obs_video_select_encode_surfaces(...) hook in obs-windows.c
libobs/obs-video.c:976 _WIN32 struct winrt_exports + init_winrt_state/uninit_winrt_state (loads winrt-capture) a move block verbatim to obs-windows.c; declare obs_winrt_init/uninit in obs-internal.h
libobs/obs-video.c:1117 _WIN32 pump Win32 message queue (PeekMessage loop) in graphics thread a obs_graphics_thread_pump_events() in obs-windows.c; no-op elsewhere
libobs/obs-video.c:1165 _WIN32 init WinRT state at thread start a calls obs_winrt_init from the same facade
libobs/obs-video.c:1192 __APPLE__ run loop via obs_graphics_thread_loop_autorelease on macOS a obs_graphics_thread_run_loop(ctx) dispatcher: obs-cocoa.m wraps autorelease; obs-nix/windows call plain loop
libobs/obs-video.c:1199 _WIN32 uninit WinRT state at thread end a calls obs_winrt_uninit from the same facade

Classes: (a) movable behind per-platform files; (b) public-header ABI/export/type selection, stays; (c) already replaced by the Rust port (platform code isolated in src/platform/). Macro column abbreviates the #if expression; ! means negated, elif means an #elif line.

Test approach: Existing cmocka libobs tests (Tier 2, ENABLE_RUST_LIBOBS OFF/ON on Linux) cover the non-Windows path unchanged; Windows/macOS branches are mechanical moves covered by the native builds (ci-full label). Add a characterization test that the facade hooks are no-ops on Linux.

Each move is one function per facade entry, mechanical, so upstream merges stay manageable; the ratchet baseline (step 1) drops by the moved count.

Activity

  1. zackees commented on Oct 16, 2026

    @zackees
    MemberAuthor

    Claiming: libobs/obs-video.c facade. Starting on master once #1071 (#868, same per-OS files and obs-internal.h) has merged, to avoid a conflict.

    Plan (one PR, ci-full), hooks in obs-internal.h with implementations in obs-windows.c / obs-cocoa.m / obs-nix.c, following #1071's naming:

    • NV12 shared-texture keyed-mutex acquire/release around the copy (:471, :504) and whether Y/UV planes are copied separately (:483);
    • the encode-surface selection (:563), next to libobs: Move obs.c's host code into obs-windows.c, obs-cocoa.m and obs-nix.c #1071's encode-surface hooks;
    • WinRT state (:976 block moved verbatim, init/uninit at :1165/:1199) and the Win32 message pump (:1117) behind graphics-thread start/stop/tick hooks;
    • the macOS autorelease loop (:1192) behind obs_host_run_graphics_loop.
      Hot path, so each hook is a plain call with the same order of operations; Linux/FreeBSD versions are no-ops or the plain loop. Tests: full Tier 2 OFF/ON, native builds via ci-full.
  2. added
    claimed
    on Oct 16, 2026
  3. zackees commented on Oct 16, 2026

    @zackees
    MemberAuthor

    Releasing: #1069 already did this (obs-video.c has no platform conditionals on master); it closes this issue.

  4. removed
    claimed
    on Oct 16, 2026
  5. added a commit that references this issue on Oct 16, 2026
    436ebb6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions