Doing < 0 instead of != 0 is a good catch. Still didn't fix the problem, though. It still failed to initialize.
I did finally get it to work. I basically added one more attempt, using a low sample rate and mono instead of stereo:
Code:
std_error_type err = SUCCESS;
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) != 0)
{
// Failed to initialize SDL_mixer library at CD quality (44.1 KHz)
// Trying the more standard 22050 Hz instead...
if (Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 1024) != 0)
{
// Try cheapest quality
if (Mix_OpenAudio(11025, MIX_DEFAULT_FORMAT, 1, 1024) != 0)
{
err = FAILED;
}
}
}
It was the mono vs stereo that got it working. Apparently some cheaper audio chipsets can't handle stereo output. Changing the channels from 2 to 1 got it working.