Allow buffer size to be set a runtime; improve latency calculation.

Latency is now calculated by adding the input and output latencies, instead of
just using the output latency.