diff -urN wine-6.20-orig/configure wine-6.20/configure
--- wine-6.20-orig/configure	2021-10-23 04:44:24 +0900
+++ wine-6.20/configure	2021-10-26 11:55:15 +0900
@@ -649,6 +649,8 @@
 CUPS_CFLAGS
 CAPI20_LIBS
 CAPI20_CFLAGS
+FAUDIO_LIBS
+FAUDIO_CFLAGS
 SDL2_LIBS
 SDL2_CFLAGS
 UNWIND_LIBS
@@ -856,6 +858,7 @@
 with_coreaudio
 with_cups
 with_dbus
+with_faudio
 with_float_abi
 with_fontconfig
 with_freetype
@@ -1978,6 +1981,8 @@
 UNWIND_LIBS
 SDL2_CFLAGS
 SDL2_LIBS
+FAUDIO_CFLAGS
+FAUDIO_LIBS
 CAPI20_CFLAGS
 CAPI20_LIBS
 CUPS_CFLAGS
@@ -2645,6 +2650,7 @@
   --without-coreaudio     do not use the CoreAudio sound support
   --without-cups          do not use CUPS
   --without-dbus          do not use DBus (dynamic device support)
+  --without-faudio        do not use FAudio (XAudio2 support)
   --with-float-abi=abi    specify the ABI (soft|softfp|hard) for ARM platforms
   --without-fontconfig    do not use fontconfig
   --without-freetype      do not use the FreeType library
@@ -2798,6 +2804,9 @@
   UNWIND_LIBS Linker flags for libunwind, overriding pkg-config
   SDL2_CFLAGS C compiler flags for sdl2, overriding pkg-config
   SDL2_LIBS   Linker flags for sdl2, overriding pkg-config
+  FAUDIO_CFLAGS
+              C compiler flags for FAudio, overriding pkg-config
+  FAUDIO_LIBS Linker flags for FAudio, overriding pkg-config
   CAPI20_CFLAGS
               C compiler flags for capi20, overriding pkg-config
   CAPI20_LIBS Linker flags for capi20, overriding pkg-config
@@ -4030,6 +4039,12 @@
 fi
 
 
+# Check whether --with-faudio was given.
+if test "${with_faudio+set}" = set; then :
+  withval=$with_faudio;
+fi
+
+
 # Check whether --with-float-abi was given.
 if test "${with_float_abi+set}" = set; then :
   withval=$with_float_abi;
@@ -14665,6 +14680,123 @@
 
 fi
 
+if test "x$with_faudio" != "xno"
+then
+    if ${FAUDIO_CFLAGS:+false} :; then :
+  if ${PKG_CONFIG+:} false; then :
+  FAUDIO_CFLAGS=`$PKG_CONFIG --cflags FAudio 2>/dev/null`
+fi
+fi
+
+if ${FAUDIO_LIBS:+false} :; then :
+  if ${PKG_CONFIG+:} false; then :
+  FAUDIO_LIBS=`$PKG_CONFIG --libs FAudio 2>/dev/null`
+fi
+fi
+
+FAUDIO_LIBS=${FAUDIO_LIBS:-"-lFAudio"}
+$as_echo "$as_me:${as_lineno-$LINENO}: FAudio cflags: $FAUDIO_CFLAGS" >&5
+$as_echo "$as_me:${as_lineno-$LINENO}: FAudio libs: $FAUDIO_LIBS" >&5
+ac_save_CPPFLAGS=$CPPFLAGS
+CPPFLAGS="$CPPFLAGS $FAUDIO_CFLAGS"
+for ac_header in FAudio.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "FAudio.h" "ac_cv_header_FAudio_h" "$ac_includes_default"
+if test "x$ac_cv_header_FAudio_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_FAUDIO_H 1
+_ACEOF
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -lFAudio" >&5
+$as_echo_n "checking for -lFAudio... " >&6; }
+if ${ac_cv_lib_soname_FAudio+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_soname_save_LIBS=$LIBS
+LIBS="-lFAudio $FAUDIO_LIBS $LIBS"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char FAudioCreate ();
+int
+main ()
+{
+return FAudioCreate ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  case "$LIBEXT" in
+    dll) ac_cv_lib_soname_FAudio=`$ac_cv_path_LDD conftest.exe | grep "FAudio" | sed -e "s/dll.*/dll/"';2,$d'` ;;
+    dylib) ac_cv_lib_soname_FAudio=`$OTOOL -L conftest$ac_exeext | grep "libFAudio*\\.[0-9A-Za-z.]*dylib" | sed -e "s/^.*\/\(libFAudio*\.[0-9A-Za-z.]*dylib\).*$/\1/"';2,$d'` ;;
+    *) ac_cv_lib_soname_FAudio=`$READELF -d conftest$ac_exeext | grep "NEEDED.*libFAudio*\\.$LIBEXT" | sed -e "s/^.*\\[\\(libFAudio*\\.$LIBEXT[^	 ]*\\)\\].*$/\1/"';2,$d'`
+       if ${ac_cv_lib_soname_FAudio:+false} :; then :
+  ac_cv_lib_soname_FAudio=`$LDD conftest$ac_exeext | grep "libFAudio*\\.$LIBEXT" | sed -e "s/^.*\(libFAudio*\.$LIBEXT[^	 ]*\).*$/\1/"';2,$d'`
+fi ;;
+  esac
+else
+  ac_cv_lib_soname_FAudio=
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  LIBS=$ac_check_soname_save_LIBS
+fi
+if ${ac_cv_lib_soname_FAudio:+false} :; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_soname_FAudio" >&5
+$as_echo "$ac_cv_lib_soname_FAudio" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define SONAME_LIBFAUDIO "$ac_cv_lib_soname_FAudio"
+_ACEOF
+
+
+fi
+fi
+
+done
+
+             ac_wine_check_funcs_save_LIBS="$LIBS"
+LIBS="$LIBS $FAUDIO_LIBS"
+for ac_func in FAudio_CommitOperationSet \
+                                   F3DAudioInitialize8 \
+                                   FAudioLinkedVersion \
+                                   FAudioCreateReverb9WithCustomAllocatorEXT
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+LIBS="$ac_wine_check_funcs_save_LIBS"
+
+CPPFLAGS=$ac_save_CPPFLAGS
+
+fi
+if test "x$ac_cv_lib_soname_FAudio" = "x"; then :
+  case "x$with_faudio" in
+  x)   as_fn_append wine_notices "|libFAudio ${notice_platform}development files not found, XAudio2 won't be supported." ;;
+  xno) ;;
+  *)   as_fn_error $? "libFAudio ${notice_platform}development files not found, XAudio2 won't be supported.
+This is an error since --with-faudio was requested." "$LINENO" 5 ;;
+esac
+
+fi
+
 if test "x$with_capi" != "xno"
 then
     if ${CAPI20_CFLAGS:+false} :; then :
