Windows port Phase 2: cpal device enumeration
Give the Windows device pickers a real device list (Phase 0/1 left pw_cli returning nothing off-Linux) and generalize enumeration into a platform-neutral interface. - audio/mod.rs: move AudioDevice here (neutral home), gate pw_cli to cfg(unix), and re-export enumerate_audio_devices per-platform (pw_cli on unix, cpal_impl on windows). Also drop a now-stale "no-op stub" doc note. - cpal_impl.rs: add enumerate_audio_devices() — iterate the cpal host's input + output devices into AudioDevice (name == description == the cpal friendly name, which is what resolve() matches target_node against, so a saved selection round-trips), sorted by description. - pw_cli.rs: use super::AudioDevice instead of a local copy; parsing + tests unchanged. - app/mod.rs: one-line import change; the device-picker logic is untouched. Verified: shipped Linux state green (build --locked, clippy, 316/316, pw_cli parse tests 6/6); the cpal enumerator compiles against real cpal via the Linux/ALSA toggle. Runtime device listing on Windows is pending a real host (M2/M3). WASAPI names are less stable than PipeWire node names, so a saved device may not always round-trip (falls back to default). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+1
-13
@@ -1,18 +1,6 @@
|
||||
use super::AudioDevice;
|
||||
use std::process::Command;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct AudioDevice {
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub is_input: bool,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for AudioDevice {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.description)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enumerate_audio_devices() -> Vec<AudioDevice> {
|
||||
let output = Command::new("pw-cli")
|
||||
.arg("list-objects")
|
||||
|
||||
Reference in New Issue
Block a user