From: Jaroslav Kysela Date: Fri, 1 Mar 2019 11:43:19 +0000 (+0100) Subject: test/latency: use frame bytes correctly in writebuf() X-Git-Tag: v1.1.9~21 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=deb07a0b208225393efc6347556310f3d8adb54d;p=alsa-lib.git test/latency: use frame bytes correctly in writebuf() Reported-by: Alessandro Lapini Signed-off-by: Jaroslav Kysela --- diff --git a/test/latency.c b/test/latency.c index e926856b..ddd5a7af 100644 --- a/test/latency.c +++ b/test/latency.c @@ -374,6 +374,7 @@ long readbuf(snd_pcm_t *handle, char *buf, long len, size_t *frames, size_t *max long writebuf(snd_pcm_t *handle, char *buf, long len, size_t *frames) { long r; + int frame_bytes = (snd_pcm_format_width(format) / 8) * channels; while (len > 0) { r = snd_pcm_writei(handle, buf, len); @@ -383,7 +384,7 @@ long writebuf(snd_pcm_t *handle, char *buf, long len, size_t *frames) if (r < 0) return r; // showstat(handle, 0); - buf += r * 4; + buf += r * frame_bytes; len -= r; *frames += r; }