[pulseaudio-discuss] [PATCH] resampler: Get rid of "cast increases required alignment of target type" warnings.
Tanu Kaskinen
tanu.kaskinen at digia.com
Fri Aug 17 04:30:10 PDT 2012
The buffers in question should be properly aligned for any
integer size, so the warnings are false positives.
---
src/pulsecore/resampler.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index 9f19559..26eca1d 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -1410,8 +1410,8 @@ static void speex_resample_float(pa_resampler *r, const pa_memchunk *input, unsi
pa_assert(output);
pa_assert(out_n_frames);
- in = (float*) ((uint8_t*) pa_memblock_acquire(input->memblock) + input->index);
- out = (float*) ((uint8_t*) pa_memblock_acquire(output->memblock) + output->index);
+ in = (float *) (void *) ((uint8_t *) pa_memblock_acquire(input->memblock) + input->index);
+ out = (float *) (void *) ((uint8_t *) pa_memblock_acquire(output->memblock) + output->index);
pa_assert_se(speex_resampler_process_interleaved_float(r->speex.state, in, &inf, out, &outf) == 0);
@@ -1431,8 +1431,8 @@ static void speex_resample_int(pa_resampler *r, const pa_memchunk *input, unsign
pa_assert(output);
pa_assert(out_n_frames);
- in = (int16_t*) ((uint8_t*) pa_memblock_acquire(input->memblock) + input->index);
- out = (int16_t*) ((uint8_t*) pa_memblock_acquire(output->memblock) + output->index);
+ in = (int16_t *) (void *) ((uint8_t *) pa_memblock_acquire(input->memblock) + input->index);
+ out = (int16_t *) (void *) ((uint8_t *) pa_memblock_acquire(output->memblock) + output->index);
pa_assert_se(speex_resampler_process_interleaved_int(r->speex.state, in, &inf, out, &outf) == 0);
@@ -1693,6 +1693,7 @@ static void ffmpeg_resample(pa_resampler *r, const pa_memchunk *input, unsigned
for (c = 0; c < r->o_ss.channels; c++) {
unsigned u;
pa_memblock *b, *w;
+ void *in_buf, *out_buf;
int16_t *p, *t, *k, *q, *s;
int consumed_frames;
@@ -1701,8 +1702,9 @@ static void ffmpeg_resample(pa_resampler *r, const pa_memchunk *input, unsigned
p = pa_memblock_acquire(b);
/* Now copy the input data, splitting up channels */
- t = ((int16_t*) ((uint8_t*) pa_memblock_acquire(input->memblock) + input->index)) + c;
- k = (int16_t*) ((uint8_t*) p);
+ in_buf = (uint8_t *) pa_memblock_acquire(input->memblock) + input->index;
+ t = (int16_t *) in_buf + c;
+ k = p;
for (u = 0; u < in_n_frames; u++) {
*k = *t;
t += r->o_ss.channels;
@@ -1729,7 +1731,8 @@ static void ffmpeg_resample(pa_resampler *r, const pa_memchunk *input, unsigned
previous_consumed_frames = consumed_frames;
/* And place the results in the output buffer */
- s = (short*) ((uint8_t*) pa_memblock_acquire(output->memblock) + output->index) + c;
+ out_buf = (uint8_t *) pa_memblock_acquire(output->memblock) + output->index;
+ s = (int16_t *) out_buf + c;
for (u = 0; u < used_frames; u++) {
*s = *q;
q++;
@@ -1741,7 +1744,8 @@ static void ffmpeg_resample(pa_resampler *r, const pa_memchunk *input, unsigned
}
if (previous_consumed_frames < (int) in_n_frames) {
- void *leftover_data = (int16_t *) ((uint8_t *) pa_memblock_acquire(input->memblock) + output->index) + previous_consumed_frames * r->o_ss.channels;
+ void *in_buf = (uint8_t *) pa_memblock_acquire(input->memblock) + input->index;
+ void *leftover_data = (int16_t *) in_buf + previous_consumed_frames * r->o_ss.channels;
size_t leftover_length = (in_n_frames - previous_consumed_frames) * r->o_ss.channels * sizeof(int16_t);
save_leftover(r, leftover_data, leftover_length);
--
1.7.9.5
More information about the pulseaudio-discuss
mailing list