summaryrefslogtreecommitdiffstats
path: root/src/pulse/stream.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-06-25 02:28:33 +0200
committerLennart Poettering <lennart@poettering.net>2008-06-25 02:43:35 +0200
commitc5cbeb5ed294af7aaae8a8bb674526da2fecdd84 (patch)
treed83de848277e5f3193b08a2365453925e2ff7fe1 /src/pulse/stream.c
parent517727ebdcd9d6dbc7eacdc843f886ed2e0f38f6 (diff)
choose more sensible default buffer sizes for old clients
Diffstat (limited to 'src/pulse/stream.c')
-rw-r--r--src/pulse/stream.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index 3bee7a05..b3f9697f 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -119,6 +119,11 @@ pa_stream *pa_stream_new_with_proplist(
s->requested_bytes = 0;
memset(&s->buffer_attr, 0, sizeof(s->buffer_attr));
+ /* We initialize der target length here, so that if the user
+ * passes no explicit buffering metrics the default is similar to
+ * what older PA versions provided. */
+ s->buffer_attr.tlength = pa_usec_to_bytes(250*PA_USEC_PER_MSEC, ss); /* 250ms of buffering */
+
s->device_index = PA_INVALID_INDEX;
s->device_name = NULL;
s->suspended = FALSE;
@@ -685,16 +690,19 @@ static void automatic_buffer_attr(pa_stream *s, pa_buffer_attr *attr, const pa_s
return;
/* Version older than 0.9.10 didn't do server side buffer_attr
- * selection, hence we have to fake it on the client side */
+ * selection, hence we have to fake it on the client side. */
+
+ /* We choose fairly conservative values here, to not confuse
+ * old clients with extremely large playback buffers */
if (!attr->maxlength <= 0)
attr->maxlength = 4*1024*1024; /* 4MB is the maximum queue length PulseAudio <= 0.9.9 supported. */
if (!attr->tlength <= 0)
- attr->tlength = pa_bytes_per_second(ss)*2; /* 2s of buffering */
+ attr->tlength = pa_usec_to_bytes(250*PA_USEC_PER_MSEC, ss); /* 250ms of buffering */
if (!attr->minreq <= 0)
- attr->minreq = (2*attr->tlength)/10; /* Ask for more data when there are only 200ms left in the playback buffer */
+ attr->minreq = (attr->tlength)/5; /* Ask for more data when there are only 200ms left in the playback buffer */
if (!attr->prebuf)
attr->prebuf = attr->tlength; /* Start to play only when the playback is fully filled up once */