Repository navigation
libobs: Add the core-audio seam - #4048
Merged
Merged
Conversation
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
force-pushed
the
fix/rust-port-add-the-core-audio-sea-690
branch
from
November 8, 2026 19:39
aa60cc6 to
6778f8f
Compare
rdoupe
marked this pull request as ready for review
November 8, 2026 19:56
Collaborator
Author
|
Handed off to the coordinator |
This was referenced Nov 8, 2026
This was referenced Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 andaudio_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_callbackand its helpers read and changestruct obs_coreandstruct obs_sourcedirectly. The port reaches the same fields through this seam, without the layouts ofobs-internal.h("Public and internal boundaries", testing-policy.md), as the transition ports reach theirs throughobs-source-transition-seam.h. The plan to extract the tick helpers into their own file first was dropped:test_audio_buffering_subsamplecompilesobs-audio.c.hand calls them by name (the exception is recorded on the Phase 6 tracker, #444). So the helpers andaudio_callbackare ported together, after this seam.libobs/obs-audio-seam.hdeclares the accessors, hidden in libobs (notEXPORT) like the transition seam's. Each is a single read, write, lock or container call, copied from the line ofobs-audio.c.hit wraps:obs->audio): the output;render_order(num, get,da_find,da_push_back,da_resize(.., 0)) androot_nodes(num, get, push, clear);buffered_timestamps(push back, peek front, pop front of onestruct ts_info);obs_audio_seam_get_buffering(), thestruct obs_audio_bufferingthataudio_buffering()fills;fixed_buffer;buffering_wait_ticksget and set;monitoring_duplicating_source; and the task queue (task_mutexlock and unlock, the queue size, pop front of onestruct obs_task_info);first_audio_sourceandaudio_sources_mutex;video.mixes_mutex, the mix count, a mix'sviewandmix_audio; a view'schannels_mutexand its channels;next_audio_source;audio_buf_mutex;audio_is_duplicatedandaudio_pending, get and set;audio_ts;audio_input_buf[0].size;obs_audio_seam_source_get_input(), thestruct obs_audio_inputthataudio_input()fills;info.type,info.output_flagsand whetherinfo.audio_renderis set;audio_output_buf(the array itself, typedobs_audio_seam_output_row_t *, asobs_audio_mix_add()takes it);muted,volume,audio_mixers; andmonitoring_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.htakes today.libobs/obs-audio-seam.c.his live C inlibobs.core-output, ahead ofobs-audio.c.hin the group's sorted order. It stays live C, like the transition seam, and never moves into a ported group.libobs.pch.hincludes the header with the otherobs-audio.cheaders, andsource-sets.d/LIBOBS_SOURCES.jsonlists it. No C caller changes:obs-audio.c.hkeeps its direct reads until the port replaces them.test_audio_seampins the seam. The accessors are hidden, so it builds the seam into itself, astest_source_transition_seam_callsdoes, 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 theda_*anddeque_*calls they copy.RED → GREEN
libobs: Stub the core-audio seam): the accessors are declared, and their bodies read, write and lock nothing.test_audio_seamfails 16/16 on the C and hybrid builds (test_output:(nil) != 0x…,test_render_order:0 != 2,test_tasksandtest_source_lock: the trylock under the lock succeeds, …).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_seampasses 16/16 on the C and hybrid builds under ASan and UBSan, with no leaks (0/16 on the RED commit).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-reference58/58 (rebuilt after the change, its mtime checked).test_audio_buffering_subsample, which compilesobs-audio.c.hand now sees the seam header throughlibobs.pch.h, passes on all three.test_source_monitor_only_loadwas left out: it hangs without a sound server, on the C build too.t) in each.--test-diffagainst the base (7295 tests passed, 6 skipped, the same on the RED commit),--lane lint,--lane dylint,--lane crossand the Windows--all-targetsclippy (x86_64-pc-windows-msvc,-D warnings) pass.libobs-c-reference58/58); the export sets are still identical (1767);./lint,./unittest(Rust 7313 and 914 tests, Tier 2 803/803 on hybrid libobs andlibobs-c-reference),--lane lint,--lane dylint,--lane crossand the Windows--all-targetsclippy pass. Theport_comparisonbench 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.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.Checklist
master(or the description starts with a Stacked: note)test_audio_seamlands 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, includingtest_audio_buffering_subsample, pass unchanged on all three builds.docs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC (not applicable)