@@ -15368,6 +15500,45 @@
 enable_openal32=${enable_openal32:-no}
 fi
 
+if test "x$ac_cv_lib_soname_FAudio" = "x"
+then
+    enable_x3daudio1_0=${enable_x3daudio1_0:-no}
+    enable_x3daudio1_1=${enable_x3daudio1_1:-no}
+    enable_x3daudio1_2=${enable_x3daudio1_2:-no}
+    enable_x3daudio1_3=${enable_x3daudio1_3:-no}
+    enable_x3daudio1_4=${enable_x3daudio1_4:-no}
+    enable_x3daudio1_5=${enable_x3daudio1_5:-no}
+    enable_x3daudio1_6=${enable_x3daudio1_6:-no}
+    enable_x3daudio1_7=${enable_x3daudio1_7:-no}
+    enable_xactengine2_0=${enable_xactengine2_0:-no}
+    enable_xactengine2_4=${enable_xactengine2_4:-no}
+    enable_xactengine2_7=${enable_xactengine2_7:-no}
+    enable_xactengine2_9=${enable_xactengine2_9:-no}
+    enable_xactengine3_0=${enable_xactengine3_0:-no}
+    enable_xactengine3_1=${enable_xactengine3_1:-no}
+    enable_xactengine3_2=${enable_xactengine3_2:-no}
+    enable_xactengine3_3=${enable_xactengine3_3:-no}
+    enable_xactengine3_4=${enable_xactengine3_4:-no}
+    enable_xactengine3_5=${enable_xactengine3_5:-no}
+    enable_xactengine3_6=${enable_xactengine3_6:-no}
+    enable_xactengine3_7=${enable_xactengine3_7:-no}
+    enable_xapofx1_1=${enable_xapofx1_1:-no}
+    enable_xapofx1_2=${enable_xapofx1_2:-no}
+    enable_xapofx1_3=${enable_xapofx1_3:-no}
+    enable_xapofx1_4=${enable_xapofx1_4:-no}
+    enable_xapofx1_5=${enable_xapofx1_5:-no}
+    enable_xaudio2_0=${enable_xaudio2_0:-no}
+    enable_xaudio2_1=${enable_xaudio2_1:-no}
+    enable_xaudio2_2=${enable_xaudio2_2:-no}
+    enable_xaudio2_3=${enable_xaudio2_3:-no}
+    enable_xaudio2_4=${enable_xaudio2_4:-no}
+    enable_xaudio2_5=${enable_xaudio2_5:-no}
+    enable_xaudio2_6=${enable_xaudio2_6:-no}
+    enable_xaudio2_7=${enable_xaudio2_7:-no}
+    enable_xaudio2_8=${enable_xaudio2_8:-no}
+    enable_xaudio2_9=${enable_xaudio2_9:-no}
+fi
+
 if test "$ac_cv_header_libprocstat_h" = "yes"
 then
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for procstat_open_sysctl in -lprocstat" >&5
@@ -18668,6 +18839,8 @@
 UNWIND_LIBS = $UNWIND_LIBS
 SDL2_CFLAGS = $SDL2_CFLAGS
 SDL2_LIBS = $SDL2_LIBS
+FAUDIO_CFLAGS = $FAUDIO_CFLAGS
+FAUDIO_LIBS = $FAUDIO_LIBS
 CAPI20_CFLAGS = $CAPI20_CFLAGS
 CAPI20_LIBS = $CAPI20_LIBS
 CUPS_CFLAGS = $CUPS_CFLAGS
diff -urN wine-6.20-orig/configure.ac wine-6.20/configure.ac
--- wine-6.20-orig/configure.ac	2021-10-23 04:44:24 +0900
+++ wine-6.20/configure.ac	2021-10-26 11:55:15 +0900
@@ -42,6 +42,7 @@
             [if test "x$withval" = "xno"; then ac_cv_header_CoreAudio_CoreAudio_h=no; fi])
 AC_ARG_WITH(cups,      AS_HELP_STRING([--without-cups],[do not use CUPS]))
 AC_ARG_WITH(dbus,      AS_HELP_STRING([--without-dbus],[do not use DBus (dynamic device support)]))
+AC_ARG_WITH(faudio,    AS_HELP_STRING([--without-faudio],[do not use FAudio (XAudio2 support)]))
 AC_ARG_WITH(float-abi, AS_HELP_STRING([--with-float-abi=abi],[specify the ABI (soft|softfp|hard) for ARM platforms]))
 AC_ARG_WITH(fontconfig,AS_HELP_STRING([--without-fontconfig],[do not use fontconfig]))
 AC_ARG_WITH(freetype,  AS_HELP_STRING([--without-freetype],[do not use the FreeType library]))
