mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-29 18:19:30 +00:00
fix endianness of OSS/Alsa (bug #3839)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5241 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <endian.h>
|
||||||
|
|
||||||
#define ALSA_PCM_NEW_HW_PARAMS_API
|
#define ALSA_PCM_NEW_HW_PARAMS_API
|
||||||
#define ALSA_PCM_NEW_SW_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 */
|
/* Don't switch between read/write modes faster than every 300 ms */
|
||||||
#define MIN_SWITCH_TIME 600
|
#define MIN_SWITCH_TIME 600
|
||||||
|
|
||||||
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
static snd_pcm_format_t format = SND_PCM_FORMAT_S16_LE;
|
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 int block = O_NONBLOCK; */
|
||||||
static char indevname[50] = ALSA_INDEV;
|
static char indevname[50] = ALSA_INDEV;
|
||||||
static char outdevname[50] = ALSA_OUTDEV;
|
static char outdevname[50] = ALSA_OUTDEV;
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <endian.h>
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
#include <linux/soundcard.h>
|
#include <linux/soundcard.h>
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
@@ -350,7 +351,13 @@ static int setformat(void)
|
|||||||
int fmt, desired, res, fd = sounddev;
|
int fmt, desired, res, fd = sounddev;
|
||||||
static int warnedalready = 0;
|
static int warnedalready = 0;
|
||||||
static int warnedalready2 = 0;
|
static int warnedalready2 = 0;
|
||||||
|
|
||||||
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
fmt = AFMT_S16_LE;
|
fmt = AFMT_S16_LE;
|
||||||
|
#else
|
||||||
|
fmt = AFMT_S16_BE;
|
||||||
|
#endif
|
||||||
|
|
||||||
res = ioctl(fd, SNDCTL_DSP_SETFMT, &fmt);
|
res = ioctl(fd, SNDCTL_DSP_SETFMT, &fmt);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
ast_log(LOG_WARNING, "Unable to set format to 16-bit signed\n");
|
ast_log(LOG_WARNING, "Unable to set format to 16-bit signed\n");
|
||||||
|
Reference in New Issue
Block a user