2004-06-08 23:54:24 +00:00
|
|
|
#ifndef foomemblockqhfoo
|
|
|
|
|
#define foomemblockqhfoo
|
|
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
|
|
#include "memblock.h"
|
2004-07-03 00:19:17 +00:00
|
|
|
#include "memchunk.h"
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-07-03 23:35:12 +00:00
|
|
|
struct pa_memblockq;
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-07-03 00:19:17 +00:00
|
|
|
/* Parameters: the maximum length of the memblock queue, a base value
|
|
|
|
|
for all operations (that is, all byte operations shall work on
|
|
|
|
|
multiples of this base value) and an amount of bytes to prebuffer
|
2004-07-03 23:35:12 +00:00
|
|
|
before having pa_memblockq_peek() succeed. */
|
|
|
|
|
struct pa_memblockq* pa_memblockq_new(size_t maxlength, size_t base, size_t prebuf);
|
|
|
|
|
void pa_memblockq_free(struct pa_memblockq*bq);
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-07-03 00:19:17 +00:00
|
|
|
/* Push a new memory chunk into the queue. Optionally specify a value for future cancellation. This is currently not implemented, however! */
|
2004-07-03 23:35:12 +00:00
|
|
|
void pa_memblockq_push(struct pa_memblockq* bq, const struct pa_memchunk *chunk, size_t delta);
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-07-03 23:35:12 +00:00
|
|
|
/* Same as pa_memblockq_push(), however chunks are filtered through a mcalign object, and thus aligned to multiples of base */
|
|
|
|
|
void pa_memblockq_push_align(struct pa_memblockq* bq, const struct pa_memchunk *chunk, size_t delta);
|
2004-07-03 00:19:17 +00:00
|
|
|
|
|
|
|
|
/* Return a copy of the next memory chunk in the queue. It is not removed from the queue */
|
2004-07-03 23:35:12 +00:00
|
|
|
int pa_memblockq_peek(struct pa_memblockq* bq, struct pa_memchunk *chunk);
|
2004-07-03 00:19:17 +00:00
|
|
|
|
|
|
|
|
/* Drop the specified bytes from the queue */
|
2004-07-03 23:35:12 +00:00
|
|
|
void pa_memblockq_drop(struct pa_memblockq *bq, size_t length);
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-07-03 23:35:12 +00:00
|
|
|
/* Shorten the pa_memblockq to the specified length by dropping data at the end of the queue */
|
|
|
|
|
void pa_memblockq_shorten(struct pa_memblockq *bq, size_t length);
|
2004-07-03 00:19:17 +00:00
|
|
|
|
2004-07-03 23:35:12 +00:00
|
|
|
/* Empty the pa_memblockq */
|
|
|
|
|
void pa_memblockq_empty(struct pa_memblockq *bq);
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-07-03 23:35:12 +00:00
|
|
|
/* Test if the pa_memblockq is currently readable, that is, more data than base */
|
|
|
|
|
int pa_memblockq_is_readable(struct pa_memblockq *bq);
|
2004-07-03 00:19:17 +00:00
|
|
|
|
2004-07-03 23:35:12 +00:00
|
|
|
/* Test if the pa_memblockq is currently writable for the specified amount of bytes */
|
|
|
|
|
int pa_memblockq_is_writable(struct pa_memblockq *bq, size_t length);
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-07-03 00:19:17 +00:00
|
|
|
/* The time memory chunks stay in the queue until they are removed completely in usecs */
|
2004-07-03 23:35:12 +00:00
|
|
|
uint32_t pa_memblockq_get_delay(struct pa_memblockq *bq);
|
2004-07-03 00:19:17 +00:00
|
|
|
|
|
|
|
|
/* Return the length of the queue in bytes */
|
2004-07-03 23:35:12 +00:00
|
|
|
uint32_t pa_memblockq_get_length(struct pa_memblockq *bq);
|
2004-06-15 15:18:33 +00:00
|
|
|
|
2004-07-03 00:19:17 +00:00
|
|
|
/* Return how many bytes are missing in queue to the specified fill amount */
|
2004-07-03 23:35:12 +00:00
|
|
|
uint32_t pa_memblockq_missing_to(struct pa_memblockq *bq, size_t qlen);
|
2004-06-23 23:17:30 +00:00
|
|
|
|
2004-06-08 23:54:24 +00:00
|
|
|
#endif
|