Skip to content

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

Closed

Description

@rdoupe

Unit

New libobs/obs-audio-seam.h / libobs/obs-audio-seam.c.h (live C in libobs.core-output): the core-audio seam, so the coming port of libobs/obs-audio.c.h (the audio tick's per-source helpers and audio_callback) to a new rust/obs-core-seam can reach the core's audio, data and video fields and a source's audio fields without the struct layouts of obs-internal.h.

Each accessor 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 audio (403-404); render_order num, get, find, push and clear (27, 30, 56, 58, 66, 334-335, 409, 480-481); root_nodes num, get, push and clear (72, 410, 454, 541-542); buffered_timestamps push back, peek front and pop front (412-413, 575); get_buffering, which fills a struct obs_audio_buffering as 220-226 do; fixed_buffer (526); buffering_wait_ticks get and set (540, 579-580); monitoring_duplicating_source (359, 375, 380, 384); task_mutex lock and unlock, tasks size and pop front (341-349).
  • The core data and video: first_audio_source, audio_sources_mutex lock and unlock (299, 315, 466-476, 520-522, 558-569); video.mixes_mutex lock and unlock, the mix count, a mix's view and mix_audio (425-464); a view's channels_mutex lock and unlock and a channel (440-462).
  • A source: next_audio_source; audio_buf_mutex lock and unlock; audio_is_duplicated get and set; audio_pending get and set; audio_ts; audio_input_buf[0].size; get_input, which fills a struct obs_audio_input as 105-112 do; info.type, info.output_flags and whether info.audio_render is set; audio_output_buf; muted, volume and audio_mixers; monitoring_enabled (an atomic load, 374).

None checks its arguments or takes a lock of its own: a caller takes audio_buf_mutex, audio_sources_mutex, mixes_mutex, channels_mutex and task_mutex where obs-audio.c.h takes them today, and the header comment lists them. Hidden in libobs (not EXPORT), like the transition seam's accessors. No C caller changes: obs-audio.c.h keeps its direct reads until the port replaces them.

Phase and position

Phase 6 (libobs core), the "internal accessors or adapter seams" item of the Phase 6 tracker (#444); tracking issue #4. It comes before the port of obs-audio.c.h. The extraction of the tick helpers into their own file was dropped (recorded on #444: test_audio_buffering_subsample compiles obs-audio.c.h and calls them by name), so the helpers and audio_callback are ported together after this seam.

Dependencies and existing tests

  • None on master: the seam is new C in a new file. The decisions it serves are already Rust (audio_discard, audio_min_ts, audio_mix, audio_render in obs-core).
  • Nothing tests these accessors yet. A characterization test, test/cmocka/test_audio_seam.c, builds the seam into itself (the accessors are hidden) over a stand-in core and stand-in sources, as test_source_transition_seam_calls does. It pins each read against the field it wraps, each write read back, each lock as one pthread_mutex_* result, and the container calls against da_* / deque_* on the same fields.

Notes

No behaviour change and no Rust: the port calls these. The seam file stays live C, like the transition seam, and never moves into a ported group. The export sets of the C, hybrid and C reference builds stay identical, with the new accessors local.

Activity

  1. added
    enhancement
    port
    ready
    on Nov 8, 2026
  2. rdoupe commented on Nov 8, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #4046

    Plan, one PR (no Rust, no behaviour change), as the transition seam's calls went in:

    1. libobs: Stub the core-audio seam: libobs/obs-audio-seam.h declares the accessors (hidden, not EXPORT; the header comment lists the locks callers take), libobs/obs-audio-seam.c.h has stub bodies, included in libobs.core-output+.h.c and libobs.pch.h. test/cmocka/test_audio_seam.c builds the seam into itself over a stand-in core and sources, registered in test-graph.json; it fails on the stubs.
    2. libobs: Add the core-audio seam: each body copied from the line of obs-audio.c.h it wraps; the test passes. Then the C tests OFF and ON and the C, hybrid and C-reference export sets compared (the accessors local).

    Draft PR once the stub commit exists, today.

  3. rdoupe commented on Nov 8, 2026

    @rdoupe
    CollaboratorAuthor

    Closed by the merge of PR #4048 (the core-audio seam): libobs/obs-audio-seam.h and libobs/obs-audio-seam.c.h are in as live C in libobs.core-output, 53 hidden accessors, each copied from the line of obs-audio.c.h it wraps, pinned by test/cmocka/test_audio_seam.c. No Rust and no behaviour change; the export sets of the C, hybrid and C-reference builds are unchanged.

    What's left: the port of libobs/obs-audio.c.h itself (the tick's per-source helpers and audio_callback, ported together) to rust/obs-core-seam, reaching the core and sources through this seam. No issue exists for it yet; it will be filed under the Phase 6 tracker (#444) as the next unit, and obs-audio.c.h keeps its direct reads until then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementportready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions