[SOLVED - my bad] What could cause AudioFormatReader to skip data?

I’ve got a background thread that processes queud-up requests to read buffers of audio from a WAV file, and allows the processBlock() function to access the data from buffers that have completed their reading. It seems to be working fine, except that sometimes there is a small portion at the end of a few of these buffers that are filled with 0s.

The read() function doesn’t return an error, it simply fills some of the data with 0s. That’s expected if there is an error reading, according to the header file documentation.

But what could the error be? I’m (currently) only reading from one file, and only performing a single read() at a time from my thread, and the file has been written and flushed to disk prior to starting to read. So there shouldn’t be anything causing a conflict with reading data from the middle of the audio.

The only clue I have so far is that the sections of 0s in the data appear to be at the end of the buffers being read. (I’m reading 65536 frames at a time, but tried at 16386, and had the same problem, only more often.)

Any ideas where to look for the problem, or how to get info on what went wrong, or suggestions on how to prevent the issue in the first place?

Oh, wait, it’s not the end of the buffers, it’s the beginning! That could happen if my thread hasn’t moved the buffer into the “completed” pool yet. I’ll have to add code to check whether that’s the case, so I can see if it’s actually unrelated to the read() function.

Never mind. The problem is that the read has not completed yet at the time I asked for the data. It arrives shortly thereafter, and that’s when I start getting real values.