I am trying to set up basic audio functionality. It seems to me that the first step is to use SDL_GetDefaultAudioInfo to grab the SDL_AudioSpec for the default device so I can use the other audio-related functions. When I try to call SDL_GetDefaultAudioInfo, however, I get an error
‘SDL_GetDefaultAudioInfo’ was not declared in this scope;
Other names from SDL_audio.h appear to be recognized without any issue. I decided to check SDL_audio.h myself, and there isn’t any mention of SDL_GetDefaultAudioInfo in the file at all! I have no clue how this happened. I installed SDL2 for Linux according to SDL2/Installation - SDL2 Wiki, using apt. I never had any problems with missing functions in SDL.h, either.
Have I made a mistake in the installation? Is this function supposed to be missing?
What version of SDL 2 is installed? The docs say that SDL_GetDefaultAudioInfo() was only added in SDL 2.24.0, and a lot of Linux distros ship old versions of SDL 2.
Yes, looking at it again, it seems like I have version 2.0.20. I must have made a mistake in that I checked the release date of 2.24.0 and assumed because it released before I installed my OS, I would have it.
$ apt show libsdl2-2.0-0 Package: libsdl2-2.0-0 Version: 2.0.20+dfsg-2ubuntu1.22.04.1
So if I want to use a more recent version of SDL2, I would need to manually install it? I’ve only done a quick search, but it looks like my available package sources don’t have any recent versions.
I think the naming convention for libsdl2-2.0-0 also confused me a lot. I always assumed that the -2.0-0 suffix was some kind of strange version numbering pattern, but it doesn’t seem like that’s correct?
What does it say if you just check “libsdl2”? Leave the “-2.0-0” off.
(this is because the versioning scheme changed towards the end of SDL2, where it jumped from SDL 2.0.22 to SDL 2.24.0; if you’re specifically requesting SDL 2.0 then you’ll never get anything past SDL 2.0.22)
$ apt search libsdl2
Sorting... Done
Full Text Search... Done
libsdl2-2.0-0/jammy-updates,now 2.0.20+dfsg-2ubuntu1.22.04.1 amd64 [installed]
Simple DirectMedia Layer
libsdl2-dev/jammy-updates,now 2.0.20+dfsg-2ubuntu1.22.04.1 amd64 [installed]
Simple DirectMedia Layer development files
libsdl2-doc/jammy-updates,jammy-updates 2.0.20+dfsg-2ubuntu1.22.04.1 all
Reference manual for libsdl2
Looks like the only version of SDL2 available on my package sources is just 2.0.22. I think I’ll just need to install it manually, which is kind of a pain but it’s not horrible. I also get the feeling that there’s something incredibly obvious that I’m missing, but it really seems like this is just a restriction I need to put up with?
No, it looks like 22.04 is the latest version of Pop!_OS. It’s a shame that I don’t have SDL_GetDefaultAudioInfo, but if my currently installed SDL version is from before it exists, then presumably I can just skip it entirely?