endOfStream

Tells the audio path that no more audio is coming.

Call this as soon as the decoder finishes, not when the buffer empties. Between those two moments the ring runs dry and the device is handed silence, and that silence is the end of the media rather than a failure to keep up. Marking it late means every file finishes by reporting a handful of underruns, which makes the counter useless for spotting the real thing.