Handmade Hero»Forums»Code
Benjamin Pedersen
46 posts
Mathematician
Writing audio to game_sound_output_buffer before polling PlayCursor / WriteCursor
Edited by Benjamin Pedersen on
I was thinking:
We know approximately how much we want to write to the sound buffer each frame and we can afford to write a safety margin. Couldn't we get our audio latency down a bit by calling Game.GetSoundSamples before GetCurrentPosition? Or is it not worth it?
39 posts
Writing audio to game_sound_output_buffer before polling PlayCursor / WriteCursor
I don't know, but maybe you could try it and see if you can see a difference in latency.

The audio system is planned to be cleaned up and debugged later in the series.
Simon Anciaux
1340 posts
Writing audio to game_sound_output_buffer before polling PlayCursor / WriteCursor
Since windows Vista, DirectSound isn't hardware accelerated, it's software emulated and goes through the kernel mixer. You can find some informations on msdn and wikipedia.

For what I remember, the difference between the write cursor and the play cursor is the minimum latency you can achieve and it's about 30ms. And the minimum change in the cursor position is 1/100s worth of samples.

And calling GetCurrentPositon later would not help, since you still need to write samples between the last write and what is expected to be the next write.