Fix ALSA device name translation and Auto mode device selection

ALSA Device Name Translation:
- Added missing patterns: front:CARD=, surround*:CARD=, iec958:CARD=
- Now shows "Cambridge Audio USB Front Output" instead of "front CS201 Output 0"
- Updated CARD_NAMES: CS201 → "Cambridge Audio USB", C20 → "Cambridge Audio"
- Surround patterns: 40→4.0, 41→4.1, 50→5.0, 51→5.1, 71→7.1
- S/PDIF (iec958) pattern added

Auto Mode Device Selection Fix (CRITICAL):
- Auto mode now only allows "System Default" (no specific device selection)
- Fixes device mismatch issue where PipeWire device names fail in ALSA
- Previous behavior caused:
  * User selects DAC in Auto mode (PipeWire device name)
  * Player uses legacy ALSA path
  * Device not found → falls back to default
  * 18+ second delay before playback starts
- Auto mode is now truly automatic - always uses System Default

This prevents cross-backend device name incompatibility. If user wants
to select specific device, they must choose PipeWire, ALSA Direct, or
PulseAudio backend explicitly.
This commit is contained in:
vicrodh committed 2026-01-17 19:52:47 -06:00
1 parent b008f333b0
commit 97fb8d332a
2 files changed
+32 -26

No files matched your search

+7 -25
View File
@@ -789,24 +789,10 @@
} }
} else { } else {
selectedBackend = 'Auto'; selectedBackend = 'Auto';
// Auto mode: load devices from first available backend // Auto mode: always use System Default (no device selection)
// This allows showing proper device names with translation // Device names from one backend (e.g., PipeWire) don't work in another (e.g., ALSA)
if (availableBackends.length > 0) { backendDevices = [];
const firstBackend = availableBackends.find(b => b.is_available); outputDevice = 'System Default';
if (firstBackend) {
await loadBackendDevices(firstBackend.backend_type);
// Set selected device from backend devices
if (settings.output_device) {
const device = backendDevices.find(d => d.id === settings.output_device);
if (device) {
outputDevice = needsTranslation(device.name) ? getDevicePrettyName(device.name) : device.name;
} else {
outputDevice = 'System Default';
}
}
}
}
} }
if (settings.alsa_plugin) { if (settings.alsa_plugin) {
@@ -925,13 +911,9 @@
if (backendType) { if (backendType) {
await loadBackendDevices(backendType); await loadBackendDevices(backendType);
} else { } else {
// Auto mode: load devices from first available backend for device selection // Auto mode: no device selection (System Default only)
if (availableBackends.length > 0) { // Device IDs from different backends are incompatible
const firstBackend = availableBackends.find(b => b.is_available); backendDevices = [];
if (firstBackend) {
await loadBackendDevices(firstBackend.backend_type);
}
}
} }
// Reset to default device when switching backends (always) // Reset to default device when switching backends (always)
+25 -1
View File
@@ -6,7 +6,8 @@
const CARD_NAMES: Record<string, string> = { const CARD_NAMES: Record<string, string> = {
'sofhdadsp': 'Intel HD Audio', 'sofhdadsp': 'Intel HD Audio',
'NVidia': 'NVIDIA GPU', 'NVidia': 'NVIDIA GPU',
'CS201': 'USB Audio', // Common USB audio chip 'CS201': 'Cambridge Audio USB',
'C20': 'Cambridge Audio',
'Generic': 'Generic Audio', 'Generic': 'Generic Audio',
'PCH': 'Onboard Audio', 'PCH': 'Onboard Audio',
'HDMI': 'HDMI Audio', 'HDMI': 'HDMI Audio',
@@ -32,6 +33,29 @@ export function getDevicePrettyName(alsaName: string): string {
return 'JACK Audio'; return 'JACK Audio';
} }
// Pattern: front:CARD=XXX,DEV=N
const frontMatch = alsaName.match(/^front:CARD=([^,]+),DEV=(\d+)$/);
if (frontMatch) {
const cardName = CARD_NAMES[frontMatch[1]] || frontMatch[1];
return `${cardName} Front Output`;
}
// Pattern: surround40, surround41, surround50, surround51, surround71:CARD=XXX,DEV=N
const surroundMatch = alsaName.match(/^surround(\d{2}):CARD=([^,]+),DEV=(\d+)$/);
if (surroundMatch) {
const channels = surroundMatch[1];
const cardName = CARD_NAMES[surroundMatch[2]] || surroundMatch[2];
const channelName = channels === '40' ? '4.0' : channels === '41' ? '4.1' : channels === '50' ? '5.0' : channels === '51' ? '5.1' : channels === '71' ? '7.1' : channels;
return `${cardName} Surround ${channelName}`;
}
// Pattern: iec958:CARD=XXX,DEV=N (S/PDIF)
const iec958Match = alsaName.match(/^iec958:CARD=([^,]+),DEV=(\d+)$/);
if (iec958Match) {
const cardName = CARD_NAMES[iec958Match[1]] || iec958Match[1];
return `${cardName} S/PDIF`;
}
// Pattern: hdmi:CARD=XXX,DEV=N // Pattern: hdmi:CARD=XXX,DEV=N
const hdmiMatch = alsaName.match(/^hdmi:CARD=([^,]+),DEV=(\d+)$/); const hdmiMatch = alsaName.match(/^hdmi:CARD=([^,]+),DEV=(\d+)$/);
if (hdmiMatch) { if (hdmiMatch) {