mirror of https://github.com/jetkvm/kvm.git
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. |
||
|---|---|---|
| .. | ||
| c | ||
| cgo_source.go | ||
| cgo_source_stub.go | ||
| relay.go | ||
| source.go | ||