Filter ALSA devices, add hw: bit-perfect devices, and fix UI issues
ALSA Device Filtering (45 → ~12 devices): - Aggressively filter to show only useful devices for audiophiles - Keep: default, sysdefault:CARD=, front:CARD=, hdmi:CARD=, iec958:CARD= - Blacklist: surround* variants, usbstream:, pipewire, pulse, bare sysdefault - Reduces 45 listed devices to ~12 actually useful ones Add hw:CARD=XXX,DEV=0 Devices for Bit-Perfect Playback: - Auto-generate hw: devices for each detected card - hw: = direct hardware access without ALSA plugins (true bit-perfect) - sysdefault:CARD= has dmix/resampling plugins (NOT bit-perfect) - Description shows "(Direct Hardware - Bit-perfect)" to distinguish - This fixes user's issue: DAC was stuck at 44.1kHz with sysdefault:CARD=C20 Loading Indicator: - Show "Loading devices..." while parsing aplay -L output - Fixes 4-5 second frozen UI on ALSA Direct backend selection - isLoadingDevices state added to SettingsView Stop Playback on Device Change: - Call stop_playback() in handleBackendDeviceChange - Prevents stuck/dead audio streams when changing output device - Fixes: "After any config change, song in player stops working" User can now: 1. Select hw:CARD=C20,DEV=0 for true bit-perfect to DAC 2. See loading indicator instead of frozen UI 3. Change device without breaking playback 4. Only see relevant devices (not 7 surround variants per card)
This commit is contained in:
1 parent
7091c64d56
commit
8f3369a583
2 files changed
+104
-11
No files matched your search
@@ -211,6 +211,7 @@
|
||||
let availableBackends = $state<BackendInfo[]>([]);
|
||||
let backendDevices = $state<AudioDevice[]>([]);
|
||||
let alsaPlugins = $state<AlsaPluginInfo[]>([]);
|
||||
let isLoadingDevices = $state(false);
|
||||
|
||||
// Backend selector options (derived)
|
||||
let backendOptions = $derived(['Auto', ...availableBackends.filter(b => b.is_available).map(b => b.name)]);
|
||||
@@ -755,6 +756,7 @@
|
||||
}
|
||||
|
||||
async function loadBackendDevices(backendType: 'PipeWire' | 'Alsa' | 'Pulse') {
|
||||
isLoadingDevices = true;
|
||||
try {
|
||||
const devices = await invoke<AudioDevice[]>('get_devices_for_backend', { backendType });
|
||||
backendDevices = devices;
|
||||
@@ -762,6 +764,8 @@
|
||||
} catch (err) {
|
||||
console.error(`Failed to load devices for ${backendType}:`, err);
|
||||
backendDevices = [];
|
||||
} finally {
|
||||
isLoadingDevices = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -980,6 +984,14 @@
|
||||
await invoke('set_audio_output_device', { device: deviceId });
|
||||
await invoke('reinit_audio_device', { device: deviceId });
|
||||
console.log('[Audio] Backend device changed:', deviceName, '(id:', deviceId ?? 'default', ')');
|
||||
|
||||
// Stop current playback to prevent stuck/dead streams
|
||||
try {
|
||||
await invoke('stop_playback');
|
||||
console.log('[Audio] Stopped playback after device change');
|
||||
} catch (err) {
|
||||
console.log('[Audio] No playback to stop');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[Audio] Failed to change backend device:', err);
|
||||
}
|
||||
@@ -1296,14 +1308,18 @@
|
||||
<span class="setting-label">{$t('settings.audio.outputDevice')}</span>
|
||||
<Tooltip text="Select your preferred audio output device. Devices shown are from the selected backend." />
|
||||
</div>
|
||||
<Dropdown
|
||||
value={outputDevice}
|
||||
options={deviceOptions}
|
||||
onchange={handleBackendDeviceChange}
|
||||
wide
|
||||
expandLeft
|
||||
compact
|
||||
/>
|
||||
{#if isLoadingDevices}
|
||||
<span class="loading-text">Loading devices...</span>
|
||||
{:else}
|
||||
<Dropdown
|
||||
value={outputDevice}
|
||||
options={deviceOptions}
|
||||
onchange={handleBackendDeviceChange}
|
||||
wide
|
||||
expandLeft
|
||||
compact
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{#if showAlsaPluginSelector}
|
||||
<div class="setting-row">
|
||||
@@ -1735,6 +1751,12 @@
|
||||
background: rgba(255, 255, 255, 0.4);
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 14px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.header {
|
||||
padding-top: 24px;
|
||||
margin-bottom: 32px;
|
||||
|
||||
Reference in new issue
Block a user