Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Danfun64

IMPORTANT FOR DEVS: SDL2 2.0.6's audio breakage in Windows

Recommended Posts

I bumped into a bug when running using Mupen64Plus's audio plugin (detailed here )

Quote

SDL 2.0.6 changed the audio backend on Windows to WASAPI, with that change, the audio format is forced to 32bit floating point samples. Audio-sdl only outputs 16 bit integer samples currently, so it needs to convert the samples to the proper format before feeding them to SDL

This bug affects other software that uses SDL2, which includes PrBoom-Plus (and possibly the SDL2 branches of Chocolate Doom and Eternity as well, though i haven't tested those two personally).

Share this post


Link to post

This bug has been reported by fraggle, https://bugzilla.libsdl.org/show_bug.cgi?id=3858 which apparently is an amalgam of issues https://bugzilla.libsdl.org/show_bug.cgi?id=3848 and https://bugzilla.libsdl.org/show_bug.cgi?id=3849.

 

I also spotted this when I switched to SDL2.0.6 release for Eternity on the SDL2 branch. It's worth noting that I found this post, which seemingly managed to fix the bug when I applied the code therein (#if guarded so it only executes on Windows): https://discourse.libsdl.org/t/sdl-2-0-6-released/23109/21

Share this post


Link to post

@Altazimuth thanks! Those bugtracker links are the most likely explanation for the following observation. Since libsdl2 2.0.6 went in to Debian, Chocolate Doom sd2-branch segfaults instantly somewhere deep inside the library whenever the game tries to play a sound. This only happens with normal sounds - PC speaker emulation and OPL music are fine. PrBoom+ is likewise unaffected. I hadn't had chance to debug it further but it seems @fraggle is already on top of it.

Share this post


Link to post

Thanks for bringing more visibility to this.

 

From following @sdl_commits on Twitter, I know there have been a bunch of audio-related changes over the past month or so. I suspect these are to blame.

Share this post


Link to post

I also had to move down to SDL2 2.0.5, as I suspected like @fraggle said -- they made a bunch of audio changes which caused a no-sound situation in EDGE. I wonder if they are going to fix those issues for SDL 2.0.7, or if our ports should manually patch the sound processing oddities. . or just "stick with SDL2 2.0.5". :S

Share this post


Link to post

Reportedly, this issue will be fixed in the SDL 2.0.7 release.

Edited by fabian : Turns out 2.0.7 hasn't been released yet

Share this post


Link to post

I can confirm that the prerelease versions of SDL 2.0.7 and SDL_mixer 2.0.2 used together do work, and the full versions won't be very far away.

Share this post


Link to post

sdl2stuffisout.png

 

EDIT: I still have to have the

#if EE_CURRENT_PLATFORM == EE_PLATFORM_WINDOWS
   SDL_setenv("SDL_AUDIODRIVER", "directsound", true);
#endif

otherwise all sound effects are pitched too high. Anybody else get that?

Edited by Altazimuth

Share this post


Link to post
11 hours ago, Altazimuth said:

I still have to have the


#if EE_CURRENT_PLATFORM == EE_PLATFORM_WINDOWS
   SDL_setenv("SDL_AUDIODRIVER", "directsound", true);
#endif

otherwise all sound effects are pitched too high. Anybody else get that?

Yes, I have. My solution was to stop using SDL_BuildAudioCVT(), do the conversion manually and then apply a low pass filter. See here. Might not be appropriate for Eternity though. Also, apparently support for the DirectSound audio driver will eventually be removed.

 

EDIT: There's also the new SDL_HINT_AUDIO_RESAMPLING_MODE hint, which may come in handy.

Edited by bradharding

Share this post


Link to post

OK so I have this weird-ass bug where eventually SDL_Init(SDL_INIT_JOYSTICK) doesn't just not fail, but the program hangs on it. Like mysteriously even the version that worked earlier today that I compiled has stopped working.

Share this post


Link to post

Another problem that may occur with 2.0.7 - if the game/port is started in fullscreen mode and then changed to windowed (by Alt+Enter combination), window frame will be borderless. However, after pressing Alt+arrows borders will appear.

Share this post


Link to post

What is the benefit, slightly off-topic, of using SDL_Mixer? EDGE doesn't use it as it has its own internal sound mixing stuff -- is it worth it to support a broader range of audio formats and effects? For instance, if it supports VOC then I would definitely incorporate it as I need a VOC decoder for ROTT SFX, but would I have to change the rest of the sound code around to compensate?

 

 

Share this post


Link to post

AFAIK the main benefit is music playback. IIRC most SDL-based ports still mix the game sound effects on their own.

 

I'm far more curious why basically no port aside from the ZDoom family has ever considered to use a real sound API like OpenAL instead and still stick to the same minimalistic approach that was originally used in 1993.

 

Share this post


Link to post
10 hours ago, Coraline said:

For instance, if it supports VOC then I would definitely incorporate it as I need a VOC decoder for ROTT SFX, but would I have to change the rest of the sound code around to compensate?

Decoding VOC is pretty simple because it's just PCM data (technically there are other formats but in practice, in all the games I have, I've only found PCM vocs); you can find code in SLADE that converts it to WAV on-the-fly.

Share this post


Link to post
17 hours ago, Graf Zahl said:

AFAIK the main benefit is music playback. IIRC most SDL-based ports still mix the game sound effects on their own.

 

I'm far more curious why basically no port aside from the ZDoom family has ever considered to use a real sound API like OpenAL instead and still stick to the same minimalistic approach that was originally used in 1993.

 

EDGE, at one point, did in fact use OpenAL. I briefly considered restoring it, but, why fix what isn't broken? :-) i don't remember why it reverted to SDL (actually based on SDL_Sound), but I think it works out fine. Not sure if OpenAL works on Linux or not either. Also I remember needing to actually install OpenAL in earlier EDGE builds, and at least the way we do it, we don't need to install anything ^_^

Share this post


Link to post

I guess it used the 'official' OpenAL, which indeed is not the greatest package out there. It's old and essentially unsupported.

ZDoom uses OpenAL Soft which is being developed for all relevant OSs there.

 

Share this post


Link to post

Do you use OpenAL Soft for Windows midi playback? Ive been hunting for an alternative, because if you aren't using WinXP, all EDGE offers ATM is OPL/OPL3 and Timidity. I think the system mixer works on Linux, but if it will get native MIDI under Windows, I'm all ears :-)

Share this post


Link to post
On 10/26/2017 at 2:45 AM, Gez said:

Decoding VOC is pretty simple because it's just PCM data (technically there are other formats but in practice, in all the games I have, I've only found PCM vocs); you can find code in SLADE that converts it to WAV on-the-fly.

Also, thank you so much Gez!! That's exactly what I needed :-) I might hit you up (just a warning) about other ROTT format intricies (I see SLADE3 supports nearly all of the IWAD data). :-)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×