aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutputs
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2006-03-25 05:33:14 +0000
committerEric Wong <normalperson@yhbt.net>2006-03-25 05:33:14 +0000
commit19021e9cc60a98c900c986c242d1816ebdddee23 (patch)
tree322c198b6cc7f48e18ac8a4c26d5f52a749dccae /src/audioOutputs
parentdb34f66d1affd4519428f5400688dcff3397e705 (diff)
downloadmpd-19021e9cc60a98c900c986c242d1816ebdddee23.tar.gz
mpd-19021e9cc60a98c900c986c242d1816ebdddee23.tar.xz
mpd-19021e9cc60a98c900c986c242d1816ebdddee23.zip
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
Diffstat (limited to 'src/audioOutputs')
-rw-r--r--src/audioOutputs/audioOutput_oss.c34
1 files changed, 19 insertions, 15 deletions
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 <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;