From 50f592b67c9d7364ab0d7ac447c565db4ab83d2a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 1 Sep 2004 15:00:44 +0000 Subject: introduce sink input and source output limits git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@170 fefdeb5f-60dc-0310-8127-8f9354f1896f --- doc/todo | 3 ++- polyp/module-x11-bell.c | 6 +----- polyp/sample.h | 4 ++-- polyp/sink-input.c | 5 +++++ polyp/sink.h | 2 ++ polyp/source-output.c | 6 ++++++ polyp/source.h | 2 ++ 7 files changed, 20 insertions(+), 8 deletions(-) diff --git a/doc/todo b/doc/todo index 107fc443..6aacd3a5 100644 --- a/doc/todo +++ b/doc/todo @@ -13,7 +13,8 @@ - cleanup tagstruct and modargs (add s32, pa_volume_t, pa_usec_t) - remove all gcc warnings - esd compatible startup script or personality -- limit number of concurrent streams +- add total sample size to stat +- implement streamed file playbacj ** later *** - xmlrpc/http diff --git a/polyp/module-x11-bell.c b/polyp/module-x11-bell.c index 3ed9b068..ae889b22 100644 --- a/polyp/module-x11-bell.c +++ b/polyp/module-x11-bell.c @@ -69,11 +69,7 @@ static int ring_bell(struct userdata *u, int percent) { return -1; } - if (pa_scache_play_item(u->core, u->scache_item, s, percent*2) < 0) { - fprintf(stderr, __FILE__": Failed to play sample\n"); - return -1; - } - + pa_scache_play_item(u->core, u->scache_item, s, percent*2); return 0; } diff --git a/polyp/sample.h b/polyp/sample.h index 4b28780d..a5479562 100644 --- a/polyp/sample.h +++ b/polyp/sample.h @@ -110,10 +110,10 @@ pa_volume_t pa_volume_from_dB(double f); double pa_volume_to_dB(pa_volume_t v); #ifdef INFINITY -#define PA_DECIBEL_MININFTY -INFINITY +#define PA_DECIBEL_MININFTY (-INFINITY) #else /** This value is used as minus infinity when using pa_volume_{to,from}_dB(). \since 0.4 */ -#define PA_DECIBEL_MININFTY -200 +#define PA_DECIBEL_MININFTY (-200) #endif PA_C_DECL_END diff --git a/polyp/sink-input.c b/polyp/sink-input.c index 9238fac0..95dc5577 100644 --- a/polyp/sink-input.c +++ b/polyp/sink-input.c @@ -42,6 +42,11 @@ struct pa_sink_input* pa_sink_input_new(struct pa_sink *s, const char *name, con char st[256]; assert(s && spec); + if (pa_idxset_ncontents(s->inputs) >= PA_MAX_INPUTS_PER_SINK) { + fprintf(stderr, __FILE__": Failed to create sink input: too many inputs per sink.\n"); + return NULL; + } + if (!pa_sample_spec_equal(spec, &s->sample_spec)) if (!(resampler = pa_resampler_new(spec, &s->sample_spec, s->core->memblock_stat))) return NULL; diff --git a/polyp/sink.h b/polyp/sink.h index 940d1618..85addf76 100644 --- a/polyp/sink.h +++ b/polyp/sink.h @@ -31,6 +31,8 @@ struct pa_sink; #include "idxset.h" #include "source.h" +#define PA_MAX_INPUTS_PER_SINK 6 + struct pa_sink { uint32_t index; diff --git a/polyp/source-output.c b/polyp/source-output.c index b8083a79..9d124f07 100644 --- a/polyp/source-output.c +++ b/polyp/source-output.c @@ -23,6 +23,7 @@ #include #endif +#include #include #include #include @@ -37,6 +38,11 @@ struct pa_source_output* pa_source_output_new(struct pa_source *s, const char *n int r; assert(s && spec); + if (pa_idxset_ncontents(s->outputs) >= PA_MAX_OUTPUTS_PER_SOURCE) { + fprintf(stderr, __FILE__": Failed to create source output: too many outputs per source.\n"); + return NULL; + } + if (!pa_sample_spec_equal(&s->sample_spec, spec)) if (!(resampler = pa_resampler_new(&s->sample_spec, spec, s->core->memblock_stat))) return NULL; diff --git a/polyp/source.h b/polyp/source.h index 32ef14e6..309b87e7 100644 --- a/polyp/source.h +++ b/polyp/source.h @@ -32,6 +32,8 @@ struct pa_source; #include "memchunk.h" #include "sink.h" +#define PA_MAX_OUTPUTS_PER_SOURCE 16 + struct pa_source { uint32_t index; -- cgit