Add UI for ALSA hardware volume control
- Add alsa_hardware_volume to AudioSettings interface - Add Tauri command set_audio_alsa_hardware_volume - Add checkbox in Settings (visible only for ALSA Direct + Hw plugin) - Checkbox disabled by default for maximum compatibility - Clear tooltip explaining experimental nature and risks
This commit is contained in:
1 parent
ce72addd90
commit
45e6df49d5
3 files changed
+38
No files matched your search
@@ -258,3 +258,12 @@ pub fn set_audio_alsa_plugin(
|
||||
let store = state.store.lock().map_err(|e| format!("Lock error: {}", e))?;
|
||||
store.set_alsa_plugin(plugin)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn set_audio_alsa_hardware_volume(
|
||||
state: tauri::State<'_, AudioSettingsState>,
|
||||
enabled: bool,
|
||||
) -> Result<(), String> {
|
||||
let store = state.store.lock().map_err(|e| format!("Lock error: {}", e))?;
|
||||
store.set_alsa_hardware_volume(enabled)
|
||||
}
|
||||
@@ -545,6 +545,7 @@ pub fn run() {
|
||||
config::audio_settings::set_audio_sample_rate,
|
||||
config::audio_settings::set_audio_backend_type,
|
||||
config::audio_settings::set_audio_alsa_plugin,
|
||||
config::audio_settings::set_audio_alsa_hardware_volume,
|
||||
// Audio backend commands
|
||||
commands::get_available_backends,
|
||||
commands::get_devices_for_backend,
|
||||
|
||||
@@ -206,6 +206,7 @@
|
||||
let dacPassthrough = $state(false);
|
||||
let selectedBackend = $state<string>('Auto');
|
||||
let selectedAlsaPlugin = $state<string>('Hw (Direct Hardware)');
|
||||
let alsaHardwareVolume = $state(false);
|
||||
|
||||
// Backend system state
|
||||
let availableBackends = $state<BackendInfo[]>([]);
|
||||
@@ -289,6 +290,11 @@
|
||||
// Show ALSA plugin selector only when ALSA backend is selected (derived)
|
||||
let showAlsaPluginSelector = $derived(selectedBackend === 'ALSA Direct');
|
||||
|
||||
// Show hardware volume control only for ALSA Direct + Hw plugin (bit-perfect)
|
||||
let showAlsaHardwareVolume = $derived(
|
||||
selectedBackend === 'ALSA Direct' && selectedAlsaPlugin === 'Hw (Direct Hardware)'
|
||||
);
|
||||
|
||||
// Smart toggle states - auto-disable incompatible features
|
||||
let exclusiveModeDisabled = $derived(selectedBackend === 'PipeWire' || selectedBackend === 'Auto' || selectedBackend === 'PulseAudio');
|
||||
let exclusiveModeTooltipOverride = $derived(
|
||||
@@ -715,6 +721,7 @@
|
||||
preferred_sample_rate: number | null;
|
||||
backend_type: 'PipeWire' | 'Alsa' | 'Pulse' | null;
|
||||
alsa_plugin: 'Hw' | 'PlugHw' | 'Pcm' | null;
|
||||
alsa_hardware_volume: boolean;
|
||||
}
|
||||
|
||||
interface BackendInfo {
|
||||
@@ -848,6 +855,8 @@
|
||||
selectedAlsaPlugin = 'Hw (Direct Hardware)';
|
||||
}
|
||||
|
||||
alsaHardwareVolume = settings.alsa_hardware_volume ?? false;
|
||||
|
||||
// Validate mutual exclusion: DAC Passthrough disables Gapless + Crossfade
|
||||
if (dacPassthrough) {
|
||||
if (gaplessPlayback) {
|
||||
@@ -1003,6 +1012,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function handleAlsaHardwareVolumeChange(enabled: boolean) {
|
||||
alsaHardwareVolume = enabled;
|
||||
try {
|
||||
await invoke('set_audio_alsa_hardware_volume', { enabled });
|
||||
console.log('[Audio] ALSA hardware volume changed:', enabled);
|
||||
} catch (err) {
|
||||
console.error('[Audio] Failed to change ALSA hardware volume:', err);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleBackendDeviceChange(deviceName: string) {
|
||||
outputDevice = deviceName;
|
||||
|
||||
@@ -1378,6 +1397,15 @@
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
{#if showAlsaHardwareVolume}
|
||||
<div class="setting-row">
|
||||
<div class="label-with-tooltip">
|
||||
<span class="setting-label">Enable Hardware Volume Control</span>
|
||||
<Tooltip text="Try to control DAC volume via ALSA mixer. Some DACs don't support this - disable for maximum compatibility or enable experimentally. Failure doesn't break playback." />
|
||||
</div>
|
||||
<Toggle enabled={alsaHardwareVolume} onchange={handleAlsaHardwareVolumeChange} />
|
||||
</div>
|
||||
{/if}
|
||||
<div class="setting-row">
|
||||
<div class="label-with-tooltip">
|
||||
<span class="setting-label">{$t('settings.audio.exclusiveMode')}</span>
|
||||
|
||||
Reference in new issue
Block a user