From 327e169964b0a5bdcffb46eb49a305f3aabaeab4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 26 Nov 2007 11:02:24 +0100 Subject: Use different buffer metrics in the PulseAudio plugin It increases the "pre-buffering level" (i.e. start threshold) to the full buffer size minus one period. This makes PA work a little bit more like normal audio devices, and makes a few drop outs go away for software which uses very small period sizes. It also increases the initial maximum buffer size, which allows a small overcommit. That's not really an issue, but cleaner nonetheless so I smuggled it into this patch. Also reported in the ALSA BTS: https://bugtrack.alsa-project.org/alsa-bug/view.php?id=3578 From: Lennart Poettering --- pulse/pcm_pulse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pulse/pcm_pulse.c b/pulse/pcm_pulse.c index ae55bcb..da15792 100644 --- a/pulse/pcm_pulse.c +++ b/pulse/pcm_pulse.c @@ -57,7 +57,7 @@ static void update_ptr(snd_pcm_pulse_t *pcm) if (size > pcm->last_size) { pcm->ptr += size - pcm->last_size; - pcm->ptr %= pcm->buffer_attr.maxlength; + pcm->ptr %= pcm->buffer_attr.tlength; } pcm->last_size = size; @@ -544,9 +544,9 @@ static int pulse_hw_params(snd_pcm_ioplug_t *io, snd_pcm_hw_params_t *params) pcm->ss.rate = io->rate; pcm->ss.channels = io->channels; - pcm->buffer_attr.maxlength = io->buffer_size * pcm->frame_size; + pcm->buffer_attr.maxlength = (io->buffer_size*3)/2 * pcm->frame_size; pcm->buffer_attr.tlength = io->buffer_size * pcm->frame_size; - pcm->buffer_attr.prebuf = io->period_size * pcm->frame_size; + pcm->buffer_attr.prebuf = (io->buffer_size - io->period_size) * pcm->frame_size; pcm->buffer_attr.minreq = io->period_size * pcm->frame_size; pcm->buffer_attr.fragsize = io->period_size * pcm->frame_size; -- cgit