commit 12713d278c9864b13de7857bb838b64808ab3dac
parent 4490d4b9e822354159c01510114f680e5cb3a826
Author: Hans Petter Selasky <hps@selasky.org>
Date: Sat, 1 Nov 2014 17:58:38 +0100
Simplify OSS format check and fix build breakage.
Signed-off-by: Hans Petter Selasky <hps@selasky.org>
Diffstat:
2 files changed, 13 insertions(+), 51 deletions(-)
diff --git a/src/Nio/OssEngine.cpp b/src/Nio/OssEngine.cpp
@@ -224,34 +224,16 @@ bool OssEngine::openAudio()
ioctl(audio.handle, SNDCTL_DSP_RESET, NULL);
/* Figure out the correct format first */
-#ifdef __linux__
- int snd_format16 = AFMT_S16_NE;
-#else
-#if defined(AFMT_S16_NE) && defined(AFMT_S32_NE)
- int snd_format32 = AFMT_S32_NE;
+
int snd_format16 = AFMT_S16_NE;
-#elif defined(BYTE_ORDER) && defined(LITTLE_ENDIAN)
-#if BYTE_ORDER == LITTLE_ENDIAN
- int snd_format32 = AFMT_S32_LE;
- int snd_format16 = AFMT_S16_LE;
-#else
- int snd_format32 = AFMT_S32_BE;
- int snd_format16 = AFMT_S16_BE;
-#endif
-#else
- int snd_format32 = AFMT_S32_LE;
- int snd_format16 = AFMT_S16_LE;
-#endif
-#endif
-#ifdef __linux__
-#define SND_32_INIT -1
-#else
-#define SND_32_INIT ioctl(audio.handle, SNDCTL_DSP_SETFMT, &snd_format32)
-#endif
- if (SND_32_INIT == 0) {
+#ifdef AFMT_S32_NE
+ int snd_format32 = AFMT_S32_NE;
+ if (ioctl(audio.handle, SNDCTL_DSP_SETFMT, &snd_format32) == 0) {
audio.is32bit = true;
- } else if (ioctl(audio.handle, SNDCTL_DSP_SETFMT, &snd_format16) == 0) {
+ } else
+#endif
+ if (ioctl(audio.handle, SNDCTL_DSP_SETFMT, &snd_format16) == 0) {
audio.is32bit = false;
} else {
cerr << "ERROR - I cannot set DSP format for "
diff --git a/src/Nio/OssMultiEngine.cpp b/src/Nio/OssMultiEngine.cpp
@@ -92,35 +92,15 @@ OssMultiEngine :: openAudio()
ioctl(handle, SNDCTL_DSP_RESET, 0);
/* Figure out the correct format first */
-#ifdef __linux__
int snd_format16 = AFMT_S16_NE;
-#else
-#if defined(AFMT_S16_NE) && defined(AFMT_S32_NE)
- int snd_format32 = AFMT_S32_NE;
- int snd_format16 = AFMT_S16_NE;
-#elif defined(BYTE_ORDER) && defined(LITTLE_ENDIAN)
-#if BYTE_ORDER == LITTLE_ENDIAN
- int snd_format32 = AFMT_S32_LE;
- int snd_format16 = AFMT_S16_LE;
-#else
- int snd_format32 = AFMT_S32_BE;
- int snd_format16 = AFMT_S16_BE;
-#endif
-#else
- int snd_format32 = AFMT_S32_LE;
- int snd_format16 = AFMT_S16_LE;
-#endif
-#endif
-#ifdef __linux__
-#define SND_32_INIT -1
-#else
-#define SND_32_INIT ioctl(audio.handle, SNDCTL_DSP_SETFMT, &snd_format32)
-#endif
-
- if (SND_32_INIT == 0) {
+#ifdef AFMT_S32_NE
+ int snd_format32 = AFMT_S32_NE;
+ if (ioctl(handle, SNDCTL_DSP_SETFMT, &snd_format32) == 0) {
is32bit = true;
- } else if (ioctl(handle, SNDCTL_DSP_SETFMT, &snd_format16) == 0) {
+ } else
+#endif
+ if (ioctl(handle, SNDCTL_DSP_SETFMT, &snd_format16) == 0) {
is32bit = false;
} else {
cerr << "ERROR - Cannot set DSP format for "