summaryrefslogtreecommitdiffstats
path: root/polyp
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-11-21 19:39:46 +0000
committerLennart Poettering <lennart@poettering.net>2004-11-21 19:39:46 +0000
commitd45abba9aa4090ebeaf09ec9ec324709e04a1bbf (patch)
tree88bd15b4123bb82bbbf6236673941f613ca8517e /polyp
parent4583c22bfd490e2cdc7ebb151a566c85987bd791 (diff)
calculate buffer sizes from sample spec
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@306 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp')
-rw-r--r--polyp/memblockq.c11
-rw-r--r--polyp/polyplib-internal.h6
-rw-r--r--polyp/polyplib-stream.c11
3 files changed, 13 insertions, 15 deletions
diff --git a/polyp/memblockq.c b/polyp/memblockq.c
index ff16f627..16c0da8e 100644
--- a/polyp/memblockq.c
+++ b/polyp/memblockq.c
@@ -68,18 +68,21 @@ struct pa_memblockq* pa_memblockq_new(size_t maxlength, size_t tlength, size_t b
bq->tlength = ((tlength+base-1)/base)*base;
if (!bq->tlength || bq->tlength >= bq->maxlength)
bq->tlength = bq->maxlength;
+
+ bq->minreq = (minreq/base)*base;
+ if (bq->minreq == 0)
+ bq->minreq = 1;
bq->prebuf = (prebuf == (size_t) -1) ? bq->maxlength/2 : prebuf;
bq->prebuf = (bq->prebuf/base)*base;
if (bq->prebuf > bq->maxlength)
bq->prebuf = bq->maxlength;
+ if (bq->prebuf > bq->tlength - bq->minreq)
+ bq->prebuf = bq->tlength - bq->minreq;
+
bq->orig_prebuf = bq->prebuf;
- bq->minreq = (minreq/base)*base;
- if (bq->minreq == 0)
- bq->minreq = 1;
-
pa_log(__FILE__": memblockq sanitized: maxlength=%u, tlength=%u, base=%u, prebuf=%u, minreq=%u\n", bq->maxlength, bq->tlength, bq->base, bq->prebuf, bq->minreq);
bq->mcalign = NULL;
diff --git a/polyp/polyplib-internal.h b/polyp/polyplib-internal.h
index 4289b3c8..d1b3a27f 100644
--- a/polyp/polyplib-internal.h
+++ b/polyp/polyplib-internal.h
@@ -37,12 +37,6 @@
#include "strlist.h"
#include "mcalign.h"
-#define DEFAULT_TLENGTH (44100*2*2/2) //(10240*8)
-#define DEFAULT_MAXLENGTH ((DEFAULT_TLENGTH*3)/2)
-#define DEFAULT_MINREQ 512
-#define DEFAULT_PREBUF (DEFAULT_TLENGTH-DEFAULT_MINREQ)
-#define DEFAULT_FRAGSIZE 1024
-
#define DEFAULT_TIMEOUT (10)
struct pa_context {
diff --git a/polyp/polyplib-stream.c b/polyp/polyplib-stream.c
index b3f1f8cd..440217e7 100644
--- a/polyp/polyplib-stream.c
+++ b/polyp/polyplib-stream.c
@@ -283,11 +283,12 @@ static void create_stream(struct pa_stream *s, const char *dev, const struct pa_
if (attr)
s->buffer_attr = *attr;
else {
- s->buffer_attr.maxlength = DEFAULT_MAXLENGTH;
- s->buffer_attr.tlength = DEFAULT_TLENGTH;
- s->buffer_attr.prebuf = DEFAULT_PREBUF;
- s->buffer_attr.minreq = DEFAULT_MINREQ;
- s->buffer_attr.fragsize = DEFAULT_FRAGSIZE;
+ /* half a second */
+ s->buffer_attr.tlength = pa_bytes_per_second(&s->sample_spec)/2;
+ s->buffer_attr.maxlength = (s->buffer_attr.tlength*3)/2;
+ s->buffer_attr.minreq = s->buffer_attr.tlength/100;
+ s->buffer_attr.prebuf = s->buffer_attr.tlength - s->buffer_attr.minreq;
+ s->buffer_attr.fragsize = s->buffer_attr.tlength/100;
}
pa_stream_set_state(s, PA_STREAM_CREATING);