From: Arun Raghavan Date: Thu, 23 Sep 2010 12:16:00 +0000 (+0530) Subject: echo-cancel: Ensure correct handling of endianness X-Git-Tag: submit/2.0-panda/20130828.192557~947 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6897217d26066353492b6b906ddbaa58c2dae054;p=profile%2Fivi%2Fpulseaudio-panda.git echo-cancel: Ensure correct handling of endianness The adrian module was using home-brewed endianness conversion instead of the appropriate mactos, and speex assumed a little-endian host. This fixes both of these. --- diff --git a/src/modules/echo-cancel/adrian.c b/src/modules/echo-cancel/adrian.c index c8acaa8..bf1918d 100644 --- a/src/modules/echo-cancel/adrian.c +++ b/src/modules/echo-cancel/adrian.c @@ -30,6 +30,7 @@ #endif #include +#include #include "echo-cancel.h" /* should be between 10-20 ms */ @@ -103,8 +104,8 @@ void pa_adrian_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t * for (i = 0; i < ec->params.priv.adrian.blocksize; i += 2) { /* We know it's S16LE mono data */ - int r = (((int8_t) rec[i + 1]) << 8) | rec[i]; - int p = (((int8_t) play[i + 1]) << 8) | play[i]; + int r = PA_INT16_FROM_LE(*(int16_t *)(rec + i)); + int p = PA_INT16_FROM_LE(*(int16_t *)(play + i)); int res; res = AEC_doAEC(ec->params.priv.adrian.aec, r, p); diff --git a/src/modules/echo-cancel/speex.c b/src/modules/echo-cancel/speex.c index 4351d23..7851510 100644 --- a/src/modules/echo-cancel/speex.c +++ b/src/modules/echo-cancel/speex.c @@ -42,7 +42,7 @@ static const char* const valid_modargs[] = { static void pa_speex_ec_fixate_spec(pa_sample_spec *source_ss, pa_channel_map *source_map, pa_sample_spec *sink_ss, pa_channel_map *sink_map) { - source_ss->format = PA_SAMPLE_S16LE; + source_ss->format = PA_SAMPLE_S16NE; *sink_ss = *source_ss; *sink_map = *source_map;