Fix audio device selection to show friendly PipeWire names

The previous implementation tried to map ALSA device names (from cpal)
to PipeWire descriptions, but the naming schemes are completely different:
- cpal returns names like "plughw:1,0"
- pactl returns sink names like "alsa_output.usb-Cambridge_Audio_..."

This fix changes the approach:
1. Use PipeWire sinks directly for the device dropdown (already filtered
   to real outputs and have friendly descriptions like "DacMagic Plus")
2. Store the PipeWire sink name when user selects a device
3. Set the PipeWire default sink using pactl when device is selected
4. Use rodio's default device (which follows PipeWire's default)

This ensures users see 4-5 meaningful devices with friendly names
instead of 30+ raw ALSA device names.

Backend changes:
- Add set_pipewire_default_sink command (pactl set-default-sink)
- Register new command in lib.rs

Frontend changes:
- Use pipewireSinks directly for device dropdown
- Display sink description (friendly name)
- Store sink name (for pactl)
- Call set_pipewire_default_sink when device changes
- Remove unused AudioDevice interface and getDevicePrettyName import
This commit is contained in:
vicrodh committed 2026-01-16 19:52:51 -06:00
1 parent eebf440f84
commit 33c5e00da0
3 files changed
+74 -65

No files matched your search

+1
View File
@@ -333,6 +333,7 @@ pub fn run() {
commands::get_audio_devices,
commands::get_audio_output_status,
commands::get_pipewire_sinks,
commands::set_pipewire_default_sink,
commands::reinit_audio_device,
// Queue commands
commands::add_to_queue,