summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-09-20 13:20:03 +0200
committerTakashi Iwai <tiwai@suse.de>2007-09-20 13:20:03 +0200
commit67399e35ff47269c324c251e611531c70c8e71ef (patch)
tree9d13975065838b1ff855739afb1ee25f13f57993
parentcda4a3cb6109dca7628092b12ff7606ce9c4f62f (diff)
downloadalsa-lib-67399e35ff47269c324c251e611531c70c8e71ef.tar.gz
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.
-rw-r--r--src/pcm/pcm_mmap.c4
1 files changed, 2 insertions, 2 deletions
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;