Audio 51: fluxer-audio PipeWire device lists and PipeWire I/O #341

Closed
opened 2026-11-12 18:34:15 +00:00 by charles · 0 comments
Owner

Plan: docs/superpowers/plans/2026-11-12-textchat.md, section "Task 51" (Audio devices and PipeWire, added 2026-11-12). Design: docs/superpowers/specs/2026-11-12-fluxer-native-audio-devices-design.md. Closes the gaps of #220 and #233 (and #225 item 7).

Task 51: fluxer-audio PipeWire device lists and PipeWire I/O

Issue: (to be created)

Files:

  • Create: crates/fluxer-audio/src/pipewire_devices.rs (pure filter: all targets; registry snapshot: #[cfg(target_os = "linux")])
  • Modify: root Cargo.toml (cpal = { version = "0.18", features = ["pipewire"] }, with a comment naming this task and audio spec §8), crates/fluxer-audio/Cargo.toml ([target.'cfg(target_os = "linux")'.dependencies] pipewire.workspace = true), crates/fluxer-audio/src/{host_cpal.rs,lib.rs}, README, Cargo.lock
  • Test: crates/fluxer-audio/src/pipewire_devices.rs (unit), crates/fluxer-audio/src/host_cpal.rs (unit)

Interfaces:

  • Produces: pipewire_devices::PwNodeProps = BTreeMap<String, String>; pipewire_devices::DefaultNodes { sink: Option<String>, source: Option<String> } with from_metadata(key: &str, value: &str) parsing {"name":"…"}; pipewire_devices::devices_from_nodes(nodes: &[PwNodeProps], defaults: &DefaultNodes) -> Devices (rules of audio spec §3.1: classes, hidden, own nodes and the original's internal labels, id pipewire:<node.name>, name with the USB id suffix stripped, is_default, de-duplicated); pipewire_devices::filter_alsa(ids: &[DeviceInfo]) -> Vec<DeviceInfo> (fallback list: alsa:default, alsa:pipewire, alsa:pulse, one alsa:sysdefault:CARD=… per card); CpalHost::with_pipewire_init(init: fn() -> bool) -> CpalHost (calls init once before any pw_* call; false → ALSA); CpalHost::new() = with_pipewire_init with pipewire::init on Linux; CpalHost::backend(&self) -> &'static str ("pipewire", "alsa", or cpal's host name elsewhere); env FLUXER_AUDIO_HOST=alsa forces ALSA.

  • Behaviour: Linux with a daemon → listing from the registry snapshot (2 s deadline by a loop timer, no leaked thread), I/O on cpal::host_from_id(HostId::PipeWire): Some(id) → device_by_id (rebuild the cpal host once if not found, then HostError::DeviceNotAvailable), None → default_input_device() / default_output_device(); the 3 s change watcher compares snapshots as today. Windows/macOS unchanged. AudioEngine, AudioHost, DeviceInfo and EngineEvent unchanged.

  • Step 1: Write failing tests: sinks_are_outputs_and_sources_are_inputs, duplex_nodes_are_both, streams_and_midi_and_video_are_not_devices, sinks_are_never_inputs, hidden_and_own_nodes_are_left_out, internal_virtual_labels_are_left_out, ids_are_cpal_pipewire_ids, names_prefer_description_then_nick_then_name, usb_id_suffix_is_stripped, default_nodes_come_from_metadata, malformed_metadata_means_no_default, duplicate_nodes_are_listed_once, alsa_fallback_keeps_default_and_one_entry_per_card, alsa_env_forces_the_alsa_backend; keep listing_devices_never_panics; real (FLUXER_AUDIO_DEVICE_TESTS=1): pipewire_lists_the_default_sink_and_source, opens_a_listed_pipewire_device_by_id.

  • Step 2–5: FAIL → implement → PASS → cargo deny check green (no new crates: cpal's pipewire feature uses the workspace's pipewire 0.10) → commit feat(audio): list and open PipeWire devices on Linux.

🤖 Generated with Claude Code

Plan: `docs/superpowers/plans/2026-11-12-textchat.md`, section "Task 51" (Audio devices and PipeWire, added 2026-11-12). Design: `docs/superpowers/specs/2026-11-12-fluxer-native-audio-devices-design.md`. Closes the gaps of #220 and #233 (and #225 item 7). ### Task 51: `fluxer-audio` PipeWire device lists and PipeWire I/O **Issue:** (to be created) **Files:** - Create: `crates/fluxer-audio/src/pipewire_devices.rs` (pure filter: all targets; registry snapshot: `#[cfg(target_os = "linux")]`) - Modify: root `Cargo.toml` (`cpal = { version = "0.18", features = ["pipewire"] }`, with a comment naming this task and audio spec §8), `crates/fluxer-audio/Cargo.toml` (`[target.'cfg(target_os = "linux")'.dependencies] pipewire.workspace = true`), `crates/fluxer-audio/src/{host_cpal.rs,lib.rs}`, README, `Cargo.lock` - Test: `crates/fluxer-audio/src/pipewire_devices.rs` (unit), `crates/fluxer-audio/src/host_cpal.rs` (unit) **Interfaces:** - Produces: `pipewire_devices::PwNodeProps = BTreeMap<String, String>`; `pipewire_devices::DefaultNodes { sink: Option<String>, source: Option<String> }` with `from_metadata(key: &str, value: &str)` parsing `{"name":"…"}`; `pipewire_devices::devices_from_nodes(nodes: &[PwNodeProps], defaults: &DefaultNodes) -> Devices` (rules of audio spec §3.1: classes, hidden, own nodes and the original's internal labels, id `pipewire:<node.name>`, name with the USB id suffix stripped, `is_default`, de-duplicated); `pipewire_devices::filter_alsa(ids: &[DeviceInfo]) -> Vec<DeviceInfo>` (fallback list: `alsa:default`, `alsa:pipewire`, `alsa:pulse`, one `alsa:sysdefault:CARD=…` per card); `CpalHost::with_pipewire_init(init: fn() -> bool) -> CpalHost` (calls `init` once before any `pw_*` call; `false` → ALSA); `CpalHost::new()` = `with_pipewire_init` with `pipewire::init` on Linux; `CpalHost::backend(&self) -> &'static str` (`"pipewire"`, `"alsa"`, or cpal's host name elsewhere); env `FLUXER_AUDIO_HOST=alsa` forces ALSA. - Behaviour: Linux with a daemon → listing from the registry snapshot (2 s deadline by a loop timer, no leaked thread), I/O on `cpal::host_from_id(HostId::PipeWire)`: `Some(id)` → `device_by_id` (rebuild the cpal host once if not found, then `HostError::DeviceNotAvailable`), `None` → `default_input_device()` / `default_output_device()`; the 3 s change watcher compares snapshots as today. Windows/macOS unchanged. `AudioEngine`, `AudioHost`, `DeviceInfo` and `EngineEvent` unchanged. - [ ] **Step 1: Write failing tests**: `sinks_are_outputs_and_sources_are_inputs`, `duplex_nodes_are_both`, `streams_and_midi_and_video_are_not_devices`, `sinks_are_never_inputs`, `hidden_and_own_nodes_are_left_out`, `internal_virtual_labels_are_left_out`, `ids_are_cpal_pipewire_ids`, `names_prefer_description_then_nick_then_name`, `usb_id_suffix_is_stripped`, `default_nodes_come_from_metadata`, `malformed_metadata_means_no_default`, `duplicate_nodes_are_listed_once`, `alsa_fallback_keeps_default_and_one_entry_per_card`, `alsa_env_forces_the_alsa_backend`; keep `listing_devices_never_panics`; real (`FLUXER_AUDIO_DEVICE_TESTS=1`): `pipewire_lists_the_default_sink_and_source`, `opens_a_listed_pipewire_device_by_id`. - [ ] **Step 2–5:** FAIL → implement → PASS → `cargo deny check` green (no new crates: cpal's `pipewire` feature uses the workspace's `pipewire` 0.10) → commit `feat(audio): list and open PipeWire devices on Linux`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
charles added this to the Text chat milestone 2026-11-12 18:34:15 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/fluxer-native#341
No description provided.