Hi all,
“My first post” ©
I’m writing a 2D game engine and have the image, sprite, background and app working etc.
I want my code to be able to run on Linux later.
Everything works as expected and compiles using various IDE gnu combinations: SDL 1.2.x,
c++ and the ming toolset on windows - IDE’s netbeans codebase, dev-cpp.
BUT no matter what combinations of parameters I pass to SDL_OpenAudio [eg see partial log below],
I cannot get the callback period below ~ 250ms which is a problem as there is a ~ 1/4 sec
delay between sprite event eg explosions and sound.
000001 000 00 [000000] zeng_audio : desired: freq [22050] samples[512] size[0]
000002 000 00 [000000] zeng_audio : desired: (samples*1000) / freq = 23
000003 000 00 [000000] zeng_audio : calling SDL_OpenAudio...
000004 000 00 [000051] zeng_audio : desired: freq [22050] samples[5512] size[11024]
000005 000 00 [000051] zeng_audio : desired: (samples*1000) / freq = 249
000006 000 00 [000051] zeng_audio : obtained: freq [22050] samples[5512] size[11024]
000007 000 00 [000051] zeng_audio : obtained: (samples*1000) / freq = 249
000001 000 00 [000000] zeng_audio : desired: freq [48000] samples[512] size[0]
000002 000 00 [000000] zeng_audio : desired: (samples*1000) / freq = 10
000003 000 00 [000000] zeng_audio : calling SDL_OpenAudio...
000004 000 00 [000056] zeng_audio : desired: freq [48000] samples[12000] size[24000]
000005 000 00 [000056] zeng_audio : desired: (samples*1000) / freq = 250
000006 000 00 [000056] zeng_audio : obtained: freq [48000] samples[12000] size[24000]
000007 000 00 [000056] zeng_audio : obtained: (samples*1000) / freq = 250
000122 000 06 [006322] AudioCallback : elasped ms[254]
000123 000 06 [006576] AudioCallback : elasped ms[254]
000124 000 06 [006820] AudioCallback : elasped ms[244]
000125 000 06 [006863] sprites_updateWC : setDying spritesid[36] id[34]
000126 000 06 [006863] sprites_imagePut : dying: replace sprite pos [16] id[34] with explosion id[37]
000127 000 06 [006863] sprites_imagePut : dying: delete sprite id[34]
000128 000 06 [006863] soundplay : playarray[0]
000129 000 06 [006863] sprites_imagePut : dying: replace sprite pos [17] id[36] with explosion id[38]
000130 000 06 [006863] sprites_imagePut : dying: delete sprite id[36]
000131 000 06 [006863] soundplay : playarray[1]
000132 000 07 [007073] AudioCallback : elasped ms[253]
As you can see above the routine playsound fires twice at ~ 6863ms [two explosions] but the audio
callback is on a ~ 250ms delay !
I’ve browsed some of the SDL audio lib code and it seems that no matter what you pass to
SDL_OpenAudio it sets a callback delay using parameters [ (samples*1000) / freq] from the
audio driver itself -
Does anyone know how to get this callback delay down from 250ms ?
Thanks in advance,
woof