steam-runtime icon indicating copy to clipboard operation
steam-runtime copied to clipboard

SDL3_mixer not yet available in sniper due to unstable API

Open ZXcolourclash opened this issue 4 months ago • 15 comments

  • Distribution: Ubuntu Studio 25.04
  • Have you checked for system updates?: Yes
  • What versions are listed in steamapps/common/SteamLinuxRuntime/VERSIONS.txt?
  • sniper 3.0.20250723.149183 sniper 3.0.20250723.149183 # sniper_platform_3.0.20250723.149183/
  • What versions are listed in steamapps/common/SteamLinuxRuntime_soldier/VERSIONS.txt?
  • soldier 2.0.20250723.149182 soldier 2.0.20250723.149182 # soldier_platform_2.0.20250723.149182/
  • What versions are listed in steamapps/common/SteamLinuxRuntime_sniper/VERSIONS.txt?
  • depot 0.20240806.0 # Overall version number

Hi, I've been developing a native Linux game for the Steam on Linux client and Steam Deck, building in the Scout Podman container. The game uses SDL2, including SDL2_mixer.

I would now like to build via the Sniper container (currently 3.0.20250723.149183) and use SDL3, but SDL_mixer 3.x is not available in this container. Do you have an ETA for inclusion of this library?

The official SDL_mixer 3.0 is here, and links to https://github.com/libsdl-org/SDL_mixer/releases but the version there appears to be 2.8.1?

I'm assuming that because libsdl-org/SDL_mixer does not have 3.x releases that's the reason why the Sniper container does not have this yet?

I noticed that OpenAL (openal-soft_1.19.1-2) is available which I may use instead of SDL_mixer if need be.

Thanks in advance.

ZXcolourclash avatar Sep 13 '25 20:09 ZXcolourclash

OK, I did some digging into why SDL_mixer 3 isn't ready yet. Basically it's a complete re-write and much improved but relies on SDL 3.4.0 functionality.

This SDL_mixer Github comment links to a blog post of Ryan's ( @icculus ) https://www.patreon.com/posts/project-sdl3-138034434: Now we have something to show for all our work. You can try SDL3_mixer today, right from its GitHub repo. It currently requires the latest in SDL3's revision control (what will eventually ship as a stable SDL 3.4.0), as that has new APIs that SDL3_mixer relies on.

So it appears that when SDL 3.4.0 stable is released, so will SDL_mixer 3 (officially).

SDL_mixer 3 sounds fantastic and was also shaped with input and testing by the Factorio audio devs.

Could this issue be kept open until the SDL_mixer 3 headers and library are dropped into Sniper please?

Thanks.

ZXcolourclash avatar Sep 14 '25 08:09 ZXcolourclash

Could this issue be kept open until the SDL_mixer 3 headers and library are dropped into Sniper please?

Yes, but we cannot do that until SDL_mixer 3 has a stable API/ABI, and that is blocked by waiting for the SDL 3.4.0 stable release.

We cannot add unstable development versions to the container, because their API/ABI are still subject to change, but then updating them would break games that were already released.

You could bundle a self-built prerelease of SDL 3.3.x and SDL_mixer 3 with your game, at your own risk; but if you do that, then you are responsible for keeping it up to date, and dropping it when those libraries become available "officially".

@kisak-valve or @TTimo, please could you retitle this issue to something more like

SDL3_mixer not yet available in sniper due to unstable API

to make its scope a bit clearer? A reader might think that the current title means we don't have SDL2_mixer, which is not true.

smcv avatar Sep 16 '25 11:09 smcv

I noticed that OpenAL (openal-soft_1.19.1-2) is available which I may use instead of SDL_mixer if need be.

That could be a good alternative if it's suitable for your use-case.

Or you could stay with SDL 2 until the whole SDL 3 family is ready for your requirements (including the mixer). SDL 2 is still a supported API in sniper: we'll probably replace "classic" SDL 2 with sdl2-compat when it's a bit more mature, but it is not going to go away.

smcv avatar Sep 16 '25 11:09 smcv

I'm assuming that because libsdl-org/SDL_mixer does not have 3.x releases that's the reason why the Sniper container does not have this yet?

As a general rule, whenever something doesn't have stable releases yet, it's too early for us to be able to ship it in a stable runtime.

smcv avatar Sep 16 '25 11:09 smcv

@smcv Thanks for the feedback.

I understand that you cannot bundle unstable releases in Sniper (stable), so in the meantime I'll have a look at OpenAL or possibly make a simple wrapper around SDL AudioStream.

Or you could stay with SDL 2 until the whole SDL 3 family is ready for your requirements (including the mixer). SDL 2 is still a supported API in sniper: we'll probably replace "classic" SDL 2 with sdl2-compat when it's a bit more mature, but it is not going to go away.

The reason for the switch from SDL2 to 3 is because I've developed my game entirely on Kubuntu and it was time for a Windows build test, but the Win X64 releases (DLLS etc) on the SDL Github page are only for 3.2.22, so I thought I'd upgrade to SDL3 on my Linux build first and that's where the SDL_mixer issue came up.

Anyway, thank you for all the fantastic work you and Valve et all have done for Linux gaming. I can't believe how far it's come since I watched 'Game Development with SDL 2.0 (Steam Dev Days 2014)'.

;-)

ZXcolourclash avatar Sep 16 '25 12:09 ZXcolourclash

Hey @ZXcolourclash, there are still a lot of 2.x releases available for all SDL libraries like this here: https://github.com/libsdl-org/SDL/releases/tag/release-2.32.10