@@ -1609,6 +1610,21 @@
 WINE_NOTICE_WITH(sdl,[test "x$ac_cv_lib_soname_SDL2" = "x"],
                  [libSDL2 ${notice_platform}development files not found, SDL2 won't be supported.])
 
+dnl **** Check for FAudio ****
+if test "x$with_faudio" != "xno"
+then
+    WINE_PACKAGE_FLAGS(FAUDIO,[FAudio],[-lFAudio],,,
+        [AC_CHECK_HEADERS([FAudio.h],
+            [WINE_CHECK_SONAME(FAudio,FAudioCreate,,,[$FAUDIO_LIBS],[[libFAudio*]])])
+             WINE_CHECK_LIB_FUNCS([FAudio_CommitOperationSet \
+                                   F3DAudioInitialize8 \
+                                   FAudioLinkedVersion \
+                                   FAudioCreateReverb9WithCustomAllocatorEXT], [$FAUDIO_LIBS])
+            ])
+fi
+WINE_NOTICE_WITH(faudio,[test "x$ac_cv_lib_soname_FAudio" = "x"],
+                 [libFAudio ${notice_platform}development files not found, XAudio2 won't be supported.])
+
 dnl **** Check for capi4linux ****
 if test "x$with_capi" != "xno"
 then
@@ -1717,6 +1733,45 @@
                  [libopenal ${notice_platform}development files not found (or too old), OpenAL won't be supported.],
                  [enable_openal32])
 
+if test "x$ac_cv_lib_soname_FAudio" = "x"
+then
+    enable_x3daudio1_0=${enable_x3daudio1_0:-no}
+    enable_x3daudio1_1=${enable_x3daudio1_1:-no}
+    enable_x3daudio1_2=${enable_x3daudio1_2:-no}
+    enable_x3daudio1_3=${enable_x3daudio1_3:-no}
+    enable_x3daudio1_4=${enable_x3daudio1_4:-no}
+    enable_x3daudio1_5=${enable_x3daudio1_5:-no}
+    enable_x3daudio1_6=${enable_x3daudio1_6:-no}
+    enable_x3daudio1_7=${enable_x3daudio1_7:-no}
+    enable_xactengine2_0=${enable_xactengine2_0:-no}
+    enable_xactengine2_4=${enable_xactengine2_4:-no}
+    enable_xactengine2_7=${enable_xactengine2_7:-no}
+    enable_xactengine2_9=${enable_xactengine2_9:-no}
+    enable_xactengine3_0=${enable_xactengine3_0:-no}
+    enable_xactengine3_1=${enable_xactengine3_1:-no}
+    enable_xactengine3_2=${enable_xactengine3_2:-no}
+    enable_xactengine3_3=${enable_xactengine3_3:-no}
+    enable_xactengine3_4=${enable_xactengine3_4:-no}
+    enable_xactengine3_5=${enable_xactengine3_5:-no}
+    enable_xactengine3_6=${enable_xactengine3_6:-no}
+    enable_xactengine3_7=${enable_xactengine3_7:-no}
+    enable_xapofx1_1=${enable_xapofx1_1:-no}
+    enable_xapofx1_2=${enable_xapofx1_2:-no}
+    enable_xapofx1_3=${enable_xapofx1_3:-no}
+    enable_xapofx1_4=${enable_xapofx1_4:-no}
+    enable_xapofx1_5=${enable_xapofx1_5:-no}
+    enable_xaudio2_0=${enable_xaudio2_0:-no}
+    enable_xaudio2_1=${enable_xaudio2_1:-no}
+    enable_xaudio2_2=${enable_xaudio2_2:-no}
+    enable_xaudio2_3=${enable_xaudio2_3:-no}
+    enable_xaudio2_4=${enable_xaudio2_4:-no}
+    enable_xaudio2_5=${enable_xaudio2_5:-no}
+    enable_xaudio2_6=${enable_xaudio2_6:-no}
+    enable_xaudio2_7=${enable_xaudio2_7:-no}
+    enable_xaudio2_8=${enable_xaudio2_8:-no}
+    enable_xaudio2_9=${enable_xaudio2_9:-no}
+fi
+
 dnl **** Check for libprocstat ****
 if test "$ac_cv_header_libprocstat_h" = "yes"
 then
diff -urN wine-6.20-orig/dlls/x3daudio1_0/Makefile.in wine-6.20/dlls/x3daudio1_0/Makefile.in
--- wine-6.20-orig/dlls/x3daudio1_0/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/x3daudio1_0/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,10 @@
 EXTRADEFS = -DX3DAUDIO1_VER=0 -DXAUDIO2_VER=0
 MODULE    = x3daudio1_0.dll
 PARENTSRC = ../xaudio2_7
-IMPORTS   = $(FAUDIO_PE_LIBS)
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	x3daudio.c
diff -urN wine-6.20-orig/dlls/x3daudio1_1/Makefile.in wine-6.20/dlls/x3daudio1_1/Makefile.in
--- wine-6.20-orig/dlls/x3daudio1_1/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/x3daudio1_1/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,10 @@
 EXTRADEFS = -DX3DAUDIO1_VER=1 -DXAUDIO2_VER=1
 MODULE    = x3daudio1_1.dll
 PARENTSRC = ../xaudio2_7
-IMPORTS   = $(FAUDIO_PE_LIBS)
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	x3daudio.c
diff -urN wine-6.20-orig/dlls/x3daudio1_2/Makefile.in wine-6.20/dlls/x3daudio1_2/Makefile.in
--- wine-6.20-orig/dlls/x3daudio1_2/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/x3daudio1_2/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,10 @@
 EXTRADEFS = -DX3DAUDIO1_VER=2 -DXAUDIO2_VER=2
 MODULE    = x3daudio1_2.dll
 PARENTSRC = ../xaudio2_7
-IMPORTS   = $(FAUDIO_PE_LIBS)
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	x3daudio.c
diff -urN wine-6.20-orig/dlls/x3daudio1_3/Makefile.in wine-6.20/dlls/x3daudio1_3/Makefile.in
--- wine-6.20-orig/dlls/x3daudio1_3/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/x3daudio1_3/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,10 @@
 EXTRADEFS = -DX3DAUDIO1_VER=3 -DXAUDIO2_VER=3
 MODULE    = x3daudio1_3.dll
 PARENTSRC = ../xaudio2_7
-IMPORTS   = $(FAUDIO_PE_LIBS)
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	x3daudio.c
diff -urN wine-6.20-orig/dlls/x3daudio1_4/Makefile.in wine-6.20/dlls/x3daudio1_4/Makefile.in
--- wine-6.20-orig/dlls/x3daudio1_4/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/x3daudio1_4/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,10 @@
 EXTRADEFS = -DX3DAUDIO1_VER=4 -DXAUDIO2_VER=4
 MODULE    = x3daudio1_4.dll
 PARENTSRC = ../xaudio2_7
-IMPORTS   = $(FAUDIO_PE_LIBS)
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	x3daudio.c
diff -urN wine-6.20-orig/dlls/x3daudio1_5/Makefile.in wine-6.20/dlls/x3daudio1_5/Makefile.in
--- wine-6.20-orig/dlls/x3daudio1_5/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/x3daudio1_5/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,10 @@
 EXTRADEFS = -DX3DAUDIO1_VER=5 -DXAUDIO2_VER=5
 MODULE    = x3daudio1_5.dll
 PARENTSRC = ../xaudio2_7
-IMPORTS   = $(FAUDIO_PE_LIBS)
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	x3daudio.c
diff -urN wine-6.20-orig/dlls/x3daudio1_6/Makefile.in wine-6.20/dlls/x3daudio1_6/Makefile.in
--- wine-6.20-orig/dlls/x3daudio1_6/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/x3daudio1_6/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,10 @@
 EXTRADEFS = -DX3DAUDIO1_VER=6 -DXAUDIO2_VER=6
 MODULE    = x3daudio1_6.dll
 PARENTSRC = ../xaudio2_7
-IMPORTS   = $(FAUDIO_PE_LIBS)
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	x3daudio.c
diff -urN wine-6.20-orig/dlls/x3daudio1_7/Makefile.in wine-6.20/dlls/x3daudio1_7/Makefile.in
--- wine-6.20-orig/dlls/x3daudio1_7/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/x3daudio1_7/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,10 @@
 EXTRADEFS = -DX3DAUDIO1_VER=7 -DXAUDIO2_VER=7
 MODULE    = x3daudio1_7.dll
 PARENTSRC = ../xaudio2_7
-IMPORTS   = $(FAUDIO_PE_LIBS)
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	x3daudio.c
diff -urN wine-6.20-orig/dlls/xactengine2_0/Makefile.in wine-6.20/dlls/xactengine2_0/Makefile.in
--- wine-6.20-orig/dlls/xactengine2_0/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xactengine2_0/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 MODULE    = xactengine2_0.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32 uuid
 EXTRADEFS = -DXACT3_VER=0x0200
 PARENTSRC = ../xactengine3_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xact_dll.c
diff -urN wine-6.20-orig/dlls/xactengine2_4/Makefile.in wine-6.20/dlls/xactengine2_4/Makefile.in
--- wine-6.20-orig/dlls/xactengine2_4/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xactengine2_4/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 MODULE    = xactengine2_4.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32 uuid
 EXTRADEFS = -DXACT3_VER=0x0204
 PARENTSRC = ../xactengine3_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xact_dll.c
diff -urN wine-6.20-orig/dlls/xactengine2_7/Makefile.in wine-6.20/dlls/xactengine2_7/Makefile.in
--- wine-6.20-orig/dlls/xactengine2_7/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xactengine2_7/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 MODULE    = xactengine2_7.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32 uuid
 EXTRADEFS = -DXACT3_VER=0x0207
 PARENTSRC = ../xactengine3_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xact_dll.c
diff -urN wine-6.20-orig/dlls/xactengine2_9/Makefile.in wine-6.20/dlls/xactengine2_9/Makefile.in
--- wine-6.20-orig/dlls/xactengine2_9/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xactengine2_9/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 MODULE    = xactengine2_9.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32 uuid
 EXTRADEFS = -DXACT3_VER=0x0209
 PARENTSRC = ../xactengine3_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xact_dll.c
diff -urN wine-6.20-orig/dlls/xactengine3_0/Makefile.in wine-6.20/dlls/xactengine3_0/Makefile.in
--- wine-6.20-orig/dlls/xactengine3_0/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xactengine3_0/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 MODULE    = xactengine3_0.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32 uuid
 EXTRADEFS = -DXACT3_VER=0x0300
 PARENTSRC = ../xactengine3_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xact_dll.c
diff -urN wine-6.20-orig/dlls/xactengine3_1/Makefile.in wine-6.20/dlls/xactengine3_1/Makefile.in
--- wine-6.20-orig/dlls/xactengine3_1/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xactengine3_1/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 MODULE    = xactengine3_1.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32 uuid
 EXTRADEFS = -DXACT3_VER=0x0301
 PARENTSRC = ../xactengine3_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xact_dll.c
diff -urN wine-6.20-orig/dlls/xactengine3_2/Makefile.in wine-6.20/dlls/xactengine3_2/Makefile.in
--- wine-6.20-orig/dlls/xactengine3_2/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xactengine3_2/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 MODULE    = xactengine3_2.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32 uuid
 EXTRADEFS = -DXACT3_VER=0x0302
 PARENTSRC = ../xactengine3_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xact_dll.c
diff -urN wine-6.20-orig/dlls/xactengine3_3/Makefile.in wine-6.20/dlls/xactengine3_3/Makefile.in
--- wine-6.20-orig/dlls/xactengine3_3/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xactengine3_3/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 MODULE    = xactengine3_3.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32 uuid
 EXTRADEFS = -DXACT3_VER=0x0303
 PARENTSRC = ../xactengine3_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xact_dll.c
diff -urN wine-6.20-orig/dlls/xactengine3_4/Makefile.in wine-6.20/dlls/xactengine3_4/Makefile.in
--- wine-6.20-orig/dlls/xactengine3_4/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xactengine3_4/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 MODULE    = xactengine3_4.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32 uuid
 EXTRADEFS = -DXACT3_VER=0x0304
 PARENTSRC = ../xactengine3_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xact_dll.c
diff -urN wine-6.20-orig/dlls/xactengine3_5/Makefile.in wine-6.20/dlls/xactengine3_5/Makefile.in
--- wine-6.20-orig/dlls/xactengine3_5/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xactengine3_5/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 MODULE    = xactengine3_5.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32 uuid
 EXTRADEFS = -DXACT3_VER=0x0305
 PARENTSRC = ../xactengine3_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xact_dll.c
diff -urN wine-6.20-orig/dlls/xactengine3_6/Makefile.in wine-6.20/dlls/xactengine3_6/Makefile.in
--- wine-6.20-orig/dlls/xactengine3_6/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xactengine3_6/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 MODULE    = xactengine3_6.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32 uuid
 EXTRADEFS = -DXACT3_VER=0x0306
 PARENTSRC = ../xactengine3_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xact_dll.c
diff -urN wine-6.20-orig/dlls/xactengine3_7/Makefile.in wine-6.20/dlls/xactengine3_7/Makefile.in
--- wine-6.20-orig/dlls/xactengine3_7/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xactengine3_7/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,7 +1,10 @@
 MODULE    = xactengine3_7.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32 uuid
 EXTRADEFS = -DXACT3_VER=0x0307
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xact_dll.c
diff -urN wine-6.20-orig/dlls/xactengine3_7/xact_dll.c wine-6.20/dlls/xactengine3_7/xact_dll.c
--- wine-6.20-orig/dlls/xactengine3_7/xact_dll.c	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xactengine3_7/xact_dll.c	2021-10-26 11:55:15 +0900
@@ -16,23 +16,21 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+
 #include <stdarg.h>
 #include <FACT.h>
 
 #define NONAMELESSUNION
 #define COBJMACROS
-#include "objbase.h"
 
-#if XACT3_VER < 0x0300
-#include "xact2wb.h"
 #include "initguid.h"
+#if XACT3_VER < 0x0300
 #include "xact.h"
 #else
-#include "xact3wb.h"
-#include "xaudio2.h"
-#include "initguid.h"
 #include "xact3.h"
 #endif
+#include "rpcproxy.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(xact3);
@@ -1466,7 +1464,11 @@
     {
     case DLL_PROCESS_ATTACH:
         DisableThreadLibraryCalls( hinstDLL );
+
+#ifdef HAVE_FAUDIOLINKEDVERSION
         TRACE("Using FAudio version %d\n", FAudioLinkedVersion() );
+#endif
+
         break;
     }
     return TRUE;
diff -urN wine-6.20-orig/dlls/xapofx1_1/Makefile.in wine-6.20/dlls/xapofx1_1/Makefile.in
--- wine-6.20-orig/dlls/xapofx1_1/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xapofx1_1/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 EXTRADEFS = -DXAPOFX1_VER=1 -DXAUDIO2_VER=2
 MODULE    = xapofx1_1.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32
 PARENTSRC = ../xaudio2_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xapo.c \
diff -urN wine-6.20-orig/dlls/xapofx1_2/Makefile.in wine-6.20/dlls/xapofx1_2/Makefile.in
--- wine-6.20-orig/dlls/xapofx1_2/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xapofx1_2/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 EXTRADEFS = -DXAPOFX1_VER=2 -DXAUDIO2_VER=3
 MODULE    = xapofx1_2.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32
 PARENTSRC = ../xaudio2_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xapo.c \
diff -urN wine-6.20-orig/dlls/xapofx1_3/Makefile.in wine-6.20/dlls/xapofx1_3/Makefile.in
--- wine-6.20-orig/dlls/xapofx1_3/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xapofx1_3/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 EXTRADEFS = -DXAPOFX1_VER=3 -DXAUDIO2_VER=4
 MODULE    = xapofx1_3.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32
 PARENTSRC = ../xaudio2_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xapo.c \
diff -urN wine-6.20-orig/dlls/xapofx1_4/Makefile.in wine-6.20/dlls/xapofx1_4/Makefile.in
--- wine-6.20-orig/dlls/xapofx1_4/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xapofx1_4/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 EXTRADEFS = -DXAPOFX1_VER=4 -DXAUDIO2_VER=6
 MODULE    = xapofx1_4.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32
 PARENTSRC = ../xaudio2_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xapo.c \
diff -urN wine-6.20-orig/dlls/xapofx1_5/Makefile.in wine-6.20/dlls/xapofx1_5/Makefile.in
--- wine-6.20-orig/dlls/xapofx1_5/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xapofx1_5/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 EXTRADEFS = -DXAPOFX1_VER=5 -DXAUDIO2_VER=7
 MODULE    = xapofx1_5.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) ole32
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = ole32
 PARENTSRC = ../xaudio2_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	xapo.c \
diff -urN wine-6.20-orig/dlls/xaudio2_0/Makefile.in wine-6.20/dlls/xaudio2_0/Makefile.in
--- wine-6.20-orig/dlls/xaudio2_0/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_0/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 EXTRADEFS = -DXAUDIO2_VER=0
 MODULE    = xaudio2_0.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) advapi32 ole32 user32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = advapi32 ole32 user32 uuid
 PARENTSRC = ../xaudio2_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	compat.c \
diff -urN wine-6.20-orig/dlls/xaudio2_1/Makefile.in wine-6.20/dlls/xaudio2_1/Makefile.in
--- wine-6.20-orig/dlls/xaudio2_1/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_1/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 EXTRADEFS = -DXAUDIO2_VER=1
 MODULE    = xaudio2_1.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) advapi32 ole32 user32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = advapi32 ole32 user32 uuid
 PARENTSRC = ../xaudio2_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	compat.c \
diff -urN wine-6.20-orig/dlls/xaudio2_2/Makefile.in wine-6.20/dlls/xaudio2_2/Makefile.in
--- wine-6.20-orig/dlls/xaudio2_2/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_2/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 EXTRADEFS = -DXAUDIO2_VER=2
 MODULE    = xaudio2_2.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) advapi32 ole32 user32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = advapi32 ole32 user32 uuid
 PARENTSRC = ../xaudio2_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	compat.c \
