[Asterisk-cvs] asterisk/channels chan_alsa.c, 1.27.2.1, 1.27.2.2 chan_oss.c, 1.33, 1.33.2.1

russell at lists.digium.com russell at lists.digium.com
Thu Mar 31 22:16:19 CST 2005


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

Modified Files:
      Tag: v1-0
	chan_alsa.c chan_oss.c 
Log Message:
fix endianness (bug #3839)


Index: chan_alsa.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_alsa.c,v
retrieving revision 1.27.2.1
retrieving revision 1.27.2.2
diff -u -d -r1.27.2.1 -r1.27.2.2
--- chan_alsa.c	20 Jan 2005 03:38:23 -0000	1.27.2.1
+++ chan_alsa.c	1 Apr 2005 04:09:45 -0000	1.27.2.2
@@ -27,6 +27,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <endian.h>
 
 #define ALSA_PCM_NEW_HW_PARAMS_API
 #define ALSA_PCM_NEW_SW_PARAMS_API
@@ -59,8 +60,13 @@
 /* Don't switch between read/write modes faster than every 300 ms */
 #define MIN_SWITCH_TIME 600
 
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 static snd_pcm_format_t format = SND_PCM_FORMAT_S16_LE;
-//static int block = O_NONBLOCK;
+#else
+static snd_pcm_format_t format = SND_PCM_FORMAT_S16_BE;
+#endif
+
+/* static int block = O_NONBLOCK; */
 static char indevname[50] = ALSA_INDEV;
 static char outdevname[50] = ALSA_OUTDEV;
 

Index: chan_oss.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_oss.c,v
retrieving revision 1.33
retrieving revision 1.33.2.1
diff -u -d -r1.33 -r1.33.2.1
--- chan_oss.c	31 Aug 2004 13:32:11 -0000	1.33
+++ chan_oss.c	1 Apr 2005 04:09:45 -0000	1.33.2.1
@@ -34,6 +34,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <endian.h>
 #ifdef __linux
 #include <linux/soundcard.h>
 #elif defined(__FreeBSD__)
@@ -322,7 +323,13 @@
 	int fmt, desired, res, fd = sounddev;
 	static int warnedalready = 0;
 	static int warnedalready2 = 0;
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 	fmt = AFMT_S16_LE;
+#else
+	fmt = AFMT_S16_BE;
+#endif
+
 	res = ioctl(fd, SNDCTL_DSP_SETFMT, &fmt);
 	if (res < 0) {
 		ast_log(LOG_WARNING, "Unable to set format to 16-bit signed\n");




More information about the svn-commits mailing list