[pulseaudio-discuss] [PATCH 1/2] core: Assert on memchunk divisibility by sample spec in pa_memblockq_push().
Jarkko Suontausta
jarkko.suontausta at digia.com
Thu May 24 00:38:22 PDT 2012
Earlier, -1 was returned if the memchunk size was not a multiple of the frame
size. Now, it is verified unconditionally through an assertion. Error code -1
is still returned when the memblock queue is full.
In those few cases where the return value of pa_memblockq_push() is checked,
an overflow is assumed to be the reason in case an error code is returned.
---
src/pulsecore/memblockq.c | 3 +--
src/pulsecore/memblockq.h | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/pulsecore/memblockq.c b/src/pulsecore/memblockq.c
index 18066f7..c31f91b 100644
--- a/src/pulsecore/memblockq.c
+++ b/src/pulsecore/memblockq.c
@@ -293,8 +293,7 @@ int pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *uchunk) {
pa_assert(uchunk->length > 0);
pa_assert(uchunk->index + uchunk->length <= pa_memblock_get_length(uchunk->memblock));
- if (uchunk->length % bq->base)
- return -1;
+ pa_assert_se(uchunk->length % bq->base == 0);
if (!can_push(bq, uchunk->length))
return -1;
diff --git a/src/pulsecore/memblockq.h b/src/pulsecore/memblockq.h
index 08c0bf0..41b067d 100644
--- a/src/pulsecore/memblockq.h
+++ b/src/pulsecore/memblockq.h
@@ -51,7 +51,7 @@ typedef struct pa_memblockq pa_memblockq;
- ss: Sample spec describing the queue contents. Only multiples
of the frame size as implied by the sample spec are
- popped from the queue or should be pushed into it.
+ allowed into the queue or can be popped from it.
- prebuf: If the queue runs empty wait until this many bytes are in
queue again before passing the first byte out. If set
--
1.7.0.4
More information about the pulseaudio-discuss
mailing list