[vlc-devel] [PATCH] aout: pulse: use jitter delay

Thomas Guillem thomas at gllm.fr
Tue Feb 5 11:46:23 CET 2019


---
 modules/audio_output/pulse.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 8be4004534..9a24d0f9f9 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -785,14 +785,17 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt,
                             | PA_STREAM_AUTO_TIMING_UPDATE
                             | PA_STREAM_FIX_RATE;
 
+    vlc_tick_t period = *jitter / 2;
+    assert(period >= AOUT_MAX_PTS_ADVANCE);
+
     struct pa_buffer_attr attr;
     attr.maxlength = -1;
     /* PulseAudio goes berserk if the target length (tlength) is not
      * significantly longer than 2 periods (minreq), or when the period length
      * is unspecified and the target length is short. */
-    attr.tlength = pa_usec_to_bytes(3 * AOUT_MIN_PREPARE_TIME, &ss);
+    attr.tlength = pa_usec_to_bytes(3 * period, &ss);
     attr.prebuf = 0; /* trigger manually */
-    attr.minreq = pa_usec_to_bytes(AOUT_MIN_PREPARE_TIME, &ss);
+    attr.minreq = pa_usec_to_bytes(period, &ss);
     attr.fragsize = 0; /* not used for output */
 
     pa_cvolume *cvolume = NULL, cvolumebuf;
@@ -819,7 +822,6 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt,
         /* Setup low latency in order to quickly react to ambisonics
          * filters viewpoint changes. */
         flags |= PA_STREAM_ADJUST_LATENCY;
-        attr.tlength = pa_usec_to_bytes(3 * AOUT_MIN_PREPARE_TIME, &ss);
     }
 
     if (encoding != PA_ENCODING_PCM)
@@ -963,7 +965,6 @@ fail:
     pa_threaded_mainloop_unlock(sys->mainloop);
     Stop(aout);
     return VLC_EGENERIC;
-    VLC_UNUSED(jitter);
 }
 
 /**
-- 
2.20.1



More information about the vlc-devel mailing list