diff -urN wine-6.20-orig/dlls/xaudio2_3/Makefile.in wine-6.20/dlls/xaudio2_3/Makefile.in
--- wine-6.20-orig/dlls/xaudio2_3/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_3/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 EXTRADEFS = -DXAUDIO2_VER=3
 MODULE    = xaudio2_3.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) advapi32 ole32 user32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = advapi32 ole32 user32 uuid
 PARENTSRC = ../xaudio2_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	compat.c \
diff -urN wine-6.20-orig/dlls/xaudio2_4/Makefile.in wine-6.20/dlls/xaudio2_4/Makefile.in
--- wine-6.20-orig/dlls/xaudio2_4/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_4/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 EXTRADEFS = -DXAUDIO2_VER=4
 MODULE    = xaudio2_4.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) advapi32 ole32 user32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = advapi32 ole32 user32 uuid
 PARENTSRC = ../xaudio2_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	compat.c \
diff -urN wine-6.20-orig/dlls/xaudio2_5/Makefile.in wine-6.20/dlls/xaudio2_5/Makefile.in
--- wine-6.20-orig/dlls/xaudio2_5/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_5/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 EXTRADEFS = -DXAUDIO2_VER=5
 MODULE    = xaudio2_5.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) advapi32 ole32 user32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = advapi32 ole32 user32 uuid
 PARENTSRC = ../xaudio2_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	compat.c \
