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.
This commit is contained in:
Antti-Ville Jansson 2011-11-11 16:22:24 +02:00 committed by Arun Raghavan
parent d320ae029b
commit 7d05ac606b

View file

@ -258,7 +258,7 @@ static void stream_unlink(pa_stream *s) {
pa_pdispatch_unregister_reply(s->context->pdispatch, s); pa_pdispatch_unregister_reply(s->context->pdispatch, s);
if (s->channel_valid) { 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 = 0;
s->channel_valid = FALSE; s->channel_valid = FALSE;
} }