diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-04-03 22:57:18 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-04-03 22:57:18 +0000 |
commit | 4ce1edc05cec917ad15513344d46fed1e35b6f58 (patch) | |
tree | 0377d7238fbc8640a0885f84f0b381aaef09d78c /frame.c | |
parent | bbbb1d493dfcc49a639c0d6fda114322041a4f2b (diff) |
handle AST_FORMAT_SLINEAR endianness properly on big-endian systems (bug #3865)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5373 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'frame.c')
-rwxr-xr-x | frame.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -83,7 +83,7 @@ void ast_smoother_set_flags(struct ast_smoother *s, int flags) s->flags = flags; } -int ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f) +int __ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f, int swap) { if (f->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Huh? Can't smooth a non-voice frame!\n"); @@ -129,7 +129,10 @@ int ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f) return 0; } } - memcpy(s->data + s->len, f->data, f->datalen); + if (swap) + ast_swapcopy_samples(s->data+s->len, f->data, f->samples); + else + memcpy(s->data + s->len, f->data, f->datalen); /* If either side is empty, reset the delivery time */ if (!s->len || (!f->delivery.tv_sec && !f->delivery.tv_usec) || (!s->delivery.tv_sec && !s->delivery.tv_usec)) @@ -399,6 +402,16 @@ int ast_fr_fdhangup(int fd) return ast_fr_fdwrite(fd, &hangup); } +void ast_swapcopy_samples(void *dst, void *src, int samples) +{ + int i; + unsigned short *dst_s = dst; + unsigned short *src_s = src; + + for (i=0; i<samples; i++) + dst_s[i] = (src_s[i]<<8) | (src_s[i]>>8); +} + static struct ast_format_list AST_FORMAT_LIST[] = { { 1, AST_FORMAT_G723_1 , "g723" , "G.723.1"}, { 1, AST_FORMAT_GSM, "gsm" , "GSM"}, |