diff -urN wine-6.20-orig/dlls/xaudio2_6/Makefile.in wine-6.20/dlls/xaudio2_6/Makefile.in
--- wine-6.20-orig/dlls/xaudio2_6/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_6/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 EXTRADEFS = -DXAUDIO2_VER=6
 MODULE    = xaudio2_6.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) advapi32 ole32 user32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = advapi32 ole32 user32 uuid
 PARENTSRC = ../xaudio2_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	compat.c \
diff -urN wine-6.20-orig/dlls/xaudio2_7/Makefile.in wine-6.20/dlls/xaudio2_7/Makefile.in
--- wine-6.20-orig/dlls/xaudio2_7/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_7/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,7 +1,10 @@
 EXTRADEFS = -DXAUDIO2_VER=7
 MODULE    = xaudio2_7.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) advapi32 ole32 user32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = advapi32 ole32 user32 uuid
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	compat.c \
diff -urN wine-6.20-orig/dlls/xaudio2_7/compat.c wine-6.20/dlls/xaudio2_7/compat.c
--- wine-6.20-orig/dlls/xaudio2_7/compat.c	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_7/compat.c	2021-10-26 11:55:15 +0900
@@ -89,6 +89,8 @@
  *     Add SideDelay member to XAUDIO2FX_REVERB_PARAMETERS
  */
 
