]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
fix endianness (bug #3839)
authorRussell Bryant <russell@russellbryant.com>
Fri, 1 Apr 2005 04:09:45 +0000 (04:09 +0000)
committerRussell Bryant <russell@russellbryant.com>
Fri, 1 Apr 2005 04:09:45 +0000 (04:09 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@5333 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_alsa.c
channels/chan_oss.c

index fa09cbe0b5fd84a146f223d08bcd8b22ade3415a..49030d1c5c67731b86247694cc65b36c5e239344 100755 (executable)
@@ -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
 /* 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 a74a9d847e8a7f972d87b90f5bf9d6b63e326803..f540a4b91996a85549e367884a144673014ce2ed 100755 (executable)
@@ -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 @@ static int setformat(void)
        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");