From f91f177b9a8def28f1f8a870fc42e7c97de1eb9e Mon Sep 17 00:00:00 2001 From: pstruebi Date: Fri, 31 Oct 2025 11:05:38 +0100 Subject: [PATCH] feat: enforce 48kHz audio capture and fix device detection - Changed audio capture rate to fixed 48kHz instead of using device default to prevent resampling latency and 44.1kHz compatibility issues - Updated device detection to use get_alsa_usb_inputs() instead of get_usb_pw_inputs() for more accurate USB audio device discovery - Maintains original channel count logic to use maximum of 2 channels based on device capabilities --- src/auracast/server/multicast_server.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/auracast/server/multicast_server.py b/src/auracast/server/multicast_server.py index 5d2a1de..90976ed 100644 --- a/src/auracast/server/multicast_server.py +++ b/src/auracast/server/multicast_server.py @@ -198,7 +198,8 @@ class StreamerWorker: # TODO: is wraping in this Worker stricly nececcarry ? if big.audio_source.startswith('device:'): big.audio_source = f'device:{device_index}' devinfo = sd.query_devices(device_index) - capture_rate = int(devinfo.get('default_samplerate') or 48000) + # Force capture at 48 kHz to avoid resampler latency and 44.1 kHz incompatibilities + capture_rate = 48000 max_in = int(devinfo.get('max_input_channels') or 1) channels = max(1, min(2, max_in)) for big in conf.bigs: @@ -446,7 +447,7 @@ async def _autostart_from_settings(): ): return # Check against the cached device lists - usb = [d for _, d in get_usb_pw_inputs()] + usb = [d for _, d in get_alsa_usb_inputs()] net = [d for _, d in get_network_pw_inputs()] names = {d.get('name') for d in usb} | {d.get('name') for d in net} if input_device_name in names: