Skip to content

rust: Port libobs/obs-hotkey-background-state.c.h to obs-hotkey #5259

Closed

Description

@zackees

Phase 6, stateful libobs core / obs-hotkey. Depends on prerequisite #5255 and its C-only extraction branch test/5255-hotkey-background-state at 9028566f07400aa6ce008b993dcfb885f05cc29e. Publication is BRANCH-ONLY because ci/backpressure.py returned 75; the prerequisite PR must be published and merged before this swap starts. Start after that prerequisite lands; this issue is the separate Rust swap.

The extracted unit is libobs/obs-hotkey-background-state.c.h, containing obs_hotkeys_get_background_state. The new test_hotkey_background_state C characterization records locking/unlocking and global-core reads, and covers every declared state, an unknown enum, unknown flag bits, failed locking and NULL output. Preserve this test unchanged; compile its external mode against the Rust entry point with real adapter sources and recording support.

Preserve the exact ordering: clear non-NULL flags before attempting the existing C-owned lock; failed locking returns NATIVE, with no unlock or background-field access; success captures the exact state and optional flags while locked, unlocks exactly once, and returns the captured enum. Keep unknown enum values and all flag bits. No new mutex, eager access to the C-owned global, public-header edits or edits to existing C tests.

Implement safe Rust orchestration in obs-hotkey and thin FFI, retaining narrow real C field/lock adapters. Add Tier 1 cases and original-C Tier 3 differential/oracle coverage in the existing Core state obs-tests-core binary, with RED then GREEN and a mutation check. Preserve dual-library Tier 2 and symbol parity. The C-only characterization currently includes the extracted source; use its external-mode seam for the Rust swap rather than changing assertions. Wire every affected native fixture and expected inventory.

Hazards: rust/obs-hotkey/src/ffi/background_query.rs already imports/calls the C query, and background_query_parity.rs defines an exact-name fake. Isolate that fake deliberately when the real Rust symbol is introduced. Before publication, build EVERY Linux cmocka *_rust target with real adapter support; run Windows MSVC linking and a separate Darwin check if Windows fails. Prove Darwin bindings with the Mach-O symbol/import table where a fake or adapter is involved (#5226); do not let two-level namespace silently select libobs instead of recording support. Preserve C-owned core/mutex behavior and the compatibility APIs. Tier 4 does not apply to this non-network wrapper.

Prerequisite validation: 322 native_build tests; deterministic C-source characterization against the original body; focused Linux Tier 2 with all eleven affected unchanged suites, every one of the 65 *_rust targets and identical 1,769-symbol libraries; Windows/Darwin hybrid and Rust-static links plus explicit new C fixture links. Native Windows/macOS execution and the complete cmocka suite remain hosted validation, not a claim from these Linux-hosted links.

Activity

  1. added
    enhancement
    port
    ready
    P2
    size:S
    on Nov 19, 2026
  2. zackees commented on Nov 19, 2026

    @zackees
    MemberAuthor

    Claiming: port the extracted hotkey background state query in pool slot obs-studio5. 1. Commit RED safe-core tests, then implement the Rust orchestration and real C lock/field adapters while preserving the existing characterization unchanged. 2. Add original-C differential coverage and verify all Rust-static consumers on Linux/MSVC/Darwin, including binding evidence. 3. Check overlapping PR merge trees, run final lint and publish a READY PR or branch-only according to backpressure. First publication expected this session; prerequisite #5263 is merged.

  3. rdoupe commented on Nov 20, 2026

    @rdoupe
    Collaborator

    Heads-up for whoever takes this: #5325 (the obs_hotkey_combination_get_background_id swap) removed the exact-name fake of that getter from rust/obs-hotkey/tests/hotkey/background_query_parity.rs. The file still defines an exact-name fake of obs_hotkeys_get_background_state, which will collide with the real Rust symbol once this swap lands, so it needs the same treatment here.

  4. rdoupe commented on Nov 20, 2026

    @rdoupe
    Collaborator

    Claiming: Rust swap of obs_hotkeys_get_background_state on branch port/5259-hotkey-background-state (the previous claim lapsed with no PR or branch).

    1. RED: Tier 1 safe-core tests against a stub, and wire test_hotkey_background_state's external mode to the Rust entry point.
    2. GREEN: safe Rust orchestration in obs-hotkey with the C lock/field adapters kept; drop the exact-name fake of obs_hotkeys_get_background_state from background_query_parity.rs the way obs-hotkey: swap hotkey-combination background-id query to safe Rust (Refs #5288) #5325 did for the combination getter; original-C Tier 3 differential in the Core state binary; C kept only in the reference group.
    3. One PR, draft once RED exists, expected this session.
  5. rdoupe commented on Nov 21, 2026

    @rdoupe
    Collaborator

    Done in #5371 (merged 2026-11-20): obs_hotkeys_get_background_state now runs through safe Rust in obs-hotkey; the C unit stays as its reference-only ported group and the master push run is green.

  6. moved this from In progress to Done in obs-rust Multiviewon Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2enhancementportreadysize:S

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions