feat: add detailed audio device logging for input stream setup

- Added comprehensive logging of audio device configuration when opening input stream
- Included host API name, device details, channel count, and latency parameters in logs
- Added PortAudio version logging to help with troubleshooting
- Implemented error handling for device query failures with warning log output
This commit is contained in:
2025-11-03 16:12:09 +01:00
parent 230db3a96b
commit c01bdb8b96
+23 -1
View File
@@ -60,7 +60,29 @@ class ModSoundDeviceAudioInput(audio_io.SoundDeviceAudioInput):
def _open(self):
"""Patched _open method that creates RawInputStream with low-latency parameters."""
try:
dev_info = sd.query_devices(self._device)
hostapis = sd.query_hostapis()
api_index = dev_info.get('hostapi')
api_name = hostapis[api_index]['name'] if isinstance(api_index, int) and 0 <= api_index < len(hostapis) else 'unknown'
pa_ver = None
try:
pa_ver = sd.get_portaudio_version()
except Exception:
pass
logging.info(
"SoundDevice backend=%s device='%s' (id=%s) ch=%s default_low_input_latency=%.4f default_high_input_latency=%.4f portaudio=%s",
api_name,
dev_info.get('name'),
self._device,
dev_info.get('max_input_channels'),
float(dev_info.get('default_low_input_latency') or 0.0),
float(dev_info.get('default_high_input_latency') or 0.0),
pa_ver[1] if isinstance(pa_ver, tuple) and len(pa_ver) >= 2 else pa_ver,
)
except Exception as e:
logging.warning("Failed to query sounddevice backend/device info: %s", e)
# Create RawInputStream with injected low-latency parameters
self._stream = sd.RawInputStream(
samplerate=self._pcm_format.sample_rate,