+ buffersize = (unsigned int)ceil((double)requested->speed / 25.0); // 2048 bytes on 24kHz to 48kHz
+
+ // Init the SDL Audio subsystem
+ wantspec.callback = Buffer_Callback;
+ wantspec.userdata = NULL;
+ wantspec.freq = requested->speed;
+ wantspec.format = ((requested->width == 1) ? AUDIO_U8 : AUDIO_S16SYS);
+ wantspec.channels = requested->channels;
+ wantspec.samples = CeilPowerOf2(buffersize); // needs to be a power of 2 on some platforms.
+
+ Con_Printf("Wanted audio Specification:\n"
+ "\tChannels : %i\n"
+ "\tFormat : 0x%X\n"
+ "\tFrequency : %i\n"
+ "\tSamples : %i\n",
+ wantspec.channels, wantspec.format, wantspec.freq, wantspec.samples);
+
+ if ((audio_device = SDL_OpenAudioDevice(NULL, 0, &wantspec, &obtainspec, 0)) == 0)
+ {
+ Con_Printf( "Failed to open the audio device! (%s)\n", SDL_GetError() );
+ return false;
+ }
+
+ Con_Printf("Obtained audio specification:\n"
+ "\tChannels : %i\n"
+ "\tFormat : 0x%X\n"
+ "\tFrequency : %i\n"
+ "\tSamples : %i\n",
+ obtainspec.channels, obtainspec.format, obtainspec.freq, obtainspec.samples);
+
+ // If we haven't obtained what we wanted
+ if (wantspec.freq != obtainspec.freq ||
+ wantspec.format != obtainspec.format ||
+ wantspec.channels != obtainspec.channels)