X-Git-Url: https://code.delx.au/pulseaudio/blobdiff_plain/22cb23eedb2eae7c79dc8fcf395be08bfc666256..fa499dad06ba6558111cdef64c18f2401e803cff:/polyp/sample-util.c diff --git a/polyp/sample-util.c b/polyp/sample-util.c index 8f5558a4..0d4d18d3 100644 --- a/polyp/sample-util.c +++ b/polyp/sample-util.c @@ -4,7 +4,7 @@ This file is part of polypaudio. polypaudio is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published + 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. @@ -13,7 +13,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with polypaudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. @@ -37,7 +37,7 @@ struct pa_memblock *pa_silence_memblock(struct pa_memblock* b, const struct pa_s void pa_silence_memchunk(struct pa_memchunk *c, const struct pa_sample_spec *spec) { assert(c && c->memblock && c->memblock->data && spec && c->length); - pa_silence_memory(c->memblock->data+c->index, c->length, spec); + pa_silence_memory((uint8_t*) c->memblock->data+c->index, c->length, spec); } void pa_silence_memory(void *p, size_t length, const struct pa_sample_spec *spec) { @@ -64,7 +64,7 @@ void pa_silence_memory(void *p, size_t length, const struct pa_sample_spec *spec memset(p, c, length); } -size_t pa_mix(struct pa_mix_info channels[], unsigned nchannels, void *data, size_t length, const struct pa_sample_spec *spec, uint32_t volume) { +size_t pa_mix(struct pa_mix_info channels[], unsigned nchannels, void *data, size_t length, const struct pa_sample_spec *spec, pa_volume_t volume) { unsigned c, d; assert(channels && data && length && spec); assert(spec->format == PA_SAMPLE_S16NE); @@ -82,10 +82,10 @@ size_t pa_mix(struct pa_mix_info channels[], unsigned nchannels, void *data, siz if (d >= channels[c].chunk.length) return d; - if (volume == PA_VOLUME_MUTE) + if (volume == PA_VOLUME_MUTED) v = 0; else { - v = *((int16_t*) (channels[c].chunk.memblock->data + channels[c].chunk.index + d)); + v = *((int16_t*) ((uint8_t*) channels[c].chunk.memblock->data + channels[c].chunk.index + d)); if (volume != PA_VOLUME_NORM) v = (int32_t) ((float)v*volume/PA_VOLUME_NORM); @@ -94,7 +94,7 @@ size_t pa_mix(struct pa_mix_info channels[], unsigned nchannels, void *data, siz sum += v; } - if (volume == PA_VOLUME_MUTE) + if (volume == PA_VOLUME_MUTED) sum = 0; else if (volume != PA_VOLUME_NORM) sum = (int32_t) ((float) sum*volume/PA_VOLUME_NORM); @@ -103,12 +103,12 @@ size_t pa_mix(struct pa_mix_info channels[], unsigned nchannels, void *data, siz if (sum > 0x7FFF) sum = 0x7FFF; *((int16_t*) data) = sum; - data += sizeof(int16_t); + data = (uint8_t*) data + sizeof(int16_t); } } -void pa_volume_memchunk(struct pa_memchunk*c, const struct pa_sample_spec *spec, uint32_t volume) { +void pa_volume_memchunk(struct pa_memchunk*c, const struct pa_sample_spec *spec, pa_volume_t volume) { int16_t *d; size_t n; assert(c && spec && (c->length % pa_frame_size(spec) == 0)); @@ -117,12 +117,12 @@ void pa_volume_memchunk(struct pa_memchunk*c, const struct pa_sample_spec *spec, if (volume == PA_VOLUME_NORM) return; - if (volume == PA_VOLUME_MUTE) { + if (volume == PA_VOLUME_MUTED) { pa_silence_memchunk(c, spec); return; } - for (d = (c->memblock->data+c->index), n = c->length/sizeof(int16_t); n > 0; d++, n--) { + for (d = (int16_t*) ((uint8_t*) c->memblock->data+c->index), n = c->length/sizeof(int16_t); n > 0; d++, n--) { int32_t t = (int32_t)(*d); t *= volume;