mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
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.
This commit is contained in:
parent
cda4a3cb61
commit
67399e35ff
1 changed files with 2 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue