summaryrefslogtreecommitdiffstats
path: root/src/polypcore/memblockq.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-02-20 04:05:16 +0000
committerLennart Poettering <lennart@poettering.net>2006-02-20 04:05:16 +0000
commit304449002cbc84fdcf235b5dfaec891278dd7085 (patch)
tree2a2d00e34d5c620835b76a0d6f7890a1d3e9fb97 /src/polypcore/memblockq.h
parent0876b1ba82ea9c988df90ca98d202765ac697313 (diff)
1) Add flexible seeking support (including absolute) for memory block queues and playback streams
2) Add support to synchronize multiple playback streams 3) add two tests for 1) and 2) 4) s/PA_ERROR/PA_ERR/ 5) s/PA_ERROR_OK/PA_OK/ 6) update simple API to deal properly with new peek/drop recording API 7) add beginnings of proper validity checking on API calls in client libs (needs to be extended) 8) report playback buffer overflows/underflows to the client 9) move client side recording mcalign stuff into the memblockq 10) create typedefs for a bunch of API callback prototypes 11) simplify handling of HUP poll() events Yes, i know, it's usually better to commit a lot of small patches instead of a single big one. In this case however, this would have contradicted the other rule: never commit broken or incomplete stuff. *** This stuff needs a lot of additional testing! *** git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@511 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/polypcore/memblockq.h')
-rw-r--r--src/polypcore/memblockq.h102
1 files changed, 66 insertions, 36 deletions
diff --git a/src/polypcore/memblockq.h b/src/polypcore/memblockq.h
index 7bb25f90..210f1a07 100644
--- a/src/polypcore/memblockq.h
+++ b/src/polypcore/memblockq.h
@@ -23,9 +23,11 @@
***/
#include <sys/types.h>
+#include <inttypes.h>
#include <polypcore/memblock.h>
#include <polypcore/memchunk.h>
+#include <polyp/def.h>
/* 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
@@ -35,42 +37,59 @@
typedef struct pa_memblockq pa_memblockq;
+
/* 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
+
+ - idx: start value for both read and write index
+
+ - maxlength: maximum length of queue. If more data is pushed into
+ the queue, the operation will fail. Must not be 0.
+
+ - tlength: the target length of the queue. Pass 0 for the default.
+
+ - base: a base value for all metrics. Only multiples of this value
+ are popped from the queue or should be pushed into
+ it. Must not be 0.
+
+ - prebuf: If the queue runs empty wait until this many bytes are in
+ queue again before passing the first byte out. If set
+ to 0 pa_memblockq_pop() will return a silence memblock
+ if no data is in the queue and will never fail. Pass
+ (size_t) -1 for the default.
+
+ - minreq: pa_memblockq_missing() will only return values greater
+ than this value. Pass 0 for the default.
+
+ - silence: return this memblock whzen reading unitialized data
*/
-pa_memblockq* pa_memblockq_new(size_t maxlength,
- size_t tlength,
- size_t base,
- size_t prebuf,
- size_t minreq,
- pa_memblock_stat *s);
+pa_memblockq* pa_memblockq_new(
+ int64_t idx,
+ size_t maxlength,
+ size_t tlength,
+ size_t base,
+ size_t prebuf,
+ size_t minreq,
+ pa_memblock *silence,
+ pa_memblock_stat *s);
+
void pa_memblockq_free(pa_memblockq*bq);
-/* Push a new memory chunk into the queue. Optionally specify a value for future cancellation. */
-void pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *chunk, size_t delta);
+/* Push a new memory chunk into the queue. */
+int pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *chunk);
-/* 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(pa_memblockq* bq, const pa_memchunk *chunk, size_t delta);
+/* Push a new memory chunk into the queue, but filter it through a
+ * pa_mcalign object. Don't mix this with pa_memblockq_seek() unless
+ * you know what you do. */
+int pa_memblockq_push_align(pa_memblockq* bq, const pa_memchunk *chunk);
/* Return a copy of the next memory chunk in the queue. It is not removed from the queue */
int pa_memblockq_peek(pa_memblockq* bq, pa_memchunk *chunk);
-/* Drop the specified bytes from the queue, only valid aufter pa_memblockq_peek() */
+/* Drop the specified bytes from the queue, but only if the first
+ * chunk in the queue matches the one passed here. If NULL is passed,
+ * this check isn't done. */
void pa_memblockq_drop(pa_memblockq *bq, const pa_memchunk *chunk, size_t length);
-/* Drop the specified bytes from the queue */
-void pa_memblockq_skip(pa_memblockq *bq, size_t length);
-
-/* Shorten the pa_memblockq to the specified length by dropping data at the end of the queue */
-void pa_memblockq_shorten(pa_memblockq *bq, size_t length);
-
-/* Empty the pa_memblockq */
-void pa_memblockq_empty(pa_memblockq *bq);
-
/* Test if the pa_memblockq is currently readable, that is, more data than base */
int pa_memblockq_is_readable(pa_memblockq *bq);
@@ -78,27 +97,38 @@ int pa_memblockq_is_readable(pa_memblockq *bq);
int pa_memblockq_is_writable(pa_memblockq *bq, size_t length);
/* Return the length of the queue in bytes */
-uint32_t pa_memblockq_get_length(pa_memblockq *bq);
+size_t pa_memblockq_get_length(pa_memblockq *bq);
/* Return how many bytes are missing in queue to the specified fill amount */
-uint32_t pa_memblockq_missing(pa_memblockq *bq);
+size_t pa_memblockq_missing(pa_memblockq *bq);
/* Returns the minimal request value */
-uint32_t pa_memblockq_get_minreq(pa_memblockq *bq);
-
-/* Force disabling of pre-buf even when the pre-buffer is not yet filled */
-void pa_memblockq_prebuf_disable(pa_memblockq *bq);
-
-/* Reenable pre-buf to the initial level */
-void pa_memblockq_prebuf_reenable(pa_memblockq *bq);
+size_t pa_memblockq_get_minreq(pa_memblockq *bq);
/* Manipulate the write pointer */
-void pa_memblockq_seek(pa_memblockq *bq, size_t delta);
+void pa_memblockq_seek(pa_memblockq *bq, int64_t offset, pa_seek_mode_t seek);
-/* Flush the queue */
+/* Set the queue to silence, set write index to read index */
void pa_memblockq_flush(pa_memblockq *bq);
/* Get Target length */
uint32_t pa_memblockq_get_tlength(pa_memblockq *bq);
+/* Return the current read index */
+int64_t pa_memblockq_get_read_index(pa_memblockq *bq);
+
+/* Return the current write index */
+int64_t pa_memblockq_get_write_index(pa_memblockq *bq);
+
+/* Shorten the pa_memblockq to the specified length by dropping data
+ * at the read end of the queue. The read index is increased until the
+ * queue has the specified length */
+void pa_memblockq_shorten(pa_memblockq *bq, size_t length);
+
+/* Ignore prebuf for now */
+void pa_memblockq_prebuf_disable(pa_memblockq *bq);
+
+/* Force prebuf */
+void pa_memblockq_prebuf_force(pa_memblockq *bq);
+
#endif