aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-04-05 07:10:06 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-04-05 07:10:06 +0000
commit94b3c595a50c02e54a2013f55b1efea76653ef1d (patch)
tree62fa2d544a4c32b0faae4aa48564d962fd55a50a /include
parent0f4f47924e0382b25bc9b6daf916c2fff9990a1a (diff)
handle AST_FORMAT_SLINEAR endianness properly on big-endian systems (bug #3865)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/v1-0@5399 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rwxr-xr-xinclude/asterisk/frame.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h
index c97973226..2c0a91c13 100755
--- a/include/asterisk/frame.h
+++ b/include/asterisk/frame.h
@@ -329,6 +329,18 @@ int ast_fr_fdwrite(int fd, struct ast_frame *frame);
*/
int ast_fr_fdhangup(int fd);
+void ast_memcpy_byteswap(void *dst, void *src, int samples);
+
+/* Helpers for byteswapping native samples to/from
+ little-endian and big-endian. */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define ast_frame_byteswap_le(fr) do { ; } while(0)
+#define ast_frame_byteswap_be(fr) do { struct ast_frame *__f = (fr); ast_memcpy_byteswap(__f->data, __f->data, __f->samples); } while(0)
+#else
+#define ast_frame_byteswap_le(fr) do { struct ast_frame *__f = (fr); ast_memcpy_byteswap(__f->data, __f->data, __f->samples); } while(0)
+#define ast_frame_byteswap_be(fr) do { ; } while(0)
+#endif
+
//! Get the name of a format
/*!
* \param format id of format
@@ -375,8 +387,16 @@ extern void ast_smoother_set_flags(struct ast_smoother *smoother, int flags);
extern int ast_smoother_get_flags(struct ast_smoother *smoother);
extern void ast_smoother_free(struct ast_smoother *s);
extern void ast_smoother_reset(struct ast_smoother *s, int bytes);
-extern int ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f);
+extern int __ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f, int swap);
extern struct ast_frame *ast_smoother_read(struct ast_smoother *s);
+#define ast_smoother_feed(s,f) do { __ast_smoother_feed(s, f, 0); } while(0)
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define ast_smoother_feed_be(s,f) do { __ast_smoother_feed(s, f, 1); } while(0)
+#define ast_smoother_feed_le(s,f) do { __ast_smoother_feed(s, f, 0); } while(0)
+#else
+#define ast_smoother_feed_be(s,f) do { __ast_smoother_feed(s, f, 0); } while(0)
+#define ast_smoother_feed_le(s,f) do { __ast_smoother_feed(s, f, 1); } while(0)
+#endif
extern void ast_frame_dump(char *name, struct ast_frame *f, char *prefix);