"Data should not be written to the part of the buffer after the play cursor and before the write cursor." However, even though we get the WriteCursor, we don't do anything with it:
Our target cursor does not take WriteCursor into account at all:
1 2 3 4
TargetCursor = ((PlayCursor + (SoundOutput.LatencySampleCount*SoundOutput.BytesPerSample)) % SoundOutput.SecondaryBufferSize);
On my machine the TargetCursor is always after the WriteCursor, but I think it's an accident, and not something we can be certain of. I put in an Assert like this:
Assert(TargetCursor < PlayCursor || TargetCursor > WriteCursor);
And I can trigger it by changing the LatencySampleCount:
SoundOutput.LatencySampleCount = SoundOutput.SamplesPerSecond / 15;
SoundOutput.LatencySampleCount = SoundOutput.SamplesPerSecond / 32;
Is this an oversight, or something that will be tightened up later?
Also, I'm not really familiar with game audio concepts in general, like what LatencySampleCount really means or what the number "15" means (15 seconds of audio?). Can someone clarify?