Thread safety issue in BufferingAudioReader?

The use of the member variable ‘nextReadPosition’ looks a bit dodgy to me.

It’s set on the audio thread within a mutex, but it’s read on the background thread without one.

It’s polled on the background thread so there’s no major problem with stale values, but it is a 64 bit variable so could potentially ‘tear’ on 32 bit systems. From inspection of the code, this would mostly likely cause the reader to throw away all the blocks it has in memory and attempt to load some invalid block, before getting back on track on the next update.