It looks their was a typo here - the code calculates the maximum audio packet size and uses it for the input buffer but not the output buffer. Now the amount of input buffering matches the amount of output buffering.