-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sdl audio queueing #1806
Sdl audio queueing #1806
Conversation
…er queueing logic more resilient for jitter, and factor out a common parameter 'SDL.audio.numSimultaneouslyQueuedBuffers' that can be used to tune for a good quality<->latency balance.
@@ -1469,7 +1469,7 @@ var LibrarySDL = { | |||
} else if (SDL.audio.channels != 1 && SDL.audio.channels != 2) { // Unsure what SDL audio spec supports. Web Audio spec supports up to 32 channels. | |||
console.log('Warning: Using untested number of audio channels ' + SDL.audio.channels); | |||
} | |||
if (SDL.audio.samples < 1024 || SDL.audio.samples > 524288 /* arbitrary cap */) { | |||
if (SDL.audio.samples < 512 || SDL.audio.samples > 524288 /* arbitrary cap */) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not remove the lower limit at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very small buffer sizes are nearly insane and will kill cpu processing power. I think it's good to have a limit. I'll lower this to 128, so this can catch any silly bogus values that someone could accidentally pass.
Ok, updated the pull request. |
++SDL.audio.numAudioTimersPending; | ||
Browser.safeSetTimeout(SDL.audio.caller, 1.0); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent here looks wrong
lgtm with indentation fix |
…to allow user code to configure how many SDL audio buffers to keep simultaneously queued up for the audio backend. More buffers means less change of starving (and cracking audio), but increases latency. Fewer buffers lower the latency at the risk of playback glitches. Make minimum audio buffer size 128, which should be way below anything reasonable already. Clean up commented out code.
Improves SDL audio streaming support, based on experiences from the MESS codebase. Thanks to Vito`` and DopefishJustin for the feedback!