From deb07a0b208225393efc6347556310f3d8adb54d Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 1 Mar 2019 12:43:19 +0100 Subject: [PATCH] test/latency: use frame bytes correctly in writebuf() Reported-by: Alessandro Lapini Signed-off-by: Jaroslav Kysela --- test/latency.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; } -- 2.47.1