#include <pulsecore/core-scache.h>
#include <pulsecore/creds.h>
#include <pulsecore/refcnt.h>
+#include <pulsecore/flist.h>
#include "pstream.h"
#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,
PA_PSTREAM_ITEM_SHMREVOKE
} type;
-
/* packet info */
pa_packet *packet;
#ifdef HAVE_CREDS
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) {
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);
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;
/* 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
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