Repository navigation
test: characterize audio-io.c before media-io port - #120
Conversation
|
Rebased onto master (old head b2891a4, replaced with --force-with-lease). The test/cmocka/CMakeLists.txt conflict is resolved by appending the test_audio_io block to master's file. As a characterization test it pins current C behaviour: |
b2891a4 to
325a49d
Compare
Pins the header-inline helpers before the Rust port: get_audio_channels for every enum speaker_layout value, get_audio_bytes_per_channel and is_audio_planar for every enum audio_format value, get_audio_planes for every format and layout pair, get_audio_size and get_total_audio_size (including TOTAL_AUDIO_SIZE), and the audio_frames_to_ns and ns_to_audio_frames conversions. Values outside the enums are characterized: an unknown layout, including 7 (the gap before SPEAKERS_7POINT1 = 8), has 0 channels, and an unknown format has 0 bytes per channel and is interleaved, so it has one plane. Planar sizes ignore the layout, even an unknown one. The conversions truncate, so a frames -> ns -> frames round trip can lose a frame. ns_to_audio_frames takes a sample rate of 0 (it is the multiplier) and returns 0. The large-value cases are inputs where both util_mul_div64 paths agree; the per-platform differences and division by zero stay with test_util_uint64.c. Nothing is swapped, so the test passes with ENABLE_RUST_LIBOBS OFF and ON alike. It is separate from the audio-io.c characterization in obs-rust#120 (test_audio_io.c), which needs a running obs core. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the rebase, @zackees, and sorry it sat waiting on us. Two small test-only commits since then:
CI on our runners passed at 94251a4 (https://github.com/chriscoveries/obsrust-fork/actions/runs/38108904258). Under |
cmocka test pinning the current C behavior of libobs/media-io/ audio-io.c ahead of the obs-media-io port (Phase 5). audio-io.c is the smallest media-io unit not already claimed by an open port order. - open(): AUDIO_OUTPUT_INVALIDPARAM for unset format/name/rate/speakers (no thread spawned, *audio untouched); getters mirror audio_output_info (interleaved float stereo: 1 plane / 2 ch / 8-byte block; planar 16-bit 5.1: 6 planes / 6 ch / 2-byte block). - connect(): NULL/zero conversion fields fall back to the output info; duplicate (callback, param) on one mix is refused while the same callback with a different param registers a second input; out-of-range mix index and NULL audio return false. - active(): tracks registered mix inputs through connect/disconnect. - Thread model: open() spawns the input thread immediately and the callback fires on the audio clock. - Characterized crashes (not endorsed): the unguarded NULL getters and, with no obs core running, audio_output_open itself die by signal (the spawned thread dereferences obs->name_store on entry) - each pinned in a forked child with cmocka's signal handlers reset. The behavioral pins need a running obs core (obs_startup), which needs a display on Linux; they skip in the headless gate and run under xvfb-run. Refs #45 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Local-Gate: v1 tree=f3d2e26bde1bcfec8370af8c615fa43998fc9ae9 secs=350 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791672334,"gate":"rust/all/fmt","host":"linux-x86_64","key":"f06beafdad8c0e6401d54ec504cdbb4c6ff8cc9c99298d7770b1042156188009","lane":"lint","parents":["b3cc16f7cbb177da70d2d0997a15d111f7dee3ec"],"secs":199,"stamp":"68289f5197c34c3b485811e11aef0a06","tree":"f3d2e26bde1bcfec8370af8c615fa43998fc9ae9","v":1,"via":"run"} Ci-Attestation: {"at":1791672334,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"f06beafdad8c0e6401d54ec504cdbb4c6ff8cc9c99298d7770b1042156188009","lane":"lint","parents":["b3cc16f7cbb177da70d2d0997a15d111f7dee3ec"],"secs":199,"stamp":"ea4878636b524b67d0b5a5c00246cd9b","tree":"f3d2e26bde1bcfec8370af8c615fa43998fc9ae9","v":1,"via":"run"} Ci-Attestation: {"at":1791672334,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"9b440df8274dd21e1d86abf9f72adc95f209321fa7b3613730625747620dda42","lane":"rust-test","parents":["b3cc16f7cbb177da70d2d0997a15d111f7dee3ec"],"secs":78,"stamp":"9a81bd835884cc8f59413b7b65a44cac","tree":"f3d2e26bde1bcfec8370af8c615fa43998fc9ae9","v":1,"via":"run"} Ci-Attestation: {"at":1791672334,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"b6e993eabe33d303d6a813f6a7b6c6c5edf09ddebf517c252f712b9d95b33f63","lane":"tier2-linux","parents":["b3cc16f7cbb177da70d2d0997a15d111f7dee3ec"],"secs":71,"stamp":"8e4d35b0e6cf8b077f8de1178e0f2bfa","tree":"f3d2e26bde1bcfec8370af8c615fa43998fc9ae9","v":1,"via":"run"}
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Local-Gate: v1 tree=18904b28bd85ff6ff08ce80f10dae94dda139a76 secs=38 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791675132,"gate":"rust/all/fmt","host":"linux-x86_64","key":"ba65b923f501ad750e65692f42aaa0a23a3021236d6ae0efd3f1c94918d7cee1","lane":"lint","parents":["325a49d29d0d9051e6b473e980fad71b822c6f87"],"secs":5,"stamp":"db7e536db53a4bb710d35628331746f3","tree":"18904b28bd85ff6ff08ce80f10dae94dda139a76","v":1,"via":"run"}
Ci-Attestation: {"at":1791675132,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"ba65b923f501ad750e65692f42aaa0a23a3021236d6ae0efd3f1c94918d7cee1","lane":"lint","parents":["325a49d29d0d9051e6b473e980fad71b822c6f87"],"secs":5,"stamp":"62b64d1aa0d162a22ecf50075452742a","tree":"18904b28bd85ff6ff08ce80f10dae94dda139a76","v":1,"via":"run"}
Ci-Attestation: {"at":1791675132,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"8ab76ba0fdab0ca2f07ef85c35d69bdce29faac588a2f8d7b312b2cd664d174e","lane":"rust-test","parents":["325a49d29d0d9051e6b473e980fad71b822c6f87"],"secs":21,"stamp":"eb5d4333df52d26eb3ebf743f506d30b","tree":"18904b28bd85ff6ff08ce80f10dae94dda139a76","v":1,"via":"run"}
Ci-Attestation: {"at":1791675132,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"ee43101ce8b5a6c42ef660cf7f6f55c3532aaadab25c2ee4811df6d285c824a2","lane":"tier2-linux","parents":["325a49d29d0d9051e6b473e980fad71b822c6f87"],"secs":12,"stamp":"2fa187fac20ed6705d15911748c303f8","tree":"18904b28bd85ff6ff08ce80f10dae94dda139a76","v":1,"via":"run"}
The input callback signals g_input_event from the audio thread, so destroying it before audio_output_close() could race a late signal. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XFvTpgDN6Zh3USjgworNmT Local-Gate: v1 tree=c4b764f6d8aa71c39e58671c953d64aa1fb41caf secs=62 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791692794,"gate":"rust/all/fmt","host":"linux-x86_64","key":"b7026c063f951c53a9d4ed45ca3c8974bd7c92ddf4320444a488f40238a5f9a1","lane":"lint","parents":["fad9f73502e5917c3bf91b2ea96ad8acb093ef1d"],"secs":14,"stamp":"bbf8ac2c04ea813a254211e50b9cb57d","tree":"c4b764f6d8aa71c39e58671c953d64aa1fb41caf","v":1,"via":"run"} Ci-Attestation: {"at":1791692794,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"b7026c063f951c53a9d4ed45ca3c8974bd7c92ddf4320444a488f40238a5f9a1","lane":"lint","parents":["fad9f73502e5917c3bf91b2ea96ad8acb093ef1d"],"secs":14,"stamp":"8683db975511caac7301b6107c277f76","tree":"c4b764f6d8aa71c39e58671c953d64aa1fb41caf","v":1,"via":"run"} Ci-Attestation: {"at":1791692794,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"515c1a621978d2e8cd35efcb9530a01d3b26eca9e5615b6dc02b99cd8b09a7e3","lane":"rust-test","parents":["fad9f73502e5917c3bf91b2ea96ad8acb093ef1d"],"secs":31,"stamp":"45108c7b930820a3ecd87f5b62ba17ce","tree":"c4b764f6d8aa71c39e58671c953d64aa1fb41caf","v":1,"via":"run"} Ci-Attestation: {"at":1791692794,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"8869ee39dcde8b028bca3040629b682d2541aae6981a1527e58b33cf13566102","lane":"tier2-linux","parents":["fad9f73502e5917c3bf91b2ea96ad8acb093ef1d"],"secs":17,"stamp":"06c66dacab9b3abfac084c0a51d7b313","tree":"c4b764f6d8aa71c39e58671c953d64aa1fb41caf","v":1,"via":"run"}
|
Verified locally, rebased onto master and stamped. The new head is
Merging once CI is green. |
94251a4 to
2f2da96
Compare
Problem
Phase 5 ports
libobs/media-io/to Rust, butmedia-io/audio-io.chad no test at all— not even a characterization test. There is nothing to port against, so the first
Rust-portable unit of that directory cannot be verified. Refs #45.
Root cause
No
test_audio_io.cexists, andmedia-io/audio-io.cis not covered by any testtarget. Per
docs/rust-port/testing-policy.mda port is only validated once theoriginal C behavior is characterized first — "characterized, not endorsed".
Fix
Adds
test/cmocka/test_audio_io.c, pinning the current C behavior ofaudio_output_open/close/connect/disconnect/activeand the getters. No productioncode changes.
Pins:
open():AUDIO_OUTPUT_INVALIDPARAMfor unset format/name/rate/speakers, nothread spawned,
*audiountouched. Getters mirroraudio_output_info(interleaved float stereo → 1 plane / 2 ch / 8 B; planar 16-bit 5.1 → 6 planes /
6 ch / 2 B).
connect(): NULL/zero conversion fields fall back to the output info; a duplicate(callback, param) is refused while the same callback with a different param
registers a second input; out-of-range mix index or NULL audio returns false.
active()tracks registered mix inputs through connect/disconnect.open()and invokes the callback on the audio clock.endorsed": unguarded NULL getters, and
audio_output_openwith no obs core running,where the spawned thread dereferences
obs->name_storeon entry.Alternatives considered, rejected: porting first and characterizing after (the policy
requires the C behavior pinned before a port, otherwise a ported bug becomes the
specification); a hand-rolled harness instead of cmocka (loses signal handling for the
characterized-crash pins).
Evidence
94251a45c: https://github.com/chriscoveries/obsrust-fork/actions/runs/38108904258.test_audio_iopasses with the Rust port OFF and ON.xvfb-runor a desktop session. Underxvfb-runin the same Tier 2 container on x86-64 Linux, 20 runs each with the Rust port OFF and ON came out identical: 7 pass, 1 skip, 0 fail per run, no flake. The skip isopen_crashes_without_obs_core, which needs the obs core absent.input_thread_runstakes about 230–320 ms, well inside its 3 s timeoutCompatibility & risk
open_crashes_without_obs_core, needs the obs core absent and skips when one is present. The crash pins are POSIX-only.Status
Ready for review. Since the rebase (thanks @zackees), two small test-only commits:
silent_outputtolerates a NULLparam, sinceconnect()accepts one and the callback still runs on the audio thread.os_eventsignalled by the callback (3 s timeout) instead of a sleep poll, and frees that event only afteraudio_output_close()has joined the thread.The crash pins depend on fork/signal handling; if your CI hosts need an opt-out flag for them, say so and I'll add one.
Thank you to the obs-rust maintainers and contributors for building this project in the open. In the American spirit of free expression and individual independence, and with the principle of judging contributions on their merit alone, this PR is a small piece of what independent people can build when they come together.