Skip to content

libobs: characterize and extract obs_set_audio_monitoring_device (Refs #5489) - #5490

Merged
rdoupe merged 2 commits into
masterfrom
test/audio-monitoring-device-extract
Nov 23, 2026
Merged

rdoupe merged 2 commits into
masterfrom
test/audio-monitoring-device-extract

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a C characterization of obs_set_audio_monitoring_device and obs_reset_audio_monitoring, then moves them (with their static helper check_all_aoc_sources) verbatim from libobs/obs.c.h into libobs/obs-audio-monitoring-device.c.h, a member of the core unity group (libobs/build/libobs.core+.h.c, alphabetical, right after obs-audio-info-queries-fields.c.h). test_set_audio_monitoring_device is registered once in the canonical test graph with its tests.d marker. No behavior change; existing C tests and public headers are unchanged.

Refs #5489. This is the C-only prerequisite; the Rust swap follows separately (as obs_reset_audio2 did: #5485, then #5486).

What the test pins

test_core_setup_rules_steps (test_monitoring_device) already pins the NULL/empty refusals and the return value per availability; test_pulse_monitor_reset pins one monitor surviving a failed PulseAudio reset. The new test covers the rest. Like test_pulse_monitor_reset, it interposes only the external libpulse symbols in the executable (-Wl,--export-dynamic, -fvisibility=default), so monitoring is available without a sound server; the monitors, the source enumeration and the deduplication signal all run in libobs.

  • New device, by copy: obs_get_audio_monitoring_device reads back the name and id given, from the core's own storage (not the caller's buffers, which are then overwritten). Each of two live monitors is reset exactly once: its old stream disconnected and unreferenced once, one new stream connected to the new id, and a later reset uses the stored id.
  • Same id: returns true, keeps the old name, creates and releases no stream, and tells no capture source (a matching one is present).
  • Audio Output Capture sources: every public input with OBS_SOURCE_DO_NOT_SELF_MONITOR is told with its own device_id setting, observed through the core's deduplication_changed signal. Setting sink_b starts deduplication for the source capturing sink_b.monitor only. Then sink_c stops it for that source (NULL) and starts it for the sink_c.monitor one, in that order. Then sink_d stops it, and a fourth id tells nobody. An input without the flag and a private flagged input, both with a matching device_id, are never told.
  • obs_reset_audio_monitoring: with no monitors it creates no context, stream or mainloop and leaves the device as it was; with two monitors it resets each once on the current id, every time it is called.
  • libobs allocations balance after obs_shutdown().

ci/test_native_b2_portability.py counts the Linux core tests that need PulseAudio; it goes from 6 to 7 for this test (the same kind of update as #5268).

The move

obs-audio-monitoring-device.c.h sorts before obs.c.h in the group. The three functions call no static helper of obs.c.h, so the new file declares nothing. The OBS_CORE_SETUP_RULES_DO_NOT_SELF_MONITOR == OBS_SOURCE_DO_NOT_SELF_MONITOR assert moves with them, since only check_all_aoc_sources relies on it. The getter stays in obs-core-monitoring-device.c.h (already on Rust). Only obs.c.h includes it, in this one group.

Evidence

  • Characterization first (test: commit 78a6654): the test and its registration alone, against the C still in obs.c.h. OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 1 --tests 'test_set_audio_monitoring_device|test_core_setup_rules_steps|test_pulse_monitor_reset': full Linux Tier 2 passed on the C reference and hybrid libobs (1086/1086 each), then the seven related tests again on each (7/7).
  • Move (libobs: commit 1179654): the 60 moved lines are identical (diff) to the lines removed from obs.c.h; the new file only adds the group's PCH include.
  • Same Tier 2 command on the final branch: 1086/1086 on each library, 7/7 on each repeat; exported symbols C vs Rust identical (1769).
  • Cases ran, none skipped: the binary run directly in the kept Tier 2 volume prints Running 5 test(s) and PASSED 5 test(s) on both libraries.
  • Mutation checks (rebuilt in the kept Tier 2 volume, run on both libraries, then reverted, then 5/5 again):
    • check_all_aoc_sources passes an empty id instead of the source's device_id: only aoc_sources_told_with_their_device_id fails (test_set_audio_monitoring_device.c:465, 0 signals instead of 1); 4 of 5 pass.
    • storing the id as the name (bstrdup(id) for monitoring_device_name): the name read-back fails ("sink_a" != "Sink A", line 333). The cases after it fail too, because the failed case leaves its monitors alive.
  • ./lint passes.

🤖 Generated with Claude Code

rdoupe and others added 2 commits November 22, 2026 23:00
On interposed libpulse, so monitoring is available without a sound
server: a new device is stored by copy and every live monitor is reset
once onto it; the same id again returns true, keeps the old name, resets
nothing and tells no capture source; each public input with
OBS_SOURCE_DO_NOT_SELF_MONITOR is told with its own device_id (the one
capturing the new device starts deduplication, the one that stops
matching stops it), inputs without the flag and private ones are not;
obs_reset_audio_monitoring with no monitors touches nothing and with
monitors resets each once.

The Linux core inventory check counts one more PulseAudio-only core
test (6 to 7).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#5489)

Moves obs_reset_audio_monitoring, the static check_all_aoc_sources and
obs_set_audio_monitoring_device verbatim from obs.c.h into
obs-audio-monitoring-device.c.h, a member of the core unity group
(alphabetical), ahead of their Rust swap. The
OBS_SOURCE_DO_NOT_SELF_MONITOR assert moves with them, since only
check_all_aoc_sources relies on it. They call no static helper of
obs.c.h, so the file declares nothing. No behavior change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ci-Attestation: {"at":1795407338,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":63,"stamp":"8255796e79fc97968af9901b41e9d0ae","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407338,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":63,"stamp":"5b85dce0cf31255bf5a358ec4417c825","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407338,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":63,"stamp":"97b1149c295ffdbb1c22b078b9f39761","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407338,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":63,"stamp":"6da3b69f9de823e868c85b3b8e4fc000","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407273,"gate":"general/all/client-lint","host":"linux-x86_64","key":"c5d79f91a96457b7273a6ee805715cb7d3493ae0fb301dc1bf1e68745adf49e5","lane":"client-lint","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":11,"stamp":"e2ef261799fbf680398d363c6e2d8d05","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407338,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":63,"stamp":"8eb7922e29368b02ab46bdad03969629","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407274,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"c5d79f91a96457b7273a6ee805715cb7d3493ae0fb301dc1bf1e68745adf49e5","lane":"client-lint","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":11,"stamp":"4fd7c128f7aea5312867be1759ac0a39","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407274,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"c5d79f91a96457b7273a6ee805715cb7d3493ae0fb301dc1bf1e68745adf49e5","lane":"client-lint","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":11,"stamp":"20a973472e859c4d21cf977fed597889","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407274,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"c5d79f91a96457b7273a6ee805715cb7d3493ae0fb301dc1bf1e68745adf49e5","lane":"client-lint","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":11,"stamp":"64fe64be9d7ed608488700ce0810936a","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407274,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"c5d79f91a96457b7273a6ee805715cb7d3493ae0fb301dc1bf1e68745adf49e5","lane":"client-lint","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":11,"stamp":"c01469a2b3b7b17bbdcfaa3dee58ed42","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407274,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"c5d79f91a96457b7273a6ee805715cb7d3493ae0fb301dc1bf1e68745adf49e5","lane":"client-lint","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":11,"stamp":"2218350a3463668c6755db4b9e68bede","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407274,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"c5d79f91a96457b7273a6ee805715cb7d3493ae0fb301dc1bf1e68745adf49e5","lane":"client-lint","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":11,"stamp":"36383eee403f57b1ced3ba0b72f87feb","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407274,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"c5d79f91a96457b7273a6ee805715cb7d3493ae0fb301dc1bf1e68745adf49e5","lane":"client-lint","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":11,"stamp":"df8659eef73a271eb53c20d8f547e65a","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407274,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"c5d79f91a96457b7273a6ee805715cb7d3493ae0fb301dc1bf1e68745adf49e5","lane":"client-lint","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":11,"stamp":"37b605294b00f4e27249070562362f35","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407274,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"c5d79f91a96457b7273a6ee805715cb7d3493ae0fb301dc1bf1e68745adf49e5","lane":"client-lint","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":11,"stamp":"16de3e6830ffc26d44b4db705b0f5fda","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407274,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"c5d79f91a96457b7273a6ee805715cb7d3493ae0fb301dc1bf1e68745adf49e5","lane":"client-lint","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":11,"stamp":"e6953bd4de35cc7f8267cfb69b2393dd","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407274,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"c5d79f91a96457b7273a6ee805715cb7d3493ae0fb301dc1bf1e68745adf49e5","lane":"client-lint","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":11,"stamp":"d6e15f9ea51d009feede27936816ace6","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407274,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"c5d79f91a96457b7273a6ee805715cb7d3493ae0fb301dc1bf1e68745adf49e5","lane":"client-lint","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":11,"stamp":"7e1a1d08521f414ad2fe733a21bea334","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}
Ci-Attestation: {"at":1795407496,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"6c005f7da8b18a666b8b7e661c6a4fca71e89bf6882f0d96b4644e53c7a45632","lane":"client-test-x86_64-unknown-linux-gnu","parents":["78a66541bc22eefca1e0f1198f3b9e0b301c82c2"],"secs":158,"stamp":"40b491b0bae48c0c9169966eb9431d15","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"7bbf74d626f4b88587877bbc16794551f1a618f4","coverage":"all-tracked-applicable-files","diff":["ci/test_native_b2_portability.py","libobs/build/libobs.core+.h.c","libobs/obs-audio-monitoring-device.c.h","libobs/obs.c.h","test/cmocka/build/test-graph.json","test/cmocka/test_set_audio_monitoring_device.c","test/cmocka/tests.d/test_set_audio_monitoring_device.cmake"],"head":"4875b6d3bd2dace7687227d3bfae3b517c96847a","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":"bc3cddfba08601175b7a71018102d5aee0f49529ae44cbd05c015fdfbdbdd396","tree":"a594c5ae17426a02763e6a1bcbb2a22fa5dcc59d"}}
@rdoupe
rdoupe requested a review from zackees as a code owner November 23, 2026 04:18
@rdoupe rdoupe changed the title libobs: extract obs_set_audio_monitoring_device into its own file (Refs #5489) libobs: characterize and extract obs_set_audio_monitoring_device (Refs #5489) Nov 23, 2026
@rdoupe
rdoupe added this pull request to the merge queue Nov 23, 2026
Merged via the queue into master with commit b0806bb Nov 23, 2026
46 checks passed
@rdoupe
rdoupe deleted the test/audio-monitoring-device-extract branch November 23, 2026 05:02
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.

1 participant