From: David Henningsson <david.henningsson@canonical.com>
To: "Rémi Denis-Courmont" <remi@remlab.net>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH 2/2] pcm_pulse: set prebuf parameter according to software parameters
Date: Fri, 16 Nov 2012 17:35:58 +0100 [thread overview]
Message-ID: <50A66B6E.7000100@canonical.com> (raw)
In-Reply-To: <201211161749.59094@leon.remlab.net>
On 11/16/2012 04:49 PM, Rémi Denis-Courmont wrote:
> Le jeudi 15 novembre 2012 10:00:03, David Henningsson a écrit :
>> On 11/14/2012 07:07 PM, Rémi Denis-Courmont wrote:
>>> The current default value for prebuf is very high, almost the full
>>> virtual ALSA buffer. This breaks some application especially where
>>> low latency is involved.
>>>
>>> This patch makes pcm_pulse implement the sw_params callback and get
>>> the prebuf value from the ALSA software parameters. Thus the
>>> trigger latency is much more like what an ALSA application should
>>> expect from an ALSA PCM device.
>>
>> This seems reasonable I believe; see review comments below.
>>
>>> ---
>>>
>>> pulse/pcm_pulse.c | 25 +++++++++++++++++++++++++
>>> 1 file changed, 25 insertions(+)
>>>
>>> diff --git a/pulse/pcm_pulse.c b/pulse/pcm_pulse.c
>>> index 0165120..08b6cea 100644
>>> --- a/pulse/pcm_pulse.c
>>> +++ b/pulse/pcm_pulse.c
>>> @@ -859,6 +859,30 @@ static int pulse_hw_params(snd_pcm_ioplug_t * io,
>>>
>>> return err;
>>>
>>> }
>>>
>>> +static int pulse_sw_params(snd_pcm_ioplug_t *io, snd_pcm_sw_params_t
>>> *params) +{
>>> + snd_pcm_pulse_t *pcm = io->private_data;
>>> + snd_pcm_uframes_t start_threshold;
>>> +
>>> + assert(pcm);
>>> +
>>> + if (!pcm->p || !pcm->p->mainloop)
>>> + return -EBADFD;
>>> +
>>> + pa_threaded_mainloop_lock(pcm->p->mainloop);
>>> +
>>> + snd_pcm_sw_params_get_start_threshold(params, &start_threshold);
>>> +
>>> + if (start_threshold < io->period_size)
>>> + start_threshold = io->period_size;
>>
>> Why do we need the above constraint?
>
> In my experience, PulseAudio really does not like having less than a period
> worth of buffered samples. I guess the code assumes there is always at least
> that much, and may underrun if not.
>
> But sure enough, we could remove the constraint and blame the ALSA application
> for using inadequate parameters if a problem occurs. What do you prefer?
Assuming you're right about the almost-empty buffer being subject to
"false underruns" (which, IIRC I confirmed a while ago), probably just a
comment explaining why we need it or so. I didn't know that the limit
was one period_size though.
--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
next prev parent reply other threads:[~2012-11-16 16:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-14 18:07 [PATCH 0/2] alsa-plugins: fix PulseAudio prebuf Rémi Denis-Courmont
2012-11-14 18:07 ` [PATCH 1/2] pcm_pulse: do not trigger immediately at start Rémi Denis-Courmont
2012-11-14 18:07 ` [PATCH 2/2] pcm_pulse: set prebuf parameter according to software parameters Rémi Denis-Courmont
2012-11-15 8:00 ` David Henningsson
2012-11-16 15:49 ` Rémi Denis-Courmont
2012-11-16 16:35 ` David Henningsson [this message]
2012-11-15 7:55 ` [PATCH 1/2] pcm_pulse: do not trigger immediately at start David Henningsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50A66B6E.7000100@canonical.com \
--to=david.henningsson@canonical.com \
--cc=alsa-devel@alsa-project.org \
--cc=remi@remlab.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.