[SDL] SDL 2.0.4, MacOsX and 32 Bits: sound problem solved. It's not SDL but Hatari code.

Jerome Vernet vernet.jerome at wanadoo.fr
Mon Sep 19 22:41:44 PDT 2016


Hello,

Found the problem. It's not (really) SDL problem but in Hatari.

When using SDL_OpenAudio, you NEED to pass as second parameter a
SDL_AudioSpec, NOT null. SDL return in this SDL_AudioSpec what it get,
NO MORE in the first parameter.
In 32 Bit, on MacOsX, desiredAudioSpec.size is not initialized and take
whatever value.

So the code have to be:

SDL_AudioSpec desiredAudioSpec,obtained;
...
if (SDL_OpenAudio(&desiredAudioSpec, &obtained))    /* Open audio device */
    {
        fprintf(stderr, "Can't use audio: %s\n", SDL_GetError());
        bSoundWorking = false;
        ConfigureParams.Sound.bEnableSound = false;
        SDL_QuitSubSystem(SDL_INIT_AUDIO);
        return;
    }

    SoundBufferSize = obtained.size;    /* May be different than the
requested one! */
    SoundBufferSize /= 4;                /* bytes -> samples (16 bit
signed stereo -> 4 bytes per sample) */
    if (SoundBufferSize > MIXBUFFER_SIZE/2)
    {
        fprintf(stderr, "Warning: Soundbuffer size is too big!\n");
    }



More information about the SDL mailing list