Wrap last_commit_ptr using boundary. Was just wrapped to 0, which is
correct only if the buffer size, and hence the boundary, is an integer
multiple of the period size.
Fixes: 467d69c5bc1 ("Fix CPU hog with combination of rate plugin")
Fixes: 29041c52207 ("fix infinite draining of the rate plugin in SND_PCM_NONBLOCK mode")
Link: https://lore.kernel.org/alsa-devel/20221230164814.901457-1-consult.awy@gmail.com/
Signed-off-by: Alan Young <consult.awy@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
slave_size -= rate->gen.slave->period_size;
rate->last_commit_ptr += pcm->period_size;
if (rate->last_commit_ptr >= pcm->boundary)
- rate->last_commit_ptr = 0;
+ rate->last_commit_ptr -= pcm->boundary;
}
return 0;
}
if (commit_err == 1) {
rate->last_commit_ptr += psize;
if (rate->last_commit_ptr >= pcm->boundary)
- rate->last_commit_ptr = 0;
+ rate->last_commit_ptr -= pcm->boundary;
} else if (commit_err == 0) {
if (pcm->mode & SND_PCM_NONBLOCK) {
commit_err = -EAGAIN;