]> git.alsa-project.org Git - alsa-plugins.git/commitdiff
Use different buffer metrics in the PulseAudio plugin
authorTakashi Iwai <tiwai@suse.de>
Mon, 26 Nov 2007 10:02:24 +0000 (11:02 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 26 Nov 2007 10:02:24 +0000 (11:02 +0100)
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 <mznyfn@0pointer.de>

pulse/pcm_pulse.c

index ae55bcbd167098c9b86aa278174232fddb69fda7..da15792cfac4b23426fff13171b341573bd8ee7c 100644 (file)
@@ -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;