Due to a round-off error, snd_pcm_avail could in some cases
return 0 even though more data could be written to the stream.
Reported-by: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
size -= pcm->offset;
/* Prevent accidental overrun of the fake ringbuffer */
- if (size >= pcm->buffer_attr.tlength)
- size = pcm->buffer_attr.tlength-1;
+ if (size > pcm->buffer_attr.tlength - pcm->frame_size)
+ size = pcm->buffer_attr.tlength - pcm->frame_size;
if (size > pcm->last_size) {
pcm->ptr += size - pcm->last_size;