[BUG]SDL2_mixer init error [format] support not available


#1

Hello, I’m making this thread because i’ve a really annoying problem.
I’m making a game using sdl, everything works, except SDL2_mixer, when i try to initialise sdl2_mixer with any format, i always get the error " [format] support not available" so for instance, no ogg support or no mp3 support.

this is my initialisation script

///Checks if the SDL is correctly initialised
	if (SDL_Init(SDL_INIT_EVERYTHING))
	{
		cout << "An error occured while initializing SDL : " << SDL_GetError() << endl;
		SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SDL error", (string("An error occured while initialising SDL : ") + string(SDL_GetError())).c_str(), nullptr);
		isRunning = false;
		return -1;
	}
	if (TTF_Init() )
	{
		cout << "An error occured while initialising SDL_TTF : " << TTF_GetError() << endl;
		SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SDL_ttf error", (string("An error occured while initialising SDL_ttf : ") + string(TTF_GetError())).c_str(), nullptr);
		isRunning = false;
		return -1;
	}
	if (!IMG_Init(IMG_INIT_PNG))
	{
		cout << "An error occured while initialising SDL_IMG : " << IMG_GetError() << endl;
		SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SDL_IMG error", (string("An error occured while initialising SDL_IMG : ") + string(IMG_GetError())).c_str(), nullptr);
		isRunning = false;
		return -1;
	}
	int flag = MIX_INIT_OGG;
	int truc = 0;
	if (flag != (truc = Mix_Init(flag)))
	{
		cout << "An error occured while initialising SDL_mixer : " << Mix_GetError() << endl;
		SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SDL_mixer error", (string("An error occured while initialising SDL_mixer : ") + string(Mix_GetError())).c_str(), nullptr);
		isRunning = false;
		return -1;
	}

all the dll are in the directory

what could be causing this problem ?


#2

We discovered that it was a bug, downgrading to sdl mixer 2.0.0 fixed the problem
it’s a problem in the defines of the ogg and some others dynamic libraries
the bug is present in the 2.0.2 version


#3

[UPDATE]:
this is actually a bug in user code that results from specifying mix_init before open_audio has been called, as detailed here:
https://trac.ffmpeg.org/ticket/6721

This is counterintuitive, as the ‘init’ functions are always called before other functions in both SDL2 and SDL_image.
Still, that’s the fix - it doesn’t make a difference which order you do it in in earlier versions of SDL_mixer.


#4

Thank you @mattbentley so much for this fix suggestion!!!
I avoided upgrading to SDL 2.0.8 and Mixer 2.0.2 because of this when they both first appeared, and was even more discouraged that there was very little if any discussion about it.

I recently wanted to try out some of the new audio functionality introduced back in 2.0.6, so I upgraded again, and relived the frustration of not knowing why it was failing.

FWIW - I did not find the link from ffmpeg ticket helpful at all, maybe I just didn’t see it, but I didn’t see anywhere that it mentioned the fix as you did about called Mix_OpenAudio prior to Mix_Init.

Anyway, thanks again!!


#5

You’re most welcome!

Hopefully they fix this issue, at some point.