Skip to content
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

More audio buffering fixes (primarily affects SDL) #12916

Merged
merged 6 commits into from
May 17, 2020

Conversation

hrydgard
Copy link
Owner

Started with the assumption that something was wrong with the rate adjustment logic, but couldn't find anything, just bad variable names not describing what was going on. Instead it turned out that the target buffer size (which is what lowwatermark really was) simply was lower than the default buffer size in SDL, which can never work reliably, leading to #12705.

Eventually ended up clamping the target buffer size so it's always larger than the SDL buffer size with some margin, and also reduced the SDL buffer size from 2048 to 1024.

So this change could have been a bit smaller but I want to keep the renaming and minor refactorings I did.

I want to later change to SDL_QueueAudio but really wanted to get this solid first.

Ported the changes to the SDL audio code used by Qt, too (we should really share that...)

Fixes #12705 , hopefully.

@hrydgard hrydgard added SDL2 Issue on SDL (or Qt in SDL code) but not all ports. Audio labels May 17, 2020
@hrydgard hrydgard added this to the v1.10.0 milestone May 17, 2020
@hrydgard
Copy link
Owner Author

Just gonna go ahead and merge, I think it's pretty safe.

@hrydgard hrydgard merged commit dc0bc00 into master May 17, 2020
Copy link
Collaborator

@unknownbrackets unknownbrackets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this makes sense. Definitely more readable now...

-[Unknown]

@@ -248,7 +263,8 @@ unsigned int StereoResampler::Mix(short* samples, unsigned int numSamples, bool
// Flush cached variable
m_indexR.store(indexR);

return realSamples / 2;
// TODO: What should we actually return here?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think actually produced samples is best, then padding can be decided per platform.

-[Unknown]

@hrydgard hrydgard deleted the more-samplerate-fixes branch May 17, 2020 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Audio SDL2 Issue on SDL (or Qt in SDL code) but not all ports.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Frequent audio popping and clicking sounds in most games.
2 participants