- add -lossaudio if needed, and a check for <soundcard.h>, to configure.in
  (run autoconf after this).  Note that the check has been altered to break
  out of the AC_CHECK_HEADERS after the first match - this is so
  <sys/soundcard.h>, if found on NetBSD (a `real' OSS), will not conflict
  with the emulated ossaudio.
- check for <soundcard.h> along with the other two in a mutually-exclusive
  manner in the various *.c files that need it; change include of
  "mmsystem.h" to "multimedia.h" so this logic is all in one place
- change mcicda.c to allow for CD audio manipulation on NetBSD.  This
  includes:
  * changing ioctl() calls to be NON-SPLIT with exactly 3 args; on NetBSD
    ossaudio, ioctl() is #defined to be _oss_ioctl by <soundcard.h>, and
    neither splitting with #-directives nor a two-arg ioctl work;
  * changing the #if logic to allow both FreeBSD and NetBSD to share the
    appropriate code blocks
- block out MIDI code for NetBSD (init.c) and/or missing SNDCTL_MIDI_INFO
  (midi.c, mcimidi.c).  NetBSD's OSS emulation does not (yet) support MIDI.
Thanks go to mycroft@netbsd.org for the 99% bulk of this work.

diff --git a/configure b/configure
index 12a3c6a..f401e62 100755
--- a/configure
+++ b/configure
@@ -2037,8 +2037,55 @@
   echo "$ac_t""no" 1>&6
 fi
 
+echo $ac_n "checking for _oss_ioctl in -lossaudio""... $ac_c" 1>&6
+echo "configure:2042: checking for _oss_ioctl in -lossaudio" >&5
+ac_lib_var=`echo ossaudio'_'_oss_ioctl | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lossaudio  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2050 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char _oss_ioctl();
+
+int main() {
+_oss_ioctl()
+; return 0; }
+EOF
+if { (eval echo configure:2061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_lib=HAVE_LIB`echo ossaudio | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+  LIBS="-lossaudio $LIBS"
+
+else
+  echo "$ac_t""no" 1>&6
+fi
+
 echo $ac_n "checking for iswalnum in -lw""... $ac_c" 1>&6
-echo "configure:2042: checking for iswalnum in -lw" >&5
+echo "configure:2089: checking for iswalnum in -lw" >&5
 ac_lib_var=`echo w'_'iswalnum | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2046,7 +2093,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lw  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2050 "configure"
+#line 2097 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2057,7 +2104,7 @@
 iswalnum()
 ; return 0; }
 EOF
-if { (eval echo configure:2061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2108: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2087,12 +2134,12 @@
 for ac_func in gethostbyname
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2091: checking for $ac_func" >&5
+echo "configure:2138: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2096 "configure"
+#line 2143 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2115,7 +2162,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2119: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2166: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2142,7 +2189,7 @@
 if test "$ac_cv_func_gethostbyname" = "no"
 then
     echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:2146: checking for gethostbyname in -lnsl" >&5
+echo "configure:2193: checking for gethostbyname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2150,7 +2197,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2154 "configure"
+#line 2201 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2161,7 +2208,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:2165: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2190,7 +2237,7 @@
 
 fi
 echo $ac_n "checking for setrunelocale in -lxpg4""... $ac_c" 1>&6
-echo "configure:2194: checking for setrunelocale in -lxpg4" >&5
+echo "configure:2241: checking for setrunelocale in -lxpg4" >&5
 ac_lib_var=`echo xpg4'_'setrunelocale | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2198,7 +2245,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lxpg4  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2202 "configure"
+#line 2249 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2209,7 +2256,7 @@
 setrunelocale()
 ; return 0; }
 EOF
-if { (eval echo configure:2213: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2260: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2237,7 +2284,7 @@
 fi
 
 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:2241: checking for dlopen in -ldl" >&5
+echo "configure:2288: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2245,7 +2292,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2249 "configure"
+#line 2296 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2256,7 +2303,7 @@
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:2260: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2307: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2288,7 +2335,7 @@
 then
     XLIB="-lXpm -lXext -lX11"
                     echo $ac_n "checking for XShmQueryExtension in -lXext""... $ac_c" 1>&6
-echo "configure:2292: checking for XShmQueryExtension in -lXext" >&5
+echo "configure:2339: checking for XShmQueryExtension in -lXext" >&5
 ac_lib_var=`echo Xext'_'XShmQueryExtension | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2296,7 +2343,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXext $X_LIBS -lXext -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2300 "configure"
+#line 2347 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2307,7 +2354,7 @@
 XShmQueryExtension()
 ; return 0; }
 EOF
-if { (eval echo configure:2311: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2331,7 +2378,7 @@
 fi
 
         echo $ac_n "checking for XF86DGAQueryExtension in -lXxf86dga""... $ac_c" 1>&6
-echo "configure:2335: checking for XF86DGAQueryExtension in -lXxf86dga" >&5
+echo "configure:2382: checking for XF86DGAQueryExtension in -lXxf86dga" >&5
 ac_lib_var=`echo Xxf86dga'_'XF86DGAQueryExtension | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2339,7 +2386,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXxf86dga $X_LIBS -lXext -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2343 "configure"
+#line 2390 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2350,7 +2397,7 @@
 XF86DGAQueryExtension()
 ; return 0; }
 EOF
-if { (eval echo configure:2354: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2401: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2374,7 +2421,7 @@
 fi
 
         echo $ac_n "checking for XF86VidModeQueryExtension in -lXxf86vm""... $ac_c" 1>&6
-echo "configure:2378: checking for XF86VidModeQueryExtension in -lXxf86vm" >&5
+echo "configure:2425: checking for XF86VidModeQueryExtension in -lXxf86vm" >&5
 ac_lib_var=`echo Xxf86vm'_'XF86VidModeQueryExtension | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2382,7 +2429,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXxf86vm $X_LIBS -lXext -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2386 "configure"
+#line 2433 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2393,7 +2440,7 @@
 XF86VidModeQueryExtension()
 ; return 0; }
 EOF
-if { (eval echo configure:2397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2444: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2422,21 +2469,21 @@
     X_LIBS=""
 fi
 
-for ac_hdr in sys/soundcard.h machine/soundcard.h
+for ac_hdr in sys/soundcard.h machine/soundcard.h soundcard.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2430: checking for $ac_hdr" >&5
+echo "configure:2477: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2435 "configure"
+#line 2482 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2440: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2487: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2456,7 +2503,7 @@
   cat >> confdefs.h <<EOF
 #define $ac_tr_hdr 1
 EOF
- 
+ break
 else
   echo "$ac_t""no" 1>&6
 fi
@@ -2464,19 +2511,20 @@
 
 
 echo $ac_n "checking "for Open Sound System"""... $ac_c" 1>&6
-echo "configure:2468: checking "for Open Sound System"" >&5
+echo "configure:2515: checking "for Open Sound System"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_opensoundsystem'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2473 "configure"
+#line 2520 "configure"
 #include "confdefs.h"
 
-	#ifdef HAVE_SYS_SOUNDCARD_H
+	#if defined(HAVE_SYS_SOUNDCARD_H)
 		#include <sys/soundcard.h>
-	#endif
-	#ifdef HAVE_MACHINE_SOUNDCARD_H
+	#elif defined(HAVE_MACHINE_SOUNDCARD_H)
 		#include <machine/soundcard.h>
+	#elif defined(HAVE_SOUNDCARD_H)
+		#include <soundcard.h>
 	#endif
 	
 int main() {
@@ -2489,7 +2537,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2493: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2541: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_opensoundsystem="yes"
 else
@@ -2513,12 +2561,12 @@
 
 
 echo $ac_n "checking "for union semun"""... $ac_c" 1>&6
-echo "configure:2517: checking "for union semun"" >&5
+echo "configure:2565: checking "for union semun"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_union_semun'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2522 "configure"
+#line 2570 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/sem.h>
@@ -2526,7 +2574,7 @@
 union semun foo
 ; return 0; }
 EOF
-if { (eval echo configure:2530: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2578: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_union_semun="yes"
 else
@@ -2554,7 +2602,7 @@
 then
   CFLAGS="$CFLAGS -Wall"
   echo $ac_n "checking "for gcc strength-reduce bug"""... $ac_c" 1>&6
-echo "configure:2558: checking "for gcc strength-reduce bug"" >&5
+echo "configure:2606: checking "for gcc strength-reduce bug"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_gcc_strength_bug'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2562,7 +2610,7 @@
   ac_cv_c_gcc_strength_bug="yes"
 else
   cat > conftest.$ac_ext <<EOF
-#line 2566 "configure"
+#line 2614 "configure"
 #include "confdefs.h"
 
 int main(void) {
@@ -2573,7 +2621,7 @@
   exit( Array[1] != -2 );
 }
 EOF
-if { (eval echo configure:2577: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2625: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_gcc_strength_bug="no"
 else
@@ -2596,7 +2644,7 @@
 
 
 echo $ac_n "checking "whether external symbols need an underscore prefix"""... $ac_c" 1>&6
-echo "configure:2600: checking "whether external symbols need an underscore prefix"" >&5
+echo "configure:2648: checking "whether external symbols need an underscore prefix"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_extern_prefix'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2608,14 +2656,14 @@
 	.long 0
 EOF
 cat > conftest.$ac_ext <<EOF
-#line 2612 "configure"
+#line 2660 "configure"
 #include "confdefs.h"
 extern int ac_test;
 int main() {
 if (ac_test) return 1
 ; return 0; }
 EOF
-if { (eval echo configure:2619: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2667: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_c_extern_prefix="yes"
 else
@@ -2639,7 +2687,7 @@
 
 
 echo $ac_n "checking "whether assembler accepts .string"""... $ac_c" 1>&6
-echo "configure:2643: checking "whether assembler accepts .string"" >&5
+echo "configure:2691: checking "whether assembler accepts .string"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_asm_string'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2649,14 +2697,14 @@
 	.string "test"
 EOF
 cat > conftest.$ac_ext <<EOF
-#line 2653 "configure"
+#line 2701 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2660: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2708: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_c_asm_string="yes"
 else
@@ -2684,21 +2732,21 @@
 if test "$LIB_TARGET" = "libwine.so.1.0"
 then
   echo $ac_n "checking "whether we can build a Linux dll"""... $ac_c" 1>&6
-echo "configure:2688: checking "whether we can build a Linux dll"" >&5
+echo "configure:2736: checking "whether we can build a Linux dll"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_dll_linux'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   saved_cflags=$CFLAGS
   CFLAGS="$CFLAGS -fPIC -shared -Wl,-soname,conftest.so.1.0"
   cat > conftest.$ac_ext <<EOF
-#line 2695 "configure"
+#line 2743 "configure"
 #include "confdefs.h"
 
 int main() {
 return 1
 ; return 0; }
 EOF
-if { (eval echo configure:2702: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2750: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_c_dll_linux="yes"
 else
@@ -2719,21 +2767,21 @@
     LDSHARED="\$(CC) -shared -Wl,-soname,libwine.so"
   else
     echo $ac_n "checking "whether we can build a NetBSD dll"""... $ac_c" 1>&6
-echo "configure:2723: checking "whether we can build a NetBSD dll"" >&5
+echo "configure:2771: checking "whether we can build a NetBSD dll"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_dll_netbsd'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   saved_cflags=$CFLAGS
     CFLAGS="$CFLAGS -fPIC -Bshareable -Bforcearchive"
     cat > conftest.$ac_ext <<EOF
-#line 2730 "configure"
+#line 2778 "configure"
 #include "confdefs.h"
 
 int main() {
 return 1
 ; return 0; }
 EOF
-if { (eval echo configure:2737: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2785: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_c_dll_netbsd="yes"
 else
@@ -2764,7 +2812,7 @@
 
 
 echo $ac_n "checking "for reentrant libc"""... $ac_c" 1>&6
-echo "configure:2768: checking "for reentrant libc"" >&5
+echo "configure:2816: checking "for reentrant libc"" >&5
 if eval "test \"`echo '$''{'wine_cv_libc_reentrant'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2772,14 +2820,14 @@
   wine_cv_libc_reentrant=yes 
 else
   cat > conftest.$ac_ext <<EOF
-#line 2776 "configure"
+#line 2824 "configure"
 #include "confdefs.h"
 int myerrno = 0;
 char buf[256];
 int *__errno_location(){return &myerrno;}
 main(){connect(0,buf,255); exit(!myerrno);}
 EOF
-if { (eval echo configure:2783: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2831: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   wine_cv_libc_reentrant=yes
 else
@@ -2804,7 +2852,7 @@
 
 
 echo $ac_n "checking "for reentrant X libraries"""... $ac_c" 1>&6
-echo "configure:2808: checking "for reentrant X libraries"" >&5
+echo "configure:2856: checking "for reentrant X libraries"" >&5
 if eval "test \"`echo '$''{'wine_cv_x_reentrant'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2849,12 +2897,12 @@
 for ac_func in clone getpagesize memmove sendmsg sigaltstack strerror stricmp tcgetattr timegm usleep wait4 waitpid vfscanf
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2853: checking for $ac_func" >&5
+echo "configure:2901: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2858 "configure"
+#line 2906 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2877,7 +2925,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2881: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2929: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2905,17 +2953,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2909: checking for $ac_hdr" >&5
+echo "configure:2957: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2914 "configure"
+#line 2962 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2919: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2967: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2942,12 +2990,12 @@
 done
 
 echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6
-echo "configure:2946: checking whether stat file-mode macros are broken" >&5
+echo "configure:2994: checking whether stat file-mode macros are broken" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2951 "configure"
+#line 2999 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -2998,12 +3046,12 @@
 fi
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:3002: checking for working const" >&5
+echo "configure:3050: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3007 "configure"
+#line 3055 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -3052,7 +3100,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3056: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3104: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -3073,12 +3121,12 @@
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:3077: checking for ANSI C header files" >&5
+echo "configure:3125: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3082 "configure"
+#line 3130 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -3086,7 +3134,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3090: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3138: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3103,7 +3151,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 3107 "configure"
+#line 3155 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -3121,7 +3169,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 3125 "configure"
+#line 3173 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -3142,7 +3190,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 3146 "configure"
+#line 3194 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -3153,7 +3201,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:3157: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3205: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -3177,12 +3225,12 @@
 fi
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:3181: checking for size_t" >&5
+echo "configure:3229: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3186 "configure"
+#line 3234 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -3210,7 +3258,7 @@
 fi
 
 echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:3214: checking size of long long" >&5
+echo "configure:3262: checking size of long long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3218,7 +3266,7 @@
   ac_cv_sizeof_long_long=0
 else
   cat > conftest.$ac_ext <<EOF
-#line 3222 "configure"
+#line 3270 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 main()
@@ -3229,7 +3277,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:3233: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3281: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long_long=`cat conftestval`
 else
@@ -3252,7 +3300,7 @@
 
 if test $ac_cv_func_sendmsg = no; then
     echo $ac_n "checking for sendmsg in -lsocket""... $ac_c" 1>&6
-echo "configure:3256: checking for sendmsg in -lsocket" >&5
+echo "configure:3304: checking for sendmsg in -lsocket" >&5
 ac_lib_var=`echo socket'_'sendmsg | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3260,7 +3308,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3264 "configure"
+#line 3312 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3271,7 +3319,7 @@
 sendmsg()
 ; return 0; }
 EOF
-if { (eval echo configure:3275: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3323: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3304,12 +3352,12 @@
 if test "$ac_cv_header_sys_vfs_h" = "yes"
 then
     echo $ac_n "checking "whether sys/vfs.h defines statfs"""... $ac_c" 1>&6
-echo "configure:3308: checking "whether sys/vfs.h defines statfs"" >&5
+echo "configure:3356: checking "whether sys/vfs.h defines statfs"" >&5
 if eval "test \"`echo '$''{'wine_cv_sys_vfs_has_statfs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3313 "configure"
+#line 3361 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -3326,7 +3374,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:3330: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3378: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_sys_vfs_has_statfs=yes
 else
@@ -3353,12 +3401,12 @@
 if test "$ac_cv_header_sys_statfs_h" = "yes"
 then
     echo $ac_n "checking "whether sys/statfs.h defines statfs"""... $ac_c" 1>&6
-echo "configure:3357: checking "whether sys/statfs.h defines statfs"" >&5
+echo "configure:3405: checking "whether sys/statfs.h defines statfs"" >&5
 if eval "test \"`echo '$''{'wine_cv_sys_statfs_has_statfs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3362 "configure"
+#line 3410 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -3373,7 +3421,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:3377: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3425: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_sys_statfs_has_statfs=yes
 else
@@ -3400,12 +3448,12 @@
 if test "$ac_cv_header_sys_mount_h" = "yes"
 then
     echo $ac_n "checking "whether sys/mount.h defines statfs"""... $ac_c" 1>&6
-echo "configure:3404: checking "whether sys/mount.h defines statfs"" >&5
+echo "configure:3452: checking "whether sys/mount.h defines statfs"" >&5
 if eval "test \"`echo '$''{'wine_cv_sys_mount_has_statfs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3409 "configure"
+#line 3457 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -3420,7 +3468,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:3424: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3472: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_sys_mount_has_statfs=yes
 else
@@ -3446,7 +3494,7 @@
 
 
 echo $ac_n "checking "for statfs.f_bfree"""... $ac_c" 1>&6
-echo "configure:3450: checking "for statfs.f_bfree"" >&5
+echo "configure:3498: checking "for statfs.f_bfree"" >&5
 if eval "test \"`echo '$''{'wine_cv_statfs_bfree'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3455,7 +3503,7 @@
         wine_cv_statfs_bfree=no
     else
     	cat > conftest.$ac_ext <<EOF
-#line 3459 "configure"
+#line 3507 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -3482,7 +3530,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:3486: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3534: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_statfs_bfree=yes
 else
@@ -3506,7 +3554,7 @@
 fi
 
 echo $ac_n "checking "for statfs.f_bavail"""... $ac_c" 1>&6
-echo "configure:3510: checking "for statfs.f_bavail"" >&5
+echo "configure:3558: checking "for statfs.f_bavail"" >&5
 if eval "test \"`echo '$''{'wine_cv_statfs_bavail'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3515,7 +3563,7 @@
         wine_cv_statfs_bavail=no
     else
     	cat > conftest.$ac_ext <<EOF
-#line 3519 "configure"
+#line 3567 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -3542,7 +3590,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:3546: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3594: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_statfs_bavail=yes
 else
@@ -3567,7 +3615,7 @@
 
 
 echo $ac_n "checking "for working sigaltstack"""... $ac_c" 1>&6
-echo "configure:3571: checking "for working sigaltstack"" >&5
+echo "configure:3619: checking "for working sigaltstack"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_working_sigaltstack'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3576,7 +3624,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 3580 "configure"
+#line 3628 "configure"
 #include "confdefs.h"
 
 	#include <stdio.h>
@@ -3614,7 +3662,7 @@
 	}
 	
 EOF
-if { (eval echo configure:3618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3666: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_working_sigaltstack="yes"
 else
@@ -3641,12 +3689,12 @@
 
 
 echo $ac_n "checking "for msg_accrights in struct msghdr"""... $ac_c" 1>&6
-echo "configure:3645: checking "for msg_accrights in struct msghdr"" >&5
+echo "configure:3693: checking "for msg_accrights in struct msghdr"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_msg_accrights'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3650 "configure"
+#line 3698 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -3654,7 +3702,7 @@
 struct msghdr hdr; hdr.msg_accrights=0
 ; return 0; }
 EOF
-if { (eval echo configure:3658: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3706: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_msg_accrights="yes"
 else
diff --git a/configure.in b/configure.in
index 6557802..1910639 100644
--- a/configure.in
+++ b/configure.in
@@ -83,6 +83,8 @@
 
 dnl Check for -li386 for NetBSD and OpenBSD
 AC_CHECK_LIB(i386,i386_set_ldt)
+dnl Check for -lossaudio for NetBSD
+AC_CHECK_LIB(ossaudio,_oss_ioctl)
 dnl Check for -lw for Solaris
 AC_CHECK_LIB(w,iswalnum)
 dnl Check for -lnsl for Solaris
@@ -115,16 +117,17 @@
 fi
 
 dnl **** Check for Open Sound System ****
-AC_CHECK_HEADERS(sys/soundcard.h machine/soundcard.h)
+AC_CHECK_HEADERS(sys/soundcard.h machine/soundcard.h soundcard.h, break)
 
 AC_CACHE_CHECK("for Open Sound System",
 	ac_cv_c_opensoundsystem,
 	AC_TRY_COMPILE([
-	#ifdef HAVE_SYS_SOUNDCARD_H
+	#if defined(HAVE_SYS_SOUNDCARD_H)
 		#include <sys/soundcard.h>
-	#endif
-	#ifdef HAVE_MACHINE_SOUNDCARD_H
+	#elif defined(HAVE_MACHINE_SOUNDCARD_H)
 		#include <machine/soundcard.h>
+	#elif defined(HAVE_SOUNDCARD_H)
+		#include <soundcard.h>
 	#endif
 	],[
 
diff --git a/include/config.h.in b/include/config.h.in
index 9d045be..ae808cb 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -141,6 +141,9 @@
 /* Define if you have the <netinet/in.h> header file.  */
 #undef HAVE_NETINET_IN_H
 
+/* Define if you have the <soundcard.h> header file.  */
+#undef HAVE_SOUNDCARD_H
+
 /* Define if you have the <strings.h> header file.  */
 #undef HAVE_STRINGS_H
 
@@ -195,6 +198,9 @@
 /* Define if you have the nsl library (-lnsl).  */
 #undef HAVE_LIBNSL
 
+/* Define if you have the ossaudio library (-lossaudio).  */
+#undef HAVE_LIBOSSAUDIO
+
 /* Define if you have the socket library (-lsocket).  */
 #undef HAVE_LIBSOCKET
 
diff --git a/include/multimedia.h b/include/multimedia.h
index ebc4f70..4d97843 100644
--- a/include/multimedia.h
+++ b/include/multimedia.h
@@ -20,11 +20,12 @@
 #define MAX_MIDIOUTDRV 	(16)
 #define MAX_MCIMIDIDRV 	(1)
 
-#ifdef HAVE_SYS_SOUNDCARD_H
+#if defined(HAVE_SYS_SOUNDCARD_H)
 # include <sys/soundcard.h>
-#endif
-#ifdef HAVE_MACHINE_SOUNDCARD_H
+#elif defined(HAVE_MACHINE_SOUNDCARD_H)
 # include <machine/soundcard.h>
+#elif defined(HAVE_SOUNDCARD_H)
+# include <soundcard.h>
 #endif
 
 #include <sys/errno.h>
diff --git a/multimedia/audio.c b/multimedia/audio.c
index 945430d..9c12677 100644
--- a/multimedia/audio.c
+++ b/multimedia/audio.c
@@ -22,20 +22,13 @@
 #include "windows.h"
 #include "user.h"
 #include "driver.h"
-#include "mmsystem.h"
+#include "multimedia.h"
 #include "heap.h"
 #include "ldt.h"
 #include "debug.h"
 
 #ifdef HAVE_OSS
 
-#ifdef HAVE_MACHINE_SOUNDCARD_H
-# include <machine/soundcard.h>
-#endif
-#ifdef HAVE_SYS_SOUNDCARD_H
-# include <sys/soundcard.h>
-#endif
-
 #define SOUND_DEV "/dev/dsp"
 #define MIXER_DEV "/dev/mixer"
 
diff --git a/multimedia/dsound.c b/multimedia/dsound.c
index b704501..36245fd 100644
--- a/multimedia/dsound.c
+++ b/multimedia/dsound.c
@@ -42,20 +42,15 @@
 #include "windows.h"
 #include "winerror.h"
 #include "interfaces.h"
-#include "mmsystem.h"
+#include "multimedia.h"
 #include "dsound.h"
 #include "thread.h"
 #include "debug.h"
 #include "xmalloc.h"
 
 #ifdef HAVE_OSS
-# include <sys/ioctl.h>
-# ifdef HAVE_MACHINE_SOUNDCARD_H
-#  include <machine/soundcard.h>
-# endif
-# ifdef HAVE_SYS_SOUNDCARD_H
-#  include <sys/soundcard.h>
-# endif
+
+#include <sys/ioctl.h>
 
 /* #define USE_DSOUND3D 1 */
 
diff --git a/multimedia/init.c b/multimedia/init.c
index e9c780d..2d53daa 100644
--- a/multimedia/init.c
+++ b/multimedia/init.c
@@ -36,6 +36,7 @@
 #ifdef HAVE_OSS
 int unixToWindowsDeviceType(int type)
 {
+#ifndef __NetBSD__
     /* MOD_MIDIPORT     output port 
      * MOD_SYNTH        generic internal synth 
      * MOD_SQSYNTH      square wave internal synth 
@@ -55,6 +56,9 @@
 	    "Assuming FM Synth\n");
 	return MOD_FMSYNTH;
     }
+#else
+    return MOD_FMSYNTH;
+#endif
 }
 #endif
 
@@ -66,7 +70,7 @@
  */
 BOOL32 MULTIMEDIA_MidiInit(void)
 {
-#ifdef HAVE_OSS
+#if defined(HAVE_OSS) && !defined(__NetBSD__)
     int 		i, status, numsynthdevs = 255, nummididevs = 255;
     struct synth_info 	sinfo;
     struct midi_info 	minfo;
diff --git a/multimedia/mcicda.c b/multimedia/mcicda.c
index 7c3127d..c9c1e52 100644
--- a/multimedia/mcicda.c
+++ b/multimedia/mcicda.c
@@ -14,9 +14,8 @@
 #include "windows.h"
 #include "user.h"
 #include "driver.h"
-#include "mmsystem.h"
-#include "debug.h"
 #include "multimedia.h"
+#include "debug.h"
 
 #ifdef HAVE_LINUX_CDROM_H
 # include <linux/cdrom.h>
@@ -24,25 +23,18 @@
 #ifdef HAVE_LINUX_UCDROM_H
 # include <linux/ucdrom.h>
 #endif
-#ifdef HAVE_MACHINE_SOUNDCARD_H
-# include <machine/soundcard.h>
-#endif
 #ifdef HAVE_SYS_CDIO_H
 # include <sys/cdio.h>
 #endif
 
-#ifdef __FreeBSD__
+#if defined(__NetBSD__)
+# define CDAUDIO_DEV "/dev/rcd0d"
+#elif defined(__FreeBSD__)
 # define CDAUDIO_DEV "/dev/rcd0c"
 #else
 # define CDAUDIO_DEV "/dev/cdrom"
 #endif
 
-#ifdef SOUND_VERSION
-# define IOCTL(a,b,c)		ioctl(a,b,&c)
-#else
-# define IOCTL(a,b,c)		(c = ioctl(a,b,c) )
-#endif
-
 #define MAX_CDAUDIODRV 		(1)
 #define MAX_CDAUDIO_TRACKS 	256
 
@@ -50,7 +42,7 @@
 #define CDFRAMES_PERMIN 	4500
 #define SECONDS_PERMIN	 	60
 
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
 typedef struct {
     int     		nUseCount;          /* Incremented for each shared open */
     BOOL16  		fShareable;         /* TRUE if first open was shareable */
@@ -61,7 +53,7 @@
     int			unixdev;
 #ifdef linux
     struct cdrom_subchnl	sc;
-#elif defined(__FreeBSD__)
+#else
     struct cd_sub_channel_info	sc;
 #endif
     int			cdMode;
@@ -103,27 +95,25 @@
  */
 static UINT16 CDAUDIO_GetNumberOfTracks(WINE_CDAUDIO* wcda)
 {
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
 #ifdef linux
     struct cdrom_tochdr	hdr;
-#elif defined(__FreeBSD__)
+#else
     struct ioc_toc_header	hdr;
 #endif
     
     if (wcda->nTracks == 0) {
-	if (ioctl(wcda->unixdev,
 #ifdef linux
-		  CDROMREADTOCHDR
-#elif defined(__FreeBSD__)
-		  CDIOREADTOCHEADER
+	if (ioctl(wcda->unixdev, CDROMREADTOCHDR, &hdr)) {
+#else
+	if (ioctl(wcda->unixdev, CDIOREADTOCHEADER, &hdr)) {
 #endif
-		  , &hdr)) {
 	    WARN(cdaudio, "(%p) -- Error occured !\n", wcda);
 	    return (WORD)-1;
 	}
 #ifdef linux
 	wcda->nTracks = hdr.cdth_trk1;
-#elif defined(__FreeBSD__)
+#else
 	wcda->nTracks = hdr.ending_track - hdr.starting_track + 1;
 #endif
     }
@@ -139,13 +129,13 @@
  */
 static BOOL32 CDAUDIO_GetTracksInfo(WINE_CDAUDIO* wcda)
 {
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     int		i, length;
     int		start, last_start = 0;
     int		total_length = 0;
 #ifdef linux
     struct cdrom_tocentry	entry;
-#elif defined(__FreeBSD__)
+#else
     struct ioc_read_toc_entry	entry;
     struct cd_toc_entry             toc_buffer;
 #endif
@@ -177,31 +167,29 @@
 	if (i == wcda->nTracks)
 #ifdef linux
 	    entry.cdte_track = CDROM_LEADOUT;
-#elif defined(__FreeBSD__)
+#else
 #define LEADOUT 0xaa
 	entry.starting_track = LEADOUT; /* XXX */
 #endif
 	else
 #ifdef linux
 	    entry.cdte_track = i + 1;
-#elif defined(__FreeBSD__)
+#else
 	entry.starting_track = i + 1;
 #endif
 #ifdef linux
 	entry.cdte_format = CDROM_MSF;
-#elif defined(__FreeBSD__)
+#else
 	bzero((char *)&toc_buffer, sizeof(toc_buffer));
 	entry.address_format = CD_MSF_FORMAT;
 	entry.data_len = sizeof(toc_buffer);
 	entry.data = &toc_buffer;
 #endif
-	if (ioctl(wcda->unixdev, 
 #ifdef linux
-		  CDROMREADTOCENTRY
-#elif defined(__FreeBSD__)
-		  CDIOREADTOCENTRYS
+	if (ioctl(wcda->unixdev, CDROMREADTOCENTRY, &entry)) {
+#else
+	if (ioctl(wcda->unixdev, CDIOREADTOCENTRYS, &entry)) {
 #endif
-		  , &entry)) {
 	    WARN(cdaudio, "error read entry\n");
 	    return FALSE;
 	}
@@ -209,7 +197,7 @@
 	start = CDFRAMES_PERSEC * (SECONDS_PERMIN * 
 				   entry.cdte_addr.msf.minute + entry.cdte_addr.msf.second) + 
 	    entry.cdte_addr.msf.frame;
-#elif defined(__FreeBSD__)
+#else
 	start = CDFRAMES_PERSEC * (SECONDS_PERMIN *
 				   toc_buffer.addr.msf.minute + toc_buffer.addr.msf.second) +
 	    toc_buffer.addr.msf.frame;
@@ -230,7 +218,7 @@
 	wcda->lpbTrackFlags[i] =
 #ifdef linux
 		(entry.cdte_adr << 4) | (entry.cdte_ctrl & 0x0f);
-#elif defined(__FreeBSD__)
+#else
 		(toc_buffer.addr_type << 4) | (toc_buffer.control & 0x0f);
 #endif 
 	TRACE(cdaudio, "track #%u flags=%02x\n", i + 1, wcda->lpbTrackFlags[i]);
@@ -248,7 +236,7 @@
  */
 static DWORD CDAUDIO_mciOpen(UINT16 wDevID, DWORD dwFlags, LPMCI_OPEN_PARMS32A lpOpenParms)
 {
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     DWORD	dwDeviceID;
     WINE_CDAUDIO* 	wcda;
 
@@ -328,7 +316,7 @@
  */
 static DWORD CDAUDIO_mciClose(UINT16 wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms)
 {
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     WINE_CDAUDIO*	wcda = CDAUDIO_mciGetOpenDrv(wDevID);
 
     TRACE(cdaudio,"(%04X, %08lX, %p);\n", wDevID, dwParam, lpParms);
@@ -351,7 +339,7 @@
 static DWORD CDAUDIO_mciGetDevCaps(UINT16 wDevID, DWORD dwFlags, 
 				   LPMCI_GETDEVCAPS_PARMS lpParms)
 {
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     TRACE(cdaudio,"(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms);
 
     if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
@@ -403,7 +391,7 @@
  */
 static DWORD CDAUDIO_mciInfo(UINT16 wDevID, DWORD dwFlags, LPMCI_INFO_PARMS16 lpParms)
 {
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     DWORD		ret = 0;
     LPSTR		str = 0;
     WINE_CDAUDIO*	wcda = CDAUDIO_mciGetOpenDrv(wDevID);
@@ -445,7 +433,7 @@
 static DWORD CDAUDIO_CalcFrame(WINE_CDAUDIO* wcda, DWORD dwTime)
 {
     DWORD	dwFrame = 0;
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     UINT16	wTrack;
     
     TRACE(cdaudio,"(%p, %08lX, %lu);\n", wcda, wcda->dwTimeFormat, dwTime);
@@ -487,9 +475,11 @@
  */
 static BOOL32 CDAUDIO_GetCDStatus(WINE_CDAUDIO*	wcda)
 {
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     int		oldmode = wcda->cdMode;
-#ifdef __FreeBSD__
+#ifdef linux
+    wcda->sc.cdsc_format = CDROM_MSF;
+#else
     struct ioc_read_subchannel	read_sc;
     
     read_sc.address_format = CD_MSF_FORMAT;
@@ -497,16 +487,12 @@
     read_sc.track          = 0;
     read_sc.data_len       = sizeof(wcda->sc);
     read_sc.data	   = (struct cd_sub_channel_info *)&wcda->sc;
-#elif linux
-    wcda->sc.cdsc_format = CDROM_MSF;
 #endif
-    if (ioctl(wcda->unixdev,
 #ifdef linux
-	      CDROMSUBCHNL, &wcda->sc
-#elif defined(__FreeBSD__)
-	      CDIOCREADSUBCHANNEL, &read_sc
+    if (ioctl(wcda->unixdev, CDROMSUBCHNL, &wcda->sc)) {
+#else
+    if (ioctl(wcda->unixdev, CDIOCREADSUBCHANNEL, &read_sc)) {
 #endif
-	      )) {
 	TRACE(cdaudio,"opened or no_media !\n");
 	wcda->cdMode = MCI_MODE_OPEN; /* was NOT_READY */
 	return TRUE;
@@ -514,13 +500,13 @@
     switch (
 #ifdef linux
 	    wcda->sc.cdsc_audiostatus
-#elif defined(__FreeBSD__)
+#else
 	    wcda->sc.header.audio_status
 #endif
 	    ) {
 #ifdef linux
     case CDROM_AUDIO_INVALID:
-#elif defined(__FreeBSD__)
+#else
     case CD_AS_AUDIO_INVALID:
 #endif
 	WARN(cdaudio, "device doesn't support status, using MCI status.\n");
@@ -528,7 +514,7 @@
 	break;
 #ifdef linux
     case CDROM_AUDIO_NO_STATUS: 
-#elif defined(__FreeBSD__)
+#else
     case CD_AS_NO_STATUS:
 #endif
 	wcda->cdMode = MCI_MODE_STOP;
@@ -536,7 +522,7 @@
 	break;
 #ifdef linux
     case CDROM_AUDIO_PLAY: 
-#elif defined(__FreeBSD__)
+#else
     case CD_AS_PLAY_IN_PROGRESS:
 #endif
 	wcda->cdMode = MCI_MODE_PLAY;
@@ -544,7 +530,7 @@
 	break;
 #ifdef linux
     case CDROM_AUDIO_PAUSED:
-#elif defined(__FreeBSD__)
+#else
     case CD_AS_PLAY_PAUSED:
 #endif
 	wcda->cdMode = MCI_MODE_PAUSE;
@@ -554,7 +540,7 @@
 #ifdef linux
 	TRACE(cdaudio,"status=%02X !\n",
 	      wcda->sc.cdsc_audiostatus);
-#elif defined(__FreeBSD__)
+#else
 	TRACE(cdaudio,"status=%02X !\n",
 	      wcda->sc.header.audio_status);
 #endif
@@ -565,7 +551,7 @@
 	CDFRAMES_PERMIN * wcda->sc.cdsc_absaddr.msf.minute +
 	CDFRAMES_PERSEC * wcda->sc.cdsc_absaddr.msf.second +
 	wcda->sc.cdsc_absaddr.msf.frame;
-#elif defined(__FreeBSD__)
+#else
     wcda->nCurTrack = wcda->sc.what.position.track_number;
     wcda->dwCurFrame = 
 	CDFRAMES_PERMIN * wcda->sc.what.position.absaddr.msf.minute +
@@ -578,7 +564,7 @@
 	  wcda->sc.cdsc_absaddr.msf.minute,
 	  wcda->sc.cdsc_absaddr.msf.second,
 	  wcda->sc.cdsc_absaddr.msf.frame);
-#elif defined(__FreeBSD__)
+#else
     TRACE(cdaudio,"%02u-%02u:%02u:%02u \n",
 	  wcda->sc.what.position.track_number,
 	  wcda->sc.what.position.absaddr.msf.minute,
@@ -605,7 +591,7 @@
 static DWORD CDAUDIO_CalcTime(WINE_CDAUDIO* wcda, DWORD dwFrame)
 {
     DWORD	dwTime = 0;
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     UINT16	wTrack;
     UINT16	wMinutes;
     UINT16	wSeconds;
@@ -651,7 +637,7 @@
  */
 static DWORD CDAUDIO_mciStatus(UINT16 wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms)
 {
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     WINE_CDAUDIO*	wcda = CDAUDIO_mciGetOpenDrv(wDevID);
     DWORD	        ret = 0;
 
@@ -759,13 +745,13 @@
  */
 static DWORD CDAUDIO_mciPlay(UINT16 wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
 {
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     int 	start, end;
     WINE_CDAUDIO*	wcda = CDAUDIO_mciGetOpenDrv(wDevID);
     DWORD		ret = 0;
 #ifdef linux
     struct 	cdrom_msf	msf;
-#elif defined(__FreeBSD__)
+#else
     struct	ioc_play_msf	msf;
 #endif
     
@@ -796,7 +782,7 @@
     msf.cdmsf_min1 = end / CDFRAMES_PERMIN;
     msf.cdmsf_sec1 = (end % CDFRAMES_PERMIN) / CDFRAMES_PERSEC;
     msf.cdmsf_frame1 = end % CDFRAMES_PERSEC;
-#elif defined(__FreeBSD__)
+#else
     msf.start_m     = start / CDFRAMES_PERMIN;
     msf.start_s     = (start % CDFRAMES_PERMIN) / CDFRAMES_PERSEC;
     msf.start_f     = start % CDFRAMES_PERSEC;
@@ -804,23 +790,19 @@
     msf.end_s       = (end % CDFRAMES_PERMIN) / CDFRAMES_PERSEC;
     msf.end_f       = end % CDFRAMES_PERSEC;
 #endif
-	if (ioctl(wcda->unixdev,
 #ifdef linux
-	      CDROMSTART
-#elif defined(__FreeBSD__)
-	      CDIOCSTART
+    if (ioctl(wcda->unixdev, CDROMSTART)) {
+#else
+    if (ioctl(wcda->unixdev, CDIOCSTART, NULL)) {
 #endif
-	      )) {
 	WARN(cdaudio, "motor doesn't start !\n");
 	return MCIERR_HARDWARE;
     }
-	if (ioctl(wcda->unixdev, 
 #ifdef linux
-	      CDROMPLAYMSF
-#elif defined(__FreeBSD__)
-	      CDIOCPLAYMSF
+    if (ioctl(wcda->unixdev, CDROMPLAYMSF, &msf)) {
+#else
+    if (ioctl(wcda->unixdev, CDIOCPLAYMSF, &msf)) {
 #endif
-	      , &msf)) {
 	WARN(cdaudio, "device doesn't play !\n");
 	return MCIERR_HARDWARE;
     }
@@ -828,7 +810,7 @@
     TRACE(cdaudio,"msf = %d:%d:%d %d:%d:%d\n",
 	  msf.cdmsf_min0, msf.cdmsf_sec0, msf.cdmsf_frame0,
 	  msf.cdmsf_min1, msf.cdmsf_sec1, msf.cdmsf_frame1);
-#elif defined(__FreeBSD__)
+#else
     TRACE(cdaudio,"msf = %d:%d:%d %d:%d:%d\n",
 	  msf.start_m, msf.start_s, msf.start_f,
 	  msf.end_m,   msf.end_s,   msf.end_f);
@@ -854,20 +836,19 @@
  */
 static DWORD CDAUDIO_mciStop(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
 {
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     WINE_CDAUDIO*	wcda = CDAUDIO_mciGetOpenDrv(wDevID);
 
     TRACE(cdaudio,"(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms);
 
     if (wcda == NULL)	return MCIERR_INVALID_DEVICE_ID;
     
-    if (ioctl(wcda->unixdev,
 #ifdef linux
-	      CDROMSTOP
-#elif defined(__FreeBSD__)
-	      CDIOCSTOP
+    if (ioctl(wcda->unixdev, CDROMSTOP))
+#else
+    if (ioctl(wcda->unixdev, CDIOCSTOP, NULL))
 #endif
-	      )) return MCIERR_HARDWARE;
+	return MCIERR_HARDWARE;
     wcda->mciMode = MCI_MODE_STOP;
     if (lpParms && (dwFlags & MCI_NOTIFY)) {
 	TRACE(cdaudio, "MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback);
@@ -885,20 +866,19 @@
  */
 static DWORD CDAUDIO_mciPause(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
 {
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     WINE_CDAUDIO*	wcda = CDAUDIO_mciGetOpenDrv(wDevID);
 
     TRACE(cdaudio,"(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms);
 
     if (wcda == NULL)	return MCIERR_INVALID_DEVICE_ID;
 
-    if (ioctl(wcda->unixdev,
 #ifdef linux
-	      CDROMPAUSE
-#elif defined(__FreeBSD__)
-	      CDIOCPAUSE
+    if (ioctl(wcda->unixdev, CDROMPAUSE))
+#else
+    if (ioctl(wcda->unixdev, CDIOCPAUSE, NULL))
 #endif
-	      )) return MCIERR_HARDWARE;
+	return MCIERR_HARDWARE;
     wcda->mciMode = MCI_MODE_PAUSE;
     if (lpParms && (dwFlags & MCI_NOTIFY)) {
         TRACE(cdaudio, "MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback);
@@ -916,20 +896,19 @@
  */
 static DWORD CDAUDIO_mciResume(UINT16 wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
 {
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     WINE_CDAUDIO*	wcda = CDAUDIO_mciGetOpenDrv(wDevID);
 
     TRACE(cdaudio,"(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms);
 
     if (wcda == NULL)	return MCIERR_INVALID_DEVICE_ID;
     
-    if (ioctl(wcda->unixdev, 
 #ifdef linux
-	      CDROMRESUME
-#elif defined(__FreeBSD__)
-	      CDIOCRESUME
+    if (ioctl(wcda->unixdev, CDROMRESUME))
+#else
+    if (ioctl(wcda->unixdev, CDIOCRESUME, NULL))
 #endif
-	      )) return MCIERR_HARDWARE;
+	return MCIERR_HARDWARE;
     wcda->mciMode = MCI_MODE_STOP;
     if (lpParms && (dwFlags & MCI_NOTIFY)) {
 	TRACE(cdaudio, "MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback);
@@ -947,7 +926,7 @@
  */
 static DWORD CDAUDIO_mciSeek(UINT16 wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
 {
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     DWORD	dwRet;
     MCI_PLAY_PARMS PlayParms;
     WINE_CDAUDIO*	wcda = CDAUDIO_mciGetOpenDrv(wDevID);
@@ -957,13 +936,11 @@
     if (wcda == NULL)	return MCIERR_INVALID_DEVICE_ID;
     if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
     
-    if (ioctl(wcda->unixdev,
 #ifdef linux
-	      CDROMRESUME
-#elif defined(__FreeBSD__)
-	      CDIOCRESUME
+    if (ioctl(wcda->unixdev, CDROMRESUME)) {
+#else
+    if (ioctl(wcda->unixdev, CDIOCRESUME, NULL)) {
 #endif
-	      )) {
 	perror("ioctl CDROMRESUME");
 	return MCIERR_HARDWARE;
     }
@@ -1004,17 +981,7 @@
 
     if (wcda == NULL) return MCIERR_INVALID_DEVICE_ID;
 
-#ifdef __FreeBSD__
-    if (ioctl(wcda->unixdev, CDIOCALLOW)) return MCIERR_HARDWARE;
-    if (open) {
-	if (ioctl(wcda->unixdev, CDIOCEJECT)) return MCIERR_HARDWARE;
-	wcda->mciMode = MCI_MODE_OPEN;
-    } else {
-	if (ioctl(wcda->unixdev, CDIOCCLOSE)) return MCIERR_HARDWARE;
-	wcda->mciMode = MCI_MODE_STOP;
-    }
-    if (ioctl(wcda->unixdev, CDIOCPREVENT)) return MCIERR_HARDWARE;
-#elif linux
+#ifdef linux
     if (open) {
 	if (ioctl(wcda->unixdev, CDROMEJECT)) return MCIERR_HARDWARE;
 	wcda->mciMode = MCI_MODE_OPEN;
@@ -1022,6 +989,16 @@
 	if (ioctl(wcda->unixdev, CDROMEJECT, 1)) return MCIERR_HARDWARE;
 	wcda->mciMode = MCI_MODE_STOP;
     }
+#else
+    if (ioctl(wcda->unixdev, CDIOCALLOW, NULL)) return MCIERR_HARDWARE;
+    if (open) {
+	if (ioctl(wcda->unixdev, CDIOCEJECT, NULL)) return MCIERR_HARDWARE;
+	wcda->mciMode = MCI_MODE_OPEN;
+    } else {
+	if (ioctl(wcda->unixdev, CDIOCCLOSE, NULL)) return MCIERR_HARDWARE;
+	wcda->mciMode = MCI_MODE_STOP;
+    }
+    if (ioctl(wcda->unixdev, CDIOCPREVENT, NULL)) return MCIERR_HARDWARE;
 #endif
     wcda->nTracks = 0;
     return 0;
@@ -1032,7 +1009,7 @@
  */
 static DWORD CDAUDIO_mciSet(UINT16 wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms)
 {
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     WINE_CDAUDIO*	wcda = CDAUDIO_mciGetOpenDrv(wDevID);
     
     TRACE(cdaudio,"(%04X, %08lX, %p);\n", wDevID, dwFlags, lpParms);
@@ -1087,7 +1064,7 @@
 LONG MCICDAUDIO_DriverProc32(DWORD dwDevID, HDRVR16 hDriv, DWORD wMsg, 
 			  DWORD dwParam1, DWORD dwParam2)
 {
-#if defined(linux) || defined(__FreeBSD__)
+#if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
     switch(wMsg) {
     case DRV_LOAD:		return 1;
     case DRV_FREE:		return 1;
diff --git a/multimedia/mcimidi.c b/multimedia/mcimidi.c
index 4700dc9..7482660 100644
--- a/multimedia/mcimidi.c
+++ b/multimedia/mcimidi.c
@@ -26,7 +26,6 @@
 #include "multimedia.h"
 #include "user.h"
 #include "driver.h"
-#include "mmsystem.h"
 #include "xmalloc.h"
 #include "debug.h"
 #include "callback.h"
@@ -72,6 +71,7 @@
  *                  	    MCI MIDI implemantation			*
  *======================================================================*/
 
+#ifdef SNDCTL_MIDI_INFO
 /**************************************************************************
  * 				MIDI_mciGetOpenDev		[internal]	
  */
@@ -1461,6 +1461,7 @@
     }
     return ret;	
 }    
+#endif
 
 /*======================================================================*
  *                  	    MIDI entry points 				*
@@ -1483,6 +1484,7 @@
     case DRV_CONFIGURE:		MessageBox16(0, "Sample Midi Linux Driver !", "MMLinux Driver", MB_OK); return 1;
     case DRV_INSTALL:		return DRVCNF_RESTART;
     case DRV_REMOVE:		return DRVCNF_RESTART;
+#ifdef SNDCTL_MIDI_INFO
     case MCI_OPEN_DRIVER:	return MIDI_mciOpen      (dwDevID, dwParam1, (LPMCI_OPEN_PARMS32A)   dwParam2);
     case MCI_CLOSE_DRIVER:	return MIDI_mciClose     (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS)   dwParam2);
     case MCI_PLAY:		return MIDI_mciPlay      (dwDevID, dwParam1, (LPMCI_PLAY_PARMS)      dwParam2);
@@ -1495,6 +1497,20 @@
     case MCI_GETDEVCAPS:	return MIDI_mciGetDevCaps(dwDevID, dwParam1, (LPMCI_GETDEVCAPS_PARMS)dwParam2);
     case MCI_INFO:		return MIDI_mciInfo      (dwDevID, dwParam1, (LPMCI_INFO_PARMS32A)   dwParam2);
     case MCI_SEEK:		return MIDI_mciSeek      (dwDevID, dwParam1, (LPMCI_SEEK_PARMS)      dwParam2);
+#else
+    case MCI_OPEN_DRIVER:
+    case MCI_CLOSE_DRIVER:
+    case MCI_PLAY:
+    case MCI_RECORD:
+    case MCI_STOP:
+    case MCI_SET:
+    case MCI_PAUSE:
+    case MCI_RESUME:
+    case MCI_STATUS:
+    case MCI_GETDEVCAPS:
+    case MCI_INFO:
+    case MCI_SEEK:
+#endif
     case MCI_LOAD:		
     case MCI_SAVE:		
     case MCI_FREEZE:		
diff --git a/multimedia/midi.c b/multimedia/midi.c
index 8c8fdf3..25a2e06 100644
--- a/multimedia/midi.c
+++ b/multimedia/midi.c
@@ -26,7 +26,6 @@
 #include "multimedia.h"
 #include "user.h"
 #include "driver.h"
-#include "mmsystem.h"
 #include "xmalloc.h"
 #include "debug.h"
 #include "callback.h"
@@ -108,7 +107,7 @@
 /*======================================================================*
  *                  Low level MIDI implemantation			*
  *======================================================================*/
-
+#ifdef SNDCTL_MIDI_INFO
 /**************************************************************************
  * 			MIDI_NotifyClient			[internal]
  */
@@ -1482,6 +1481,7 @@
      */
     return MMSYSERR_NOTENABLED;
 }
+#endif
 
 /*======================================================================*
  *                  	    MIDI entry points 				*
@@ -1497,6 +1497,7 @@
 	  wDevID, wMsg, dwUser, dwParam1, dwParam2);
 
     switch (wMsg) {
+#ifdef SNDCTL_MIDI_INFO
     case MODM_OPEN:
 	return modOpen(wDevID, (LPMIDIOPENDESC)dwParam1, dwParam2);
     case MODM_CLOSE:
@@ -1519,6 +1520,7 @@
 	return 0;
     case MODM_RESET:
 	return modReset(wDevID);
+#endif
     default:
 	TRACE(midi, "Unsupported message\n");
     }
diff --git a/multimedia/mixer.c b/multimedia/mixer.c
index 921d1f9..d00c39a 100644
--- a/multimedia/mixer.c
+++ b/multimedia/mixer.c
@@ -11,25 +11,11 @@
 #include "windows.h"
 #include "user.h"
 #include "driver.h"
-#include "mmsystem.h"
+#include "multimedia.h"
 #include "debug.h"
 
-#ifdef HAVE_SYS_SOUNDCARD_H
-# include <sys/soundcard.h>
-#endif
-#ifdef HAVE_MACHINE_SOUNDCARD_H
-# include <machine/soundcard.h>
-#endif
-
 #define MIXER_DEV "/dev/mixer"
 
-#ifdef SOUND_VERSION
-#define IOCTL(a,b,c)		ioctl(a,b,&c)
-#else
-#define IOCTL(a,b,c)		(c = ioctl(a,b,c) )
-#endif
-
-
 /**************************************************************************
  * 				MIX_GetDevCaps			[internal]
  */
diff --git a/multimedia/mmaux.c b/multimedia/mmaux.c
index 4272db4..1933306 100644
--- a/multimedia/mmaux.c
+++ b/multimedia/mmaux.c
@@ -13,25 +13,11 @@
 #include "windows.h"
 #include "user.h"
 #include "driver.h"
-#include "mmsystem.h"
+#include "multimedia.h"
 #include "debug.h"
 
-#ifdef HAVE_SYS_SOUNDCARD_H
-# include <sys/soundcard.h>
-#endif
-#ifdef HAVE_MACHINE_SOUNDCARD_H
-# include <machine/soundcard.h>
-#endif
-
 #define MIXER_DEV "/dev/mixer"
 
-#ifdef SOUND_VERSION
-#define IOCTL(a,b,c)		ioctl(a,b,&c)
-#else
-#define IOCTL(a,b,c)		(c = ioctl(a,b,c) )
-#endif
-
-
 static int	NumDev = 6;
 
 /*-----------------------------------------------------------------------*/