diff options
author | Lennart Poettering <lennart@poettering.net> | 2007-08-11 00:10:29 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2007-08-11 00:10:29 +0000 |
commit | 59c9ed5473a04e51eed51112612a9065f4f41093 (patch) | |
tree | 8a183c3b236447202a6a8cda99376f53a07d6fac | |
parent | d2fed9d419be4cc3aa7417471166e16f1de3f7dd (diff) |
move pstream item allocation to pa_flist
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1628 fefdeb5f-60dc-0310-8127-8f9354f1896f
-rw-r--r-- | src/pulsecore/pstream.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/pulsecore/pstream.c b/src/pulsecore/pstream.c index b91813e4..33bc520c 100644 --- a/src/pulsecore/pstream.c +++ b/src/pulsecore/pstream.c @@ -49,6 +49,7 @@ #include <pulsecore/core-scache.h> #include <pulsecore/creds.h> #include <pulsecore/refcnt.h> +#include <pulsecore/flist.h> #include "pstream.h" @@ -84,6 +85,8 @@ typedef uint32_t pa_pstream_descriptor[PA_PSTREAM_DESCRIPTOR_MAX]; #define FRAME_SIZE_MAX_ALLOW PA_SCACHE_ENTRY_SIZE_MAX /* allow uploading a single sample in one frame at max */ #define FRAME_SIZE_MAX_USE (1024*64) +PA_STATIC_FLIST_DECLARE(items, 0, pa_xfree); + struct item_info { enum { PA_PSTREAM_ITEM_PACKET, @@ -92,7 +95,6 @@ struct item_info { PA_PSTREAM_ITEM_SHMREVOKE } type; - /* packet info */ pa_packet *packet; #ifdef HAVE_CREDS @@ -295,7 +297,8 @@ static void item_free(void *item, PA_GCC_UNUSED void *q) { pa_packet_unref(i->packet); } - pa_xfree(i); + if (pa_flist_push(PA_STATIC_FLIST_GET(items), i) < 0) + pa_xfree(i); } static void pstream_free(pa_pstream *p) { @@ -330,7 +333,9 @@ void pa_pstream_send_packet(pa_pstream*p, pa_packet *packet, const pa_creds *cre if (p->dead) return; - i = pa_xnew(struct item_info, 1); + if (!(i = pa_flist_pop(PA_STATIC_FLIST_GET(items)))) + i = pa_xnew(struct item_info, 1); + i->type = PA_PSTREAM_ITEM_PACKET; i->packet = pa_packet_ref(packet); @@ -362,7 +367,8 @@ void pa_pstream_send_memblock(pa_pstream*p, uint32_t channel, int64_t offset, pa struct item_info *i; size_t n; - i = pa_xnew(struct item_info, 1); + if (!(i = pa_flist_pop(PA_STATIC_FLIST_GET(items)))) + i = pa_xnew(struct item_info, 1); i->type = PA_PSTREAM_ITEM_MEMBLOCK; n = length < FRAME_SIZE_MAX_USE ? length : FRAME_SIZE_MAX_USE; @@ -396,7 +402,8 @@ void pa_pstream_send_release(pa_pstream *p, uint32_t block_id) { /* pa_log("Releasing block %u", block_id); */ - item = pa_xnew(struct item_info, 1); + if (!(item = pa_flist_pop(PA_STATIC_FLIST_GET(items)))) + item = pa_xnew(struct item_info, 1); item->type = PA_PSTREAM_ITEM_SHMRELEASE; item->block_id = block_id; #ifdef HAVE_CREDS @@ -432,7 +439,8 @@ void pa_pstream_send_revoke(pa_pstream *p, uint32_t block_id) { return; /* pa_log("Revoking block %u", block_id); */ - item = pa_xnew(struct item_info, 1); + if (!(item = pa_flist_pop(PA_STATIC_FLIST_GET(items)))) + item = pa_xnew(struct item_info, 1); item->type = PA_PSTREAM_ITEM_SHMREVOKE; item->block_id = block_id; #ifdef HAVE_CREDS |