Stop Linux mic detection from counting Anarlog's own ALSA stream

VI
2d ago
+38-0

Summary

Context: On Linux with PipeWire, Anarlog's own microphone capture is listed by PulseAudio as a source output whose application.name is PipeWire ALSA [anarlog] and which has no application.process.binary, so linux::list_mic_using_apps reports it with both id and name set to that string. On desktop 1.4.36 (Ubuntu 26.04, PipeWire 1.6.2), the journal shows detected event=MicStarted([InstalledApp { id: "PipeWire ALSA [anarlog]", ... }]) right after a recording starts, and mic_detected app_id=PipeWire ALSA [anarlog] threshold_secs=15 once the threshold passes.

Intention: is_self_app only matches exact self names, bundle IDs and .app paths, so Anarlog's own recording is tracked as another app using the microphone. It then shows up in every mic-app snapshot, for example the one confirmAutoStop takes. It isn't offered in the exclusion list either (that list shows "Anarlog"), so users can't exclude it.

Direction: Unwrap the ALSA client names that PipeWire (PipeWire ALSA [<process>]) and PulseAudio's ALSA plugin (ALSA plug-in [<process>]) give, and compare the process name with the existing SELF_APP_NAMES, reading hyphens as spaces so anarlog-nightly matches anarlog nightly. Other apps' wrapped names, such as PipeWire ALSA [teams], are unaffected.

Demo

N/A: a filter change with no UI. Before and after is the journal line above disappearing once the stream is recognized.

Verification

  • Local (Ubuntu 26.04, x86_64): cargo test -p detect --features list,mic --lib: 110 passed, including new cases in is_self_app_matches_only_anarlog_identities (own stream in PipeWire and PulseAudio form, the nightly name, and non-matches [teams], [charm] and trailing text).
  • cargo clippy -p detect --features list,mic --lib --tests: no findings in the changed file; rustfmt --edition 2024 --check clean.
  • Not run: a packaged build. The stream naming was observed on 1.4.36 with pactl list source-outputs and the app's journal.

🤖 Generated with Claude Code


Summary by cubic

Stops Linux mic detection from counting Anarlog's own ALSA stream as another app using the microphone, and also recognizes the dev build's stream.

On Linux with PipeWire, Anarlog's capture appears as PipeWire ALSA [anarlog] (or ALSA plug-in [anarlog] on PulseAudio) with no process binary, so is_self_app never matched it and the mic tracker treated it as another app using the mic. is_self_app now unwraps those ALSA client names and compares the process name against the self app names, treating hyphens as spaces so anarlog-nightly matches anarlog nightly. The dev build's anarlog-dev name is now included as anarlog dev so a development build also recognizes its own stream. Other apps' wrapped names, such as PipeWire ALSA [teams], are unaffected.