summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-04-16 12:44:43 +0000
committerLennart Poettering <lennart@poettering.net>2006-04-16 12:44:43 +0000
commit2f3fa42ca6dddc56c4ddab1d7d8ac89ff6eb75d6 (patch)
treee310820c2f30649ce21452891ac9050948cf84cf /src
parent08397d98e23d3ec953c66bd8cd90efb316e4bad1 (diff)
limit number of concurrent RTP streams
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@730 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src')
-rw-r--r--src/modules/rtp/module-rtp-recv.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/modules/rtp/module-rtp-recv.c b/src/modules/rtp/module-rtp-recv.c
index e47ca95ab..95d13c338 100644
--- a/src/modules/rtp/module-rtp-recv.c
+++ b/src/modules/rtp/module-rtp-recv.c
@@ -97,6 +97,8 @@ struct userdata {
pa_hashmap *by_origin;
char *sink_name;
+
+ int n_sessions;
};
static void session_free(struct session *s, int from_hash);
@@ -261,6 +263,11 @@ static struct session *session_new(struct userdata *u, const pa_sdp_info *sdp_in
int fd = -1;
pa_memblock *silence;
+ if (u->n_sessions >= MAX_SESSIONS) {
+ pa_log(__FILE__": session limit reached.");
+ goto fail;
+ }
+
if (!(sink = pa_namereg_get(u->core, u->sink_name, PA_NAMEREG_SINK, 1))) {
pa_log(__FILE__": sink does not exist.");
goto fail;
@@ -323,6 +330,8 @@ static struct session *session_new(struct userdata *u, const pa_sdp_info *sdp_in
pa_rtp_context_init_recv(&s->rtp_context, fd, pa_frame_size(&s->sdp_info.sample_spec));
pa_log_info(__FILE__": Found new session '%s'", s->sdp_info.session_name);
+
+ u->n_sessions++;
return s;
@@ -354,6 +363,9 @@ static void session_free(struct session *s, int from_hash) {
pa_memblockq_free(s->memblockq);
pa_sdp_info_destroy(&s->sdp_info);
pa_rtp_context_destroy(&s->rtp_context);
+
+ assert(s->userdata->n_sessions >= 1);
+ s->userdata->n_sessions--;
pa_xfree(s);
}