From 7e6e3b7044ba47772dbaeea0ef71842ec799f7c6 Mon Sep 17 00:00:00 2001 From: Jarkko Suontausta Date: Thu, 24 May 2012 10:38:22 +0300 Subject: [PATCH] core: Assert on memchunk divisibility by sample spec in pa_memblockq_push(). 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 4eeb4d6db..0c245d2b2 100644 --- a/src/pulsecore/memblockq.c +++ b/src/pulsecore/memblockq.c @@ -287,8 +287,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 83a54152f..88906ba4a 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