fixes buffer overflow and channel position tracking

samples might actually be less than the lag. If that is the case, a
bufferoverflow occurs.

position tracking was also brocken, as it compared the bytes read and
not the current channel position.