[pulseaudio-discuss] [PATCH] resampler: Get rid of "cast increases required alignment of target type" warnings.
David Henningsson
david.henningsson at canonical.com
Fri Aug 17 04:36:54 PDT 2012
On 08/17/2012 01:30 PM, Tanu Kaskinen wrote:
> The buffers in question should be properly aligned for any
> integer size, so the warnings are false positives.
Oh, so there were that many of them. Well, how about
static inline void* pa_memblock_acquire_index(memblock, index)
{
return (void *) ((uint8_t *) pa_memblock_acquire(memblock) + index);
}
?
> ---
> 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);
>
--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
More information about the pulseaudio-discuss
mailing list