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 2.0.6 causes crashes with small audio buffer sizes #945
Comments
Changed description to be more specific; if it is incorrect please fix. |
Here's what is happening with latest Chocolate Doom build on Windows:
I was trying to recompile CD sources with updating SDL's development libraries to 2.0.6, but no luck. Also, @turol explained on IRC that this is seems to be a combination problem of new SDL + SDL_mixer, i.e., we need a new version of SDL_mixer which was not released yet. |
Filed a bug with SDL: |
This has been resolved upstream by SDL devs. https://bugzilla.libsdl.org/show_bug.cgi?id=3858 |
It's known now (#945) that the game is unusable with SDL 2.0.6 due to a crash bug in the sound code. To avoid recurring bug reports about this, add a guard in the sound startup code that will cause the game startup to abort if the user has v2.0.6 installed.
Updated to 2.0.7 a moment ago. The crash is still happening, at least on Linux. |
I can confirm it is still crashing on Arch Linux with SDL 2.0.7. |
Thanks for the feedback. I've reopened the SDL bug. |
@fragglet do you think it is up to SDL developers to fix or do you think chocolate-doom should, somehow, find a fix ? |
The fix from our end is to not ship prebuilt binaries containing SDL 2.0.6 or SDL 2.0.7. The rest is up to the SDL devs. |
I'm getting a crash with 4746d23 on macOS 10.13 and SDL 2.0.7 installed from homebrew. I think there is a bug in chocolate doom: I added a
btw I configured with:
|
My 2 cents about this topic, the above comment seems to confirm what I thought at this time |
The problem is the SDL_BuildAudioCVT() call in i_sdlsound.c. SDL_BuildAudioCVT(&convertor, AUDIO_U8, 1, 11025, AUDIO_S16LSB, 2, 44100)); one would expect convertor.len_mult to be set to 16 (2*2*4), but instead it's set 64. --- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -208,7 +208,7 @@ static allocated_sound_t *AllocateSound(sfxinfo_t *sfxinfo, size_t len)
do
{
- snd = malloc(sizeof(allocated_sound_t) + len);
+ snd = malloc(4 * (sizeof(allocated_sound_t) + len));
// Out of memory? Try to free an old sound, then loop round
// and try again. |
Here's an alternate patch:
The reason SDL_ConvertAudio requires a larger buffer in 2.0.6/2.0.7 is SDL2 got a "real" (FIR-filter) resampler (previous versions were very poor quality nearest/linear resamplers). Internally it doesn't resample in place now, but writes the output after the input part of the provided buffer, then copies it back to the start. |
@ericwa I would have avoided creating the buf_len variable and just have the multiplication inlined. |
Sounds good - I'll make a PR. |
Similar issue than here
bradharding/doomretro#410
looking at i_sdlsound.c seems the same kind of change fixes the issue (with Doom II again).
@fragglet if you have a better insight since I m not a SDL wizard, would appreciate.
The text was updated successfully, but these errors were encountered: