[pulseaudio-commits] src/pulsecore
Arun Raghavan
arun at kemper.freedesktop.org
Tue May 12 05:50:55 PDT 2015
src/pulsecore/protocol-native.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
New commits:
commit e490a900e236917caf9158bb30546f48075a2bca
Author: Arun Raghavan <git at arunraghavan.net>
Date: Mon Apr 13 14:53:45 2015 +0530
protocol-native: Fix source latency calculation in ADJUST_LATENCY mode
This fixes buffer attr calculation so that we set the source latency to
the requested latency. This makes sense because the intermediate
delay_memblockq is just a mechanism to send data to the client. It
should not actually add to the total latency over what the source
already provides.
With this, the meaning of fragsize and maxlength become more
meaningful/accurate with regards to ADJUST_LATENCY mode -- fragsize
becomes the latency the source is configured for (which is then
approximately the total latency until the buffer reaches the client).
Maxlength, as before, continues to be the maximum amount of data we
might hold for the client before overrunning.
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index b06f553..ec223be 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -568,11 +568,14 @@ static void fix_record_buffer_attr_pre(record_stream *s) {
} else if (s->adjust_latency) {
/* So, the user asked us to adjust the latency according to
- * what the source can provide. Half the latency will be
- * spent on the hw buffer, half of it in the async buffer
- * queue we maintain for each client. */
+ * what the source can provide. We set the source to whatever
+ * latency it can provide that is closest to what we want, and
+ * let the client buffer be equally large. This does NOT mean
+ * that we are doing (2 * fragsize) bytes of buffering, since
+ * the client-side buffer is only data that is on the way to
+ * the client. */
- source_usec = fragsize_usec/2;
+ source_usec = fragsize_usec;
} else {
@@ -598,12 +601,10 @@ static void fix_record_buffer_attr_pre(record_stream *s) {
} else if (s->adjust_latency) {
- /* Now subtract what we actually got */
+ /* We keep the client buffer large enough to transfer one
+ * hardware-buffer-sized chunk at a time to the client. */
- if (fragsize_usec >= s->configured_source_latency*2)
- fragsize_usec -= s->configured_source_latency;
- else
- fragsize_usec = s->configured_source_latency;
+ fragsize_usec = s->configured_source_latency;
}
if (pa_usec_to_bytes(orig_fragsize_usec, &s->source_output->sample_spec) !=
More information about the pulseaudio-commits
mailing list