move pstream item allocation to pa_flist

git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1628 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2007-08-11 00:10:29 +00:00
parent d2fed9d419
commit 59c9ed5473

View file

@ -49,6 +49,7 @@
#include <pulsecore/core-scache.h> #include <pulsecore/core-scache.h>
#include <pulsecore/creds.h> #include <pulsecore/creds.h>
#include <pulsecore/refcnt.h> #include <pulsecore/refcnt.h>
#include <pulsecore/flist.h>
#include "pstream.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_ALLOW PA_SCACHE_ENTRY_SIZE_MAX /* allow uploading a single sample in one frame at max */
#define FRAME_SIZE_MAX_USE (1024*64) #define FRAME_SIZE_MAX_USE (1024*64)
PA_STATIC_FLIST_DECLARE(items, 0, pa_xfree);
struct item_info { struct item_info {
enum { enum {
PA_PSTREAM_ITEM_PACKET, PA_PSTREAM_ITEM_PACKET,
@ -92,7 +95,6 @@ struct item_info {
PA_PSTREAM_ITEM_SHMREVOKE PA_PSTREAM_ITEM_SHMREVOKE
} type; } type;
/* packet info */ /* packet info */
pa_packet *packet; pa_packet *packet;
#ifdef HAVE_CREDS #ifdef HAVE_CREDS
@ -295,6 +297,7 @@ static void item_free(void *item, PA_GCC_UNUSED void *q) {
pa_packet_unref(i->packet); pa_packet_unref(i->packet);
} }
if (pa_flist_push(PA_STATIC_FLIST_GET(items), i) < 0)
pa_xfree(i); pa_xfree(i);
} }
@ -330,7 +333,9 @@ void pa_pstream_send_packet(pa_pstream*p, pa_packet *packet, const pa_creds *cre
if (p->dead) if (p->dead)
return; return;
if (!(i = pa_flist_pop(PA_STATIC_FLIST_GET(items))))
i = pa_xnew(struct item_info, 1); i = pa_xnew(struct item_info, 1);
i->type = PA_PSTREAM_ITEM_PACKET; i->type = PA_PSTREAM_ITEM_PACKET;
i->packet = pa_packet_ref(packet); i->packet = pa_packet_ref(packet);
@ -362,6 +367,7 @@ void pa_pstream_send_memblock(pa_pstream*p, uint32_t channel, int64_t offset, pa
struct item_info *i; struct item_info *i;
size_t n; size_t n;
if (!(i = pa_flist_pop(PA_STATIC_FLIST_GET(items))))
i = pa_xnew(struct item_info, 1); i = pa_xnew(struct item_info, 1);
i->type = PA_PSTREAM_ITEM_MEMBLOCK; i->type = PA_PSTREAM_ITEM_MEMBLOCK;
@ -396,6 +402,7 @@ void pa_pstream_send_release(pa_pstream *p, uint32_t block_id) {
/* pa_log("Releasing block %u", block_id); */ /* pa_log("Releasing block %u", block_id); */
if (!(item = pa_flist_pop(PA_STATIC_FLIST_GET(items))))
item = pa_xnew(struct item_info, 1); item = pa_xnew(struct item_info, 1);
item->type = PA_PSTREAM_ITEM_SHMRELEASE; item->type = PA_PSTREAM_ITEM_SHMRELEASE;
item->block_id = block_id; item->block_id = block_id;
@ -432,6 +439,7 @@ void pa_pstream_send_revoke(pa_pstream *p, uint32_t block_id) {
return; return;
/* pa_log("Revoking block %u", block_id); */ /* pa_log("Revoking block %u", block_id); */
if (!(item = pa_flist_pop(PA_STATIC_FLIST_GET(items))))
item = pa_xnew(struct item_info, 1); item = pa_xnew(struct item_info, 1);
item->type = PA_PSTREAM_ITEM_SHMREVOKE; item->type = PA_PSTREAM_ITEM_SHMREVOKE;
item->block_id = block_id; item->block_id = block_id;