CRAS: fmt_conv - Handle leaked frame

When input device opened in 16KHz then SRC to 48KHz, there's a
corner case in fmt_conv when converting 1 frame of data to 2
frames buffer.
The scenario is when linear resampler resamples 1 frame to 1
frame, and the speex library resamples 0 frame to 2 frames in
the 16KHz -> 48KHz round of SRC.

It is a bug that leaks one frame, because linear resampler processed
1 frame, but later SRC didn't consume it. This could get accumulated
and introduce large latency between multiple input iodevs.

Fixing this problem by specifically checking if the used input
frames in speex resampling is zero, and sets 0 frame as used
by fmt_conv.

BUG=chromium:862047
TEST=Enable two Jabra devices, run
cras_test_client --capture_file /tmp/1 --rate 48000
and check the device buffer levels doesn't deviate.

Change-Id: Ia232a29464c8e3d99d09850b76f6209c44826cf4
Reviewed-on: https://chromium-review.googlesource.com/1131358
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
2 files changed