diff options
author | Tanu Kaskinen <ext-tanu.kaskinen@nokia.com> | 2009-12-03 13:22:05 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-01-15 01:38:19 +0100 |
commit | 52c66b47664d47154b2c8368e32beef27d4b2d03 (patch) | |
tree | 368a1dcf5e200f14c136d7c56ee275785a934be3 /src/pulse/context.c | |
parent | fd5c802ecb5ae5ed9b294422410761126a37d1b3 (diff) |
libpulse: Store pa_stream pointers to hashmaps instead of dynarrays.
Since the stream identifiers (channels) are monotonically growing integer, it
isn't a good idea to use them as index to a dynamic array, because the array
will grow all the time. This is not a problem with client connections that
don't create many streams, but, for example, long-running clients that use
libcanberra for playing event sounds, this means that the client connection
effectively leaks memory.
Diffstat (limited to 'src/pulse/context.c')
-rw-r--r-- | src/pulse/context.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/pulse/context.c b/src/pulse/context.c index c83230d6..91f4817c 100644 --- a/src/pulse/context.c +++ b/src/pulse/context.c @@ -63,7 +63,7 @@ #include <pulsecore/native-common.h> #include <pulsecore/pdispatch.h> #include <pulsecore/pstream.h> -#include <pulsecore/dynarray.h> +#include <pulsecore/hashmap.h> #include <pulsecore/socket-client.h> #include <pulsecore/pstream-util.h> #include <pulsecore/core-rtclock.h> @@ -157,8 +157,8 @@ pa_context *pa_context_new_with_proplist(pa_mainloop_api *mainloop, const char * c->system_bus = c->session_bus = NULL; #endif c->mainloop = mainloop; - c->playback_streams = pa_dynarray_new(); - c->record_streams = pa_dynarray_new(); + c->playback_streams = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); + c->record_streams = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); c->client_index = PA_INVALID_INDEX; c->use_rtclock = pa_mainloop_is_our_api(mainloop); @@ -252,9 +252,9 @@ static void context_free(pa_context *c) { #endif if (c->record_streams) - pa_dynarray_free(c->record_streams, NULL, NULL); + pa_hashmap_free(c->record_streams, NULL, NULL); if (c->playback_streams) - pa_dynarray_free(c->playback_streams, NULL, NULL); + pa_hashmap_free(c->playback_streams, NULL, NULL); if (c->mempool) pa_mempool_free(c->mempool); @@ -361,7 +361,7 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o pa_context_ref(c); - if ((s = pa_dynarray_get(c->record_streams, channel))) { + if ((s = pa_hashmap_get(c->record_streams, PA_UINT32_TO_PTR(channel)))) { if (chunk->memblock) { pa_memblockq_seek(s->record_memblockq, offset, seek, TRUE); |