SDL_OpenAudio changes my SDL_AudioSpec 'samples' field

I have an application that does the following:


   sdlAudioSpec.callback = SDL_GetMoreData;
   sdlAudioSpec.userdata = NULL;
   sdlAudioSpec.channels = 1;
   sdlAudioSpec.format = AUDIO_S16SYS;
   sdlAudioSpec.freq = 22050;
   sdlAudioSpec.samples = 1024;

   SDL_OpenAudio ( &sdlAudioSpec, &obtained );

The SDL_OpenAudio returns successfully. However, in Ubuntu inside VirtualBox on my Win7 i5 laptop I see the following change in both ‘sdlAudioSpec’ and ‘obtained’:

.samples = 512

This is true regardless of what I set .samples to before calling SDL_OpenAudio. Then in my callback I see that it’s also only asking for 1024 bytes which is 512 samples at AUDIO_S16SYS-size.

My problem is not that I can’t deal with this situation…it’s just that it seems strange that this occurs only on Ubuntu, not on my native Win7.

In actuality, though, this causes sound problems in my app because I don’t have enough time between interrupts at 512 samples to do what I need to do.

I’ve also heard from another person helping me that, even though 16-bit, 1024 samples, 22050 freq is requested he’s seeing the obtained comes back as 44100 freq.

Is it typical that this should occur? What is the application developers recourse if the SDL audio format required is not “obtainable”?

Is this a libsdl bug in Linux SDL?