[Asterisk-cvs] asterisk/channels chan_oss.c, 1.43, 1.44 chan_alsa.c, 1.37, 1.38

markster at lists.digium.com markster at lists.digium.com
Wed Mar 23 19:01:30 CST 2005


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

Modified Files:
	chan_oss.c chan_alsa.c 
Log Message:
fix endianness of OSS/Alsa (bug #3839)


Index: chan_oss.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_oss.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- chan_oss.c	4 Mar 2005 06:47:24 -0000	1.43
+++ chan_oss.c	24 Mar 2005 00:55:40 -0000	1.44
@@ -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__)
@@ -350,7 +351,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");

Index: chan_alsa.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_alsa.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- chan_alsa.c	4 Mar 2005 06:47:24 -0000	1.37
+++ chan_alsa.c	24 Mar 2005 00:55:40 -0000	1.38
@@ -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,7 +60,12 @@
 /* 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;
+#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;




More information about the svn-commits mailing list