[Asterisk-cvs] asterisk/include/asterisk frame.h,1.45,1.46

kpfleming at lists.digium.com kpfleming at lists.digium.com
Sun Apr 3 18:04:21 CDT 2005


Update of /usr/cvsroot/asterisk/include/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv28318/include/asterisk

Modified Files:
	frame.h 
Log Message:
handle AST_FORMAT_SLINEAR endianness properly on big-endian systems (bug #3865)


Index: frame.h
===================================================================
RCS file: /usr/cvsroot/asterisk/include/asterisk/frame.h,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- frame.h	29 Mar 2005 04:49:24 -0000	1.45
+++ frame.h	3 Apr 2005 22:57:18 -0000	1.46
@@ -301,6 +301,19 @@
  */
 int ast_fr_fdhangup(int fd);
 
+void ast_swapcopy_samples(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_swapcopy_samples(__f->data, __f->data, __f->samples); } while(0)
+#else
+#define ast_frame_byteswap_le(fr) do { struct ast_frame *__f = (fr); ast_swapcopy_samples(__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
@@ -347,8 +360,16 @@
 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);
 




More information about the svn-commits mailing list