[SDL] callback issue
Rhythmic Fistman
rfistman at gmail.com
Sun Apr 29 00:42:00 PDT 2007
> From: "Chris Dobbs" <chris_dobbs at dobbscr.karoo.co.uk>
>
> Futher update on this:
> I tried it on another linux box and guess what ? yep, I get 512 passed in as the length as expected.
> Guess this means there is something not right with the other box, anyone got and ideas what it could be. I am running with SDL1.2 in tandem with the SDL_AudioIn project to provide microphone input.
> Strange thing is I have looke thru some old logs and it definitley used to behave correctly so unless I have installed something that's upset the sound layer or worse the dsp is shot.
The sdl audio callback has a length argument which leaves
open the possibility that you will be asked for more or
even less sound than you specified in SDL_OpenAudio.
I don't know why SDL_OpenAudio asks what buffer size you
want if it's just going to ignore it, but anyway. Some
driver/os/hardware combinations honour it and some don't,
so you always have to put something sensible there.
So, you need to spoon out the audio data in chunk sizes that
SDL asks for:
while(len > 0) {
if(nbytes_in_buffer == 0) generate_more_audio();
int n = min(nbytes_in_buffer, len);
memcpy(dst, snd_buf, n);
len -= n;
nbytes_in_buffer -= n;
}
I've run into this prob on 2 different hp laptops,
one running xp, and the other some linux.
RF
More information about the SDL
mailing list