| Summary: | directsound: underruns with 44100Hz/1024 samples, not in SDL1.2, due to timer resolution change | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Eric Wasylishen <ewasylishen> |
| Component: | audio | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | sezeroz |
| Version: | HG 2.1 | Keywords: | target-2.0.4 |
| Hardware: | x86_64 | ||
| OS: | Windows 8 | ||
Yeah, we should be upping the timer resolution by default and offer a hint to tell SDL not to for the unlikely cases you wouldn't want it. There's some coderot that is preventing this from working correctly though. Fixing it now. --ryan. This is fixed in https://hg.libsdl.org/SDL/rev/7454bfce9202, thanks! --ryan. Thanks! Confirmed the fix works for me. |
Requesting a 1024 sample buffer for 44100Hz audio worked fine with SDL1.2, but I get buffer underruns with these settings in SDL2 with the directsound backend. Steps to reproduce: In test/loopwave.c: + SDL_AudioInit("directsound"); + wave.spec.callback = fillerup; + wave.spec.samples = 1024; + wave.spec.freq = 44100; Also replace sample.wav with a 44100Hz sample, otherwise you'll have sped-up audio. Expected is pop-free audio, observed behaviour is occasional pops in the audio (every few seconds). I can't reproduce it 100% of the time, but the issue usually comes back after a reboot or restarting VS. Tested on Windows 8, on two systems, one Cirrus Logic and one Realtek audio. Analysis: -The cause seems to be SDL1.2 set the OS timer resolution to 1ms a startup (in SDL_StartTicks), but SDL2 no longer does this. The default 15 ms resolution in Windows 8 is too large for the directsound backend to work with 1024 samples / 44100Hz. I realize that changing the default timer resolution is a separate topic, and defaulting to 1ms for SDL2 would increase power use. However, I think asking for a 1024 sample buffer to work with directsound is not unreasonable, that's 23ms, and it used to work in SDL1.2. One possible solution could be calling timeBeginPeriod/timeEndPeriod in the directsound wait function, so the extra power use only applies when the directsound backend is used, and the timer res change won't be visible outside (assuming it works to change the resolution for a short block of time like that.)