]> git.alsa-project.org Git - alsa-plugins.git/commitdiff
Pulse: Fix snd_pcm_avail returning 0 in some cases
authorDavid Henningsson <david.henningsson@canonical.com>
Thu, 21 Apr 2011 13:10:19 +0000 (15:10 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 26 Apr 2011 14:37:46 +0000 (16:37 +0200)
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>
pulse/pcm_pulse.c

index 2df0a80f01243dad58765af3db553ed5f3e3b26e..9105d4dfd611f655e1e4d64c94bbb469f59d7a52 100644 (file)
@@ -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;