Skip to content

obs-output: port the obs-service lifecycle, references and activation (#1920) - #1923

Merged
zackees merged 4 commits into
masterfrom
port/1920-service-lifecycle
Oct 23, 2026
Merged

zackees merged 4 commits into
masterfrom
port/1920-service-lifecycle

Conversation

@zackees

@zackees zackees commented Oct 23, 2026

Copy link
Copy Markdown
Member

Refs #1920 (#1846 unit 8, slice 3, the last). Stacked on #1916 (base port/1913-service-settings); Tier 2 is #1921.

Commits

What moved

  • C side: obs_service_get_module, _load_state, _create, _create_private, _destroy, _activate, _deactivate, _initialize, _release, _get_ref, _get_weak_service, and obs_weak_service_get_service / _addref / _release / _references_service move into obs-service-getters.c.h (the ported group).
  • What stays in obs-service.c.h: struct obs_service, its context (obs_context_data_init/insert/remove/free, obs_context_init_control) and the reference counts (obs_ref_*, obs_weak_ref_*, which are static inlines). They sit behind 25 hidden obs_service_*() / obs_weak_service_*() steps, declared in obs-internal.h. The moved C and the Rust shims call the same steps, so the struct layout stays private to C.
  • What the port keeps from the C:
    • destroy is deferred while active, and deactivate frees it;
    • release order: destroy first, then the control's weak ref;
    • the log lines, including activation's "obs_service_deactivate: …" warning (characterized, not endorsed);
    • a create() that returns NULL still yields a service.
  • Exports: the 11 public names go in the fragment. obs_service_destroy, _activate, _deactivate and _initialize have no EXPORT in C, so they are hidden: rust-hidden.txt, rust-exports.map, rust-unexports-macos.txt.
  • Still C: obs_service_get_signal_handler and _get_proc_handler (no public prototype, see rust: Port the obs-service settings, properties and identity functions to obs-output (#1846 unit 8, slice 2) #1913), plus the context and refcount primitives above. Nothing else.

Tiers

  • Tier 1: 14 cases. They pin every call's order through a traced fake.
  • Tier 2: test_service_lifecycle (test: characterize the obs-service lifecycle and references (#1920) #1921), the public half. activate/deactivate/initialize have no public entry.
  • Tier 3: service_lifecycle_parity.rs runs the C oracle and the Rust shims over the same test doubles.
    • Inputs: all 8 tables of the 3 optional callbacks, a failing and a succeeding create(), and both initialize() results.
    • Each run covers unknown type, failed context, public and private create, refs through the last release, weak refs after the service is gone, activation, initialization and a deferred destroy.
    • It compares the full step and plugin-call trace and the results. It also checks that both frees are reached.
    • Module lookups are compared over 4 list shapes.
    • Mutation check: swapping the release order in Rust fails both Tier 1 and Tier 3.
    • The slice 2 parity test and this one now share one lock (SERVICE_GLOBALS in tests/output/main.rs), because find_service() and the trace hook are process-wide.
  • Tier 4: not applicable.
  • Local runs: soldr cargo test -p obs-data --test obs-tests-core service passes (35 passed). obs-util's export-list tests pass. ./lint passes. obs-service.c.h and obs-service-getters.c.h pass gcc -fsyntax-only -Wall -Wextra -Wcast-qual -Werror.

port_comparison (Rust / C, over the oracle doubles)

bench Rust C
get_ref + release 11.04 ns 10.89 ns
weak_get_service + release 10.59 ns 10.54 ns
activate + deactivate 13.62 ns 13.94 ns
load_state (2 modules) 25.88 ns 23.65 ns

Not user-visible, so there is no features.md line.

@zackees
zackees force-pushed the port/1920-service-lifecycle branch from d6b8365 to 9576fe5 Compare October 23, 2026 09:56
@zackees
zackees changed the base branch from port/1913-service-settings to master October 23, 2026 10:41
@zackees
zackees enabled auto-merge October 23, 2026 10:41
@zackees
zackees force-pushed the port/1920-service-lifecycle branch from 9576fe5 to 6b5c1de Compare October 23, 2026 10:42
@zackees

zackees commented Oct 23, 2026

Copy link
Copy Markdown
Member Author

Coordinator: #1916 landed. I retargeted this PR to master and rebased only its own four commits onto master (git rebase --onto origin/master <fork point>). The export-list tests pass locally. Auto-merge is on.

@zackees
zackees force-pushed the port/1920-service-lifecycle branch from 6b5c1de to 4e8a33f Compare October 23, 2026 10:46
@zackees zackees closed this Oct 23, 2026
auto-merge was automatically disabled October 23, 2026 10:46

Pull request was closed

@zackees zackees reopened this Oct 23, 2026
14 Tier 1 cases for create, destroy (deferred while active), release,
strong and weak refs, module lookup and activate/deactivate/initialize,
against todo!() stubs. All 14 fail: not yet implemented: #1920.
create, destroy, release, the strong and weak ref functions, the module
lookups and activate/deactivate/initialize in the C's order of calls.
GREEN for Tier 1: 14 passed.
… the obs-output port (#1920)

Moves obs_service_get_module, _load_state, _create, _create_private,
_destroy, _activate, _deactivate, _initialize, _release and the strong and
weak reference functions into obs-service-getters.c.h. struct obs_service,
its context and its reference counts stay in obs-service.c.h behind hidden
obs_service_*() / obs_weak_service_*() steps, which the Rust shims and the
moved C both call. The 11 public names are exported; the 4 internal ones are
hidden like the C. Tier 3 runs both sides over every callback table, a
failing create() and both initialize() results, comparing results and the
step and plugin-call trace, plus the module lookups. GREEN: Tier 1 and
Tier 3 pass.
get_ref+release 11.04 / 10.89 ns, weak_get_service+release 10.59 /
10.54 ns, activate+deactivate 13.62 / 13.94 ns, load_state 25.88 /
23.65 ns (Rust / C, over the oracle's doubles).
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.

1 participant