Adelay use of tempBufferPos

You increase mCircularBufferWriteHead for every sample that’s wrong. Just unroll your second loop (for sample = 0…) and you will see what’s wrong.