[alsa-devel] [PATCH] alsa-plugins: Pulse: only underrun if no more data has been written

David Henningsson david.henningsson at canonical.com
Thu Aug 25 08:17:17 CEST 2011


On 08/25/2011 07:53 AM, Raymond Yau wrote:
> 2011/8/23 Takashi Iwai<tiwai at suse.de>:
>   be enough just to have a
>> boolean for underrun_detect yes/no.
>>
>> So, the patch would be like below.
>>
>> What do you think?
>>
>>
>> Takashi
>>
>> ---
>> diff --git a/pulse/pcm_pulse.c b/pulse/pcm_pulse.c
>> index d6c6792..b0e52ab 100644
>> --- a/pulse/pcm_pulse.c
>> +++ b/pulse/pcm_pulse.c
>> @@ -42,6 +42,7 @@ typedef struct snd_pcm_pulse {
>>         int handle_underrun;
>>
>>         size_t offset;
>> +       int64_t written;
>>
>>         pa_stream *stream;
>>
>> @@ -460,6 +461,7 @@ static snd_pcm_sframes_t pulse_write(snd_pcm_ioplug_t * io,
>>
>>         /* Make sure the buffer pointer is in sync */
>>         pcm->last_size -= writebytes;
>> +       pcm->written += writebytes;
>>         ret = update_ptr(pcm);
>>         if (ret<  0)
>>                 goto finish;
>> @@ -585,6 +587,15 @@ static void stream_request_cb(pa_stream * p, size_t length, void *userdata)
>>         update_active(pcm);
>>   }
>>
>> +#if defined(PA_CHECK_VERSION)&&  PA_CHECK_VERSION(0,99,0)
>
> compile fail at these line since PA_CHECK_VERSION is not defined in
> pulseaudio 0.9.14

I don't have PA 0.9.14 available, but that's why the line starts with 
"if defined(PA_CHECK_VERSION)" so that the second part should never be 
evaluated.

> seem that pcm->wriiten is application pointer of pulse device in bytes
>
> does it mean that pa_stream_get_underflow_index(0 is the hardware pointer ?
>
> does it mean that pulse device no longer can be run 7 x 24 non-stop
> since pcm->written may overflow ?

Hmm. It's an int64, so your computer is likely to break down before 
there is a wraparound, but perhaps there is a slight chance that the 
comparision will be wrong if there is an underrun at the exact 
wraparound moment.

-- 
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic


More information about the Alsa-devel mailing list