From 19021e9cc60a98c900c986c242d1816ebdddee23 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 25 Mar 2006 05:33:14 +0000 Subject: src/audioOutputs/audioOutput_oss.c: fix for big-endian machines Patch by Qball. Signed-off-by: Eric Wong git-svn-id: https://svn.musicpd.org/mpd/trunk@3935 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/audioOutputs/audioOutput_oss.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/audioOutputs/audioOutput_oss.c b/src/audioOutputs/audioOutput_oss.c index 6cfb4f18f..ee3f4e19a 100644 --- a/src/audioOutputs/audioOutput_oss.c +++ b/src/audioOutputs/audioOutput_oss.c @@ -45,6 +45,12 @@ # include #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; -- cgit v1.2.3