[vlc-devel] commit: Patch: Fix pulseaudio clicking and latency issues (Danny Wood )

git version control git at videolan.org
Sun May 10 11:45:09 CEST 2009


vlc | branch: 1.0-bugfix | Danny Wood <danwood76 at gmail.com> | Sat May  9 11:05:31 2009 +0100| [b8f23ea716693d8d07dd8bd0cb4c9ba8ed05f568] | committer: Rémi Denis-Courmont 

Patch: Fix pulseaudio clicking and latency issues

Here is the updated patch with the modified configure.ac.
I have also added some comments and cleaned up a little bit of code.

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

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

 configure.ac                 |    2 +-
 modules/audio_output/pulse.c |   28 +++++++++++-----------------
 2 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/configure.ac b/configure.ac
index 51a42d9..be6e24c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4724,7 +4724,7 @@ AC_ARG_ENABLE(pulse,
   [  --enable-pulse          Pulseaudio support (default enabled)])
   if test "${enable_pulse}" != "no"
    then
-     PKG_CHECK_MODULES(PULSE, libpulse >= 0.9.8,
+     PKG_CHECK_MODULES(PULSE, libpulse >= 0.9.11,
        [ VLC_ADD_PLUGIN([pulse])
         VLC_ADD_CFLAGS([pulse],[${PULSE_CFLAGS}])
         VLC_ADD_LDFLAGS([pulse],[${PULSE_LIBS}])],
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 19e4b75..86bd6dd 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -176,16 +176,15 @@ static int Open ( vlc_object_t *p_this )
         goto fail;
     }
 
-    a.maxlength = pa_bytes_per_second(&ss)/4/pa_frame_size(&ss);
-    a.tlength = a.maxlength*9/10;
-    a.prebuf = a.tlength/2;
-    a.minreq = a.tlength/10;
-
-    a.maxlength *= pa_frame_size(&ss);
-    a.tlength *= pa_frame_size(&ss);
-    a.prebuf *= pa_frame_size(&ss);
-    a.minreq *= pa_frame_size(&ss);
-
+    /* Reduce overall latency to 200mS to reduce audible clicks
+     * Also pulse minreq and internal buffers are now 20mS which reduces resampling
+     */
+    a.tlength = pa_bytes_per_second(&ss)/5;
+    a.maxlength = a.tlength * 2;
+    a.prebuf = a.tlength;
+    a.minreq = a.tlength / 10;
+
+    /* Buffer size is 20mS */
     p_sys->buffer_size = a.minreq;
 
     /* Initialise the speaker map setup above */
@@ -240,7 +239,7 @@ static int Open ( vlc_object_t *p_this )
     pa_stream_set_write_callback(p_sys->stream, stream_request_cb, p_aout);
     pa_stream_set_latency_update_callback(p_sys->stream, stream_latency_update_cb, p_aout);
 
-    if (pa_stream_connect_playback(p_sys->stream, NULL, &a, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL) < 0) {
+    if (pa_stream_connect_playback(p_sys->stream, NULL, &a, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE|PA_STREAM_ADJUST_LATENCY, NULL, NULL) < 0) {
         msg_Err(p_aout, "Failed to connect stream: %s", pa_strerror(pa_context_errno(p_sys->context)));
         goto unlock_and_fail;
     }
@@ -448,16 +447,11 @@ static void stream_request_cb(pa_stream *s, size_t length, void *userdata) {
                 latency = 0;
 
             }
+
             PULSE_DEBUG( "Pulse stream request latency=%"PRId64"", latency);
             next_date = mdate() + latency;
 
-
             if(p_sys->start_date < next_date + AOUT_PTS_TOLERANCE ){
-    /*
-                  vlc_mutex_lock( &p_aout->output_fifo_lock );
-                p_buffer = aout_FifoPop( p_aout, &p_aout->output.fifo );
-                vlc_mutex_unlock( &p_aout->output_fifo_lock );
-    */
                 p_buffer = aout_OutputNextBuffer( p_aout, next_date, 0);
             }
         }




More information about the vlc-devel mailing list