[pulseaudio-commits] r1493 - /branches/lennart/src/pulsecore/sample-util.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Sun Jun 24 09:09:44 PDT 2007
Author: lennart
Date: Sun Jun 24 18:09:43 2007
New Revision: 1493
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1493&root=3Dpulseaudio&vi=
ew=3Drev
Log:
Fix length calculation in pa_silence_memblock_new() and make use of pa_asse=
rt() everywhere instead of assert()
Modified:
branches/lennart/src/pulsecore/sample-util.c
Modified: branches/lennart/src/pulsecore/sample-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
sample-util.c?rev=3D1493&root=3Dpulseaudio&r1=3D1492&r2=3D1493&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/sample-util.c (original)
+++ branches/lennart/src/pulsecore/sample-util.c Sun Jun 24 18:09:43 2007
@@ -28,12 +28,12 @@
=
#include <stdio.h>
#include <string.h>
-#include <assert.h>
#include <stdlib.h>
=
#include <liboil/liboilfuncs.h>
=
#include <pulsecore/log.h>
+#include <pulsecore/macro.h>
=
#include "sample-util.h"
#include "endianmacros.h"
@@ -42,20 +42,23 @@
=
pa_memblock *pa_silence_memblock_new(pa_mempool *pool, const pa_sample_spe=
c *spec, size_t length) {
size_t fs;
- assert(pool);
- assert(spec);
-
- if (length =3D=3D 0)
+ pa_assert(pool);
+ pa_assert(spec);
+
+ if (length <=3D 0)
length =3D pa_bytes_per_second(spec)/20; /* 50 ms */
=
if (length > PA_SILENCE_MAX)
length =3D PA_SILENCE_MAX;
=
fs =3D pa_frame_size(spec);
- length =3D ((PA_SILENCE_MAX+fs-1) / fs) * fs;
+
+ length =3D (length+fs-1)/fs;
=
if (length <=3D 0)
- length =3D fs;
+ length =3D 1;
+ =
+ length *=3D fs;
=
return pa_silence_memblock(pa_memblock_new(pool, length), spec);
}
@@ -63,8 +66,8 @@
pa_memblock *pa_silence_memblock(pa_memblock* b, const pa_sample_spec *spe=
c) {
void *data;
=
- assert(b);
- assert(spec);
+ pa_assert(b);
+ pa_assert(spec);
=
data =3D pa_memblock_acquire(b);
pa_silence_memory(data, pa_memblock_get_length(b), spec);
@@ -75,9 +78,9 @@
void pa_silence_memchunk(pa_memchunk *c, const pa_sample_spec *spec) {
void *data;
=
- assert(c);
- assert(c->memblock);
- assert(spec);
+ pa_assert(c);
+ pa_assert(c->memblock);
+ pa_assert(spec);
=
data =3D pa_memblock_acquire(c->memblock);
pa_silence_memory((uint8_t*) data+c->index, c->length, spec);
@@ -86,7 +89,9 @@
=
void pa_silence_memory(void *p, size_t length, const pa_sample_spec *spec)=
{
uint8_t c =3D 0;
- assert(p && length && spec);
+ pa_assert(p);
+ pa_assert(length > 0);
+ pa_assert(spec);
=
switch (spec->format) {
case PA_SAMPLE_U8:
@@ -103,7 +108,7 @@
c =3D 80;
break;
default:
- assert(0);
+ pa_assert_not_reached();
}
=
memset(p, c, length);
@@ -122,10 +127,10 @@
size_t d =3D 0;
unsigned k;
=
- assert(streams);
- assert(data);
- assert(length);
- assert(spec);
+ pa_assert(streams);
+ pa_assert(data);
+ pa_assert(length);
+ pa_assert(spec);
=
if (!volume)
volume =3D pa_cvolume_reset(&full_volume, spec->channels);
@@ -347,10 +352,10 @@
=
void *ptr;
=
- assert(c);
- assert(spec);
- assert(c->length % pa_frame_size(spec) =3D=3D 0);
- assert(volume);
+ pa_assert(c);
+ pa_assert(spec);
+ pa_assert(c->length % pa_frame_size(spec) =3D=3D 0);
+ pa_assert(volume);
=
if (pa_cvolume_channels_equal_to(volume, PA_VOLUME_NORM))
return;
More information about the pulseaudio-commits
mailing list