At 2:14:26 into the Day 20 video, I see Casey adding a new variable called ExpectedBytesUntilFlip.
The problem is, Casey didn't actually use that variable. The end result was that ExpectedBytesUntilFlip was never used, even though it's initialized.
I don't see Casey resolving this issue in Day 21 (jumping around in the video, didn't view through all of them), perhaps it went unnoticed.
------------
I decided to use that ExpectedBytesUntilFlip in the following code snippet:
| float SecondsLeftUntilFlip = (TargetSecondsPerFrame - FromBeginToAudioSeconds);
DWORD ExpectedBytesUntilFlip = (DWORD) ((SecondsLeftUntilFlip / TargetSecondsPerFrame)* (float) ExpectedSoundBytesPerFrame);
DWORD ExpectedFrameBoundaryBytes = PlayCursor + ExpectedBytesUntilFlip;
|
What it did was the expected flip cursor is now very accurately close to the write cursor, and is within the margin of errors, which Casey was expecting before.