src/audioOutputs/audioOutput_oss.c: fix for big-endian machines
Patch by Qball. Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@3935 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
db34f66d1a
commit
19021e9cc6
@ -45,6 +45,12 @@
|
||||
# include <sys/soundcard.h>
|
||||
#endif /* !(defined(__OpenBSD__) || defined(__NetBSD__) */
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
# define AFMT_S16_MPD AFMT_S16_BE
|
||||
#else
|
||||
# define AFMT_S16_MPD AFMT_S16_LE
|
||||
#endif /* WORDS_BIGENDIAN */
|
||||
|
||||
typedef struct _OssData {
|
||||
int fd;
|
||||
char * device;
|
||||
@ -415,6 +421,7 @@ static int setParam(OssData * od, int param, int * value) {
|
||||
}
|
||||
|
||||
static int oss_open(AudioOutput * audioOutput) {
|
||||
int tmp;
|
||||
OssData * od = audioOutput->data;
|
||||
|
||||
if((od->fd = open(od->device, O_WRONLY)) < 0) {
|
||||
@ -423,13 +430,6 @@ static int oss_open(AudioOutput * audioOutput) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if(ioctl(od->fd, SNDCTL_DSP_SETFMT, &od->bitFormat)) {
|
||||
ERROR("Error setting bitformat on OSS device \"%s\": %s\n",
|
||||
od->device,
|
||||
strerror(errno));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if(setParam(od, SNDCTL_DSP_CHANNELS, &od->channels)) {
|
||||
ERROR("OSS device \"%s\" does not support %i channels: %s\n",
|
||||
od->device,
|
||||
@ -446,10 +446,18 @@ static int oss_open(AudioOutput * audioOutput) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if(setParam(od, SNDCTL_DSP_SAMPLESIZE, &od->bits)) {
|
||||
switch(od->bits) {
|
||||
case 8:
|
||||
tmp = AFMT_S8;
|
||||
break;
|
||||
case 16:
|
||||
tmp = AFMT_S16_MPD;
|
||||
}
|
||||
|
||||
if(setParam(od, SNDCTL_DSP_SAMPLESIZE, &tmp)) {
|
||||
ERROR("OSS device \"%s\" does not support %i bit audio: %s\n",
|
||||
od->device,
|
||||
od->bits,
|
||||
tmp,
|
||||
strerror(errno));
|
||||
goto fail;
|
||||
}
|
||||
@ -469,12 +477,8 @@ static int oss_openDevice(AudioOutput * audioOutput)
|
||||
int ret = -1;
|
||||
OssData * od = audioOutput->data;
|
||||
AudioFormat * audioFormat = &audioOutput->outAudioFormat;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
od->bitFormat = AFMT_S16_BE;
|
||||
#else
|
||||
od->bitFormat = AFMT_S16_LE;
|
||||
#endif
|
||||
od->channels = audioFormat->channels;
|
||||
|
||||
od->channels = audioFormat->channels;
|
||||
od->sampleRate = audioFormat->sampleRate;
|
||||
od->bits = audioFormat->bits;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user