From 9f13450e50a314fff6b51b1c1cd711b38b81efc7 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Fri, 23 Nov 2018 15:08:50 +0200 Subject: make convert return frames instead of bytes --- src/pcm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pcm.c b/src/pcm.c index 548d043..89ce9d0 100644 --- a/src/pcm.c +++ b/src/pcm.c @@ -444,7 +444,7 @@ convert(snd_pcm_t *pcm, const size_t frames, const struct io *io, void *arg) } } - return io_bytes; + return io_bytes / (params[ei].bps * chans); } static size_t @@ -482,7 +482,7 @@ snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size) snd_pcm_uframes_t ret; if (pcm->hw.needs_conversion) { - ret = snd_pcm_bytes_to_frames(pcm, convert(pcm, size, &io, &state)); + ret = convert(pcm, size, &io, &state); } else { ret = snd_pcm_bytes_to_frames(pcm, io.write(buffer, snd_pcm_frames_to_bytes(pcm, size), &state)); } @@ -528,7 +528,7 @@ snd_pcm_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size) snd_pcm_uframes_t ret; if (pcm->hw.needs_conversion) { - ret = snd_pcm_bytes_to_frames(pcm, convert(pcm, size, &io, &state)); + ret = convert(pcm, size, &io, &state); } else { ret = snd_pcm_bytes_to_frames(pcm, io.read(buffer, snd_pcm_frames_to_bytes(pcm, size), &state)); } -- cgit v1.2.3-70-g09d2