With the very last modification done, the ExpectedFrameBoundaryByte wasn't updated to the better value.
The very last line in this code block:
1 2 3 4 5 6 | DWORD ExpectedSoundBytesPerFrame = (SoundOutput.SamplesPerSecond*SoundOutput.BytesPerSample) / GameUpdateHz; real32 SecondsLeftUntilFlip = (TargetSecondsPerFrame - FromBeginToAudioSeconds); DWORD ExpectedBytesUntilFlip = (DWORD)((SecondsLeftUntilFlip/TargetSecondsPerFrame)*(real32)ExpectedSoundBytesPerFrame); DWORD ExpectedFrameBoundaryByte = PlayCursor + ExpectedSoundBytesPerFrame; |
What it probably should be:
1 | DWORD ExpectedFrameBoundaryByte = PlayCursor + ExpectedBytesUntilFlip; |