Use number of audio samples provided by frames since it may be different (+/- 1) when playing from playback buffer.
Use buffered playback in frame by frame mode.