kvm/internal/audio
Alex P 236291a454 Fix: eliminate audio warping by auto-adapting to actual device sample rate
Root cause: ALSA was silently using a different sample rate than configured,
causing severe pitch/speed distortion (the "cassette player" warping effect).

The bug occurred when:
- User configured 48 kHz in UI
- HDMI source output 44.1 kHz audio
- set_rate() failed, set_rate_near() chose 44.1 kHz
- Code never checked what rate was actually set
- Opus encoder created for 48 kHz but received 44.1 kHz audio
- Result: ~9% pitch shift and timing mismatch

Fix:
- Always use set_rate_near() and check the actual rate returned
- Pass detected rate and frame size to Opus encoder/decoder creation
- Avoid modifying global state to prevent capture/playback interference
- Recalculate frame_size for 20ms at the actual rate
- Verify rate after hw_params application
- Add detailed logging for rate adaptation

This ensures Opus encoder/decoder use the correct rate matching the hardware,
regardless of what the HDMI source outputs.
2025-11-18 00:53:15 +02:00
..
c Fix: eliminate audio warping by auto-adapting to actual device sample rate 2025-11-18 00:53:15 +02:00
cgo_source.go Fix: improve EDID compatibility and add audio configuration options 2025-11-18 00:53:15 +02:00
cgo_source_stub.go Add runtime configurable audio parameters with UI controls 2025-11-17 21:51:08 +02:00
relay.go Add runtime configurable audio parameters with UI controls 2025-11-17 21:51:08 +02:00
source.go Fix: improve EDID compatibility and add audio configuration options 2025-11-18 00:53:15 +02:00