+#include "config.h"
+
 #define NONAMELESSUNION
 #define NONAMELESSSTRUCT
 #define COBJMACROS
@@ -2160,6 +2162,16 @@
 
     This->mst.effect_chain = wrap_effect_chain(pEffectChain);
 
+    pthread_mutex_lock(&This->mst.engine_lock);
+
+    This->mst.engine_thread = CreateThread(NULL, 0, &engine_thread, &This->mst, 0, NULL);
+
+    pthread_cond_wait(&This->mst.engine_done, &This->mst.engine_lock);
+
+    pthread_mutex_unlock(&This->mst.engine_lock);
+
+    FAudio_SetEngineProcedureEXT(This->faudio, &engine_cb, &This->mst);
+
     FAudio_CreateMasteringVoice(This->faudio, &This->mst.faudio_voice, inputChannels,
             inputSampleRate, flags, deviceIndex, This->mst.effect_chain);
 
@@ -2385,6 +2397,16 @@
 
     This->mst.effect_chain = wrap_effect_chain(pEffectChain);
 
+    pthread_mutex_lock(&This->mst.engine_lock);
+
+    This->mst.engine_thread = CreateThread(NULL, 0, &engine_thread, &This->mst, 0, NULL);
+
+    pthread_cond_wait(&This->mst.engine_done, &This->mst.engine_lock);
+
+    pthread_mutex_unlock(&This->mst.engine_lock);
+
+    FAudio_SetEngineProcedureEXT(This->faudio, &engine_cb, &This->mst);
+
     FAudio_CreateMasteringVoice(This->faudio, &This->mst.faudio_voice, inputChannels,
             inputSampleRate, flags, deviceIndex, This->mst.effect_chain);
 
@@ -2609,6 +2631,16 @@
 
     This->mst.effect_chain = wrap_effect_chain(pEffectChain);
 
+    pthread_mutex_lock(&This->mst.engine_lock);
+
+    This->mst.engine_thread = CreateThread(NULL, 0, &engine_thread, &This->mst, 0, NULL);
+
+    pthread_cond_wait(&This->mst.engine_done, &This->mst.engine_lock);
+
+    pthread_mutex_unlock(&This->mst.engine_lock);
+
+    FAudio_SetEngineProcedureEXT(This->faudio, &engine_cb, &This->mst);
+
     FAudio_CreateMasteringVoice(This->faudio, &This->mst.faudio_voice, inputChannels,
             inputSampleRate, flags, deviceIndex, This->mst.effect_chain);
 
@@ -2787,6 +2819,16 @@
 
     This->mst.effect_chain = wrap_effect_chain(pEffectChain);
 
+    pthread_mutex_lock(&This->mst.engine_lock);
+
+    This->mst.engine_thread = CreateThread(NULL, 0, &engine_thread, &This->mst, 0, NULL);
+
+    pthread_cond_wait(&This->mst.engine_done, &This->mst.engine_lock);
+
+    pthread_mutex_unlock(&This->mst.engine_lock);
+
+    FAudio_SetEngineProcedureEXT(This->faudio, &engine_cb, &This->mst);
+
     FAudio_CreateMasteringVoice(This->faudio, &This->mst.faudio_voice, inputChannels,
             inputSampleRate, flags, deviceIndex, This->mst.effect_chain);
 
diff -urN wine-6.20-orig/dlls/xaudio2_7/x3daudio.c wine-6.20/dlls/xaudio2_7/x3daudio.c
--- wine-6.20-orig/dlls/xaudio2_7/x3daudio.c	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_7/x3daudio.c	2021-10-26 11:55:15 +0900
@@ -17,6 +17,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+
 #include <stdarg.h>
 
 #include "windef.h"
