Skip to content

facade: libobs/obs.c: move 8 platform conditionals into obs-<os> files #868

Closed

Description

@zackees

Part of #847.

NV12 encode staging surfaces (Windows), macOS QoS thread attributes and COM init/uninit are inline in obs.c.

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

file:line macro branch class proposed function / target
libobs/obs.c:375 _WIN32 create NV12 stage surfaces for encoding when using_nv12_tex a obs_video_platform_init_surfaces(video, info) in obs-windows.c
libobs/obs.c:445 _WIN32 destroy copy_surfaces_encode on init failure a obs_video_platform_free_surfaces(video)
libobs/obs.c:746 __APPLE__ pthread attr with QOS_CLASS_USER_INTERACTIVE for graphics thread a obs_platform_graphics_thread_attr(pthread_attr_t*) in obs-cocoa.m
libobs/obs.c:804 _WIN32 destroy copy_surfaces_encode at video shutdown a same obs_video_platform_free_surfaces
libobs/obs.c:1337 _WIN32 decl initialize_com/uninitialize_com + com_initialized static a move to obs-windows.c; expose obs_platform_init()/obs_platform_shutdown()
libobs/obs.c:1400 _WIN32 com_initialized = initialize_com() at startup a call obs_platform_init() (nix/mac stub returns true)
libobs/obs.c:1409 _WIN32 uninitialize COM on startup failure path a call obs_platform_shutdown()
libobs/obs.c:1552 _WIN32 uninitialize COM at obs_shutdown a call obs_platform_shutdown()

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 Linux, Rust OFF/ON); Windows/macOS via native builds (ci-full). Facade has no-op defaults on other OSes.

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.c facade.

    Plan (one PR, ci-full), using the existing per-OS files (obs-windows.c, obs-nix.c, obs-cocoa.m) and declaring the hooks in obs-internal.h:

    1. obs_video_host_init_surfaces(video) / obs_video_host_free_surfaces(video): the Windows NV12 encode staging surfaces (creation at :375, cleanup at :445 and :804); no-ops elsewhere.
    2. obs_host_graphics_thread_attr(pthread_attr_t *): macOS QOS_CLASS_USER_INTERACTIVE (:746); returns NULL attr elsewhere so pthread_create keeps today's defaults.
    3. obs_host_startup() / obs_host_shutdown(): COM init/uninit with the com_initialized state moved into obs-windows.c (:1337, :1400, :1409, :1552); stubs elsewhere.
      Behavior-preserving; obs.c leaves the ci: ratchet lint for platform conditionals in shared C/C++ (#847 step 1) #848 baseline. Naming follows Rename platform folders and files to hosts/{windows,macos,linux,posix} (match the Rust layout) #1009 ("host"). Tests: existing libobs cmocka on Tier 2 (OFF/ON) plus ci-full for Windows/macOS.
  2. added
    claimed
    on Oct 16, 2026
  3. zackees commented on Oct 16, 2026

    @zackees
    MemberAuthor

    Done by #1069 (libobs/obs-host/): obs.c has no platform conditionals left (only #ifndef SEC_TO_MSEC), and it is out of the #848 baseline. My duplicate #1071 is closed. Nothing left here.

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

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions