Text chat 49: fluxer-capture audio target listing, property rules, one PipeWire initialiser (#339) #345
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "textchat-49-capture-audio-targets"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this builds (Text chat 49, audio spec §3.3, #225.1/.6/.7)
audio::AudioTarget { props: BTreeMap<String, String> }andAUDIO_TARGET_FIELDS(the 14 keys ofLinuxAudioCapture.ts:43-58, same order).StreamAudioCapturer::list_targets()with a default body returningCaptureError::Unsupported("no audio source listing")(soUnsupportedand WASAPI need nothing).AppMatch::Props(BTreeMap)andAudioRule.exclude: Vec<BTreeMap>(default empty).RoutingRule::from_audio_rule:Propsbecomeinclude_whenminusfluxer.display.*keys (a display-only pattern is ignored, so "specific" with nothing routable still falls back to the system rule);excludeentries becomenever_whenwith the same stripping.fluxer.target.objectskeeps working throughmatches_pattern. WASAPI ignores both.routing::Graph::targets(&identity, own_sink): routable nodes (is_routable_media_class, moved toroutingand made pub) ofenriched_nodes, minusidentity.matches, the node namedown_sinkand anyfluxer-native-stream-audio-*node, projected to the 14 fields, sorted byobject.serial(numerically, serial-less last) thennode.name.PipeWireAudioCapturer::list_targets: snapshot thread +Graph::targets, at mostREADY_TIMEOUT(nowpub); the running session's sink name is kept inSessionso it is excluded by name too.snapshot_grapharms a loop timer forREADY_TIMEOUTthat quits the main loop, so thefluxer-pipewire-listthread always ends; a snapshot that did not complete isNone.list_applicationskeeps its signature over the same snapshot.#[cfg(target_os = "linux")] pub fn initialize_pipewire() -> boolindesktop/rtc.rs(webrtc'sInitializePipeWirethenpw_init), re-exported asfluxer_capture::initialize_pipewire, the only declaration of_ZN6webrtc18InitializePipeWireEv;pipewire_audio::init_pipewirecalls it.FakeCaptureControl::set_audio_targets,list_targetsreturns them; default Firefox (pid 4242), mpv (pid 4343) and anAudio/Sink"Speakers".Tests
routing.rs):props_match_is_an_include_pattern_without_display_keys,display_only_props_match_is_ignored,exclude_patterns_become_never_when,target_objects_pattern_routes_streams_to_that_sink,targets_are_routable_nodes_minus_self_and_own_sink,targets_are_projected_to_the_fourteen_fields.tests/fake.rs:default_list_targets_is_unsupported,fake_lists_its_targets_and_records_props_rules,audio_rule_default_has_no_exclude.FLUXER_CAPTURE_TESTS=1,tests/pipewire_real.rs):list_targets_sees_a_playing_tone_and_not_itself,list_targets_thread_ends_within_timeout. Ran on this machine (CachyOS, Wayland desktop, PipeWire withpw-play) withFLUXER_CAPTURE_TESTS=1 cargo test -p fluxer-capture --test pipewire_real -- --test-threads 1: all 6 pass, including the existing ones. Not part of CI.FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen locally.Deviations
apps/fluxer/src/capture_rt.rs: one line,exclude: Vec::new()in thecapture::AudioRuleliteral so the app compiles with the new field. The real conversion ofProps/excludeis Text chat 52's.pipewire_audio::READY_TIMEOUTis nowpub(the real timeout test uses it);routing::is_routable_media_classandrouting::OWN_SINK_PREFIXare nowpub.list_targetson PipeWire answersBackend(not an empty list) when the snapshot fails or is late, so the app can answerAudioTargets(None).Closes #339
🤖 Generated with Claude Code
Independent review: Text chat 49 (capture audio targets)
Scope:
git diff 9fcc13d..origin/textchat-49-capture-audio-targets(one commit,df0ec50).Plan tests (step 1): all 11 named tests exist and assert what the plan asks. Unit tests in
routing.rs: props include without display keys, display-only props ignored (rule equals the System rule), exclude goes tonever_whenand wins over an include,fluxer.target.objectsmatched againsttarget.object/node.targetby serial and by name, targets minus self and own sink, projection to the 14 fields. Tests intests/fake.rs: defaultlist_targetsis Unsupported, the fake inventory and rule recording,AudioRule::default().excludeis empty. Real tests intests/pipewire_real.rs, gated onFLUXER_CAPTURE_TESTS. The fake's default inventory is Firefox pid 4242, mpv pid 4343 and anAudio/Sink"Speakers", as specified.Interfaces: match the plan exactly.
AudioTarget { props },AUDIO_TARGET_FIELDS: [&str; 14](checked key by key and in order againstfluxer_desktop/src/main/LinuxAudioCapture.ts:43-58), thelist_targetsdefault body with the message"no audio source listing",AppMatch::Props,AudioRule.exclude(empty by default),Graph::targets(&SelfIdentity, Option<&str>),FakeCaptureControl::set_audio_targets, andinitialize_pipewire()(Linux only) re-exported at the crate root. That function is the only declaration of_ZN6webrtc18InitializePipeWireEvin the workspace, andpipewire_audio::init_pipewiredelegates to it. The WASAPI match is extended only for the new variant. The one-lineexclude: Vec::new()inapps/fluxer/src/capture_rt.rsis needed to compile and is acceptable until Task 52 converts the rule.Invariants: this change touches no fluxer-core, fluxer-ui or fluxer-emoji code, adds no dependency and no fixture, and contains no secrets or paths. The listing fails with
Backenderrors instead of panicking. #225.6:snapshot_grapharms aREADY_TIMEOUTloop timer that quits the main loop. Thedoneflag correctly tells a timer quit apart from a completed round trip (a late answer returnsNone, which becomesBackend), so thefluxer-pipewire-listthread always ends.Sort key (implementer asked): the key is (numeric serial, with a missing or non-numeric serial as
u64::MAX; then the raw serial string; thennode.name). This sorts numerically as the plan intends and puts serial-less nodes last, ordered by name. The test covers this.Review Focus: none of items 1-7 belongs to this task.
Findings
crates/fluxer-capture/README.mdnow has twodesktoprows in the module table (lines 14 and 17). The new row should be merged into the existing one.list_targets_thread_ends_within_timeoutonly exercises the path where the daemon answers. The timer-quit path (#225.6) is not tested directly. A test with an unresponsive remote would be hard to build, so this is a note, not a request.Applicationsrule that contains onlyPropsreturnsUnsupported("picks an application by its process id") instead of being ignored as audio spec §3.3 says. This is the same as today's handling ofName/Binary, and the core should not sendPropson Windows (Task 50/52 should keep it that way).Local CI:
FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciin a fresh review worktree finished with "all steps passed" (exit 0). I did not rerun the PipeWire real tests.Verdict: approve. There are no blocking findings.