From 7d05ac606bd5a86c94ab13f8d6c898ad86b6b78a Mon Sep 17 00:00:00 2001 From: Antti-Ville Jansson Date: Fri, 11 Nov 2011 16:22:24 +0200 Subject: [PATCH] stream: Fix upload samples' cleanup In pa_create_stream_callback, a stream is inserted into s->context->record_streams only if it's a record stream. Otherwise it's inserted into s->context->playback_streams. However, in stream_unlink the stream is removed from s->context->playback_streams only if it's a playback stream and otherwise it's removed from s->context->record_streams. Thus, if the stream is an upload stream, we first insert it into s->context->playback_streams in pa_create_stream_callback and then try to remove it unsuccessfully from s->context->record_streams in stream_unlink. This means that we are leaking hashmap entries until the context is freed, constantly consuming more memory with applications that upload and unload a large number of samples through one context. Of course, this begs the question whether upload streams even belong in either of those hashmaps. I don't want to mess around with the code too much at this point though, so this patch should be a sufficient improvement. --- src/pulse/stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pulse/stream.c b/src/pulse/stream.c index 3bf2d96..5433abf 100644 --- a/src/pulse/stream.c +++ b/src/pulse/stream.c @@ -258,7 +258,7 @@ static void stream_unlink(pa_stream *s) { pa_pdispatch_unregister_reply(s->context->pdispatch, s); if (s->channel_valid) { - pa_hashmap_remove((s->direction == PA_STREAM_PLAYBACK) ? s->context->playback_streams : s->context->record_streams, PA_UINT32_TO_PTR(s->channel)); + pa_hashmap_remove((s->direction == PA_STREAM_RECORD) ? s->context->record_streams : s->context->playback_streams, PA_UINT32_TO_PTR(s->channel)); s->channel = 0; s->channel_valid = FALSE; } -- 2.7.4