[vlc-commits] pulse: let pulseaudio define prebuffer/ minrequest and use that as buffersize, also change maxlength to 100ms

Ilkka Ollakka git at videolan.org
Sat May 28 11:56:34 CEST 2011


vlc/vlc-1.1 | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sat Mar 26 13:44:14 2011 +0200| [53543a4db7e66974760c9452a5b40e826f1a89d3] | committer: Rémi Denis-Courmont

pulse: let pulseaudio define prebuffer/minrequest and use that as buffersize, also change maxlength to 100ms

It's more along pulseaudio recommendations, and we don't really need to define those
ourself. Maxlength is defined to keep latency in someway in limits. Please tell if
this acts for you.
(cherry picked from commit 100fb7292499805025523060e37f006acb153d22)

Conflicts:

    modules/audio_output/pulse.c

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=53543a4db7e66974760c9452a5b40e826f1a89d3
---

 modules/audio_output/pulse.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 3a858ba..4427d1e 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -200,17 +200,14 @@ static int Open ( vlc_object_t *p_this )
         goto fail;
     }
 
-    /* Reduce overall latency to 200mS to reduce audible clicks
+    /* Reduce overall latency to 100mS to reduce audible clicks
      * Also pulse minreq and internal buffers are now 100mS which reduces resampling
      * but still shouldn't drop samples with some usb sound cards
      */
-    a.tlength = pa_bytes_per_second(&ss)/5;
+    a.tlength = pa_bytes_per_second(&ss)/10;
     a.maxlength = a.tlength * 2;
-    a.prebuf = a.tlength / 2;
-    a.minreq = a.tlength / 2;
-
-    /* Buffer size is 100mS */
-    p_sys->buffer_size = a.minreq;
+    a.prebuf = -1;
+    a.minreq = -1;
 
     /* Initialise the speaker map setup above */
     pa_channel_map_init_auto(&map, ss.channels, PA_CHANNEL_MAP_ALSA);
@@ -296,6 +293,9 @@ static int Open ( vlc_object_t *p_this )
 
     buffer_attr = pa_stream_get_buffer_attr(p_sys->stream);
     p_aout->output.i_nb_samples = buffer_attr->minreq / pa_frame_size(&ss);
+
+    /* Set buffersize from pulseaudio defined minrequest */
+    p_sys->buffer_size = buffer_attr->minreq;
     p_aout->output.pf_play = Play;
     aout_VolumeSoftInit(p_aout);
     msg_Dbg(p_aout, "Pulse initialized successfully");
@@ -498,10 +498,10 @@ static void stream_request_cb(pa_stream *s, size_t length, void *userdata) {
         else
         {
             PULSE_DEBUG( "Pulse stream request write zeroes");
-            void *data = pa_xmalloc(buffer_size);
-            bzero(data, buffer_size);
-            pa_stream_write(p_sys->stream, data, buffer_size, pa_xfree, 0, PA_SEEK_RELATIVE);
-            length -= buffer_size;
+            void *data = pa_xmalloc(length);
+            memset(data, 0, length);
+            pa_stream_write(p_sys->stream, data, length, pa_xfree, 0, PA_SEEK_RELATIVE);
+            length = 0;
         }
     }while(length > buffer_size);
 



More information about the vlc-commits mailing list