summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/memblock.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulsecore/memblock.h')
-rw-r--r--src/pulsecore/memblock.h61
1 files changed, 25 insertions, 36 deletions
diff --git a/src/pulsecore/memblock.h b/src/pulsecore/memblock.h
index d4f2b7aa..9937818f 100644
--- a/src/pulsecore/memblock.h
+++ b/src/pulsecore/memblock.h
@@ -25,6 +25,7 @@
#include <sys/types.h>
#include <inttypes.h>
+#include <pulse/def.h>
#include <pulsecore/llist.h>
#include <pulsecore/refcnt.h>
@@ -54,45 +55,25 @@ typedef struct pa_memexport pa_memexport;
typedef void (*pa_memimport_release_cb_t)(pa_memimport *i, uint32_t block_id, void *userdata);
typedef void (*pa_memexport_revoke_cb_t)(pa_memexport *e, uint32_t block_id, void *userdata);
-struct pa_memblock {
- pa_memblock_type_t type;
- int read_only; /* boolean */
- PA_REFCNT_DECLARE; /* the reference counter */
- size_t length;
- void *data;
- pa_mempool *pool;
-
- union {
- struct {
- void (*free_cb)(void *p); /* If type == PA_MEMBLOCK_USER this points to a function for freeing this memory block */
- } user;
-
- struct {
- uint32_t id;
- pa_memimport_segment *segment;
- } imported;
- } per_type;
-};
-
/* Please note that updates to this structure are not locked,
* i.e. n_allocated might be updated at a point in time where
* n_accumulated is not yet. Take these values with a grain of salt,
- * threy are here for purely statistical reasons.*/
+ * they are here for purely statistical reasons.*/
struct pa_mempool_stat {
- AO_t n_allocated;
- AO_t n_accumulated;
- AO_t n_imported;
- AO_t n_exported;
- AO_t allocated_size;
- AO_t accumulated_size;
- AO_t imported_size;
- AO_t exported_size;
-
- AO_t n_too_large_for_pool;
- AO_t n_pool_full;
-
- AO_t n_allocated_by_type[PA_MEMBLOCK_TYPE_MAX];
- AO_t n_accumulated_by_type[PA_MEMBLOCK_TYPE_MAX];
+ pa_atomic_int_t n_allocated;
+ pa_atomic_int_t n_accumulated;
+ pa_atomic_int_t n_imported;
+ pa_atomic_int_t n_exported;
+ pa_atomic_int_t allocated_size;
+ pa_atomic_int_t accumulated_size;
+ pa_atomic_int_t imported_size;
+ pa_atomic_int_t exported_size;
+
+ pa_atomic_int_t n_too_large_for_pool;
+ pa_atomic_int_t n_pool_full;
+
+ pa_atomic_int_t n_allocated_by_type[PA_MEMBLOCK_TYPE_MAX];
+ pa_atomic_int_t n_accumulated_by_type[PA_MEMBLOCK_TYPE_MAX];
};
/* Allocate a new memory block of type PA_MEMBLOCK_MEMPOOL or PA_MEMBLOCK_APPENDED, depending on the size */
@@ -116,9 +97,17 @@ pa_memblock* pa_memblock_ref(pa_memblock*b);
/* This special unref function has to be called by the owner of the
memory of a static memory block when he wants to release all
references to the memory. This causes the memory to be copied and
-converted into a PA_MEMBLOCK_DYNAMIC type memory block */
+converted into a pool or malloc'ed memory block. Please note that this
+function is not multiple caller safe, i.e. needs to be locked
+manually if called from more than one thread at the same time. */
void pa_memblock_unref_fixed(pa_memblock*b);
+int pa_memblock_is_read_only(pa_memblock *b);
+void* pa_memblock_acquire(pa_memblock *b);
+void pa_memblock_release(pa_memblock *b);
+size_t pa_memblock_get_length(pa_memblock *b);
+pa_mempool * pa_memblock_get_pool(pa_memblock *b);
+
/* The memory block manager */
pa_mempool* pa_mempool_new(int shared);
void pa_mempool_free(pa_mempool *p);