I also wanted to at least use most of SDL3 and I would be happy to use SDL2_mixer in conjunction with the rest of SDL3 and it appears to be possible with this (I have not tried this yet, but I want to): https://github.com/libsdl-org/SDL_mixer/tree/sdl2-api-on-sdl3

It would be good to have a release of this "sdl2-api-on-sdl3", for people who don't want or can't create their own binaries @smcv 🤔

Cheers 🖖 ~ Jan

sor avatar Sep 16 '25 17:09 sor

I would be happy to use SDL2_mixer in conjunction with the rest of SDL3

This is not possible. You can use either SDL 2 or SDL 3, but you cannot mix the two APIs within one process.

The "sdl2-api-on-sdl3" branch of SDL_mixer is not SDL2_mixer, and it is not the future SDL3_mixer either; it is a third, incompatible thing that vaguely resembles the SDL2_mixer API, but depends on SDL3.

It would be good to have a release of this "sdl2-api-on-sdl3"

It is not up to me whether there will be a release of that: that's up to SDL upstream, who do not seem to have any intention to do releases of that branch as something independent of the "real" SDL3_mixer.

If there is no stable release, then we can't include it in sniper: that would just break games later, when the "real" SDL3_mixer appears.

I believe the intention for that branch is that you could build your own and bundle or statically link it into your game, if you want to do that.

smcv avatar Sep 16 '25 19:09 smcv

It would be good to have a release of this "sdl2-api-on-sdl3"

Feedback from upstream is: no, that branch will never have releases. If you want to use that branch of the library, then you will have to build your own copy as a static library that you can link into your game.

for people who don't want or can't create their own binaries

I'm not sure I understand this. If you want to use SDL_mixer, then you need to have a C/C++ executable (your game or game engine) to link it into, but if that's the case then you are already compiling C/C++ code into your own binaries, and you could certainly add a suitable branch of SDL_mixer to that build process.

smcv avatar Sep 19 '25 11:09 smcv

Thanks for your reply. I have compiled that hybrid sdl2/3_mixer thing and it works fine for me for now and I will switch to proper sdl3_mixer once it's released.

I was just thinking of people who like to grab some precompiled .dll/.so, to just care about compiling their app and not a lot else, especially if it's not for their daily comfortable OS - thanks for bringing this to upstream and I totally get that they rather want to finish sdl3_mixer than release frankenstein mixers ;)

sor avatar Sep 29 '25 23:09 sor

Update: OK so I completely removed SDL2_Mixer from my game engine and replaced it with direct calls to the SDL3 Audio sub-system. IMO this is a great API as there are no user-defined callback funcs needed by default and it works marvellously.

I created separate logical audio devices (SDL_AudioDeviceID's), one each for music and SFX. In this way I could independently set the logical device gain (volume) of the music and SFX. Music and SFX can also be paused and resumed independently.

In SDL2_mixer, music and SFX (samples) were separate types, but in SDL3, music and SFX are both SDL_AudioStreams and are treated the same. Without too much bother, my engine is able to load music and SFX data from (compiled-in) source files (arrays) into the streams. A per-frame audio update func in the game engine checks if any audio streams need more data and fills their respective buffers, changing music tracks using SDL_ClearAudioStream(), and rapidly fading out/in streams using SDL_SetAudioDeviceGain() to prevent pops.

As it stands the engine has simple music and SFX playback functionality which is all I require at the moment, your needs may differ.

SDL3_mixer includes audio effects, so I'll definitely be looking to add that when its released in Sniper... "It offers audio file decoding, mixing multiple sounds together, basic 3D positional audio, and various audio effects."

If anyone needs help on this migration, message me ;-)

Helpful links: SDL3 Audio sub-system libsdl.org examples

ZXcolourclash avatar Oct 29 '25 14:10 ZXcolourclash

Very cool. :)

icculus avatar Oct 29 '25 15:10 icculus

I completely removed SDL2_Mixer from my game engine and replaced it with direct calls to the SDL3 Audio sub-system [and used that for multiple audio streams]

@icculus, @slouken: am I correct to think that some of the lower-level audio mixing functionality that used to require SDL_mixer has been absorbed by core SDL3, and therefore in SDL3 world, SDL_mixer is only necessary if you want the features that are out-of-scope for core SDL3, like decoding compressed audio formats, audio effects, and positional audio?

If yes, it might be worth mentioning that in its readme, so that developers porting from SDL2 + SDL2_mixer don't assume that they will necessarily need to wait for SDL3_mixer.

smcv avatar Nov 03 '25 12:11 smcv

The primary thing in SDL3 is you can just bind multiple audio streams to an opened device (or open the same physical device multiple times, each with a separate input), and it will handle the mixing, and that is definitely a significant part of SDL_mixer's functionality, but I think there's a significant value-add over that, especially in SDL3_mixer.

What @ZXcolourclash did was definitely a boss move, but I'm not prepared to say it's the right approach for most people.

icculus avatar Nov 03 '25 12:11 icculus

Hi @icculus, thanks for the kudos ;-) and thank you both for the work that you and @slouken have put into SDL, its such a great library, especially for Linux gaming imo. It's the main reason I started this game dev journey, and being made aware of SDL with Game Development with SDL 2.0 (Steam Dev Days 2014).

@smcv I would like to add stereo panning to my engine using SDL3_audio so I'll update this thread if successful.

ZXcolourclash avatar Nov 03 '25 13:11 ZXcolourclash

I would like to add stereo panning to my engine using SDL3_audio so I'll update this thread if successful

I think it would be better to take that to a different location (SDL's Discourse forum, perhaps?), and keep the scope of this issue limited to "why sniper can't have SDL3_mixer yet".

smcv avatar Nov 03 '25 14:11 smcv