]> code.delx.au - pulseaudio/commitdiff
stream: Fix upload samples' cleanup
authorAntti-Ville Jansson <antti-ville.jansson@digia.com>
Fri, 11 Nov 2011 14:22:24 +0000 (16:22 +0200)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Mon, 14 Nov 2011 05:24:18 +0000 (10:54 +0530)
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

index 3bf2d964b0e9137ebbb6a3aa45af27d9da6c4d36..5433abf4b02b931a81132c10d80af5f3878ce57b 100644 (file)
@@ -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;
     }