diff options
author | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2010-09-23 17:46:00 +0530 |
---|---|---|
committer | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2011-03-28 14:41:00 +0530 |
commit | 1212a6fd78570f1f31e77bf46fa2e46981013ab3 (patch) | |
tree | 7f2f16837070d50c20b25d462f5d6a840b146cfb | |
parent | d8fab8429d68e54b05ae444e84840114073ac833 (diff) |
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.
-rw-r--r-- | src/modules/echo-cancel/adrian.c | 5 | ||||
-rw-r--r-- | src/modules/echo-cancel/speex.c | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/modules/echo-cancel/adrian.c b/src/modules/echo-cancel/adrian.c index 86db1e2c..810d6ea6 100644 --- a/src/modules/echo-cancel/adrian.c +++ b/src/modules/echo-cancel/adrian.c @@ -30,6 +30,7 @@ #endif #include <pulsecore/modargs.h> +#include <pulsecore/endianmacros.h> #include "echo-cancel.h" /* should be between 10-20 ms */ @@ -99,8 +100,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 17a89d23..dc765f51 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; |