[alsa-devel] [PATCH] Wrong latency in pulseaudio plugin breaks Adobe Flash Player
Philip Spencer
pspencer at fields.utoronto.ca
Thu Feb 23 16:18:35 CET 2012
On Thu, 23 Feb 2012, Clemens Ladisch wrote:
> Philip Spencer wrote:
>> 3. What should happen?
>>
>> (a) The call returns immediately, since there's lots of room
>> in the buffer.
>>
>> (b) The call returns after one I/O period's worth of data has
>> been drained from the buffer.
>
> (a)
>
>> If the correct answer is (a) (ALSA's current behaviour), then is there
>> any mechanism for an app to achieve (b) -- get woken up after one I/O
>> period's worth of data have been drained (other than just doing some
>> infinite loop of sleeping then checking snd_pcm_avail periodically)?
>
> Adjust avail_min (but note that wakeups happen only at period
> boundaries).
That won't work if using the pulseaudio plugin as the backend -- it'll
stop the first part of snd_pcm_wait from succeeding right away, but when
it moves on to snd_pcm_wait_nocheck the poll call will return right away,
because the pulseaudio plugin marks the file descriptor as ready whenever
there are more than buffer_attr.minreq bytes available in the buffer.
Perhaps (though that won't help me, as I don't imagine I'll have any
success getting Flash Player developers to change anything!, but it may
help any other similar app) that should be fixed in the pulseaudio plugin:
- Implement sw_params
- When sw_params is called, check the avail_min value and record it
as a new field avail_min (and if it's different from the previous
recorded value and the stream is running, call update_active)
- In check_active, instead of "return wsize >= pcm->buffer_attr.minreq",
"return wsize >= pcm->avail_min". (Question: should
buffer_attr.minreq be changed too, or left alone?)
- At the same time the start_threshold parameter could be implemented
too.
I could whip up a patch for that if needed, although of course it won't
actually help my situation -- I may just have to be resigned to using
non-live mode with about a 3/4 second latency for linux users.
Regards,
Philip
--------------------------------------------+-------------------------------
Philip Spencer pspencer at fields.utoronto.ca | Director of Computing Services
Room 336 (416)-348-9710 ext3036 | The Fields Institute for
222 College St, Toronto ON M5T 3J1 Canada | Research in Mathematical Sciences
More information about the Alsa-devel
mailing list