Merged the NAS driver written by Nicolas
Escuder <n.escuder@alineanet.com>.
diff --git a/configure b/configure
index eb19ffc..4945733 100755
--- a/configure
+++ b/configure
@@ -9255,6 +9255,233 @@
fi
+NASLIBS=""
+
+
+for ac_header in audio/audiolib.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ egrep -v '^ *\+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+ yes:no )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
+ no:yes )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+for ac_header in audio/soundlib.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+#include <audio/audiolib.h>
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_Header=yes"
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+ echo "$as_me:$LINENO: checking for AuCreateFlow in -laudio" >&5
+echo $ECHO_N "checking for AuCreateFlow in -laudio... $ECHO_C" >&6
+if test "${ac_cv_lib_audio_AuCreateFlow+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-laudio -lXt $X_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char AuCreateFlow ();
+#ifdef F77_DUMMY_MAIN
+# ifdef __cplusplus
+ extern "C"
+# endif
+ int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+AuCreateFlow ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_audio_AuCreateFlow=yes
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_audio_AuCreateFlow=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_audio_AuCreateFlow" >&5
+echo "${ECHO_T}$ac_cv_lib_audio_AuCreateFlow" >&6
+if test $ac_cv_lib_audio_AuCreateFlow = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_NAS 1
+_ACEOF
+
+ NASLIBS="-laudio -lXt \$(X_LIBS) \$(XLIB)"
+fi
+
+fi
+
+done
+
+
echo "$as_me:$LINENO: checking whether mmap64 works defined as mmap" >&5
echo $ECHO_N "checking whether mmap64 works defined as mmap... $ECHO_C" >&6
@@ -13583,7 +13810,7 @@
MAKE_PROG_RULES=programs/Makeprog.rules
-ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules programs/Makeprog.rules Makefile debugger/Makefile dlls/Makefile dlls/advapi32/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/d3d8/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dsound/Makefile dlls/gdi/Makefile dlls/glu32/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/kernel/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msdmo/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt20/Makefile dlls/msvideo/Makefile dlls/netapi32/Makefile dlls/ntdll/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleaut32/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/snmpapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/user/Makefile dlls/version/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winspool/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile include/Makefile library/Makefile miscemu/Makefile ole/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/notepad/Makefile programs/osversioncheck/Makefile programs/progman/Makefile programs/regapi/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/regtest/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineconsole/Makefile programs/winefile/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/wmc/Makefile tools/wpp/Makefile tools/wrc/Makefile tsx11/Makefile unicode/Makefile"
+ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules programs/Makeprog.rules Makefile debugger/Makefile dlls/Makefile dlls/advapi32/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/d3d8/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput8/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dsound/Makefile dlls/gdi/Makefile dlls/glu32/Makefile dlls/icmp/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/kernel/Makefile dlls/lzexpand/Makefile dlls/mapi32/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msdmo/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt20/Makefile dlls/msvideo/Makefile dlls/netapi32/Makefile dlls/ntdll/Makefile dlls/odbc32/Makefile dlls/ole32/Makefile dlls/oleaut32/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/psapi/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/rasapi32/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/snmpapi/Makefile dlls/sti/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/user/Makefile dlls/version/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winenas/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winspool/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/x11drv/Makefile documentation/Makefile include/Makefile library/Makefile miscemu/Makefile ole/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/notepad/Makefile programs/osversioncheck/Makefile programs/progman/Makefile programs/regapi/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/regtest/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineconsole/Makefile programs/winefile/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/wmc/Makefile tools/wpp/Makefile tools/wrc/Makefile tsx11/Makefile unicode/Makefile"
cat >confcache <<\_ACEOF
@@ -14151,6 +14378,7 @@
"dlls/winmm/midimap/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winmm/midimap/Makefile" ;;
"dlls/winmm/wavemap/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winmm/wavemap/Makefile" ;;
"dlls/winmm/winealsa/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winmm/winealsa/Makefile" ;;
+ "dlls/winmm/winenas/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winmm/winenas/Makefile" ;;
"dlls/winmm/winearts/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winmm/winearts/Makefile" ;;
"dlls/winmm/wineoss/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winmm/wineoss/Makefile" ;;
"dlls/winnls/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winnls/Makefile" ;;
@@ -14389,6 +14617,7 @@
s,@ARTSLIBS@,$ARTSLIBS,;t t
s,@ARTSINCL@,$ARTSINCL,;t t
s,@ALSALIBS@,$ALSALIBS,;t t
+s,@NASLIBS@,$NASLIBS,;t t
s,@DLLWRAP@,$DLLWRAP,;t t
s,@ac_ct_DLLWRAP@,$ac_ct_DLLWRAP,;t t
s,@DLLIBS@,$DLLIBS,;t t
diff --git a/configure.ac b/configure.ac
index f0617d7..5f2983e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -568,6 +568,15 @@
ALSALIBS="-lasound")
fi
+dnl **** Check for NAS ****
+AC_SUBST(NASLIBS,"")
+AC_CHECK_HEADERS(audio/audiolib.h,
+ [AC_CHECK_HEADERS(audio/soundlib.h,,,[#include <audio/audiolib.h>])
+ AC_CHECK_LIB(audio,AuCreateFlow,
+ [AC_DEFINE(HAVE_NAS,1,[Define if you have NAS including devel headers])
+ NASLIBS="-laudio -lXt \$(X_LIBS) \$(XLIB)"],,
+ [-lXt $X_LIBS -lXext -lX11 $X_EXTRA_LIBS])])
+
dnl **** Check for broken glibc mmap64 ****
AC_CACHE_CHECK( [whether mmap64 works defined as mmap], ac_cv_mmap64_works,
@@ -1403,6 +1412,7 @@
dlls/winmm/midimap/Makefile
dlls/winmm/wavemap/Makefile
dlls/winmm/winealsa/Makefile
+dlls/winmm/winenas/Makefile
dlls/winmm/winearts/Makefile
dlls/winmm/wineoss/Makefile
dlls/winnls/Makefile
diff --git a/dlls/Makefile.in b/dlls/Makefile.in
index 1751421..81d300b 100644
--- a/dlls/Makefile.in
+++ b/dlls/Makefile.in
@@ -98,6 +98,7 @@
winmm/wavemap \
winmm/winealsa \
winmm/winearts \
+ winmm/winenas \
winmm/wineoss \
winnls \
winsock \
@@ -242,6 +243,7 @@
winearts.drv$(DLLEXT) \
winedos.dll$(DLLEXT) \
winemp3.acm$(DLLEXT) \
+ winenas.drv$(DLLEXT) \
wineoss.drv$(DLLEXT) \
wineps.dll$(DLLEXT) \
wineps16.dll$(DLLEXT) \
@@ -513,6 +515,9 @@
winemp3.acm$(DLLEXT): msacm/winemp3/winemp3.acm$(DLLEXT)
$(RM) $@ && $(LN_S) msacm/winemp3/winemp3.acm$(DLLEXT) $@
+winenas.drv$(DLLEXT): winmm/winenas/winenas.drv$(DLLEXT)
+ $(RM) $@ && $(LN_S) winmm/winenas/winenas.drv$(DLLEXT) $@
+
wineoss.drv$(DLLEXT): winmm/wineoss/wineoss.drv$(DLLEXT)
$(RM) $@ && $(LN_S) winmm/wineoss/wineoss.drv$(DLLEXT) $@
@@ -633,6 +638,7 @@
winmm/winearts/winearts.drv$(DLLEXT): winmm/winearts
winedos/winedos.dll$(DLLEXT): winedos
msacm/winemp3/winemp3.acm$(DLLEXT): msacm/winemp3
+winmm/winenas/winenas.drv$(DLLEXT): winmm/winenas
winmm/wineoss/wineoss.drv$(DLLEXT): winmm/wineoss
wineps/wineps.dll$(DLLEXT): wineps
wininet/wininet.dll$(DLLEXT): wininet
@@ -730,6 +736,7 @@
winmm/winearts/__install__: winearts.drv$(DLLEXT)
winedos/__install__: winedos.dll$(DLLEXT)
msacm/winemp3/__install__: winemp3.acm$(DLLEXT)
+winmm/winenas/__install__: winenas.drv$(DLLEXT)
winmm/wineoss/__install__: wineoss.drv$(DLLEXT)
wineps/__install__: wineps.dll$(DLLEXT)
wininet/__install__: wininet.dll$(DLLEXT)
@@ -765,7 +772,7 @@
dplay: dplayx.dll$(DLLEXT)
dplayx: winmm.dll$(DLLEXT) ole32.dll$(DLLEXT) user32.dll$(DLLEXT) advapi32.dll$(DLLEXT) \
kernel32.dll$(DLLEXT)
-dsound: winmm.dll$(DLLEXT) advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
+dsound: winmm.dll$(DLLEXT) advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT) ntdll.dll$(DLLEXT)
gdi: advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT) libkernel32.dll.$(LIBEXT) libntdll.dll.$(LIBEXT)
glu32: kernel32.dll$(DLLEXT)
icmp: kernel32.dll$(DLLEXT)
@@ -842,6 +849,7 @@
winmm/wavemap: msacm32.dll$(DLLEXT) winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
winmm/winealsa: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT) ntdll.dll$(DLLEXT)
winmm/winearts: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
+winmm/winenas: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
winmm/wineoss: winmm.dll$(DLLEXT) user32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
winmm: user32.dll$(DLLEXT) advapi32.dll$(DLLEXT) kernel32.dll$(DLLEXT)
winnls: kernel32.dll$(DLLEXT)
diff --git a/dlls/winmm/winenas/.cvsignore b/dlls/winmm/winenas/.cvsignore
new file mode 100644
index 0000000..1bcddab
--- /dev/null
+++ b/dlls/winmm/winenas/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+winenas.drv.dbg.c
+winenas.drv.spec.c
diff --git a/dlls/winmm/winenas/Makefile.in b/dlls/winmm/winenas/Makefile.in
new file mode 100644
index 0000000..6eb906b
--- /dev/null
+++ b/dlls/winmm/winenas/Makefile.in
@@ -0,0 +1,18 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+MODULE = winenas.drv
+IMPORTS = winmm user32 kernel32
+EXTRALIBS = @NASLIBS@
+
+LDDLLFLAGS = @LDDLLFLAGS@
+SYMBOLFILE = $(MODULE).tmp.o
+
+C_SRCS = \
+ audio.c \
+ nas.c
+
+@MAKE_DLL_RULES@
+
+### Dependencies:
diff --git a/dlls/winmm/winenas/audio.c b/dlls/winmm/winenas/audio.c
new file mode 100644
index 0000000..0748052
--- /dev/null
+++ b/dlls/winmm/winenas/audio.c
@@ -0,0 +1,1569 @@
+/* -*- tab-width: 8; c-basic-offset: 4 -*- */
+/*
+ * Wine Driver for NAS Network Audio System
+ * http://radscan.com/nas.html
+ *
+ * Copyright 1994 Martin Ayotte
+ * 1999 Eric Pouech (async playing in waveOut/waveIn)
+ * 2000 Eric Pouech (loops in waveOut)
+ * 2002 Chris Morgan (aRts version of this file)
+ * 2002 Nicolas Escuder (NAS version of this file)
+ *
+ * Copyright 2002 Nicolas Escuder <n.escuder@alineanet.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+/* NOTE:
+ * with nas we cannot stop the audio that is already in
+ * the servers buffer.
+ *
+ * FIXME:
+ * pause in waveOut does not work correctly in loop mode
+ *
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <errno.h>
+#include <fcntl.h>
+
+//#define EMULATE_SB16
+#define FRAG_SIZE 1764
+#define FRAG_COUNT 1
+
+/* avoid type conflicts */
+#define INT32 X_INT32
+#define INT16 X_INT16
+#define BOOL X_BOOL
+#define BYTE X_BYTE
+#ifdef HAVE_AUDIO_AUDIOLIB_H
+#include <audio/audiolib.h>
+#endif
+#ifdef HAVE_AUDIO_SOUNDLIB_H
+#include <audio/soundlib.h>
+#endif
+#undef INT32
+#undef INT16
+#undef BOOL
+#undef BYTE
+
+#include "windef.h"
+#include "wingdi.h"
+#include "winerror.h"
+#include "wine/winuser16.h"
+#include "mmddk.h"
+#include "dsound.h"
+#include "dsdriver.h"
+#include "nas.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(wave);
+
+/* Allow 1% deviation for sample rates (some ES137x cards) */
+#define NEAR_MATCH(rate1,rate2) (((100*((int)(rate1)-(int)(rate2)))/(rate1))==0)
+
+#ifdef HAVE_NAS
+
+static AuServer *AuServ;
+
+#define MAX_WAVEOUTDRV (1)
+
+/* state diagram for waveOut writing:
+ *
+ * +---------+-------------+---------------+---------------------------------+
+ * | state | function | event | new state |
+ * +---------+-------------+---------------+---------------------------------+
+ * | | open() | | STOPPED |
+ * | PAUSED | write() | | PAUSED |
+ * | STOPPED | write() | <thrd create> | PLAYING |
+ * | PLAYING | write() | HEADER | PLAYING |
+ * | (other) | write() | <error> | |
+ * | (any) | pause() | PAUSING | PAUSED |
+ * | PAUSED | restart() | RESTARTING | PLAYING (if no thrd => STOPPED) |
+ * | (any) | reset() | RESETTING | STOPPED |
+ * | (any) | close() | CLOSING | CLOSED |
+ * +---------+-------------+---------------+---------------------------------+
+ */
+
+/* states of the playing device */
+#define WINE_WS_PLAYING 0
+#define WINE_WS_PAUSED 1
+#define WINE_WS_STOPPED 2
+#define WINE_WS_CLOSED 3
+
+/* events to be send to device */
+enum win_wm_message {
+ WINE_WM_PAUSING = WM_USER + 1, WINE_WM_RESTARTING, WINE_WM_RESETTING, WINE_WM_HEADER,
+ WINE_WM_UPDATE, WINE_WM_BREAKLOOP, WINE_WM_CLOSING
+};
+
+typedef struct {
+ enum win_wm_message msg; /* message identifier */
+ DWORD param; /* parameter for this message */
+ HANDLE hEvent; /* if message is synchronous, handle of event for synchro */
+} RING_MSG;
+
+/* implement an in-process message ring for better performance
+ * (compared to passing thru the server)
+ * this ring will be used by the input (resp output) record (resp playback) routine
+ */
+typedef struct {
+#define NAS_RING_BUFFER_SIZE 30
+ RING_MSG messages[NAS_RING_BUFFER_SIZE];
+ int msg_tosave;
+ int msg_toget;
+ HANDLE msg_event;
+ CRITICAL_SECTION msg_crst;
+} MSG_RING;
+
+typedef struct {
+ volatile int state; /* one of the WINE_WS_ manifest constants */
+ WAVEOPENDESC waveDesc;
+ WORD wFlags;
+ PCMWAVEFORMAT format;
+ WAVEOUTCAPSA caps;
+ int Id;
+ int open;
+ AuServer *AuServ;
+ AuDeviceID AuDev;
+ AuFlowID AuFlow;
+ int bps;
+ int sendBytes;
+ int writeBytes;
+ int freeBytes;
+ int maxBytes;
+ int gettime;
+ struct timeval last_tv;
+
+ int BufferUsed;
+ DWORD dwBufferSize; /* size of whole buffer in bytes */
+
+ char* sound_buffer;
+ long buffer_size;
+
+ DWORD volume_left; /* volume control information */
+ DWORD volume_right;
+
+ LPWAVEHDR lpQueuePtr; /* start of queued WAVEHDRs (waiting to be notified) */
+ LPWAVEHDR lpPlayPtr; /* start of not yet fully played buffers */
+
+ LPWAVEHDR lpLoopPtr; /* pointer of first buffer in loop, if any */
+ DWORD dwLoops; /* private copy of loop counter */
+
+ DWORD dwPlayedTotal; /* number of bytes actually played since opening */
+ DWORD dwWrittenTotal; /* number of bytes written to the audio device since opening */
+
+ /* synchronization stuff */
+ HANDLE hStartUpEvent;
+ HANDLE hThread;
+ DWORD dwThreadID;
+ MSG_RING msgRing;
+} WINE_WAVEOUT;
+
+static WINE_WAVEOUT WOutDev [MAX_WAVEOUTDRV];
+
+static DWORD wodDsCreate(UINT wDevID, PIDSDRIVER* drv);
+
+
+// NASFUNC
+static AuBool event_handler(AuServer* aud, AuEvent* ev, AuEventHandlerRec* hnd);
+static int nas_init(void);
+static int nas_end(void);
+
+static int nas_dev(WINE_WAVEOUT* wwo);
+static int nas_open(WINE_WAVEOUT* wwo);
+static int nas_close(WINE_WAVEOUT* wwo);
+int nas_getdelay(WINE_WAVEOUT* wwo);
+static void buffer_resize(WINE_WAVEOUT* wwo, int len);
+static int send_buffer(WINE_WAVEOUT* wwo);
+
+/* These strings used only for tracing */
+static const char *wodPlayerCmdString[] = {
+ "WINE_WM_PAUSING",
+ "WINE_WM_RESTARTING",
+ "WINE_WM_RESETTING",
+ "WINE_WM_HEADER",
+ "WINE_WM_UPDATE",
+ "WINE_WM_BREAKLOOP",
+ "WINE_WM_CLOSING",
+};
+
+static char *nas_event_types[] = {
+ "Undefined",
+ "Undefined",
+ "ElementNotify",
+ "GrabNotify",
+ "MonitorNotify",
+ "BucketNotify",
+ "DeviceNotify"
+};
+
+static char *nas_elementnotify_kinds[] = {
+ "LowWater",
+ "HighWater",
+ "State",
+ "Unknown"
+};
+
+static char *nas_states[] = {
+ "Stop",
+ "Start",
+ "Pause",
+ "Any"
+};
+
+static char *nas_reasons[] = {
+ "User",
+ "Underrun",
+ "Overrun",
+ "EOF",
+ "Watermark",
+ "Hardware",
+ "Any"
+};
+
+static char* nas_reason(unsigned int reason)
+{
+ if (reason > 6) reason = 6;
+ return nas_reasons[reason];
+}
+
+static char* nas_elementnotify_kind(unsigned int kind)
+{
+ if (kind > 2) kind = 3;
+ return nas_elementnotify_kinds[kind];
+}
+
+
+static char* nas_event_type(unsigned int type)
+{
+ if (type > 6) type = 0;
+ return nas_event_types[type];
+}
+
+
+static char* nas_state(unsigned int state)
+{
+ if (state > 3) state = 3;
+ return nas_states[state];
+}
+
+/*======================================================================*
+ * Low level WAVE implementation *
+ *======================================================================*/
+
+/* Volume functions derived from Alsaplayer source */
+/* length is the number of 16 bit samples */
+void volume_effect16(void *bufin, void* bufout, int length, int left,
+ int right, int nChannels)
+{
+ short *d_out = (short *)bufout;
+ short *d_in = (short *)bufin;
+ int i, v;
+
+/*
+ TRACE("length == %d, nChannels == %d\n", length, nChannels);
+*/
+
+ if (right == -1) right = left;
+
+ for(i = 0; i < length; i+=(nChannels))
+ {
+ v = (int) ((*(d_in++) * left) / 100);
+ *(d_out++) = (v>32767) ? 32767 : ((v<-32768) ? -32768 : v);
+ if(nChannels == 2)
+ {
+ v = (int) ((*(d_in++) * right) / 100);
+ *(d_out++) = (v>32767) ? 32767 : ((v<-32768) ? -32768 : v);
+ }
+ }
+}
+
+/* length is the number of 8 bit samples */
+void volume_effect8(void *bufin, void* bufout, int length, int left,
+ int right, int nChannels)
+{
+ char *d_out = (char *)bufout;
+ char *d_in = (char *)bufin;
+ int i, v;
+
+/*
+ TRACE("length == %d, nChannels == %d\n", length, nChannels);
+*/
+
+ if (right == -1) right = left;
+
+ for(i = 0; i < length; i+=(nChannels))
+ {
+ v = (char) ((*(d_in++) * left) / 100);
+ *(d_out++) = (v>255) ? 255 : ((v<0) ? 0 : v);
+ if(nChannels == 2)
+ {
+ v = (char) ((*(d_in++) * right) / 100);
+ *(d_out++) = (v>255) ? 255 : ((v<0) ? 0 : v);
+ }
+ }
+}
+
+/******************************************************************
+ * NAS_CloseDevice
+ *
+ */
+void NAS_CloseDevice(WINE_WAVEOUT* wwo)
+{
+
+ TRACE("NAS_CloseDevice\n");
+ nas_close(wwo);
+/*
+ if(wwo->sound_buffer)
+ HeapFree(GetProcessHeap(), 0, wwo->sound_buffer);
+ wwo->buffer_size = 0;
+*/
+}
+
+/******************************************************************
+ * NAS_WaveClose
+ */
+LONG NAS_WaveClose(void)
+{
+ nas_end(); /* free up nas server */
+ return 1;
+}
+
+/******************************************************************
+ * NAS_WaveInit
+ *
+ * Initialize internal structures from NAS server info
+ */
+LONG NAS_WaveInit(void)
+{
+ int i;
+ nas_init();
+
+ /* initialize all device handles to -1 */
+ for (i = 0; i < MAX_WAVEOUTDRV; ++i)
+ {
+ memset(&WOutDev[i].caps, 0, sizeof(WOutDev[i].caps)); /* zero out caps values */
+
+ WOutDev[i].AuServ = AuServ;
+ WOutDev[i].AuDev = AuNone;
+ WOutDev[i].Id = i;
+ /* FIXME: some programs compare this string against the content of the registry
+ * for MM drivers. The names have to match in order for the program to work
+ * (e.g. MS win9x mplayer.exe)
+ */
+#ifdef EMULATE_SB16
+ WOutDev[i].caps.wMid = 0x0002;
+ WOutDev[i].caps.wPid = 0x0104;
+ strcpy(WOutDev[i].caps.szPname, "SB16 Wave Out");
+#else
+ WOutDev[i].caps.wMid = 0x00FF; /* Manufac ID */
+ WOutDev[i].caps.wPid = 0x0001; /* Product ID */
+ /* strcpy(WOutDev[i].caps.szPname, "OpenSoundSystem WAVOUT Driver");*/
+ strcpy(WOutDev[i].caps.szPname, "CS4236/37/38");
+#endif
+ WOutDev[i].AuFlow = 0;
+ WOutDev[i].caps.vDriverVersion = 0x0100;
+ WOutDev[i].caps.dwFormats = 0x00000000;
+ WOutDev[i].caps.dwSupport = WAVECAPS_VOLUME;
+
+ WOutDev[i].caps.wChannels = 2;
+ WOutDev[i].caps.dwSupport |= WAVECAPS_LRVOLUME;
+
+ WOutDev[i].caps.dwFormats |= WAVE_FORMAT_4M08;
+ WOutDev[i].caps.dwFormats |= WAVE_FORMAT_4S08;
+ WOutDev[i].caps.dwFormats |= WAVE_FORMAT_4S16;
+ WOutDev[i].caps.dwFormats |= WAVE_FORMAT_4M16;
+ WOutDev[i].caps.dwFormats |= WAVE_FORMAT_2M08;
+ WOutDev[i].caps.dwFormats |= WAVE_FORMAT_2S08;
+ WOutDev[i].caps.dwFormats |= WAVE_FORMAT_2M16;
+ WOutDev[i].caps.dwFormats |= WAVE_FORMAT_2S16;
+ WOutDev[i].caps.dwFormats |= WAVE_FORMAT_1M08;
+ WOutDev[i].caps.dwFormats |= WAVE_FORMAT_1S08;
+ WOutDev[i].caps.dwFormats |= WAVE_FORMAT_1M16;
+ WOutDev[i].caps.dwFormats |= WAVE_FORMAT_1S16;
+ }
+
+
+ return 0;
+}
+
+/******************************************************************
+ * NAS_InitRingMessage
+ *
+ * Initialize the ring of messages for passing between driver's caller and playback/record
+ * thread
+ */
+static int NAS_InitRingMessage(MSG_RING* mr)
+{
+ mr->msg_toget = 0;
+ mr->msg_tosave = 0;
+ mr->msg_event = CreateEventA(NULL, FALSE, FALSE, NULL);
+ memset(mr->messages, 0, sizeof(RING_MSG) * NAS_RING_BUFFER_SIZE);
+ InitializeCriticalSection(&mr->msg_crst);
+ return 0;
+}
+
+/******************************************************************
+ * NAS_DestroyRingMessage
+ *
+ */
+static int NAS_DestroyRingMessage(MSG_RING* mr)
+{
+ CloseHandle(mr->msg_event);
+ DeleteCriticalSection(&mr->msg_crst);
+ return 0;
+}
+
+/******************************************************************
+ * NAS_AddRingMessage
+ *
+ * Inserts a new message into the ring (should be called from DriverProc derivated routines)
+ */
+static int NAS_AddRingMessage(MSG_RING* mr, enum win_wm_message msg, DWORD param, BOOL wait)
+{
+ HANDLE hEvent = INVALID_HANDLE_VALUE;
+
+ EnterCriticalSection(&mr->msg_crst);
+ if ((mr->msg_toget == ((mr->msg_tosave + 1) % NAS_RING_BUFFER_SIZE))) /* buffer overflow? */
+ {
+ ERR("buffer overflow !?\n");
+ LeaveCriticalSection(&mr->msg_crst);
+ return 0;
+ }
+ if (wait)
+ {
+ hEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
+ if (hEvent == INVALID_HANDLE_VALUE)
+ {
+ ERR("can't create event !?\n");
+ LeaveCriticalSection(&mr->msg_crst);
+ return 0;
+ }
+ if (mr->msg_toget != mr->msg_tosave && mr->messages[mr->msg_toget].msg != WINE_WM_HEADER)
+ FIXME("two fast messages in the queue!!!!\n");
+
+ /* fast messages have to be added at the start of the queue */
+ mr->msg_toget = (mr->msg_toget + NAS_RING_BUFFER_SIZE - 1) % NAS_RING_BUFFER_SIZE;
+
+ mr->messages[mr->msg_toget].msg = msg;
+ mr->messages[mr->msg_toget].param = param;
+ mr->messages[mr->msg_toget].hEvent = hEvent;
+ }
+ else
+ {
+ mr->messages[mr->msg_tosave].msg = msg;
+ mr->messages[mr->msg_tosave].param = param;
+ mr->messages[mr->msg_tosave].hEvent = INVALID_HANDLE_VALUE;
+ mr->msg_tosave = (mr->msg_tosave + 1) % NAS_RING_BUFFER_SIZE;
+ }
+
+ LeaveCriticalSection(&mr->msg_crst);
+
+ SetEvent(mr->msg_event); /* signal a new message */
+
+ if (wait)
+ {
+ /* wait for playback/record thread to have processed the message */
+ WaitForSingleObject(hEvent, INFINITE);
+ CloseHandle(hEvent);
+ }
+
+ return 1;
+}
+
+/******************************************************************
+ * NAS_RetrieveRingMessage
+ *
+ * Get a message from the ring. Should be called by the playback/record thread.
+ */
+static int NAS_RetrieveRingMessage(MSG_RING* mr,
+ enum win_wm_message *msg, DWORD *param, HANDLE *hEvent)
+{
+ EnterCriticalSection(&mr->msg_crst);
+
+ if (mr->msg_toget == mr->msg_tosave) /* buffer empty ? */
+ {
+ LeaveCriticalSection(&mr->msg_crst);
+ return 0;
+ }
+
+ *msg = mr->messages[mr->msg_toget].msg;
+ mr->messages[mr->msg_toget].msg = 0;
+ *param = mr->messages[mr->msg_toget].param;
+ *hEvent = mr->messages[mr->msg_toget].hEvent;
+ mr->msg_toget = (mr->msg_toget + 1) % NAS_RING_BUFFER_SIZE;
+ LeaveCriticalSection(&mr->msg_crst);
+ return 1;
+}
+
+/*======================================================================*
+ * Low level WAVE OUT implementation *
+ *======================================================================*/
+
+/**************************************************************************
+ * wodNotifyClient [internal]
+ */
+static DWORD wodNotifyClient(WINE_WAVEOUT* wwo, WORD wMsg, DWORD dwParam1, DWORD dwParam2)
+{
+ TRACE("wMsg = 0x%04x dwParm1 = %04lX dwParam2 = %04lX\n", wMsg, dwParam1, dwParam2);
+
+ switch (wMsg) {
+ case WOM_OPEN:
+ case WOM_CLOSE:
+ case WOM_DONE:
+ if (wwo->wFlags != DCB_NULL &&
+ !DriverCallback(wwo->waveDesc.dwCallback, wwo->wFlags, wwo->waveDesc.hWave,
+ wMsg, wwo->waveDesc.dwInstance, dwParam1, dwParam2)) {
+ WARN("can't notify client !\n");
+ return MMSYSERR_ERROR;
+ }
+ break;
+ default:
+ FIXME("Unknown callback message %u\n", wMsg);
+ return MMSYSERR_INVALPARAM;
+ }
+ return MMSYSERR_NOERROR;
+}
+
+/**************************************************************************
+ * wodUpdatePlayedTotal [internal]
+ *
+ */
+static BOOL wodUpdatePlayedTotal(WINE_WAVEOUT* wwo)
+{
+ static int i = 0;
+ /* total played is the bytes written less the bytes to write ;-) */
+ if (wwo->sendBytes)
+ wwo->dwPlayedTotal = wwo->writeBytes;
+ else
+ wwo->dwPlayedTotal = i++;
+ return TRUE;
+}
+
+/**************************************************************************
+ * wodPlayer_BeginWaveHdr [internal]
+ *
+ * Makes the specified lpWaveHdr the currently playing wave header.
+ * If the specified wave header is a begin loop and we're not already in
+ * a loop, setup the loop.
+ */
+static void wodPlayer_BeginWaveHdr(WINE_WAVEOUT* wwo, LPWAVEHDR lpWaveHdr)
+{
+ wwo->lpPlayPtr = lpWaveHdr;
+
+ if (!lpWaveHdr) return;
+
+ if (lpWaveHdr->dwFlags & WHDR_BEGINLOOP) {
+ if (wwo->lpLoopPtr) {
+ WARN("Already in a loop. Discarding loop on this header (%p)\n", lpWaveHdr);
+ TRACE("Already in a loop. Discarding loop on this header (%p)\n", lpWaveHdr);
+ } else {
+ TRACE("Starting loop (%ldx) with %p\n", lpWaveHdr->dwLoops, lpWaveHdr);
+ wwo->lpLoopPtr = lpWaveHdr;
+ /* Windows does not touch WAVEHDR.dwLoops,
+ * so we need to make an internal copy */
+ wwo->dwLoops = lpWaveHdr->dwLoops;
+ }
+ }
+}
+
+/**************************************************************************
+ * wodPlayer_PlayPtrNext [internal]
+ *
+ * Advance the play pointer to the next waveheader, looping if required.
+ */
+static LPWAVEHDR wodPlayer_PlayPtrNext(WINE_WAVEOUT* wwo)
+{
+ LPWAVEHDR lpWaveHdr = wwo->lpPlayPtr;
+
+ if ((lpWaveHdr->dwFlags & WHDR_ENDLOOP) && wwo->lpLoopPtr) {
+ /* We're at the end of a loop, loop if required */
+ if (--wwo->dwLoops > 0) {
+ wwo->lpPlayPtr = wwo->lpLoopPtr;
+ } else {
+ /* Handle overlapping loops correctly */
+ if (wwo->lpLoopPtr != lpWaveHdr && (lpWaveHdr->dwFlags & WHDR_BEGINLOOP)) {
+ FIXME("Correctly handled case ? (ending loop buffer also starts a new loop)\n");
+ /* shall we consider the END flag for the closing loop or for
+ * the opening one or for both ???
+ * code assumes for closing loop only
+ */
+ } else {
+ lpWaveHdr = lpWaveHdr->lpNext;
+ }
+ wwo->lpLoopPtr = NULL;
+ wodPlayer_BeginWaveHdr(wwo, lpWaveHdr);
+ }
+ } else {
+ /* We're not in a loop. Advance to the next wave header */
+ wodPlayer_BeginWaveHdr(wwo, lpWaveHdr = lpWaveHdr->lpNext);
+ }
+ return lpWaveHdr;
+}
+
+/**************************************************************************
+ * wodPlayer_WriteMaxFrags [internal]
+ * Writes the maximum number of bytes possible to the DSP and returns
+ * the number of bytes written.
+ */
+static int wodPlayer_WriteMaxFrags(WINE_WAVEOUT* wwo)
+{
+ DWORD len = wwo->lpPlayPtr->dwBufferLength;
+
+ buffer_resize(wwo, len);
+ memcpy(wwo->sound_buffer + wwo->BufferUsed, wwo->lpPlayPtr->lpData, len);
+ wwo->BufferUsed += len;
+ wwo->dwWrittenTotal += len;
+
+// if (wwo->BufferUsed < 8820 && wwo->writeBytes == 0)
+// return len;
+
+ if (wwo->freeBytes)
+ send_buffer(wwo);
+
+ return len;
+
+}
+
+
+/**************************************************************************
+ * wodPlayer_NotifyCompletions [internal]
+ *
+ * Notifies and remove from queue all wavehdrs which have been played to
+ * the speaker (ie. they have cleared the audio device). If force is true,
+ * we notify all wavehdrs and remove them all from the queue even if they
+ * are unplayed or part of a loop.
+ */
+static DWORD wodPlayer_NotifyCompletions(WINE_WAVEOUT* wwo, BOOL force)
+{
+ LPWAVEHDR lpWaveHdr;
+
+ /* Start from lpQueuePtr and keep notifying until:
+ * - we hit an unwritten wavehdr
+ * - we hit the beginning of a running loop
+ * - we hit a wavehdr which hasn't finished playing
+ */
+ while ((lpWaveHdr = wwo->lpQueuePtr) && (force || (lpWaveHdr != wwo->lpPlayPtr &&
+ lpWaveHdr != wwo->lpLoopPtr && lpWaveHdr->reserved <= wwo->dwPlayedTotal))) {
+
+ wwo->lpQueuePtr = lpWaveHdr->lpNext;
+
+ lpWaveHdr->dwFlags &= ~WHDR_INQUEUE;
+ lpWaveHdr->dwFlags |= WHDR_DONE;
+
+ wodNotifyClient(wwo, WOM_DONE, (DWORD)lpWaveHdr, 0);
+ }
+ return (lpWaveHdr && lpWaveHdr != wwo->lpPlayPtr && lpWaveHdr != wwo->lpLoopPtr) ?
+ 1 : 1;
+}
+
+/**************************************************************************
+ * wodPlayer_Reset [internal]
+ *
+ * wodPlayer helper. Resets current output stream.
+ */
+static void wodPlayer_Reset(WINE_WAVEOUT* wwo, BOOL reset)
+{
+ wodUpdatePlayedTotal(wwo);
+ wodPlayer_NotifyCompletions(wwo, FALSE); /* updates current notify list */
+
+ /* we aren't able to flush any data that has already been written */
+ /* to nas, otherwise we would do the flushing here */
+
+ if (reset) {
+ enum win_wm_message msg;
+ DWORD param;
+ HANDLE ev;
+
+ /* remove any buffer */
+ wodPlayer_NotifyCompletions(wwo, TRUE);
+
+ wwo->lpPlayPtr = wwo->lpQueuePtr = wwo->lpLoopPtr = NULL;
+ wwo->state = WINE_WS_STOPPED;
+ wwo->dwPlayedTotal = wwo->dwWrittenTotal = 0;
+
+ /* remove any existing message in the ring */
+ EnterCriticalSection(&wwo->msgRing.msg_crst);
+
+ /* return all pending headers in queue */
+ while (NAS_RetrieveRingMessage(&wwo->msgRing, &msg, ¶m, &ev))
+ {
+ TRACE("flushing msg\n");
+ if (msg != WINE_WM_HEADER)
+ {
+ FIXME("shouldn't have headers left\n");
+ SetEvent(ev);
+ continue;
+ }
+ ((LPWAVEHDR)param)->dwFlags &= ~WHDR_INQUEUE;
+ ((LPWAVEHDR)param)->dwFlags |= WHDR_DONE;
+
+ wodNotifyClient(wwo, WOM_DONE, param, 0);
+ }
+ ResetEvent(wwo->msgRing.msg_event);
+ LeaveCriticalSection(&wwo->msgRing.msg_crst);
+ } else {
+ if (wwo->lpLoopPtr) {
+ /* complicated case, not handled yet (could imply modifying the loop counter */
+ FIXME("Pausing while in loop isn't correctly handled yet, except strange results\n");
+ wwo->lpPlayPtr = wwo->lpLoopPtr;
+ wwo->dwWrittenTotal = wwo->dwPlayedTotal; /* this is wrong !!! */
+ } else {
+ /* the data already written is going to be played, so take */
+ /* this fact into account here */
+ wwo->dwPlayedTotal = wwo->dwWrittenTotal;
+ }
+ wwo->state = WINE_WS_PAUSED;
+ }
+}
+
+/**************************************************************************
+ * wodPlayer_ProcessMessages [internal]
+ */
+static void wodPlayer_ProcessMessages(WINE_WAVEOUT* wwo)
+{
+ LPWAVEHDR lpWaveHdr;
+ enum win_wm_message msg;
+ DWORD param;
+ HANDLE ev;
+
+ while (NAS_RetrieveRingMessage(&wwo->msgRing, &msg, ¶m, &ev)) {
+ TRACE("Received %s %lx\n", wodPlayerCmdString[msg - WM_USER - 1], param);
+ switch (msg) {
+ case WINE_WM_PAUSING:
+ wodPlayer_Reset(wwo, FALSE);
+ SetEvent(ev);
+ break;
+ case WINE_WM_RESTARTING:
+ wwo->state = WINE_WS_PLAYING;
+ SetEvent(ev);
+ break;
+ case WINE_WM_HEADER:
+ lpWaveHdr = (LPWAVEHDR)param;
+
+ /* insert buffer at the end of queue */
+ {
+ LPWAVEHDR* wh;
+ for (wh = &(wwo->lpQueuePtr); *wh; wh = &((*wh)->lpNext));
+ *wh = lpWaveHdr;
+ }
+ if (!wwo->lpPlayPtr)
+ wodPlayer_BeginWaveHdr(wwo,lpWaveHdr);
+ if (wwo->state == WINE_WS_STOPPED)
+ wwo->state = WINE_WS_PLAYING;
+ break;
+ case WINE_WM_RESETTING:
+ wodPlayer_Reset(wwo, TRUE);
+ SetEvent(ev);
+ break;
+ case WINE_WM_UPDATE:
+ wodUpdatePlayedTotal(wwo);
+ SetEvent(ev);
+ break;
+ case WINE_WM_BREAKLOOP:
+ if (wwo->state == WINE_WS_PLAYING && wwo->lpLoopPtr != NULL) {
+ /* ensure exit at end of current loop */
+ wwo->dwLoops = 1;
+ }
+ SetEvent(ev);
+ break;
+ case WINE_WM_CLOSING:
+ // sanity check: this should not happen since the device must have been reset before
+ if (wwo->lpQueuePtr || wwo->lpPlayPtr) ERR("out of sync\n");
+ wwo->hThread = 0;
+ wwo->state = WINE_WS_CLOSED;
+ SetEvent(ev);
+ ExitThread(0);
+ // shouldn't go here
+ default:
+ FIXME("unknown message %d\n", msg);
+ break;
+ }
+ }
+}
+
+/**************************************************************************
+ * wodPlayer_FeedDSP [internal]
+ * Feed as much sound data as we can into the DSP and return the number of
+ * milliseconds before it will be necessary to feed the DSP again.
+ */
+static DWORD wodPlayer_FeedDSP(WINE_WAVEOUT* wwo)
+{
+ wodUpdatePlayedTotal(wwo);
+
+ // Feed wavehdrs until we run out of wavehdrs or DSP space
+ while(wwo->lpPlayPtr) {
+ TRACE("feeding waveheaders until we run out of space\n");
+ wwo->lpPlayPtr->reserved = wwo->dwWrittenTotal + wwo->lpPlayPtr->dwBufferLength;
+ wodPlayer_WriteMaxFrags(wwo);
+ wodPlayer_PlayPtrNext(wwo);
+ wodUpdatePlayedTotal(wwo);
+ }
+
+ return 1;
+}
+
+
+/**************************************************************************
+ * wodPlayer [internal]
+ */
+static DWORD CALLBACK wodPlayer(LPVOID pmt)
+{
+ WORD uDevID = (DWORD)pmt;
+ WINE_WAVEOUT* wwo = (WINE_WAVEOUT*)&WOutDev[uDevID];
+ DWORD dwNextFeedTime = INFINITE; /* Time before DSP needs feeding */
+ DWORD dwNextNotifyTime = INFINITE; /* Time before next wave completion */
+ DWORD dwSleepTime;
+
+ wwo->state = WINE_WS_STOPPED;
+ SetEvent(wwo->hStartUpEvent);
+
+ for (;;) {
+ /** Wait for the shortest time before an action is required. If there
+ * are no pending actions, wait forever for a command.
+ */
+ dwSleepTime = min(dwNextFeedTime, dwNextNotifyTime);
+ TRACE("waiting %lums (%lu,%lu)\n", dwSleepTime, dwNextFeedTime, dwNextNotifyTime);
+ AuHandleEvents(wwo->AuServ);
+ WaitForSingleObject(wwo->msgRing.msg_event, 1);
+ wodPlayer_ProcessMessages(wwo);
+ if (wwo->state == WINE_WS_PLAYING) {
+ dwNextFeedTime = wodPlayer_FeedDSP(wwo);
+ dwNextNotifyTime = wodPlayer_NotifyCompletions(wwo, FALSE);
+ } else {
+ dwNextFeedTime = dwNextNotifyTime = INFINITE;
+ }
+ }
+}
+
+/**************************************************************************
+ * wodGetDevCaps [internal]
+ */
+static DWORD wodGetDevCaps(WORD wDevID, LPWAVEOUTCAPSA lpCaps, DWORD dwSize)
+{
+ TRACE("(%u, %p, %lu);\n", wDevID, lpCaps, dwSize);
+
+ if (lpCaps == NULL) return MMSYSERR_NOTENABLED;
+
+ if (wDevID >= MAX_WAVEOUTDRV) {
+ TRACE("MAX_WAVOUTDRV reached !\n");
+ return MMSYSERR_BADDEVICEID;
+ }
+
+ memcpy(lpCaps, &WOutDev[wDevID].caps, min(dwSize, sizeof(*lpCaps)));
+ return MMSYSERR_NOERROR;
+}
+
+/**************************************************************************
+ * wodOpen [internal]
+ */
+static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
+{
+ WINE_WAVEOUT* wwo;
+
+ TRACE("wodOpen (%u, %p, %08lX);\n", wDevID, lpDesc, dwFlags);
+
+ if (lpDesc == NULL) {
+ WARN("Invalid Parameter !\n");
+ return MMSYSERR_INVALPARAM;
+ }
+ if (wDevID >= MAX_WAVEOUTDRV) {
+ TRACE("MAX_WAVOUTDRV reached !\n");
+ return MMSYSERR_BADDEVICEID;
+ }
+
+ /* if this device is already open tell the app that it is allocated */
+
+ wwo = &WOutDev[wDevID];
+
+ if(wwo->open)
+ {
+ TRACE("device already allocated\n");
+ return MMSYSERR_ALLOCATED;
+ }
+
+
+ /* only PCM format is supported so far... */
+ if (lpDesc->lpFormat->wFormatTag != WAVE_FORMAT_PCM ||
+ lpDesc->lpFormat->nChannels == 0 ||
+ lpDesc->lpFormat->nSamplesPerSec == 0) {
+ WARN("Bad format: tag=%04X nChannels=%d nSamplesPerSec=%ld !\n",
+ lpDesc->lpFormat->wFormatTag, lpDesc->lpFormat->nChannels,
+ lpDesc->lpFormat->nSamplesPerSec);
+ return WAVERR_BADFORMAT;
+ }
+
+ if (dwFlags & WAVE_FORMAT_QUERY) {
+ TRACE("Query format: tag=%04X nChannels=%d nSamplesPerSec=%ld !\n",
+ lpDesc->lpFormat->wFormatTag, lpDesc->lpFormat->nChannels,
+ lpDesc->lpFormat->nSamplesPerSec);
+ return MMSYSERR_NOERROR;
+ }
+
+ /* direct sound not supported, ignore the flag */
+ dwFlags &= ~WAVE_DIRECTSOUND;
+
+ wwo->wFlags = HIWORD(dwFlags & CALLBACK_TYPEMASK);
+
+ memcpy(&wwo->waveDesc, lpDesc, sizeof(WAVEOPENDESC));
+ memcpy(&wwo->format, lpDesc->lpFormat, sizeof(PCMWAVEFORMAT));
+
+ if (wwo->format.wBitsPerSample == 0) {
+ WARN("Resetting zeroed wBitsPerSample\n");
+ wwo->format.wBitsPerSample = 8 *
+ (wwo->format.wf.nAvgBytesPerSec /
+ wwo->format.wf.nSamplesPerSec) /
+ wwo->format.wf.nChannels;
+ }
+
+ if (!nas_open(wwo))
+ return MMSYSERR_ALLOCATED;
+
+ NAS_InitRingMessage(&wwo->msgRing);
+
+ /* create player thread */
+ if (!(dwFlags & WAVE_DIRECTSOUND)) {
+ wwo->hStartUpEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
+ wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD)wDevID, 0, &(wwo->dwThreadID));
+ WaitForSingleObject(wwo->hStartUpEvent, INFINITE);
+ CloseHandle(wwo->hStartUpEvent);
+ } else {
+ wwo->hThread = INVALID_HANDLE_VALUE;
+ wwo->dwThreadID = 0;
+ }
+ wwo->hStartUpEvent = INVALID_HANDLE_VALUE;
+
+ TRACE("stream=0x%lx, dwBufferSize=%ld\n", (long)wwo->AuServ, wwo->dwBufferSize);
+
+ TRACE("wBitsPerSample=%u nAvgBytesPerSec=%lu nSamplesPerSec=%lu nChannels=%u nBlockAlign=%u\n",
+ wwo->format.wBitsPerSample, wwo->format.wf.nAvgBytesPerSec,
+ wwo->format.wf.nSamplesPerSec, wwo->format.wf.nChannels,
+ wwo->format.wf.nBlockAlign);
+
+ return wodNotifyClient(wwo, WOM_OPEN, 0L, 0L);
+}
+
+/**************************************************************************
+ * wodClose [internal]
+ */
+static DWORD wodClose(WORD wDevID)
+{
+ DWORD ret = MMSYSERR_NOERROR;
+ WINE_WAVEOUT* wwo;
+
+ TRACE("(%u);\n", wDevID);
+
+ if (wDevID >= MAX_WAVEOUTDRV || AuServ == NULL)
+ {
+ WARN("bad device ID !\n");
+ return MMSYSERR_BADDEVICEID;
+ }
+
+/*
+ret = WAVERR_STILLPLAYING;
+return ret;
+*/
+ wwo = &WOutDev[wDevID];
+ if (wwo->lpQueuePtr) {
+ WARN("buffers still playing !\n");
+ ret = WAVERR_STILLPLAYING;
+ } else {
+ TRACE("imhere[3-close]\n");
+ if (wwo->hThread != INVALID_HANDLE_VALUE) {
+ NAS_AddRingMessage(&wwo->msgRing, WINE_WM_CLOSING, 0, TRUE);
+ }
+
+ NAS_DestroyRingMessage(&wwo->msgRing);
+
+ NAS_CloseDevice(wwo); /* close the stream and clean things up */
+
+ ret = wodNotifyClient(wwo, WOM_CLOSE, 0L, 0L);
+ }
+ return ret;
+}
+
+/**************************************************************************
+ * wodWrite [internal]
+ *
+ */
+static DWORD wodWrite(WORD wDevID, LPWAVEHDR lpWaveHdr, DWORD dwSize)
+{
+ TRACE("(%u, %p, %08lX);\n", wDevID, lpWaveHdr, dwSize);
+
+ /* first, do the sanity checks... */
+ if (wDevID >= MAX_WAVEOUTDRV || AuServ == NULL)
+ {
+ WARN("bad dev ID !\n");
+ return MMSYSERR_BADDEVICEID;
+ }
+
+ if (lpWaveHdr->lpData == NULL || !(lpWaveHdr->dwFlags & WHDR_PREPARED))
+ {
+ TRACE("unprepared\n");
+ return WAVERR_UNPREPARED;
+ }
+
+ if (lpWaveHdr->dwFlags & WHDR_INQUEUE)
+ {
+ TRACE("still playing\n");
+ return WAVERR_STILLPLAYING;
+ }
+
+ lpWaveHdr->dwFlags &= ~WHDR_DONE;
+ lpWaveHdr->dwFlags |= WHDR_INQUEUE;
+ lpWaveHdr->lpNext = 0;
+
+ TRACE("adding ring message\n");
+ NAS_AddRingMessage(&WOutDev[wDevID].msgRing, WINE_WM_HEADER, (DWORD)lpWaveHdr, FALSE);
+
+ return MMSYSERR_NOERROR;
+}
+
+/**************************************************************************
+ * wodPrepare [internal]
+ */
+static DWORD wodPrepare(WORD wDevID, LPWAVEHDR lpWaveHdr, DWORD dwSize)
+{
+ TRACE("(%u, %p, %08lX);\n", wDevID, lpWaveHdr, dwSize);
+
+ if (wDevID >= MAX_WAVEOUTDRV) {
+ WARN("bad device ID !\n");
+ return MMSYSERR_BADDEVICEID;
+ }
+
+ if (lpWaveHdr->dwFlags & WHDR_INQUEUE)
+ return WAVERR_STILLPLAYING;
+
+ lpWaveHdr->dwFlags |= WHDR_PREPARED;
+ lpWaveHdr->dwFlags &= ~WHDR_DONE;
+ return MMSYSERR_NOERROR;
+}
+
+/**************************************************************************
+ * wodUnprepare [internal]
+ */
+static DWORD wodUnprepare(WORD wDevID, LPWAVEHDR lpWaveHdr, DWORD dwSize)
+{
+ TRACE("(%u, %p, %08lX);\n", wDevID, lpWaveHdr, dwSize);
+
+ if (wDevID >= MAX_WAVEOUTDRV) {
+ WARN("bad device ID !\n");
+ return MMSYSERR_BADDEVICEID;
+ }
+
+ if (lpWaveHdr->dwFlags & WHDR_INQUEUE)
+ return WAVERR_STILLPLAYING;
+
+ lpWaveHdr->dwFlags &= ~WHDR_PREPARED;
+ lpWaveHdr->dwFlags |= WHDR_DONE;
+
+ return MMSYSERR_NOERROR;
+}
+
+/**************************************************************************
+ * wodPause [internal]
+ */
+static DWORD wodPause(WORD wDevID)
+{
+ TRACE("(%u);!\n", wDevID);
+
+ if (wDevID >= MAX_WAVEOUTDRV || AuServ == NULL)
+ {
+ WARN("bad device ID !\n");
+ return MMSYSERR_BADDEVICEID;
+ }
+
+ TRACE("imhere[3-PAUSING]\n");
+ NAS_AddRingMessage(&WOutDev[wDevID].msgRing, WINE_WM_PAUSING, 0, TRUE);
+
+ return MMSYSERR_NOERROR;
+}
+
+/**************************************************************************
+ * wodRestart [internal]
+ */
+static DWORD wodRestart(WORD wDevID)
+{
+ TRACE("(%u);\n", wDevID);
+
+ if (wDevID >= MAX_WAVEOUTDRV || AuServ == NULL)
+ {
+ WARN("bad device ID !\n");
+ return MMSYSERR_BADDEVICEID;
+ }
+
+ if (WOutDev[wDevID].state == WINE_WS_PAUSED) {
+ TRACE("imhere[3-RESTARTING]\n");
+ NAS_AddRingMessage(&WOutDev[wDevID].msgRing, WINE_WM_RESTARTING, 0, TRUE);
+ }
+
+ /* FIXME: is NotifyClient with WOM_DONE right ? (Comet Busters 1.3.3 needs this notification) */
+ /* FIXME: Myst crashes with this ... hmm -MM
+ return wodNotifyClient(wwo, WOM_DONE, 0L, 0L);
+ */
+
+ return MMSYSERR_NOERROR;
+}
+
+/**************************************************************************
+ * wodReset [internal]
+ */
+static DWORD wodReset(WORD wDevID)
+{
+ TRACE("(%u);\n", wDevID);
+
+ if (wDevID >= MAX_WAVEOUTDRV || AuServ == NULL)
+ {
+ WARN("bad device ID !\n");
+ return MMSYSERR_BADDEVICEID;
+ }
+
+ TRACE("imhere[3-RESET]\n");
+ NAS_AddRingMessage(&WOutDev[wDevID].msgRing, WINE_WM_RESETTING, 0, TRUE);
+
+ return MMSYSERR_NOERROR;
+}
+
+/**************************************************************************
+ * wodGetPosition [internal]
+ */
+static DWORD wodGetPosition(WORD wDevID, LPMMTIME lpTime, DWORD uSize)
+{
+ int time;
+ DWORD val;
+ WINE_WAVEOUT* wwo;
+
+ TRACE("%u, %p, %lu);\n", wDevID, lpTime, uSize);
+
+ if (wDevID >= MAX_WAVEOUTDRV || AuServ == NULL)
+ {
+ WARN("bad device ID !\n");
+ return MMSYSERR_BADDEVICEID;
+ }
+
+ if (lpTime == NULL) return MMSYSERR_INVALPARAM;
+
+ wwo = &WOutDev[wDevID];
+ NAS_AddRingMessage(&wwo->msgRing, WINE_WM_UPDATE, 0, TRUE);
+ val = wwo->dwPlayedTotal;
+
+ TRACE("wType=%04X wBitsPerSample=%u nSamplesPerSec=%lu nChannels=%u nAvgBytesPerSec=%lu\n",
+ lpTime->wType, wwo->format.wBitsPerSample,
+ wwo->format.wf.nSamplesPerSec, wwo->format.wf.nChannels,
+ wwo->format.wf.nAvgBytesPerSec);
+ TRACE("dwPlayedTotal=%lu\n", val);
+
+ switch (lpTime->wType) {
+ case TIME_BYTES:
+ lpTime->u.cb = val;
+ TRACE("TIME_BYTES=%lu\n", lpTime->u.cb);
+ break;
+ case TIME_SAMPLES:
+ lpTime->u.sample = val * 8 / wwo->format.wBitsPerSample /wwo->format.wf.nChannels;
+ TRACE("TIME_SAMPLES=%lu\n", lpTime->u.sample);
+ break;
+ case TIME_SMPTE:
+ time = val / (wwo->format.wf.nAvgBytesPerSec / 1000);
+ lpTime->u.smpte.hour = time / 108000;
+ time -= lpTime->u.smpte.hour * 108000;
+ lpTime->u.smpte.min = time / 1800;
+ time -= lpTime->u.smpte.min * 1800;
+ lpTime->u.smpte.sec = time / 30;
+ time -= lpTime->u.smpte.sec * 30;
+ lpTime->u.smpte.frame = time;
+ lpTime->u.smpte.fps = 30;
+ TRACE("TIME_SMPTE=%02u:%02u:%02u:%02u\n",
+ lpTime->u.smpte.hour, lpTime->u.smpte.min,
+ lpTime->u.smpte.sec, lpTime->u.smpte.frame);
+ break;
+ default:
+ FIXME("Format %d not supported ! use TIME_MS !\n", lpTime->wType);
+ lpTime->wType = TIME_MS;
+ case TIME_MS:
+ lpTime->u.ms = val / (wwo->format.wf.nAvgBytesPerSec / 1000);
+ TRACE("TIME_MS=%lu\n", lpTime->u.ms);
+ break;
+ }
+ return MMSYSERR_NOERROR;
+}
+
+/**************************************************************************
+ * wodBreakLoop [internal]
+ */
+static DWORD wodBreakLoop(WORD wDevID)
+{
+ TRACE("(%u);\n", wDevID);
+
+ if (wDevID >= MAX_WAVEOUTDRV || AuServ == NULL)
+ {
+ WARN("bad device ID !\n");
+ return MMSYSERR_BADDEVICEID;
+ }
+ NAS_AddRingMessage(&WOutDev[wDevID].msgRing, WINE_WM_BREAKLOOP, 0, TRUE);
+ return MMSYSERR_NOERROR;
+}
+
+/**************************************************************************
+ * wodGetVolume [internal]
+ */
+static DWORD wodGetVolume(WORD wDevID, LPDWORD lpdwVol)
+{
+ DWORD left, right;
+
+ left = WOutDev[wDevID].volume_left;
+ right = WOutDev[wDevID].volume_right;
+
+ TRACE("(%u, %p);\n", wDevID, lpdwVol);
+
+ *lpdwVol = ((left * 0xFFFFl) / 100) + (((right * 0xFFFFl) / 100) << 16);
+
+ return MMSYSERR_NOERROR;
+}
+
+/**************************************************************************
+ * wodSetVolume [internal]
+ */
+static DWORD wodSetVolume(WORD wDevID, DWORD dwParam)
+{
+ DWORD left, right;
+
+ left = (LOWORD(dwParam) * 100) / 0xFFFFl;
+ right = (HIWORD(dwParam) * 100) / 0xFFFFl;
+
+ TRACE("(%u, %08lX);\n", wDevID, dwParam);
+
+ WOutDev[wDevID].volume_left = left;
+ WOutDev[wDevID].volume_right = right;
+
+ return MMSYSERR_NOERROR;
+}
+
+/**************************************************************************
+ * wodGetNumDevs [internal]
+ */
+static DWORD wodGetNumDevs(void)
+{
+ return MAX_WAVEOUTDRV;
+}
+
+/**************************************************************************
+ * wodMessage (WINENAS.@)
+ */
+DWORD WINAPI NAS_wodMessage(UINT wDevID, UINT wMsg, DWORD dwUser,
+ DWORD dwParam1, DWORD dwParam2)
+{
+ TRACE("(%u, %04X, %08lX, %08lX, %08lX);\n", wDevID, wMsg, dwUser, dwParam1, dwParam2);
+
+ switch (wMsg) {
+ case DRVM_INIT:
+ case DRVM_EXIT:
+ case DRVM_ENABLE:
+ case DRVM_DISABLE:
+ /* FIXME: Pretend this is supported */
+ return 0;
+ case WODM_OPEN: return wodOpen (wDevID, (LPWAVEOPENDESC)dwParam1, dwParam2);
+ case WODM_CLOSE: return wodClose (wDevID);
+ case WODM_WRITE: return wodWrite (wDevID, (LPWAVEHDR)dwParam1, dwParam2);
+ case WODM_PAUSE: return wodPause (wDevID);
+ case WODM_GETPOS: return wodGetPosition (wDevID, (LPMMTIME)dwParam1, dwParam2);
+ case WODM_BREAKLOOP: return wodBreakLoop (wDevID);
+ case WODM_PREPARE: return wodPrepare (wDevID, (LPWAVEHDR)dwParam1, dwParam2);
+ case WODM_UNPREPARE: return wodUnprepare (wDevID, (LPWAVEHDR)dwParam1, dwParam2);
+ case WODM_GETDEVCAPS: return wodGetDevCaps (wDevID, (LPWAVEOUTCAPSA)dwParam1, dwParam2);
+ case WODM_GETNUMDEVS: return wodGetNumDevs ();
+ case WODM_GETPITCH: return MMSYSERR_NOTSUPPORTED;
+ case WODM_SETPITCH: return MMSYSERR_NOTSUPPORTED;
+ case WODM_GETPLAYBACKRATE: return MMSYSERR_NOTSUPPORTED;
+ case WODM_SETPLAYBACKRATE: return MMSYSERR_NOTSUPPORTED;
+ case WODM_GETVOLUME: return wodGetVolume (wDevID, (LPDWORD)dwParam1);
+ case WODM_SETVOLUME: return wodSetVolume (wDevID, dwParam1);
+ case WODM_RESTART: return wodRestart (wDevID);
+ case WODM_RESET: return wodReset (wDevID);
+
+ case DRV_QUERYDSOUNDIFACE: return wodDsCreate(wDevID, (PIDSDRIVER*)dwParam1);
+ default:
+ FIXME("unknown message %d!\n", wMsg);
+ }
+ return MMSYSERR_NOTSUPPORTED;
+}
+
+/*======================================================================*
+ * Low level DSOUND implementation *
+ *======================================================================*/
+static DWORD wodDsCreate(UINT wDevID, PIDSDRIVER* drv)
+{
+ /* we can't perform memory mapping as we don't have a file stream
+ interface with nas like we do with oss */
+ MESSAGE("This sound card s driver does not support direct access\n");
+ MESSAGE("The (slower) DirectSound HEL mode will be used instead.\n");
+ return MMSYSERR_NOTSUPPORTED;
+}
+
+static int nas_init(void) {
+ TRACE("NAS INIT\n");
+ if (!(AuServ = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL)))
+ return 0;
+
+ return 1;
+}
+
+static int nas_dev(WINE_WAVEOUT* wwo) {
+ int i;
+
+ for (i = 0; i < AuServerNumDevices(wwo->AuServ); i++) {
+ if ((AuDeviceKind(AuServerDevice(wwo->AuServ, i)) ==
+ AuComponentKindPhysicalOutput) &&
+ AuDeviceNumTracks(AuServerDevice(wwo->AuServ, i)) == wwo->format.wf.nChannels)
+ {
+ wwo->AuDev = AuDeviceIdentifier(AuServerDevice(wwo->AuServ, i));
+ break;
+ }
+ }
+
+ if (wwo->AuDev == AuNone)
+ return 0;
+ return 1;
+}
+
+static int nas_open(WINE_WAVEOUT* wwo) {
+ AuElement elements[3];
+ AuEvent ev;
+ AFormat fmt;
+
+ if (!wwo->AuServ)
+ return 0;
+
+ if (!nas_dev(wwo))
+ return 0;
+
+ if (!(wwo->AuFlow = AuCreateFlow(wwo->AuServ, NULL)))
+ return 0;
+
+ wwo->dwBufferSize = (2500 * wwo->format.wf.nSamplesPerSec) / 1000;
+
+ fmt = wwo->format.wBitsPerSample == 16 ? AuFormatLinearSigned16LSB : AuFormatLinearUnsigned8;
+ wwo->bps = wwo->format.wf.nSamplesPerSec * wwo->format.wf.nChannels * AuSizeofFormat(fmt);
+
+ wwo->dwBufferSize = 4096;//8820;//FRAG_SIZE * FRAG_COUNT;
+
+ AuRegisterEventHandler(wwo->AuServ, AuEventHandlerIDMask, 0, wwo->AuFlow,
+ event_handler, (AuPointer) wwo);
+
+ AuMakeElementImportClient(&elements[0], wwo->format.wf.nSamplesPerSec,
+ wwo->format.wBitsPerSample == 16 ? AuFormatLinearSigned16LSB : AuFormatLinearUnsigned8,
+ wwo->format.wf.nChannels, AuTrue, wwo->dwBufferSize, wwo->dwBufferSize / 2, 0, NULL);
+
+ AuMakeElementExportDevice(&elements[1], 0, wwo->AuDev, wwo->format.wf.nSamplesPerSec,
+ AuUnlimitedSamples, 0, NULL);
+
+ AuSetElements(wwo->AuServ, wwo->AuFlow, AuTrue, 2, elements, NULL);
+
+
+ wwo->dwPlayedTotal = 0;
+ wwo->dwWrittenTotal = 0;
+
+ wwo->dwPlayedTotal = 0;
+ wwo->dwWrittenTotal = 0;
+ wwo->open = 1;
+
+ wwo->BufferUsed = 0;
+ wwo->sendBytes = 0;
+ wwo->writeBytes = 0;
+ wwo->freeBytes = -1;
+ wwo->gettime = 0;
+ wwo->sound_buffer = NULL;
+ gettimeofday(&wwo->last_tv, 0);
+
+ AuStartFlow(wwo->AuServ, wwo->AuFlow, NULL);
+
+ AuNextEvent(wwo->AuServ, AuTrue, &ev);
+ AuDispatchEvent(wwo->AuServ, &ev);
+
+ return 1;
+}
+
+static AuBool
+event_handler(AuServer* aud, AuEvent* ev, AuEventHandlerRec* hnd)
+{
+ WINE_WAVEOUT *wwo = (WINE_WAVEOUT *)hnd->data;
+ switch (ev->type) {
+
+ case AuEventTypeElementNotify: {
+ AuElementNotifyEvent* event = (AuElementNotifyEvent *)ev;
+
+
+ TRACE("event_handler: kind %s state %s->%s reason %s numbytes %ld freeB %d maxB %d\n",
+ nas_elementnotify_kind(event->kind),
+ nas_state(event->prev_state),
+ nas_state(event->cur_state),
+ nas_reason(event->reason),
+ event->num_bytes, wwo->freeBytes, wwo->maxBytes);
+
+
+ switch (event->kind) {
+ case AuElementNotifyKindLowWater:
+ if (wwo->freeBytes >= 0) {
+ wwo->sendBytes += event->num_bytes;
+ wwo->freeBytes += event->num_bytes;
+ send_buffer(wwo);
+ } else {
+ wwo->freeBytes = event->num_bytes;
+ wwo->maxBytes = event->num_bytes;
+ }
+ break;
+ case AuElementNotifyKindState:
+ if (event->cur_state == AuStatePause && event->reason != AuReasonUser) {
+ if (wwo->freeBytes >= 0) {
+ wwo->sendBytes += event->num_bytes;
+ wwo->freeBytes += event->num_bytes;
+ send_buffer(wwo);
+ } else {
+ wwo->freeBytes = event->num_bytes;
+ wwo->maxBytes = event->num_bytes;
+ }
+ }
+ break;
+ }
+ }
+ }
+ return AuTrue;
+}
+
+static void
+buffer_resize(WINE_WAVEOUT* wwo, int len)
+{
+ void *newbuf = malloc(wwo->BufferUsed + len);
+ void *oldbuf = wwo->sound_buffer;
+ memcpy(newbuf, oldbuf, wwo->BufferUsed);
+ wwo->sound_buffer = newbuf;
+ if (oldbuf != NULL)
+ free(oldbuf);
+}
+
+static int send_buffer(WINE_WAVEOUT* wwo) {
+ int len;
+ char *ptr, *newdata;
+ newdata = NULL;
+
+ if (!wwo->freeBytes)
+ return 0;
+
+ if (wwo->sound_buffer == NULL || wwo->BufferUsed == 0)
+ return 0;
+
+ if (wwo->BufferUsed <= wwo->freeBytes) {
+ len = wwo->BufferUsed;
+ ptr = wwo->sound_buffer;
+ } else {
+ len = wwo->freeBytes;
+ ptr = malloc(len);
+ memcpy(ptr,wwo->sound_buffer,len);
+ newdata = malloc(wwo->BufferUsed - len);
+ memcpy(newdata, wwo->sound_buffer + len, wwo->BufferUsed - len);
+ }
+
+TRACE("envoye de %d bytes / %d bytes\n", len, wwo->BufferUsed);
+
+ wwo->BufferUsed -= len;
+
+ AuWriteElement(wwo->AuServ, wwo->AuFlow, 0, len, ptr, AuFalse, NULL);
+
+ gettimeofday(&wwo->last_tv,0);
+ wwo->freeBytes -= len;
+ wwo->writeBytes += len;
+
+ if (wwo->sound_buffer != NULL)
+ free(wwo->sound_buffer);
+
+ wwo->sound_buffer = NULL;
+
+ if (newdata != NULL)
+ wwo->sound_buffer = newdata;
+
+ return len;
+}
+
+static int nas_close(WINE_WAVEOUT* wwo)
+{
+ AuEvent ev;
+ AuFlush(wwo->AuServ);
+
+ if (wwo->writeBytes > 0) {
+ while (wwo->sendBytes != wwo->writeBytes) {
+ AuNextEvent(wwo->AuServ, AuTrue, &ev);
+ AuDispatchEvent(wwo->AuServ, &ev);
+ send_buffer(wwo);
+ }
+ }
+
+ AuStopFlow(wwo->AuServ, wwo->AuFlow, NULL);
+ AuDestroyFlow(wwo->AuServ, wwo->AuFlow, NULL);
+
+ AuNextEvent(wwo->AuServ, AuTrue, &ev);
+ AuDispatchEvent(wwo->AuServ, &ev);
+
+ wwo->AuFlow = 0;
+ wwo->open = 0;
+ return 1;
+}
+
+static int nas_end(void)
+{
+ AuCloseServer(AuServ);
+ AuServ = 0;
+ return 1;
+}
+
+int
+nas_getdelay(WINE_WAVEOUT* wwo)
+{
+ static struct timeval now_tv;
+ static int temp, temp2;
+ int retval = 0;
+
+ gettimeofday(&now_tv, 0);
+ temp = now_tv.tv_sec - wwo->last_tv.tv_sec;
+ temp *= 44100;
+
+ temp2 = now_tv.tv_usec - wwo->last_tv.tv_usec;
+ temp2 /= 1000;
+ temp2 *= 44100;
+ temp2 /= 1000;
+ temp += temp2;
+
+ retval = temp - 32768;
+
+ if (retval < 0) retval = 0;
+
+ return (retval);
+}
+
+#else /* !HAVE_NAS */
+
+/**************************************************************************
+ * wodMessage (WINENAS.@)
+ */
+DWORD WINAPI NAS_wodMessage(WORD wDevID, WORD wMsg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2)
+{
+ FIXME("(%u, %04X, %08lX, %08lX, %08lX):stub\n", wDevID, wMsg, dwUser, dwParam1, dwParam2);
+ return MMSYSERR_NOTENABLED;
+}
+#endif
diff --git a/dlls/winmm/winenas/nas.c b/dlls/winmm/winenas/nas.c
new file mode 100644
index 0000000..afce103
--- /dev/null
+++ b/dlls/winmm/winenas/nas.c
@@ -0,0 +1,93 @@
+/* -*- tab-width: 8; c-basic-offset: 4 -*- */
+/*
+ *
+ * Wine Driver for NAS Network Audio System
+ * http://radscan.com/nas.html
+ *
+ * Copyright 2002 Nicolas Escuder <n.escuder@alineanet.com>
+ *
+ * Code massively copied from Eric Pouech's OSS driver
+ * and Chris Morgan aRts driver
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "config.h"
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "mmddk.h"
+#include "nas.h"
+
+#ifdef HAVE_NAS
+static int nas = 0;
+
+/**************************************************************************
+ * NAS_drvOpen [internal]
+ */
+static DWORD NAS_drvOpen(LPSTR str)
+{
+ if (nas)
+ return 0;
+
+ /* I know, this is ugly, but who cares... */
+ nas = 1;
+ return 1;
+}
+
+/**************************************************************************
+ * NAS_drvClose [internal]
+ */
+static DWORD NAS_drvClose(DWORD dwDevID)
+{
+ if (nas) {
+ nas = 0;
+ return 1;
+ }
+ return 0;
+}
+#endif /* #ifdef HAVE_NAS */
+
+
+/**************************************************************************
+ * DriverProc (WINENAS.@)
+ */
+LONG CALLBACK NAS_DriverProc(DWORD dwDevID, HDRVR hDriv, DWORD wMsg,
+ DWORD dwParam1, DWORD dwParam2)
+{
+/* EPP TRACE("(%08lX, %04X, %08lX, %08lX, %08lX)\n", */
+/* EPP dwDevID, hDriv, wMsg, dwParam1, dwParam2); */
+
+ switch(wMsg) {
+#ifdef HAVE_NAS
+ case DRV_LOAD: NAS_WaveInit();
+/* NAS_MidiInit(); FIXME: no midi */
+ return 1;
+ case DRV_FREE: return NAS_WaveClose();
+ case DRV_OPEN: return NAS_drvOpen((LPSTR)dwParam1);
+ case DRV_CLOSE: return NAS_drvClose(dwDevID);
+ case DRV_ENABLE: return 1;
+ case DRV_DISABLE: return 1;
+ case DRV_QUERYCONFIGURE: return 1;
+ case DRV_CONFIGURE: MessageBoxA(0, "NAS MultiMedia Driver !", "NAS Driver", MB_OK); return 1;
+ case DRV_INSTALL: return DRVCNF_RESTART;
+ case DRV_REMOVE: return DRVCNF_RESTART;
+#endif
+ default:
+ return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
+ }
+}
diff --git a/dlls/winmm/winenas/nas.h b/dlls/winmm/winenas/nas.h
new file mode 100644
index 0000000..15ef0ad
--- /dev/null
+++ b/dlls/winmm/winenas/nas.h
@@ -0,0 +1,28 @@
+/* Definition for NAS driver : wine multimedia system
+ *
+ * Copyright 2002 Nicolas Escuder <n.escuder@alineanet.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __WINE_NAS_H
+#define __WINE_NAS_H
+
+extern LONG NAS_WaveInit(void);
+extern LONG NAS_WaveClose(void);
+
+typedef unsigned int AFormat;
+
+#endif /* __WINE_NAS_H */
diff --git a/dlls/winmm/winenas/winenas.drv.spec b/dlls/winmm/winenas/winenas.drv.spec
new file mode 100644
index 0000000..8167118
--- /dev/null
+++ b/dlls/winmm/winenas/winenas.drv.spec
@@ -0,0 +1,2 @@
+@ stdcall DriverProc(long long long long long) NAS_DriverProc
+@ stdcall wodMessage(long long long long long) NAS_wodMessage
diff --git a/include/config.h.in b/include/config.h.in
index 1a3e26b..28d7edd 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -35,6 +35,12 @@
/* Define to use .string instead of .ascii */
#undef HAVE_ASM_STRING
+/* Define to 1 if you have the <audio/audiolib.h> header file. */
+#undef HAVE_AUDIO_AUDIOLIB_H
+
+/* Define to 1 if you have the <audio/soundlib.h> header file. */
+#undef HAVE_AUDIO_SOUNDLIB_H
+
/* Define to 1 if you have the `chsize' function. */
#undef HAVE_CHSIZE
@@ -302,6 +308,9 @@
/* Define if struct msghdr contains msg_accrights */
#undef HAVE_MSGHDR_ACCRIGHTS
+/* Define if you have NAS including devel headers */
+#undef HAVE_NAS
+
/* Define to 1 if you have the <ncurses.h> header file. */
#undef HAVE_NCURSES_H