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)
commit7d05ac606bd5a86c94ab13f8d6c898ad86b6b78a
treeb700a3188c6c3ccf0571d4e628f768fc308d795e
parentd320ae029b136bb54fcd19f9c29fa033106ca1b8
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