[pulseaudio-discuss] [PATCH] pulse: Fix invalid buffer pointer return value

David Henningsson launchpad.web at epost.diwic.se
Thu Jan 14 23:53:45 PST 2010


Lennart Poettering wrote:
> On Sat, 09.01.10 10:00, David Henningsson (launchpad.web at epost.diwic.se) wrote:
> 
>> The pulse ALSA plugin has been known, for a while, to not work properly,
>> causing underruns, hangs etc. I sat down yesterday trying to figure it
>> out, and I'm pretty certain this patch improves the situation, but I
>> don't mind getting some help testing it before it is committed
>> upstream.
> 
> I am kinda convinced that the actual fix for this issue is this
> patch. Could you check that?
> 
> http://git.0pointer.de/?p=pulseaudio.git;a=patch;h=8d356659e69556fa25d0579a66084f820683e2b8

What I saw happened during the hang inside snd_pcm_writei, was that we
had a tlength/buffersize of say 2048 frames with 4 fragments, but
pulseaudio's pa_stream_writable_size() returned say 30800, possibly
because it had adjusted the latency upwards. What then happened was that
the hw_ptr in the fake ringbuffer advanced with 30800 % 2048 = 80, less
than a fragment. So snd_pcm_writei waits forever for 512 frames to
become available before it writes anything, because it thinks there are
just 80 available. The patch corrects that situation by advancing the
hw_ptr with 2047 % 2048 instead.

So I'm kinda convinced too, but I'll test your patch if you test mine ;-)

@Daniel: I saw Lucid got a new version of pulseaudio today, can you tell
if this commit is included in that version or whether I must compile it
myself?

// David



More information about the pulseaudio-discuss mailing list