diff options
author | Takashi Iwai <tiwai@suse.de> | 2007-09-20 13:20:03 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2007-09-20 13:20:03 +0200 |
commit | 67399e35ff47269c324c251e611531c70c8e71ef (patch) | |
tree | 9d13975065838b1ff855739afb1ee25f13f57993 | |
parent | cda4a3cb6109dca7628092b12ff7606ce9c4f62f (diff) | |
download | alsa-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.c | 4 |
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; |