From 521daf6f0ac4fa6a2fbfb5d523c0c743342dca2b Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 4 Jan 2007 13:43:45 +0000 Subject: Huge trailing whitespace cleanup. Let's keep the tree pure from here on, mmmkay? git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1418 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/sample-util.c | 138 ++++++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 69 deletions(-) (limited to 'src/pulsecore/sample-util.c') diff --git a/src/pulsecore/sample-util.c b/src/pulsecore/sample-util.c index a7a5ed8f..ddf72920 100644 --- a/src/pulsecore/sample-util.c +++ b/src/pulsecore/sample-util.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio is free software; you can redistribute it and/or modify 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. - + PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 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 Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -78,7 +78,7 @@ void pa_silence_memory(void *p, size_t length, const pa_sample_spec *spec) { default: assert(0); } - + memset(p, c, length); } @@ -90,42 +90,42 @@ size_t pa_mix( const pa_sample_spec *spec, const pa_cvolume *volume, int mute) { - + assert(streams && data && length && spec); switch (spec->format) { case PA_SAMPLE_S16NE:{ size_t d; unsigned channel = 0; - + for (d = 0;; d += sizeof(int16_t)) { int32_t sum = 0; - + if (d >= length) return d; if (!mute && volume->values[channel] != PA_VOLUME_MUTED) { unsigned i; - + for (i = 0; i < nstreams; i++) { int32_t v; pa_volume_t cvolume = streams[i].volume.values[channel]; - + if (d >= streams[i].chunk.length) return d; - + if (cvolume == PA_VOLUME_MUTED) v = 0; else { v = *((int16_t*) ((uint8_t*) streams[i].chunk.memblock->data + streams[i].chunk.index + d)); - + if (cvolume != PA_VOLUME_NORM) v = (int32_t) (v * pa_sw_volume_to_linear(cvolume)); } - + sum += v; } - + if (volume->values[channel] != PA_VOLUME_NORM) sum = (int32_t) (sum * pa_sw_volume_to_linear(volume->values[channel])); @@ -133,10 +133,10 @@ size_t pa_mix( if (sum > 0x7FFF) sum = 0x7FFF; } - + *((int16_t*) data) = sum; data = (uint8_t*) data + sizeof(int16_t); - + if (++channel >= spec->channels) channel = 0; } @@ -145,35 +145,35 @@ size_t pa_mix( case PA_SAMPLE_S16RE:{ size_t d; unsigned channel = 0; - + for (d = 0;; d += sizeof(int16_t)) { int32_t sum = 0; - + if (d >= length) return d; if (!mute && volume->values[channel] != PA_VOLUME_MUTED) { unsigned i; - + for (i = 0; i < nstreams; i++) { int32_t v; pa_volume_t cvolume = streams[i].volume.values[channel]; - + if (d >= streams[i].chunk.length) return d; - + if (cvolume == PA_VOLUME_MUTED) v = 0; else { v = INT16_SWAP(*((int16_t*) ((uint8_t*) streams[i].chunk.memblock->data + streams[i].chunk.index + d))); - + if (cvolume != PA_VOLUME_NORM) v = (int32_t) (v * pa_sw_volume_to_linear(cvolume)); } - + sum += v; } - + if (volume->values[channel] != PA_VOLUME_NORM) sum = (int32_t) (sum * pa_sw_volume_to_linear(volume->values[channel])); @@ -181,40 +181,40 @@ size_t pa_mix( if (sum > 0x7FFF) sum = 0x7FFF; } - + *((int16_t*) data) = INT16_SWAP(sum); data = (uint8_t*) data + sizeof(int16_t); - + if (++channel >= spec->channels) channel = 0; } } - + case PA_SAMPLE_U8: { size_t d; unsigned channel = 0; - + for (d = 0;; d ++) { int32_t sum = 0; - + if (d >= length) return d; if (!mute && volume->values[channel] != PA_VOLUME_MUTED) { unsigned i; - + for (i = 0; i < nstreams; i++) { int32_t v; pa_volume_t cvolume = streams[i].volume.values[channel]; - + if (d >= streams[i].chunk.length) return d; - + if (cvolume == PA_VOLUME_MUTED) v = 0; else { v = (int32_t) *((uint8_t*) streams[i].chunk.memblock->data + streams[i].chunk.index + d) - 0x80; - + if (cvolume != PA_VOLUME_NORM) v = (int32_t) (v * pa_sw_volume_to_linear(cvolume)); } @@ -229,51 +229,51 @@ size_t pa_mix( if (sum > 0x7F) sum = 0x7F; } - + *((uint8_t*) data) = (uint8_t) (sum + 0x80); data = (uint8_t*) data + 1; - + if (++channel >= spec->channels) channel = 0; } } - + case PA_SAMPLE_FLOAT32NE: { size_t d; unsigned channel = 0; - + for (d = 0;; d += sizeof(float)) { float sum = 0; - + if (d >= length) return d; - + if (!mute && volume->values[channel] != PA_VOLUME_MUTED) { unsigned i; - + for (i = 0; i < nstreams; i++) { float v; pa_volume_t cvolume = streams[i].volume.values[channel]; - + if (d >= streams[i].chunk.length) return d; - + if (cvolume == PA_VOLUME_MUTED) v = 0; else { v = *((float*) ((uint8_t*) streams[i].chunk.memblock->data + streams[i].chunk.index + d)); - + if (cvolume != PA_VOLUME_NORM) v *= pa_sw_volume_to_linear(cvolume); } - + sum += v; } - + if (volume->values[channel] != PA_VOLUME_NORM) sum *= pa_sw_volume_to_linear(volume->values[channel]); } - + *((float*) data) = sum; data = (uint8_t*) data + sizeof(float); @@ -281,7 +281,7 @@ size_t pa_mix( channel = 0; } } - + default: pa_log_error("ERROR: Unable to mix audio data of format %s.", pa_sample_format_to_string(spec->format)); abort(); @@ -310,17 +310,17 @@ void pa_volume_memchunk(pa_memchunk*c, const pa_sample_spec *spec, const pa_cvol for (channel = 0; channel < spec->channels; channel++) linear[channel] = pa_sw_volume_to_linear(volume->values[channel]); - + for (channel = 0, 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 = (int32_t) (t * linear[channel]); - + if (t < -0x8000) t = -0x8000; if (t > 0x7FFF) t = 0x7FFF; - + *d = (int16_t) t; - + if (++channel >= spec->channels) channel = 0; } @@ -332,66 +332,66 @@ void pa_volume_memchunk(pa_memchunk*c, const pa_sample_spec *spec, const pa_cvol size_t n; unsigned channel; double linear[PA_CHANNELS_MAX]; - + for (channel = 0; channel < spec->channels; channel++) linear[channel] = pa_sw_volume_to_linear(volume->values[channel]); - + for (channel = 0, 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)(INT16_SWAP(*d)); - + t = (int32_t) (t * linear[channel]); - + if (t < -0x8000) t = -0x8000; if (t > 0x7FFF) t = 0x7FFF; - + *d = INT16_SWAP((int16_t) t); - + if (++channel >= spec->channels) channel = 0; } break; } - + case PA_SAMPLE_U8: { uint8_t *d; size_t n; unsigned channel = 0; - + for (d = (uint8_t*) c->memblock->data + c->index, n = c->length; n > 0; d++, n--) { int32_t t = (int32_t) *d - 0x80; - + t = (int32_t) (t * pa_sw_volume_to_linear(volume->values[channel])); - + if (t < -0x80) t = -0x80; if (t > 0x7F) t = 0x7F; - + *d = (uint8_t) (t + 0x80); - + if (++channel >= spec->channels) channel = 0; } break; } - + case PA_SAMPLE_FLOAT32NE: { float *d; int skip; unsigned n; unsigned channel; - + d = (float*) ((uint8_t*) c->memblock->data + c->index); skip = spec->channels * sizeof(float); n = c->length/sizeof(float)/spec->channels; - + for (channel = 0; channel < spec->channels ; channel ++) { float v, *t; - + if (volume->values[channel] == PA_VOLUME_NORM) continue; - + v = (float) pa_sw_volume_to_linear(volume->values[channel]); - + t = d + channel; oil_scalarmult_f32(t, skip, t, skip, &v, n); } -- cgit