foxygit / doom Log in
commit 125f86e18b31dcf1885164b754bf23ffe3e3bc04
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Tue Apr 15 23:16:16 2008 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Tue Apr 15 23:16:16 2008 +0000

    Make the BSD PC speaker driver work on FreeBSD.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 1113
---
 configure.in          |  2 +-
 pcsound/pcsound.c     | 12 ++++++++++--
 pcsound/pcsound_bsd.c | 17 +++++++++++++++--
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/configure.in b/configure.in
index 322c4957..6fa7f1f6 100644
--- a/configure.in
+++ b/configure.in
@@ -24,7 +24,7 @@ then
         CFLAGS="-O$OPT_LEVEL -g -Wall $orig_CFLAGS"
 fi

-AC_CHECK_HEADERS([linux/kd.h dev/isa/spkrio.h])
+AC_CHECK_HEADERS([linux/kd.h dev/isa/spkrio.h dev/speaker/speaker.h])

 AM_PATH_SDL(1.1.3)

diff --git a/pcsound/pcsound.c b/pcsound/pcsound.c
index aeba5148..0746e24e 100644
--- a/pcsound/pcsound.c
+++ b/pcsound/pcsound.c
@@ -31,11 +31,19 @@
 #include "pcsound.h"
 #include "pcsound_internal.h"

+
+#ifdef HAVE_DEV_ISA_SPKRIO_H
+#define HAVE_BSD_SPEAKER
+#endif
+#ifdef HAVE_DEV_SPEAKER_SPEAKER_H
+#define HAVE_BSD_SPEAKER
+#endif
+
 #ifdef _WIN32
 extern pcsound_driver_t pcsound_win32_driver;
 #endif

-#ifdef HAVE_DEV_ISA_SPKRIO_H
+#ifdef HAVE_BSD_SPEAKER
 extern pcsound_driver_t pcsound_bsd_driver;
 #endif

@@ -50,7 +58,7 @@ static pcsound_driver_t *drivers[] =
 #ifdef HAVE_LINUX_KD_H
     &pcsound_linux_driver,
 #endif
-#ifdef HAVE_DEV_ISA_SPKRIO_H
+#ifdef HAVE_BSD_SPEAKER
     &pcsound_bsd_driver,
 #endif
 #ifdef _WIN32
diff --git a/pcsound/pcsound_bsd.c b/pcsound/pcsound_bsd.c
index 68884e0e..6ba73037 100644
--- a/pcsound/pcsound_bsd.c
+++ b/pcsound/pcsound_bsd.c
@@ -26,14 +26,27 @@

 #include "config.h"

+// OpenBSD/NetBSD:
+
 #ifdef HAVE_DEV_ISA_SPKRIO_H
+#define HAVE_BSD_SPEAKER
+#include <dev/isa/spkrio.h>
+#endif
+
+// FreeBSD
+
+#ifdef HAVE_DEV_SPEAKER_SPEAKER_H
+#define HAVE_BSD_SPEAKER
+#include <dev/speaker/speaker.h>
+#endif
+
+#ifdef HAVE_BSD_SPEAKER

 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 #include <signal.h>
-#include <dev/isa/spkrio.h>
 #include <sys/ioctl.h>
 #include <sys/signal.h>
 #include <sys/socket.h>
@@ -310,5 +323,5 @@ pcsound_driver_t pcsound_bsd_driver =
     PCSound_BSD_Shutdown,
 };

-#endif /* #ifdef HAVE_DEV_ISA_SPKRIO_H */
+#endif /* #ifdef HAVE_BSD_SPEAKER */