@@ -36,7 +38,12 @@
         X3DAUDIO_HANDLE handle)
 {
     TRACE("0x%x, %f, %p\n", chanmask, speedofsound, handle);
+#ifdef HAVE_F3DAUDIOINITIALIZE8
     return F3DAudioInitialize8(chanmask, speedofsound, handle);
+#else
+    F3DAudioInitialize(chanmask, speedofsound, handle);
+    return S_OK;
+#endif
 }
 #endif /* XAUDIO2_VER >= 8 */
 
diff -urN wine-6.20-orig/dlls/xaudio2_7/xapo.c wine-6.20/dlls/xaudio2_7/xapo.c
--- wine-6.20-orig/dlls/xaudio2_7/xapo.c	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_7/xapo.c	2021-10-26 11:55:15 +0900
@@ -18,6 +18,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+
 #include <stdarg.h>
 
 #define NONAMELESSUNION
@@ -311,6 +313,7 @@
             XAudio_Internal_Free,
             XAudio_Internal_Realloc
         );
+#if XAUDIO2_VER >= 9 && HAVE_FAUDIOCREATEREVERB9WITHCUSTOMALLOCATOREXT
     if(IsEqualGUID(clsid, &CLSID_AudioReverb27))
         return FAudioCreateReverb9WithCustomAllocatorEXT(
             fapo,
@@ -319,6 +322,16 @@
             XAudio_Internal_Free,
             XAudio_Internal_Realloc
         );
+#else
+    if(IsEqualGUID(clsid, &CLSID_AudioReverb27))
+        return FAudioCreateReverbWithCustomAllocatorEXT(
+            fapo,
+            0,
+            XAudio_Internal_Malloc,
+            XAudio_Internal_Free,
+            XAudio_Internal_Realloc
+        );
+#endif
 #endif
 #if XAUDIO2_VER >= 8 || defined XAPOFX1_VER
     if(IsEqualGUID(clsid, &CLSID_FXReverb) ||
diff -urN wine-6.20-orig/dlls/xaudio2_7/xapofx.c wine-6.20/dlls/xaudio2_7/xapofx.c
--- wine-6.20-orig/dlls/xaudio2_7/xapofx.c	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_7/xapofx.c	2021-10-26 11:55:15 +0900
@@ -17,6 +17,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+
 #include <stdarg.h>
 
 #define NONAMELESSUNION
diff -urN wine-6.20-orig/dlls/xaudio2_7/xaudio_allocator.c wine-6.20/dlls/xaudio2_7/xaudio_allocator.c
--- wine-6.20-orig/dlls/xaudio2_7/xaudio_allocator.c	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_7/xaudio_allocator.c	2021-10-26 11:55:15 +0900
@@ -16,6 +16,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+
 #include <stdarg.h>
 
 #define NONAMELESSUNION
diff -urN wine-6.20-orig/dlls/xaudio2_7/xaudio_dll.c wine-6.20/dlls/xaudio2_7/xaudio_dll.c
--- wine-6.20-orig/dlls/xaudio2_7/xaudio_dll.c	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_7/xaudio_dll.c	2021-10-26 11:55:15 +0900
@@ -18,15 +18,13 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+
 #include <stdarg.h>
 
 #define NONAMELESSUNION
 #define COBJMACROS
 
-#include "windows.h"
-#include "objbase.h"
-#include "mmdeviceapi.h"
-
 #include "initguid.h"
 #include "xaudio_private.h"
 #include "xaudio2fx.h"
@@ -34,6 +32,9 @@
 #include "xapofx.h"
 #endif
 
+#include "ole2.h"
+#include "rpcproxy.h"
+
 #include "wine/asm.h"
 #include "wine/debug.h"
 #include "wine/heap.h"
@@ -86,7 +87,9 @@
     {
     case DLL_PROCESS_ATTACH:
         DisableThreadLibraryCalls( hinstDLL );
+#ifdef HAVE_FAUDIOLINKEDVERSION
         TRACE("Using FAudio version %d\n", FAudioLinkedVersion() );
+#endif
         break;
     }
     return TRUE;
@@ -1280,6 +1283,13 @@
     EnterCriticalSection(&This->lock);
 
     destroy_voice(This);
+    pthread_mutex_lock(&This->engine_lock);
+    This->engine_params.proc = NULL;
+    pthread_cond_broadcast(&This->engine_ready);
+    pthread_mutex_unlock(&This->engine_lock);
+
+    WaitForSingleObject(This->engine_thread, INFINITE);
+    This->engine_thread = NULL;
 
     LeaveCriticalSection(&This->lock);
 }
@@ -1650,6 +1660,49 @@
     return S_OK;
 }
 
