Skip to content

libobs: Synchronize capture and mixer audio state - #662

Merged
zackees merged 5 commits into
masterfrom
fix/130-audio-buffer-race
Oct 14, 2026
Merged

zackees merged 5 commits into
masterfrom
fix/130-audio-buffer-race

Conversation

@zackees

@zackees zackees commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Capture and mixing now use audio_buf_mutex consistently for source timestamps and input buffers. The initial timestamp check, sample copy, and volume timing share a protected snapshot. Buffer sufficiency, minimum timestamps, and backward-time recovery use the same mutex. Transition rendering reads each child's timestamp once through the synchronized accessor.

Plugin audio callbacks and transition mix callbacks run without a source buffer lock held. No public signature or layout changes.

Fixes #130.

Validation:

  • RED 94909f355: the new real capture/mixer test fails under ThreadSanitizer in audio_buffer_insufficient, reading a deque size concurrently with source_output_audio_place/deque_upsize.

  • GREEN 187d72a52 and 0c50becd0: ThreadSanitizer passes direct capture/mixing and capture beneath an active transition. The latter asserts successful transition audio renders and mix callbacks. The test paces capture with semaphores and uses no sleeps.

  • Sanitizer build: ENABLE_RUST_LIBOBS=OFF, ENABLE_UNIT_TESTS=ON, C/C++ flags -fsanitize=thread -fno-omit-frame-pointer; run under Xvfb with TSAN_OPTIONS=halt_on_error=1. The only suppression is race:libgallium for the external Mesa driver. Docker requires --security-opt seccomp=unconfined so TSan can control ASLR.

  • Pre-push review: clean, one reviewer; transition reader finding fixed and expanded regression validated.

  • Tier 2: all 192 C tests pass OFF and ON; the focused capture/transition test passed 100 consecutive runs in each configuration under Xvfb with -noreset. Exported symbol sets are identical (1766 symbols).

  • Final local gate passed all four lanes in 380 seconds; pushed head 7df40153479c is stamped for tree e6d5982bffde.

  • CI run 38491380151: all 21 checks passed or were appropriately skipped on 7df40153479c, including native macOS and Windows Rust tests and OFF/ON C compatibility.

Local-Gate: v1 tree=e6d5982bffde75e35349980671c9a122230698f6 secs=380 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1791938304,"gate":"rust/all/fmt","host":"linux-x86_64","key":"c545af4887452d1b5c4a80993224d7f996020568a0f77bcc4274ca17c82eb096","lane":"lint","parents":["c14bd36efae3ee99be90050278a8bdac3dfb84e4"],"secs":34,"stamp":"b4c1c80318cdac91de93123f6c105de2","tree":"e6d5982bffde75e35349980671c9a122230698f6","v":1,"via":"run"}
Ci-Attestation: {"at":1791938304,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"c545af4887452d1b5c4a80993224d7f996020568a0f77bcc4274ca17c82eb096","lane":"lint","parents":["c14bd36efae3ee99be90050278a8bdac3dfb84e4"],"secs":34,"stamp":"573eef8fdf76a68c6bfe60f3e5f4663a","tree":"e6d5982bffde75e35349980671c9a122230698f6","v":1,"via":"run"}
Ci-Attestation: {"at":1791938304,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"e5e2bab33fd8d04947560d8cb7dcb69420a8c09b172b51708ca85cb40c0364a1","lane":"rust-test","parents":["c14bd36efae3ee99be90050278a8bdac3dfb84e4"],"secs":132,"stamp":"fb6c40abac9bb615a8db14a7816d80b1","tree":"e6d5982bffde75e35349980671c9a122230698f6","v":1,"via":"run"}
Ci-Attestation: {"at":1791938304,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"eb3e0e35395e0dba033468202d4d13193288ff3a42b5cba6c77f91b43519543a","lane":"cross","parents":["c14bd36efae3ee99be90050278a8bdac3dfb84e4"],"secs":95,"stamp":"2276a630a4051c8537495f8905aa4c35","tree":"e6d5982bffde75e35349980671c9a122230698f6","v":1,"via":"run"}
Ci-Attestation: {"at":1791938304,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"eb3e0e35395e0dba033468202d4d13193288ff3a42b5cba6c77f91b43519543a","lane":"cross","parents":["c14bd36efae3ee99be90050278a8bdac3dfb84e4"],"secs":95,"stamp":"c16e6b9935b1502b256b4b57d5ff4ca4","tree":"e6d5982bffde75e35349980671c9a122230698f6","v":1,"via":"run"}
Ci-Attestation: {"at":1791938304,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"eb3e0e35395e0dba033468202d4d13193288ff3a42b5cba6c77f91b43519543a","lane":"cross","parents":["c14bd36efae3ee99be90050278a8bdac3dfb84e4"],"secs":95,"stamp":"41cdee321b4340f1195a3ad8d83acd31","tree":"e6d5982bffde75e35349980671c9a122230698f6","v":1,"via":"run"}
Ci-Attestation: {"at":1791938304,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"eb3e0e35395e0dba033468202d4d13193288ff3a42b5cba6c77f91b43519543a","lane":"cross","parents":["c14bd36efae3ee99be90050278a8bdac3dfb84e4"],"secs":95,"stamp":"c6affd5596ce4282fc38bcb2dfe0fbbe","tree":"e6d5982bffde75e35349980671c9a122230698f6","v":1,"via":"run"}
Ci-Attestation: {"at":1791938304,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"eb3e0e35395e0dba033468202d4d13193288ff3a42b5cba6c77f91b43519543a","lane":"cross","parents":["c14bd36efae3ee99be90050278a8bdac3dfb84e4"],"secs":95,"stamp":"8d80aca117e90794754c2cb7215bee1b","tree":"e6d5982bffde75e35349980671c9a122230698f6","v":1,"via":"run"}
Ci-Attestation: {"at":1791938304,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"eb3e0e35395e0dba033468202d4d13193288ff3a42b5cba6c77f91b43519543a","lane":"cross","parents":["c14bd36efae3ee99be90050278a8bdac3dfb84e4"],"secs":95,"stamp":"6fd03ad04040c8866102a318968ed873","tree":"e6d5982bffde75e35349980671c9a122230698f6","v":1,"via":"run"}
Ci-Attestation: {"at":1791938304,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"ea2f62ae2dee39a4bbcca0e901a7406928d47e5648273c76cbcaf577e4f2e048","lane":"tier2-linux","parents":["c14bd36efae3ee99be90050278a8bdac3dfb84e4"],"secs":118,"stamp":"2d0a818cae27ffa088013afa2a374f41","tree":"e6d5982bffde75e35349980671c9a122230698f6","v":1,"via":"run"}
@zackees
zackees merged commit bace91b into master Oct 14, 2026
21 checks passed
@zackees
zackees deleted the fix/130-audio-buffer-race branch October 26, 2026 15:43
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.

TSan: audio thread reads source audio_ts / audio_input_buf without audio_buf_mutex

1 participant