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 --- pulse/pcm_pulse.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/pulse/pcm_pulse.c b/pulse/pcm_pulse.c index 2df0a80..9105d4d 100644 --- a/pulse/pcm_pulse.c +++ b/pulse/pcm_pulse.c @@ -92,8 +92,8 @@ static int update_ptr(snd_pcm_pulse_t *pcm) 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;