Skip to content

libobs: Add the core-audio seam - #4048

Merged
rdoupe merged 2 commits into
masterfrom
fix/rust-port-add-the-core-audio-sea-690
Nov 8, 2026
Merged

rdoupe merged 2 commits into
masterfrom
fix/rust-port-add-the-core-audio-sea-690

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #4046

What and why

The core-audio seam that the port of the audio tick (libobs/obs-audio.c.h: the per-source helpers and audio_callback) needs, before that port. There is no Rust and no change in behaviour: it is new C in a new file, and nothing calls it yet.

audio_callback and its helpers read and change struct obs_core and struct obs_source directly. The port reaches the same fields through this seam, without the layouts of obs-internal.h ("Public and internal boundaries", testing-policy.md), as the transition ports reach theirs through obs-source-transition-seam.h. The plan to extract the tick helpers into their own file first was dropped: test_audio_buffering_subsample compiles obs-audio.c.h and calls them by name (the exception is recorded on the Phase 6 tracker, #444). So the helpers and audio_callback are ported together, after this seam.

libobs/obs-audio-seam.h declares the accessors, hidden in libobs (not EXPORT) like the transition seam's. Each is a single read, write, lock or container call, copied from the line of obs-audio.c.h it wraps:

  • the core audio (obs->audio): the output; render_order (num, get, da_find, da_push_back, da_resize(.., 0)) and root_nodes (num, get, push, clear); buffered_timestamps (push back, peek front, pop front of one struct ts_info); obs_audio_seam_get_buffering(), the struct obs_audio_buffering that audio_buffering() fills; fixed_buffer; buffering_wait_ticks get and set; monitoring_duplicating_source; and the task queue (task_mutex lock and unlock, the queue size, pop front of one struct obs_task_info);
  • the core data and video: first_audio_source and audio_sources_mutex; video.mixes_mutex, the mix count, a mix's view and mix_audio; a view's channels_mutex and its channels;
  • a source: next_audio_source; audio_buf_mutex; audio_is_duplicated and audio_pending, get and set; audio_ts; audio_input_buf[0].size; obs_audio_seam_source_get_input(), the struct obs_audio_input that audio_input() fills; info.type, info.output_flags and whether info.audio_render is set; audio_output_buf (the array itself, typed obs_audio_seam_output_row_t *, as obs_audio_mix_add() takes it); muted, volume, audio_mixers; and monitoring_enabled, an atomic load.

None checks its arguments or takes a lock of its own. The header comment lists the locks a caller takes around them, which are the ones obs-audio.c.h takes today. libobs/obs-audio-seam.c.h is live C in libobs.core-output, ahead of obs-audio.c.h in the group's sorted order. It stays live C, like the transition seam, and never moves into a ported group. libobs.pch.h includes the header with the other obs-audio.c headers, and source-sets.d/LIBOBS_SOURCES.json lists it. No C caller changes: obs-audio.c.h keeps its direct reads until the port replaces them.

test_audio_seam pins the seam. The accessors are hidden, so it builds the seam into itself, as test_source_transition_seam_calls does, and runs it on a stand-in core (obs, with only the fields the seam reads) and stand-in sources and views. It has 16 cases: each read against the field it wraps, each write read back, each lock holding its mutex (a trylock is refused) and each unlock letting it go, and the render order, root node, buffered timestamp and task queue calls against the da_* and deque_* calls they copy.

RED → GREEN

  • RED commit: 9f77dd6 (libobs: Stub the core-audio seam): the accessors are declared, and their bodies read, write and lock nothing. test_audio_seam fails 16/16 on the C and hybrid builds (test_output: (nil) != 0x…, test_render_order: 0 != 2, test_tasks and test_source_lock: the trylock under the lock succeeds, …).
  • GREEN: 6778f8f (libobs: Add the core-audio seam, the stamped head): each body copied from the line it wraps. Runs were on 907f3c2d1 (on master 731a4eb), then stamped as 6778f8f (same tree).
    • test_audio_seam passes 16/16 on the C and hybrid builds under ASan and UBSan, with no leaks (0/16 on the RED commit).
    • The audio, seam and transition-audio C tests (ctest -R 'audio|seam|transition_audio|scene_audio', under Xvfb, TMPDIR unset) pass on all three builds, none skipped: C 50/50, hybrid 58/58, libobs-c-reference 58/58 (rebuilt after the change, its mtime checked). test_audio_buffering_subsample, which compiles obs-audio.c.h and now sees the seam header through libobs.pch.h, passes on all three. test_source_monitor_only_load was left out: it hangs without a sound server, on the C build too.
    • The export sets of the C, hybrid and C reference builds are identical and unchanged (1767). All 53 accessors are local (t) in each.
    • Local gate lanes, before the rebase onto 731a4eb: --test-diff against the base (7295 tests passed, 6 skipped, the same on the RED commit), --lane lint, --lane dylint, --lane cross and the Windows --all-targets clippy (x86_64-pc-windows-msvc, -D warnings) pass.
    • After the rebase (the shared lists checked against master by hand: only this PR's lines), the C tests above pass again on all three builds, none skipped (C 50/50, hybrid 58/58, libobs-c-reference 58/58); the export sets are still identical (1767); ./lint, ./unittest (Rust 7313 and 914 tests, Tier 2 803/803 on hybrid libobs and libobs-c-reference), --lane lint, --lane dylint, --lane cross and the Windows --all-targets clippy pass. The port_comparison bench aborts in its service module, as on master (bug: obs-c-oracle: port_comparison service bench dereferences its stand-in output #3886, fixed by the open fix(obs-c-oracle): give the service bench a real stand-in output #3898); this PR touches no Rust.
    • Local gate, ci-lint local-gate run: lint, dylint, rust-test, cross and Tier 2 on Linux (tier2-linux) passed, and HEAD is stamped; the macOS and Windows native lanes do not apply on this host.
  • Real app (UI, protocol output or logging changes): N/A, no behaviour change.

Checklist

  • Base is master (or the description starts with a Stacked: note)
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits (N/A for docs-only; a focused CI fix may push RED and GREEN together). Here there is no characterization commit, because there is nothing to characterize. A characterization test pins the existing behaviour of a C unit that has no C test (coordination.md: "characterization test (if the unit had none)"; testing-policy.md, "Characterization tests for units without C tests"). The seam is new code with no C original: before the RED commit its functions don't exist, so no test of them could build, let alone pass. New code starts RED against stubs (obs-worker §3), so test_audio_seam lands with the stubs in 9f77dd6 and passes with the bodies in 6778f8f, as the transition seam's calls did (libobs: Add seam calls, move transition stop #3841). The fields it wraps keep their existing coverage: the audio C tests above, including test_audio_buffering_subsample, pass unchanged on all three builds.
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): built with scripting ON (PR CI builds no OBS app: run gh workflow run ci.yml --ref <branch> for the full builds) and cross-checked with clang and MSVC (not applicable)
  • Intentional differences from C listed in the parity test header and rust/README.md (ports) (not applicable: no port)

The audio tick (obs-audio.c) reads and changes struct obs_core and
struct obs_source directly. Its port needs a seam that reaches the same
fields without the layouts of obs-internal.h, as the transition ports
reach theirs through obs-source-transition-seam.h.

obs-audio-seam.h declares it, hidden in libobs like the transition
seam: the core audio (the output, render_order and root_nodes, the
buffered timestamps, the buffering fields, the monitoring duplicate and
the task queue), the core data and video (the audio source list, the
mixes and a view's channels, with their locks), and a source (the next
audio source, its buffer lock, the duplicate and pending flags, its
audio timestamp and input, its type, flags and audio_render, its output
buffers, and its mute, volume, mixers and monitoring state). Its header
comment lists the locks a caller takes around them, the ones
obs-audio.c takes today. obs-audio-seam.c is in libobs.core-output with
stub bodies that read, write and lock nothing.

test_audio_seam pins the seam. The accessors are hidden, so it builds
the seam into itself and runs it on a stand-in core and stand-in
sources and views. 16 cases: each read against the field it wraps,
each write read back, each lock holding its mutex and each unlock
letting it go, and the render order, root node, buffered timestamp and
task queue calls against the da_* and deque_* calls they copy. All 16
fail on the stubs.

Refs #4046.
The core-audio seam's accessors get their bodies, each a single read,
write, lock or container call copied from the line of obs-audio.c it
wraps, and named beside it:
- the core audio: obs->audio's output, render_order and root_nodes
  (num, get, da_find(), da_push_back(), da_resize(.., 0)),
  buffered_timestamps (deque_push_back(), deque_peek_front(),
  deque_pop_front() of one struct ts_info), the struct
  obs_audio_buffering audio_buffering() fills, fixed_buffer,
  buffering_wait_ticks, monitoring_duplicating_source and the task
  queue (task_mutex, tasks.size, deque_pop_front() of one
  struct obs_task_info);
- the core data and video: first_audio_source, audio_sources_mutex,
  video.mixes_mutex, the mix count and a mix's view and mix_audio, and
  a view's channels_mutex and channels;
- a source: next_audio_source, audio_buf_mutex, audio_is_duplicated,
  audio_pending, audio_ts, audio_input_buf[0].size, the struct
  obs_audio_input audio_input() fills, info.type, info.output_flags,
  whether info.audio_render is set, audio_output_buf, muted, volume,
  audio_mixers and monitoring_enabled (os_atomic_load_bool()).

No C caller changes: obs-audio.c keeps its direct reads until its port
replaces them. test_audio_seam passes 16/16 on the C and hybrid
builds, and the export sets of the C, hybrid and C reference builds
are unchanged, with the accessors local.

Fixes #4046.

Local-Gate: v1 tree=40433d0758fb24226e8d328e6c91dd371a79dcf5 secs=2241 lanes=lint:run,dylint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a
Ci-Attestation: {"at":1794166761,"gate":"rust/all/fmt","host":"linux-x86_64","key":"11edcd0f4e6ec735412bc145cb65de9b6302e19813fb9d1f7b65c37bb8b3e65b","lane":"lint","parents":["9f77dd6b88ed02d0e668e110451b7679d39d895d"],"secs":47,"stamp":"db2a124eaa991896731606ba8acfcd4f","tree":"40433d0758fb24226e8d328e6c91dd371a79dcf5","v":1,"via":"run"}
Ci-Attestation: {"at":1794166761,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"11edcd0f4e6ec735412bc145cb65de9b6302e19813fb9d1f7b65c37bb8b3e65b","lane":"lint","parents":["9f77dd6b88ed02d0e668e110451b7679d39d895d"],"secs":47,"stamp":"afaa15d7ba1541cd2d3ee3321ff18450","tree":"40433d0758fb24226e8d328e6c91dd371a79dcf5","v":1,"via":"run"}
Ci-Attestation: {"at":1794166761,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"fbb61fe95024041b3bd92229b056fbb27df66c3a8b1c0352bb423c2789c374f7","lane":"rust-test","parents":["9f77dd6b88ed02d0e668e110451b7679d39d895d"],"secs":118,"stamp":"9dd18ef7b9c08279d6f3cc47dcac11a5","tree":"40433d0758fb24226e8d328e6c91dd371a79dcf5","v":1,"via":"run"}
Ci-Attestation: {"at":1794166761,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"014a65065b0ee341e2550d86a4b2ca213a48b81852d78ac12ff3d9b7c73c3bc6","lane":"cross","parents":["9f77dd6b88ed02d0e668e110451b7679d39d895d"],"secs":70,"stamp":"4495bc2ed3803120f963e720aeb88868","tree":"40433d0758fb24226e8d328e6c91dd371a79dcf5","v":1,"via":"run"}
Ci-Attestation: {"at":1794166761,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"014a65065b0ee341e2550d86a4b2ca213a48b81852d78ac12ff3d9b7c73c3bc6","lane":"cross","parents":["9f77dd6b88ed02d0e668e110451b7679d39d895d"],"secs":70,"stamp":"74c5960f6f9c38af0213a7dd05fd911e","tree":"40433d0758fb24226e8d328e6c91dd371a79dcf5","v":1,"via":"run"}
Ci-Attestation: {"at":1794166761,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"014a65065b0ee341e2550d86a4b2ca213a48b81852d78ac12ff3d9b7c73c3bc6","lane":"cross","parents":["9f77dd6b88ed02d0e668e110451b7679d39d895d"],"secs":70,"stamp":"bbe87afc3829567e0b23a01e6b8ca255","tree":"40433d0758fb24226e8d328e6c91dd371a79dcf5","v":1,"via":"run"}
Ci-Attestation: {"at":1794166761,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"014a65065b0ee341e2550d86a4b2ca213a48b81852d78ac12ff3d9b7c73c3bc6","lane":"cross","parents":["9f77dd6b88ed02d0e668e110451b7679d39d895d"],"secs":70,"stamp":"a676e7e6d59a841a46039d53bfa48eac","tree":"40433d0758fb24226e8d328e6c91dd371a79dcf5","v":1,"via":"run"}
Ci-Attestation: {"at":1794166761,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"e5903b2bb002beded05f1145678666ac7207bb501e9a575662a572a60e933d93","lane":"tier2-linux","parents":["9f77dd6b88ed02d0e668e110451b7679d39d895d"],"secs":2241,"stamp":"5d68122c63dbaf256f6574f88d0d0b2a","tree":"40433d0758fb24226e8d328e6c91dd371a79dcf5","v":1,"via":"run"}
@rdoupe
rdoupe force-pushed the fix/rust-port-add-the-core-audio-sea-690 branch from aa60cc6 to 6778f8f Compare November 8, 2026 19:39
@rdoupe
rdoupe marked this pull request as ready for review November 8, 2026 19:56
@rdoupe
rdoupe requested a review from zackees as a code owner November 8, 2026 19:56
@rdoupe
rdoupe added this pull request to the merge queue Nov 8, 2026
@rdoupe

rdoupe commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

Handed off to the coordinator

Merged via the queue into master with commit 826cead Nov 8, 2026
42 checks passed
@rdoupe
rdoupe deleted the fix/rust-port-add-the-core-audio-sea-690 branch November 8, 2026 20:10
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Needs fix to Done in obs-rust Multiview Nov 8, 2026
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.

rust: Port the core-audio seam (obs-audio-seam.c)

1 participant