Repository navigation
obs-source: port process_media_actions to Rust (Fixes #5902) - #5907
Conversation
70a026f to
2b2075d
Compare
|
Coordinator rebase 2b2075d. The usual |
|
Checked the rebase locally on the same tree (identical apart from the word order in the |
zackees
left a comment
There was a problem hiding this comment.
Coordinator review: LGTM. It follows the #5889 shape: a verbatim extraction of process_media_actions, the cmocka characterization, Tier 1 RED before GREEN, and Tier 3 parity (media_actions_parity.rs) against the oracle. No C test or public header is edited, and it has a Test cost line. It's already on auto-merge.
2b2075d to
3ac2df6
Compare
|
Coordinator: I took this out of the queue, since it collided with #5898 on the |
|
ai-rebase: skipped skipped: worker active |
Move process_media_actions() out of obs-source.c.h into obs-source-media-actions.c.h, unchanged, in the live core-source group. obs_source_video_tick() keeps calling it through the prototype left in obs-source.c.h. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
process_media_actions() and obs_source_video_tick() are hidden, so the test reaches them through the core's video thread: a tick callback queues a batch for a public CONTROLLABLE_MEDIA source, which the same frame's tick drains. One tick runs every action oldest first, each callback with the source's data and then its signal (none for set-time) on the source's own handler, with only "source" in a fixed 128-byte calldata; callbacks and signals run on the video thread with media_actions_mutex released, so what they queue runs in the same tick; a type outside the enum is dropped and a MEDIA_ACTION_NONE ends the tick with the rest left for the next. Linux with OpenGL, under xvfb-run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A model of the queue, the six callbacks and the signal pins the cases of test_source_media_actions: every queued action in one tick, oldest first, callback then signal (none for set-time); actions queued from a callback or a signal run in the same tick; out-of-enum types are dropped and a MEDIA_ACTION_NONE ends the tick with the rest left; pause is read only for play/pause; plus a proptest over any queue. The core is a stub, so all six fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Swap process_media_actions() in hybrid libobs for a safe Rust core over a
Source trait: until the queue is empty, take the front action off under
media_actions_mutex (released before anything else runs), ask
media_admission for the step, call the matching info.media_* callback with
context.data, then emit its signal on the source's own handler; a
MEDIA_ACTION_NONE ends the tick and an out-of-enum type is dropped. The
locked pop (reading only the union member the type uses), the six
callback calls and obs_source_dosignal() stay behind
obs-source-media-actions-fields.c.h (live group, no EXPORT); the shim is
hidden through rust-hidden.d, and the original moves to the ported group
for the C reference.
Tier 3 runs the original C (with the original dispatch and signal steps)
and the Rust shim on a noise-filled real-header source with a real queue
and signal handler, comparing every lock and unlock, callback and signal
in order, the queue left and every other byte, over each action alone, a
NONE mid-queue, actions queued from a callback or a signal and a
proptest, and rejects five mutants. No intentional differences.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ci-Attestation: {"at":1795911536,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":76,"stamp":"b38f9bb9f63f49258df1156e40dbe406","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911536,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":76,"stamp":"aeb777051e14a629b8c233d8c10e2fc9","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911536,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":76,"stamp":"7c06d231c7dbd81f9581a38d22207031","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911536,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":76,"stamp":"f170e6a9ad94f96ffeb567720605cd43","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911459,"gate":"general/all/client-lint","host":"linux-x86_64","key":"871c8527c0f29193c96c7ac9f958dc362e92fce32a2b52b66435be1910677feb","lane":"client-lint","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":9,"stamp":"fe3d009e92731a7445efbe65123e4b1c","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911536,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":76,"stamp":"fad11009648ebe71595478764dc4e1e7","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911459,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"871c8527c0f29193c96c7ac9f958dc362e92fce32a2b52b66435be1910677feb","lane":"client-lint","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":9,"stamp":"6820bd2eabbdb24910de6a83a26879b4","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911460,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"871c8527c0f29193c96c7ac9f958dc362e92fce32a2b52b66435be1910677feb","lane":"client-lint","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":9,"stamp":"22ac5e4843694087b2fe861876583764","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911459,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"871c8527c0f29193c96c7ac9f958dc362e92fce32a2b52b66435be1910677feb","lane":"client-lint","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":9,"stamp":"da73f7fd896b4a601668b6a9003b4753","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911459,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"871c8527c0f29193c96c7ac9f958dc362e92fce32a2b52b66435be1910677feb","lane":"client-lint","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":9,"stamp":"5ccb57a81b5fa2cf959f942c8c54734d","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911459,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"871c8527c0f29193c96c7ac9f958dc362e92fce32a2b52b66435be1910677feb","lane":"client-lint","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":9,"stamp":"ce3db09b17b65fd8688dff51e337ce9c","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911459,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"871c8527c0f29193c96c7ac9f958dc362e92fce32a2b52b66435be1910677feb","lane":"client-lint","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":9,"stamp":"0b6d0b624a72b44dd28904de0c8dd255","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911459,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"871c8527c0f29193c96c7ac9f958dc362e92fce32a2b52b66435be1910677feb","lane":"client-lint","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":9,"stamp":"bce3fd3843becb66c4ff9e872751d8b4","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911459,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"871c8527c0f29193c96c7ac9f958dc362e92fce32a2b52b66435be1910677feb","lane":"client-lint","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":9,"stamp":"863ebc0219f344b2f2b2a2e0d2a5c3e0","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911459,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"871c8527c0f29193c96c7ac9f958dc362e92fce32a2b52b66435be1910677feb","lane":"client-lint","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":9,"stamp":"1e40cda8107afddf487a8aa0a708091e","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911459,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"871c8527c0f29193c96c7ac9f958dc362e92fce32a2b52b66435be1910677feb","lane":"client-lint","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":9,"stamp":"12269ec370f6380c2ecd8b64f3fc84a6","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911459,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"871c8527c0f29193c96c7ac9f958dc362e92fce32a2b52b66435be1910677feb","lane":"client-lint","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":9,"stamp":"9b3bff5775f13a6c66b3e7b8c1cdf9b7","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911459,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"871c8527c0f29193c96c7ac9f958dc362e92fce32a2b52b66435be1910677feb","lane":"client-lint","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":9,"stamp":"143796daffb81219a3d8b1fe81bf34d3","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Ci-Attestation: {"at":1795911748,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"166d7a4df29656d7ac9c2bf63e4f2d5e23e7702c16e09997767b2fd1f35753a2","lane":"client-test-x86_64-unknown-linux-gnu","parents":["5a1a93468b6b451d53b1cbd844584f0df23e8d9f"],"secs":212,"stamp":"9b58132e4be4ad8485689bdbba8987de","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff","v":1,"via":"run"}
Client-Checks: {"checks":{"base":"e5ca61531cc08ea6d160d8a3e10cf1f98cf55526","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-source+.h.c","libobs/build/libobs.ported-source-media-actions+.h.c","libobs/build/ported-source-sets/source-media-actions.json","libobs/cmake/rust-hidden.d/obs-source-source_media_actions.txt","libobs/obs-source-media-actions-fields.c.h","libobs/obs-source-media-actions.c.h","libobs/obs-source.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_source_media_actions_swap_is_registered.rs","rust/obs-c-oracle/oracle.d/source-media-actions.list","rust/obs-c-oracle/oracle/source_media_actions.c","rust/obs-source/Cargo.toml","rust/obs-source/src/ffi/mod.rs","rust/obs-source/src/ffi/source_media_actions.rs","rust/obs-source/src/lib.rs","rust/obs-source/src/media_actions.rs","rust/obs-source/src/media_controls.rs","rust/obs-source/tests/source/main.rs","rust/obs-source/tests/source/media_actions.rs","rust/obs-source/tests/source/media_actions_parity.rs","test/cmocka/build/test-graph.json","test/cmocka/test_source_media_actions.c","test/cmocka/tests.d/test_source_media_actions.cmake"],"head":"413d21381daece99d153fbc9cb046a92029dd8e5","tools":{"orchestrator-python":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]","schema-dependencies":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]\n{'jsonschema': '4.26.0', 'json_source_map': '1.0.5'}","uv":"uv 0.13.5 (x86_64-unknown-linux-gnu)","xmllint":"xmllint: using libxml version 21504-GITv2.15.4\n compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ICU ISO8859X Regexps Automata RelaxNG Schemas Schematron Modules Debug Zlib"},"tracked-digest":"d9dbe229a19c1924c357951f3346e2e40a9e38a50b037ebc140c6d2882a47642","tree":"83c04bd6e8cfaa2ec0d4e9c5853efbe4424febff"}}
3ac2df6 to
0096645
Compare
|
Coordinator rebase onto master after #5912: |
Fixes #5902.
Ports
process_media_actions(), the drain of a source's media action queue thatobs_source_video_tick()runs once per tick for a source withOBS_SOURCE_CONTROLLABLE_MEDIA, toobs-source. It is the last C step of the media control path: theobs_source_media_*calls that fill the queue are Rust since #5617, and the dispatch and signal decisions it asks are Rust since #2257. Same shape as #5900.Commits, in order:
libobs: extract ...): the function moves unchanged intolibobs/obs-source-media-actions.c.h, still in the livecore-sourcegroup;obs-source.c.hkeeps its prototype forobs_source_video_tick(). No behavior change.test_source_media_actions. The drain andobs_source_video_tick()are both hidden, so the test goes through the core's video thread, liketest_source_video_tick_callbacks: a tick callback queues a batch for a public controllable source, and the same frame's tick drains it. It pins: every action in one tick, oldest first; each callback with the source's data (pause / ms) and then its signal (media_pause/media_play,media_restart,media_stopped,media_next,media_previous; none for set-time) on the source's own handler, with onlysourcein a fixed 128-byte calldata; callbacks and signals on the video thread withmedia_actions_mutexreleased, so actions queued from a callback or a signal handler run in the same tick; an out-of-enum type dropped with no call or signal; aMEDIA_ACTION_NONEmid-queue ends the tick and the rest run on the next one. Linux with OpenGL, under xvfb-run.media_actions::processover aSourcetrait (pop, six callbacks, signal), stubbedtodo!(), with Tier 1 tests in obs-source's existingsourcetest binary (no new test binary).rust-hidden.d; noEXPORT). The locked pop (the original lock / copy / pop / unlock, reading only the union member the type uses), the sixinfo.media_*calls withcontext.dataandobs_source_dosignal(source, NULL, ...)stay C in the newobs-source-media-actions-fields.c.h(live group, noEXPORT). The extracted C moves to the reference-only grouplibobs.ported-source-media-actions.Tier 3, new
media_actions_parity: the original C (compiled from the extracted file with the original C dispatch and signal steps) and the Rust shim run on a noise-filled real-header source with a real queue and a real signal handler. Every lock and unlock of the queue mutex (with the queue length), every callback (data pointer and argument) and every signal (name and calldata shape) is recorded in order and must match, as must the queue left behind and every other byte of the source. Cases: empty queue, each action type alone (includingi64::MIN/MAXtimes and out-of-enum types) under three noise fills,NONEmid-queue, actions queued from the restart callback or themedia_restartsignal, and a proptest over queues of up to 16 entries. The oracle uses a stand-in forobs_source_dosignal()with the same body minus theobs->signalsbranch (the core global can't be linked there; both sides pass NULL for it, and a non-NULL name would be recorded). Registration testcanonical_source_media_actions_swap_is_registered.No intentional differences; Tier 4 does not apply. Not user-visible, so no features.md line.
Evidence
RED, at the RED commit 2d8ad84:
GREEN, at the head 70a026f (on 13854a4):
Mutation check on the Tier 3 parity (each run alone, then restored):
Skipreturning instead of continuing,stopnot called,pauseinverted for the signal, the signal emitted twice, and the shim'snextcalling thepreviousadapter all fail it (3-4 of 5 tests each); an identity edit passes 5/5.Tier 2 (cmocka against hybrid libobs and the C reference). The characterization at d79577f, run in the kept build volume under
xvfb-run -a:[ PASSED ] 4 test(s)on both libraries, none skipped. On the GREEN commit:./lint:== lane lint: ok.Test cost: new tests (6 Tier 1 incl. one proptest, 5 Tier 3 incl. one proptest, 1 registration): the
media_actionsfilter finishes in 0.06 s in the debug build (0.01 s withOBS_PARITY_CASES=reduced); peak RSS 15.4 MB over 20 runs of the filtered binary (systemd-run MemoryAccounting); no threads of their own. The new cmocka test runs 0.70 s in ctest (a few 60 fps frames per case).🤖 Generated with Claude Code