From: Takashi Iwai Date: Thu, 20 Sep 2007 11:20:03 +0000 (+0200) Subject: Fix wrong offset calculation in snd_pcm_{read|write}_mmap() X-Git-Tag: v1.0.15rc3~1 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=67399e35ff47269c324c251e611531c70c8e71ef;p=alsa-lib.git Fix wrong offset calculation in snd_pcm_{read|write}_mmap() The offset used in snd_pcm_{read|write}_mmap() is not the linear offset but the offset in a ring buffer. It has to be rounded. --- diff --git a/src/pcm/pcm_mmap.c b/src/pcm/pcm_mmap.c index d07a0806..4621fe6f 100644 --- a/src/pcm/pcm_mmap.c +++ b/src/pcm/pcm_mmap.c @@ -575,7 +575,7 @@ snd_pcm_sframes_t snd_pcm_write_mmap(snd_pcm_t *pcm, snd_pcm_uframes_t offset, if (err < 0) break; xfer += frames; - offset += frames; + offset = (offset + frames) % pcm->buffer_size; } if (xfer > 0) return xfer; @@ -625,7 +625,7 @@ snd_pcm_sframes_t snd_pcm_read_mmap(snd_pcm_t *pcm, snd_pcm_uframes_t offset, if (err < 0) break; xfer += frames; - offset += frames; + offset = (offset + frames) % pcm->buffer_size; } if (xfer > 0) return xfer;