merge 'lennart' branch back into trunk.

git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1971 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2007-10-28 19:13:50 +00:00
parent 6687dd0131
commit a67c21f093
294 changed files with 79057 additions and 11614 deletions

View file

@ -28,6 +28,7 @@
#include <sys/types.h>
#include <inttypes.h>
#include <pulse/def.h>
#include <pulsecore/llist.h>
#include <pulsecore/refcnt.h>
#include <pulsecore/atomic.h>
@ -58,45 +59,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 {
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_t n_allocated;
pa_atomic_t n_accumulated;
pa_atomic_t n_imported;
pa_atomic_t n_exported;
pa_atomic_t allocated_size;
pa_atomic_t accumulated_size;
pa_atomic_t imported_size;
pa_atomic_t exported_size;
pa_atomic_int_t n_too_large_for_pool;
pa_atomic_int_t n_pool_full;
pa_atomic_t n_too_large_for_pool;
pa_atomic_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];
pa_atomic_t n_allocated_by_type[PA_MEMBLOCK_TYPE_MAX];
pa_atomic_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 */
@ -120,9 +101,20 @@ 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);
int pa_memblock_ref_is_one(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);
pa_memblock *pa_memblock_will_need(pa_memblock *b);
/* The memory block manager */
pa_mempool* pa_mempool_new(int shared);
void pa_mempool_free(pa_mempool *p);
@ -130,6 +122,7 @@ const pa_mempool_stat* pa_mempool_get_stat(pa_mempool *p);
void pa_mempool_vacuum(pa_mempool *p);
int pa_mempool_get_shm_id(pa_mempool *p, uint32_t *id);
int pa_mempool_is_shared(pa_mempool *p);
size_t pa_mempool_block_size_max(pa_mempool *p);
/* For recieving blocks from other nodes */
pa_memimport* pa_memimport_new(pa_mempool *p, pa_memimport_release_cb_t cb, void *userdata);