+/* called thread created by SDL, must not access Wine TEB */
+void engine_cb(FAudioEngineCallEXT proc, FAudio *faudio, float *stream, void *user)
+{
+    XA2VoiceImpl *This = user;
+
+    pthread_mutex_lock(&This->engine_lock);
+
+    This->engine_params.proc = proc;
+    This->engine_params.stream = stream;
+    This->engine_params.faudio = faudio;
+
+    pthread_cond_broadcast(&This->engine_ready);
+
+    while(This->engine_params.proc)
+        pthread_cond_wait(&This->engine_done, &This->engine_lock);
+
+    pthread_mutex_unlock(&This->engine_lock);
+}
+
+/* wine thread, OK to access TEB, invoke client code, etc */
+DWORD WINAPI engine_thread(void *user)
+{
+    XA2VoiceImpl *This = user;
+
+    pthread_mutex_lock(&This->engine_lock);
+
+    pthread_cond_broadcast(&This->engine_done);
+
+    do{
+        pthread_cond_wait(&This->engine_ready, &This->engine_lock);
+
+        if(This->engine_params.proc){
+            This->engine_params.proc(This->engine_params.faudio, This->engine_params.stream);
+            This->engine_params.proc = NULL;
+            pthread_cond_broadcast(&This->engine_done);
+        }
+    }while(This->in_use);
+
+    pthread_mutex_unlock(&This->engine_lock);
+
+    return 0;
+}
+
 static HRESULT WINAPI IXAudio2Impl_CreateMasteringVoice(IXAudio2 *iface,
         IXAudio2MasteringVoice **ppMasteringVoice, UINT32 inputChannels,
         UINT32 inputSampleRate, UINT32 flags, const WCHAR *deviceId,
@@ -1683,6 +1736,16 @@
 
     This->mst.effect_chain = wrap_effect_chain(pEffectChain);
 
+    pthread_mutex_lock(&This->mst.engine_lock);
+
+    This->mst.engine_thread = CreateThread(NULL, 0, &engine_thread, &This->mst, 0, NULL);
+
+    pthread_cond_wait(&This->mst.engine_done, &This->mst.engine_lock);
+
+    pthread_mutex_unlock(&This->mst.engine_lock);
+
+    FAudio_SetEngineProcedureEXT(This->faudio, &engine_cb, &This->mst);
+
     FAudio_CreateMasteringVoice8(This->faudio, &This->mst.faudio_voice, inputChannels,
             inputSampleRate, flags, NULL /* TODO: (uint16_t*)deviceId */,
             This->mst.effect_chain, (FAudioStreamCategory)streamCategory);
@@ -1719,7 +1782,11 @@
 
     TRACE("(%p)->(0x%x)\n", This, operationSet);
 
+#ifdef HAVE_FAUDIO_COMMITOPERATIONSET
     return FAudio_CommitOperationSet(This->faudio, operationSet);
+#else
+    return FAudio_CommitChanges(This->faudio);
+#endif
 }
 
 static void WINAPI IXAudio2Impl_GetPerformanceData(IXAudio2 *iface,
@@ -1856,6 +1923,10 @@
     InitializeCriticalSection(&object->mst.lock);
     object->mst.lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": XA2MasteringVoice.lock");
 
+    pthread_mutex_init(&object->mst.engine_lock, NULL);
+    pthread_cond_init(&object->mst.engine_done, NULL);
+    pthread_cond_init(&object->mst.engine_ready, NULL);
+
     FAudioCOMConstructWithCustomAllocatorEXT(
         &object->faudio,
         XAUDIO2_VER,
diff -urN wine-6.20-orig/dlls/xaudio2_7/xaudio_private.h wine-6.20/dlls/xaudio2_7/xaudio_private.h
--- wine-6.20-orig/dlls/xaudio2_7/xaudio_private.h	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_7/xaudio_private.h	2021-10-26 11:55:15 +0900
@@ -26,6 +26,8 @@
 #include <FAudio.h>
 #include <FAPO.h>
 
+#include <pthread.h>
+
 #if XAUDIO2_VER == 0
 #define COMPAT_E_INVALID_CALL E_INVALIDARG
 #define COMPAT_E_DEVICE_INVALIDATED XAUDIO20_E_DEVICE_INVALIDATED
@@ -95,6 +97,10 @@
         float *stream;
     } engine_params;
 
+    HANDLE engine_thread;
+    pthread_cond_t engine_done, engine_ready;
+    pthread_mutex_t engine_lock;
+
     struct list entry;
 } XA2VoiceImpl;
 
diff -urN wine-6.20-orig/dlls/xaudio2_8/Makefile.in wine-6.20/dlls/xaudio2_8/Makefile.in
--- wine-6.20-orig/dlls/xaudio2_8/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_8/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 EXTRADEFS = -DXAUDIO2_VER=8
 MODULE    = xaudio2_8.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) advapi32 ole32 user32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = advapi32 ole32 user32 uuid
 PARENTSRC = ../xaudio2_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	compat.c \
diff -urN wine-6.20-orig/dlls/xaudio2_9/Makefile.in wine-6.20/dlls/xaudio2_9/Makefile.in
--- wine-6.20-orig/dlls/xaudio2_9/Makefile.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/dlls/xaudio2_9/Makefile.in	2021-10-26 11:55:15 +0900
@@ -1,8 +1,11 @@
 EXTRADEFS = -DXAUDIO2_VER=9
 MODULE    = xaudio2_9.dll
-IMPORTS   = $(FAUDIO_PE_LIBS) advapi32 ole32 user32 uuid
-EXTRAINCL = $(FAUDIO_PE_CFLAGS)
+IMPORTS   = advapi32 ole32 user32 uuid
 PARENTSRC = ../xaudio2_7
+EXTRALIBS = $(FAUDIO_LIBS)
+EXTRAINCL = $(FAUDIO_CFLAGS)
+
+EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	compat.c \
diff -urN wine-6.20-orig/include/config.h.in wine-6.20/include/config.h.in
--- wine-6.20-orig/include/config.h.in	2021-10-23 04:44:24 +0900
+++ wine-6.20/include/config.h.in	2021-10-26 11:55:15 +0900
@@ -68,6 +68,22 @@
 /* Define to 1 if you have the `epoll_create' function. */
 #undef HAVE_EPOLL_CREATE
 
+/* Define to 1 if you have the `F3DAudioInitialize8' function. */
+#undef HAVE_F3DAUDIOINITIALIZE8
+
+/* Define to 1 if you have the `FAudioCreateReverb9WithCustomAllocatorEXT'
+   function. */
+#undef HAVE_FAUDIOCREATEREVERB9WITHCUSTOMALLOCATOREXT
+
+/* Define to 1 if you have the `FAudioLinkedVersion' function. */
+#undef HAVE_FAUDIOLINKEDVERSION
+
+/* Define to 1 if you have the `FAudio_CommitOperationSet' function. */
+#undef HAVE_FAUDIO_COMMITOPERATIONSET
+
+/* Define to 1 if you have the <FAudio.h> header file. */
+#undef HAVE_FAUDIO_H
+
 /* Define to 1 if you have the <float.h> header file. */
 #undef HAVE_FLOAT_H
 
@@ -898,6 +914,9 @@
 /* Define to the soname of the libEGL library. */
 #undef SONAME_LIBEGL
 
+/* Define to the soname of the libFAudio library. */
+#undef SONAME_LIBFAUDIO
+
 /* Define to the soname of the libfontconfig library. */
 #undef SONAME_LIBFONTCONFIG
 
