2004-06-08 23:54:24 +00:00
|
|
|
#ifndef foomemblockqhfoo
|
|
|
|
|
#define foomemblockqhfoo
|
|
|
|
|
|
2004-07-16 19:56:36 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
This file is part of polypaudio.
|
|
|
|
|
|
|
|
|
|
polypaudio is free software; you can redistribute it and/or modify
|
2004-11-21 21:31:28 +00:00
|
|
|
it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version.
|
2004-07-16 19:56:36 +00:00
|
|
|
|
|
|
|
|
polypaudio is distributed in the hope that it will be useful, but
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
2004-11-21 21:31:28 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
License along with polypaudio; if not, write to the Free Software
|
2004-07-16 19:56:36 +00:00
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
|
USA.
|
|
|
|
|
***/
|
|
|
|
|
|
2004-06-08 23:54:24 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
2006-02-17 12:10:58 +00:00
|
|
|
#include <polypcore/memblock.h>
|
|
|
|
|
#include <polypcore/memchunk.h>
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-11-21 21:31:28 +00:00
|
|
|
/* A memblockq is a queue of pa_memchunks (yepp, the name is not
|
|
|
|
|
* perfect). It is similar to the ring buffers used by most other
|
|
|
|
|
* audio software. In contrast to a ring buffer this memblockq data
|
|
|
|
|
* type doesn't need to copy any data around, it just maintains
|
|
|
|
|
* references to reference counted memory blocks. */
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
typedef struct pa_memblockq pa_memblockq;
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-07-07 00:22:46 +00:00
|
|
|
/* Parameters:
|
|
|
|
|
- maxlength: maximum length of queue. If more data is pushed into the queue, data from the front is dropped
|
|
|
|
|
- length: the target length of the queue.
|
|
|
|
|
- base: a base value for all metrics. Only multiples of this value are popped from the queue
|
|
|
|
|
- prebuf: before passing the first byte out, make sure that enough bytes are in the queue
|
|
|
|
|
- minreq: pa_memblockq_missing() will only return values greater than this value
|
|
|
|
|
*/
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_memblockq* pa_memblockq_new(size_t maxlength,
|
2004-07-07 00:22:46 +00:00
|
|
|
size_t tlength,
|
|
|
|
|
size_t base,
|
|
|
|
|
size_t prebuf,
|
2004-08-17 19:37:29 +00:00
|
|
|
size_t minreq,
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_memblock_stat *s);
|
|
|
|
|
void pa_memblockq_free(pa_memblockq*bq);
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-08-22 21:13:58 +00:00
|
|
|
/* Push a new memory chunk into the queue. Optionally specify a value for future cancellation. */
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_memblockq_push(pa_memblockq* bq, const 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 */
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_memblockq_push_align(pa_memblockq* bq, const 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 */
|
2006-01-11 01:17:39 +00:00
|
|
|
int pa_memblockq_peek(pa_memblockq* bq, pa_memchunk *chunk);
|
2004-07-03 00:19:17 +00:00
|
|
|
|
2004-08-22 21:13:58 +00:00
|
|
|
/* Drop the specified bytes from the queue, only valid aufter pa_memblockq_peek() */
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_memblockq_drop(pa_memblockq *bq, const pa_memchunk *chunk, size_t length);
|
2004-08-22 21:13:58 +00:00
|
|
|
|
2004-07-03 00:19:17 +00:00
|
|
|
/* Drop the specified bytes from the queue */
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_memblockq_skip(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 */
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_memblockq_shorten(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 */
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_memblockq_empty(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 */
|
2006-01-11 01:17:39 +00:00
|
|
|
int pa_memblockq_is_readable(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 */
|
2006-01-11 01:17:39 +00:00
|
|
|
int pa_memblockq_is_writable(pa_memblockq *bq, size_t length);
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-07-03 00:19:17 +00:00
|
|
|
/* Return the length of the queue in bytes */
|
2006-01-11 01:17:39 +00:00
|
|
|
uint32_t pa_memblockq_get_length(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 */
|
2006-01-11 01:17:39 +00:00
|
|
|
uint32_t pa_memblockq_missing(pa_memblockq *bq);
|
2004-07-07 00:22:46 +00:00
|
|
|
|
2004-08-17 18:53:42 +00:00
|
|
|
/* Returns the minimal request value */
|
2006-01-11 01:17:39 +00:00
|
|
|
uint32_t pa_memblockq_get_minreq(pa_memblockq *bq);
|
2004-06-23 23:17:30 +00:00
|
|
|
|
2004-08-17 18:53:42 +00:00
|
|
|
/* Force disabling of pre-buf even when the pre-buffer is not yet filled */
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_memblockq_prebuf_disable(pa_memblockq *bq);
|
2004-08-17 18:53:42 +00:00
|
|
|
|
2004-09-26 17:02:26 +00:00
|
|
|
/* Reenable pre-buf to the initial level */
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_memblockq_prebuf_reenable(pa_memblockq *bq);
|
2004-09-26 17:02:26 +00:00
|
|
|
|
2004-08-22 21:13:58 +00:00
|
|
|
/* Manipulate the write pointer */
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_memblockq_seek(pa_memblockq *bq, size_t delta);
|
2004-08-22 21:13:58 +00:00
|
|
|
|
|
|
|
|
/* Flush the queue */
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_memblockq_flush(pa_memblockq *bq);
|
2004-08-22 21:13:58 +00:00
|
|
|
|
2004-09-01 00:23:51 +00:00
|
|
|
/* Get Target length */
|
2006-01-11 01:17:39 +00:00
|
|
|
uint32_t pa_memblockq_get_tlength(pa_memblockq *bq);
|
2004-09-01 00:23:51 +00:00
|
|
|
|
2004-06-08 23:54:24 +00:00
|
|
|
#endif
|