We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2835

Summary: Audio Latency - Artificial buffer limit of 1/4 second.
Product: SDL Reporter: Jon Olick <zelexi>
Component: audioAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 Keywords: triage-2.0.4
Version: 2.0.3   
Hardware: x86_64   
OS: Windows 8   

Description Jon Olick 2015-01-07 01:05:50 UTC
Turns out in the code there is an artificial mimimum audio buffer size of a quarter second. This is a pretty significant amount of latency, especially in VR. Removing the minimum was an easy fix for this.

--- a/deps/sdl2-2.0.3/src/audio/winmm/SDL_winmm.c
+++ b/deps/sdl2-2.0.3/src/audio/winmm/SDL_winmm.c
@@ -280,8 +280,8 @@ WINMM_OpenDevice(_THIS, const char *devname, int iscapture)
         this->spec.channels = 2;        /* !!! FIXME: is this right? */

     /* Check the buffer size -- minimum of 1/4 second (word aligned) */
-    if (this->spec.samples < (this->spec.freq / 4))
-        this->spec.samples = ((this->spec.freq / 4) + 3) & ~3;
+    //if (this->spec.samples < (this->spec.freq / 4))
+    //    this->spec.samples = ((this->spec.freq / 4) + 3) & ~3;

     while ((!valid_datatype) && (test_format)) {
         switch (test_format) {
Comment 1 Ryan C. Gordon 2015-02-19 06:32:14 UTC
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry
if you got a lot of email from this. This is to help me sort through some bugs
in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4,
though!
Comment 2 Ryan C. Gordon 2015-03-24 06:13:41 UTC
This patch is now https://hg.libsdl.org/SDL/rev/eb1bde345c4b, thanks!

--ryan.