SDL_OpenAudioDevice and SDL_OpenAudio fails when setting more that 2 channels in specs

Hi all.

I’m making a simple Media Player with FFMPEG and SDL2.
I’ve finished with the most of it, but now I’m trying to open a MKV video that has 6 channels and both SDL_OpenAudioDevice and SDL_OpenAudio functions fail with the:
“Failed to open audio device: DirectSound CreateSoundBuffer: Invalid parameter.”
message.

This is the code in question:

SDL_AudioSpec wanted_specs;
SDL_AudioSpec specs;

// Set audio settings from codec info
wanted_specs.freq = Audio.ptrAudioCodecCtx_->sample_rate;
wanted_specs.format = AUDIO_S16SYS;

wanted_specs.channels = Audio.ptrAudioCodecCtx_->channels;  // 6 channels
wanted_specs.silence = 0;
wanted_specs.samples = SDL_AUDIO_BUFFER_SIZE;
wanted_specs.callback = audio_callback;
wanted_specs.userdata = videoState;

SDL_AudioInit("directsound");

// open audio device
videoState->audioDevice = SDL_OpenAudioDevice(NULL, 0, &wanted_specs, &specs, 0);
// SDL_OpenAudioDevice returns a valid device ID that is > 0 on success or 0 on failure
if (videoState->audioDevice == 0)
{
    printf("Failed to open audio device: %s.\n", SDL_GetError());
    return -1;
}

Did I miss something?

The hardware doesn’t have a surround sound configuration and you’ve passed 0 for flags, which means that SDL can’t do internal conversion. Try passing

SDL_AUDIO_ALLOW_ANY_CHANGE to SDL_OpenAudioDevice() instead.

I still get the error with the same error string.