[pulseaudio-commits] 3 commits - src/pulse src/pulsecore
Tanu Kaskinen
tanuk at kemper.freedesktop.org
Mon Mar 25 06:45:23 PDT 2013
src/pulse/def.h | 8 +++++++-
src/pulsecore/protocol-native.c | 12 ++++++++++--
2 files changed, 17 insertions(+), 3 deletions(-)
New commits:
commit feeec28de481de41fc99f73ccc9bc64ff06235f8
Author: David Henningsson <david.henningsson at canonical.com>
Date: Mon Mar 25 09:20:16 2013 +0100
client API: Document buffer_attr.maxlength
Let's officially support that people use maxlength to put an upper
bound on playback latency.
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
diff --git a/src/pulse/def.h b/src/pulse/def.h
index 495302f..a7f592b 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -360,7 +360,13 @@ typedef struct pa_buffer_attr {
uint32_t maxlength;
/**< Maximum length of the buffer in bytes. Setting this to (uint32_t) -1
* will initialize this to the maximum value supported by server,
- * which is recommended. */
+ * which is recommended.
+ *
+ * In strict low-latency playback scenarios you might want to set this to
+ * a lower value, likely together with the PA_STREAM_ADJUST_LATENCY flag.
+ * If you do so, you ensure that the latency doesn't grow beyond what is
+ * acceptable for the use case, at the cost of getting more underruns if
+ * the latency is lower than what the server can reliably handle. */
uint32_t tlength;
/**< Playback only: target length of the buffer. The server tries
commit 5f326b705d8f7f0c14e7e0c7d7c2751f3a5ebe43
Author: David Henningsson <david.henningsson at canonical.com>
Date: Mon Mar 25 09:20:15 2013 +0100
protocol-native: Lower default minreq in low-latency scenarios
If minreq is not explicitly specified, it was always initialized to
20 ms (DEFAULT_PROCESS_MSEC). However when the total latency is not
much higher than 20 ms, this is way too high. Instead use
tlength/4 as a measure: this will give a decent sink_usec in all
modes (both traditional, adjust latency and early request modes).
This greatly improves PulseAudio's ability to ask for data in time
in low-latency scenarios.
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index e8aa13c..9523e7a 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -939,8 +939,14 @@ static void fix_playback_buffer_attr(playback_stream *s) {
if (s->buffer_attr.tlength > s->buffer_attr.maxlength)
s->buffer_attr.tlength = s->buffer_attr.maxlength;
- if (s->buffer_attr.minreq == (uint32_t) -1)
- s->buffer_attr.minreq = (uint32_t) pa_usec_to_bytes_round_up(DEFAULT_PROCESS_MSEC*PA_USEC_PER_MSEC, &s->sink_input->sample_spec);
+ if (s->buffer_attr.minreq == (uint32_t) -1) {
+ uint32_t process = (uint32_t) pa_usec_to_bytes_round_up(DEFAULT_PROCESS_MSEC*PA_USEC_PER_MSEC, &s->sink_input->sample_spec);
+ /* With low-latency, tlength/4 gives a decent default in all of traditional, adjust latency and early request modes. */
+ uint32_t m = s->buffer_attr.tlength / 4;
+ if (frame_size)
+ m -= m % frame_size;
+ s->buffer_attr.minreq = PA_MIN(process, m);
+ }
if (s->buffer_attr.minreq <= 0)
s->buffer_attr.minreq = (uint32_t) frame_size;
commit 2026c41be6f4e1a526c94c1368e5e528597df03a
Author: David Henningsson <david.henningsson at canonical.com>
Date: Mon Mar 25 09:20:14 2013 +0100
protocol-native: Ensure tlength is not set higher than maxlength
Tlength should never be set higher than maxlength. While this is
corrected by memblockq later, we still need a correct tlength for
the subsequent calculations.
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 7095519..e8aa13c 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -936,6 +936,8 @@ static void fix_playback_buffer_attr(playback_stream *s) {
s->buffer_attr.tlength = (uint32_t) pa_usec_to_bytes_round_up(DEFAULT_TLENGTH_MSEC*PA_USEC_PER_MSEC, &s->sink_input->sample_spec);
if (s->buffer_attr.tlength <= 0)
s->buffer_attr.tlength = (uint32_t) frame_size;
+ if (s->buffer_attr.tlength > s->buffer_attr.maxlength)
+ s->buffer_attr.tlength = s->buffer_attr.maxlength;
if (s->buffer_attr.minreq == (uint32_t) -1)
s->buffer_attr.minreq = (uint32_t) pa_usec_to_bytes_round_up(DEFAULT_PROCESS_MSEC*PA_USEC_PER_MSEC, &s->sink_input->sample_spec);
More information about the pulseaudio-commits
mailing list