summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.lib53
-rw-r--r--projects/openttd_vs100.vcxproj10
-rw-r--r--projects/openttd_vs100.vcxproj.filters6
-rw-r--r--projects/openttd_vs100.vcxproj.in8
-rw-r--r--projects/openttd_vs140.vcxproj10
-rw-r--r--projects/openttd_vs140.vcxproj.filters6
-rw-r--r--projects/openttd_vs140.vcxproj.in8
-rw-r--r--projects/openttd_vs141.vcxproj10
-rw-r--r--projects/openttd_vs141.vcxproj.filters6
-rw-r--r--projects/openttd_vs141.vcxproj.in8
-rw-r--r--projects/openttd_vs80.vcproj8
-rw-r--r--projects/openttd_vs90.vcproj8
-rw-r--r--source.list2
-rw-r--r--src/sound/win32_s.h2
-rw-r--r--src/sound/xaudio2_s.cpp273
-rw-r--r--src/sound/xaudio2_s.h33
16 files changed, 426 insertions, 25 deletions
diff --git a/config.lib b/config.lib
index 7fa44f5b3..d6ebb68a1 100644
--- a/config.lib
+++ b/config.lib
@@ -77,6 +77,7 @@ set_default() {
enable_builtin_depend="1"
with_makedepend="0"
with_direct_music="1"
+ with_xaudio2="1"
with_sort="1"
with_iconv="1"
with_midi=""
@@ -152,6 +153,7 @@ set_default() {
enable_builtin_depend
with_makedepend
with_direct_music
+ with_xaudio2
with_sort
with_iconv
with_midi
@@ -411,6 +413,10 @@ detect_params() {
--without-direct-music) with_direct_music="0";;
--with-direct-music=*) with_direct_music="$optarg";;
+ --with-xaudio2) with_xaudio2="2";;
+ --without-xaudio2) with_xaudio2="0";;
+ --with-xaudio2=*) with_xaudio2="$optarg";;
+
--with-sort) with_sort="2";;
--without-sort) with_sort="0";;
--with-sort=*) with_sort="$optarg";;
@@ -871,6 +877,20 @@ check_params() {
fi
fi
+ if [ "$with_xaudio2" != "0" ]; then
+ if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
+ if [ "$with_xaudio2" != "1" ]; then
+ log 1 "configure: error: xaudio2 is only supported on Win32 targets"
+ exit 1
+ fi
+ with_xaudio2="0"
+
+ log 1 "checking xaudio2... not Windows, skipping"
+ else
+ check_xaudio2
+ fi
+ fi
+
detect_sort
# Suppress language errors when there is a version defined, indicating a release
@@ -1772,6 +1792,10 @@ make_cflags_and_ldflags() {
fi
fi
+ if [ "$with_xaudio2" != "0" ]; then
+ CFLAGS="$CFLAGS -DWITH_XAUDIO2"
+ fi
+
if [ -n "$libtimidity_config" ]; then
CFLAGS="$CFLAGS -DLIBTIMIDITY"
CFLAGS="$CFLAGS `$libtimidity_config --cflags | tr '\n\r' ' '`"
@@ -2160,6 +2184,35 @@ check_direct_music() {
fi
}
+check_xaudio2() {
+ echo "
+ #include <windows.h>
+
+ #undef NTDDI_VERSION
+ #undef _WIN32_WINNT
+
+ #define NTDDI_VERSION NTDDI_WIN8
+ #define _WIN32_WINNT _WIN32_WINNT_WIN8
+
+ #include <xaudio2.h>
+ int main(int argc, char *argv[]) { }" > xaudio2.test.c
+ $cxx_host $CFLAGS xaudio2.test.c -o xaudio2.test 2> /dev/null
+ res=$?
+ rm -f xaudio2.test.c xaudio2.test
+
+ if [ "$res" != "0" ]; then
+ if [ "$with_xaudio2" != "1" ]; then
+ log 1 "configure: error: xaudio2 is not available on this system"
+ exit 1
+ fi
+ with_xaudio2="0"
+
+ log 1 "checking xaudio2... not found"
+ else
+ log 1 "checking xaudio2... found"
+ fi
+}
+
check_makedepend() {
if [ "$enable_builtin_depend" != "0" ]; then
with_makedepend="0"
diff --git a/projects/openttd_vs100.vcxproj b/projects/openttd_vs100.vcxproj
index f83ea167a..f8daad6c9 100644
--- a/projects/openttd_vs100.vcxproj
+++ b/projects/openttd_vs100.vcxproj
@@ -102,7 +102,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -162,7 +162,7 @@
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
@@ -216,7 +216,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -274,7 +274,7 @@
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
@@ -684,6 +684,7 @@
<ClInclude Include="..\src\window_func.h" />
<ClInclude Include="..\src\window_gui.h" />
<ClInclude Include="..\src\window_type.h" />
+ <ClInclude Include="..\src\sound\xaudio2_s.h" />
<ClInclude Include="..\src\zoom_func.h" />
<ClInclude Include="..\src\zoom_type.h" />
<ClCompile Include="..\src\core\alloc_func.cpp" />
@@ -1297,6 +1298,7 @@
<ClCompile Include="..\src\sound\null_s.cpp" />
<ClCompile Include="..\src\sound\sdl_s.cpp" />
<ClCompile Include="..\src\sound\win32_s.cpp" />
+ <ClCompile Include="..\src\sound\xaudio2_s.cpp" />
<ClCompile Include="..\src\os\windows\crashlog_win.cpp" />
<ResourceCompile Include="..\src\os\windows\ottdres.rc" />
<ClCompile Include="..\src\os\windows\win32.cpp" />
diff --git a/projects/openttd_vs100.vcxproj.filters b/projects/openttd_vs100.vcxproj.filters
index a7508493c..c5dfab137 100644
--- a/projects/openttd_vs100.vcxproj.filters
+++ b/projects/openttd_vs100.vcxproj.filters
@@ -1209,6 +1209,9 @@
<ClInclude Include="..\src\window_type.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\src\sound\xaudio2_s.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
<ClInclude Include="..\src\zoom_func.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -3048,6 +3051,9 @@
<ClCompile Include="..\src\sound\win32_s.cpp">
<Filter>Sound</Filter>
</ClCompile>
+ <ClCompile Include="..\src\sound\xaudio2_s.cpp">
+ <Filter>Sound</Filter>
+ </ClCompile>
<ClCompile Include="..\src\os\windows\crashlog_win.cpp">
<Filter>Windows files</Filter>
</ClCompile>
diff --git a/projects/openttd_vs100.vcxproj.in b/projects/openttd_vs100.vcxproj.in
index ab2ae133a..76db41667 100644
--- a/projects/openttd_vs100.vcxproj.in
+++ b/projects/openttd_vs100.vcxproj.in
@@ -102,7 +102,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -162,7 +162,7 @@
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
@@ -216,7 +216,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -274,7 +274,7 @@
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
diff --git a/projects/openttd_vs140.vcxproj b/projects/openttd_vs140.vcxproj
index 4adaaaec9..e07d8ce86 100644
--- a/projects/openttd_vs140.vcxproj
+++ b/projects/openttd_vs140.vcxproj
@@ -105,7 +105,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -170,7 +170,7 @@
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
@@ -228,7 +228,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -291,7 +291,7 @@
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
@@ -705,6 +705,7 @@
<ClInclude Include="..\src\window_func.h" />
<ClInclude Include="..\src\window_gui.h" />
<ClInclude Include="..\src\window_type.h" />
+ <ClInclude Include="..\src\sound\xaudio2_s.h" />
<ClInclude Include="..\src\zoom_func.h" />
<ClInclude Include="..\src\zoom_type.h" />
<ClCompile Include="..\src\core\alloc_func.cpp" />
@@ -1318,6 +1319,7 @@
<ClCompile Include="..\src\sound\null_s.cpp" />
<ClCompile Include="..\src\sound\sdl_s.cpp" />
<ClCompile Include="..\src\sound\win32_s.cpp" />
+ <ClCompile Include="..\src\sound\xaudio2_s.cpp" />
<ClCompile Include="..\src\os\windows\crashlog_win.cpp" />
<ResourceCompile Include="..\src\os\windows\ottdres.rc" />
<ClCompile Include="..\src\os\windows\win32.cpp" />
diff --git a/projects/openttd_vs140.vcxproj.filters b/projects/openttd_vs140.vcxproj.filters
index a7508493c..c5dfab137 100644
--- a/projects/openttd_vs140.vcxproj.filters
+++ b/projects/openttd_vs140.vcxproj.filters
@@ -1209,6 +1209,9 @@
<ClInclude Include="..\src\window_type.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\src\sound\xaudio2_s.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
<ClInclude Include="..\src\zoom_func.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -3048,6 +3051,9 @@
<ClCompile Include="..\src\sound\win32_s.cpp">
<Filter>Sound</Filter>
</ClCompile>
+ <ClCompile Include="..\src\sound\xaudio2_s.cpp">
+ <Filter>Sound</Filter>
+ </ClCompile>
<ClCompile Include="..\src\os\windows\crashlog_win.cpp">
<Filter>Windows files</Filter>
</ClCompile>
diff --git a/projects/openttd_vs140.vcxproj.in b/projects/openttd_vs140.vcxproj.in
index 1e490d29e..93debc867 100644
--- a/projects/openttd_vs140.vcxproj.in
+++ b/projects/openttd_vs140.vcxproj.in
@@ -105,7 +105,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -170,7 +170,7 @@
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
@@ -228,7 +228,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -291,7 +291,7 @@
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
diff --git a/projects/openttd_vs141.vcxproj b/projects/openttd_vs141.vcxproj
index 60f0aea88..411ea573d 100644
--- a/projects/openttd_vs141.vcxproj
+++ b/projects/openttd_vs141.vcxproj
@@ -105,7 +105,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -170,7 +170,7 @@
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
@@ -228,7 +228,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -291,7 +291,7 @@
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
@@ -705,6 +705,7 @@
<ClInclude Include="..\src\window_func.h" />
<ClInclude Include="..\src\window_gui.h" />
<ClInclude Include="..\src\window_type.h" />
+ <ClInclude Include="..\src\sound\xaudio2_s.h" />
<ClInclude Include="..\src\zoom_func.h" />
<ClInclude Include="..\src\zoom_type.h" />
<ClCompile Include="..\src\core\alloc_func.cpp" />
@@ -1318,6 +1319,7 @@
<ClCompile Include="..\src\sound\null_s.cpp" />
<ClCompile Include="..\src\sound\sdl_s.cpp" />
<ClCompile Include="..\src\sound\win32_s.cpp" />
+ <ClCompile Include="..\src\sound\xaudio2_s.cpp" />
<ClCompile Include="..\src\os\windows\crashlog_win.cpp" />
<ResourceCompile Include="..\src\os\windows\ottdres.rc" />
<ClCompile Include="..\src\os\windows\win32.cpp" />
diff --git a/projects/openttd_vs141.vcxproj.filters b/projects/openttd_vs141.vcxproj.filters
index a7508493c..c5dfab137 100644
--- a/projects/openttd_vs141.vcxproj.filters
+++ b/projects/openttd_vs141.vcxproj.filters
@@ -1209,6 +1209,9 @@
<ClInclude Include="..\src\window_type.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\src\sound\xaudio2_s.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
<ClInclude Include="..\src\zoom_func.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -3048,6 +3051,9 @@
<ClCompile Include="..\src\sound\win32_s.cpp">
<Filter>Sound</Filter>
</ClCompile>
+ <ClCompile Include="..\src\sound\xaudio2_s.cpp">
+ <Filter>Sound</Filter>
+ </ClCompile>
<ClCompile Include="..\src\os\windows\crashlog_win.cpp">
<Filter>Windows files</Filter>
</ClCompile>
diff --git a/projects/openttd_vs141.vcxproj.in b/projects/openttd_vs141.vcxproj.in
index f4ec557c6..dc6dcd17f 100644
--- a/projects/openttd_vs141.vcxproj.in
+++ b/projects/openttd_vs141.vcxproj.in
@@ -105,7 +105,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -170,7 +170,7 @@
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
@@ -228,7 +228,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -291,7 +291,7 @@
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index 0255f18da..88899bbbc 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -1923,6 +1923,10 @@
>
</File>
<File
+ RelativePath=".\..\src\sound\xaudio2_s.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\zoom_func.h"
>
</File>
@@ -4490,6 +4494,10 @@
RelativePath=".\..\src\sound\win32_s.cpp"
>
</File>
+ <File
+ RelativePath=".\..\src\sound\xaudio2_s.cpp"
+ >
+ </File>
</Filter>
<Filter
Name="Windows files"
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj
index c4f63c919..6fb57832d 100644
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -1920,6 +1920,10 @@
>
</File>
<File
+ RelativePath=".\..\src\sound\xaudio2_s.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\zoom_func.h"
>
</File>
@@ -4487,6 +4491,10 @@
RelativePath=".\..\src\sound\win32_s.cpp"
>
</File>
+ <File
+ RelativePath=".\..\src\sound\xaudio2_s.cpp"
+ >
+ </File>
</Filter>
<Filter
Name="Windows files"
diff --git a/source.list b/source.list
index 249d22116..7555044d2 100644
--- a/source.list
+++ b/source.list
@@ -396,6 +396,7 @@ video/win32_v.h
window_func.h
window_gui.h
window_type.h
+sound/xaudio2_s.h
zoom_func.h
zoom_type.h
#if WIN32
@@ -1134,6 +1135,7 @@ sound/null_s.cpp
#end
#if WIN32
sound/win32_s.cpp
+ sound/xaudio2_s.cpp
#end
#end
diff --git a/src/sound/win32_s.h b/src/sound/win32_s.h
index 77906c88a..c6c8e8d14 100644
--- a/src/sound/win32_s.h
+++ b/src/sound/win32_s.h
@@ -26,7 +26,7 @@ public:
/** Factory for the sound driver for Windows. */
class FSoundDriver_Win32 : public DriverFactoryBase {
public:
- FSoundDriver_Win32() : DriverFactoryBase(Driver::DT_SOUND, 10, "win32", "Win32 WaveOut Sound Driver") {}
+ FSoundDriver_Win32() : DriverFactoryBase(Driver::DT_SOUND, 9, "win32", "Win32 WaveOut Sound Driver") {}
/* virtual */ Driver *CreateInstance() const { return new SoundDriver_Win32(); }
};
diff --git a/src/sound/xaudio2_s.cpp b/src/sound/xaudio2_s.cpp
new file mode 100644
index 000000000..60311ced2
--- /dev/null
+++ b/src/sound/xaudio2_s.cpp
@@ -0,0 +1,273 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD 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 General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file xaudio2_s.cpp XAudio2 sound driver. */
+
+#ifdef WITH_XAUDIO2
+
+#include "../stdafx.h"
+#include "../openttd.h"
+#include "../driver.h"
+#include "../mixer.h"
+#include "../debug.h"
+#include "../core/alloc_func.hpp"
+#include "../core/bitmath_func.hpp"
+#include "../core/math_func.hpp"
+
+// Windows 8 SDK required for XAudio2
+#undef NTDDI_VERSION
+#undef _WIN32_WINNT
+
+#define NTDDI_VERSION NTDDI_WIN8
+#define _WIN32_WINNT _WIN32_WINNT_WIN8
+
+#include "xaudio2_s.h"
+
+#include <windows.h>
+#include <mmsystem.h>
+#include <wrl\client.h>
+#include <xaudio2.h>
+
+using Microsoft::WRL::ComPtr;
+
+#include "../os/windows/win32.h"
+#include "../safeguards.h"
+
+// Definition of the "XAudio2Create" call used to initialise XAudio2
+typedef HRESULT(__stdcall *API_XAudio2Create)(_Outptr_ IXAudio2** ppXAudio2, UINT32 Flags, XAUDIO2_PROCESSOR XAudio2Processor);
+
+static FSoundDriver_XAudio2 iFSoundDriver_XAudio2;
+
+/**
+* Implementation of the IXAudio2VoiceCallback interface.
+* Provides buffered audio to XAudio2 from the OpenTTD mixer.
+*/
+class StreamingVoiceContext : public IXAudio2VoiceCallback
+{
+private:
+ int bufferLength;
+ char *buffer;
+
+public:
+ IXAudio2SourceVoice* SourceVoice;
+
+ StreamingVoiceContext(int bufferLength)
+ {
+ this->bufferLength = bufferLength;
+ this->buffer = MallocT<char>(bufferLength);
+ }
+
+ virtual ~StreamingVoiceContext()
+ {
+ free(this->buffer);
+ }
+
+ HRESULT SubmitBuffer()
+ {
+ // Ensure we do have a valid voice
+ if (this->SourceVoice == nullptr)
+ {
+ return E_FAIL;
+ }
+
+ MxMixSamples(this->buffer, this->bufferLength / 4);
+
+ XAUDIO2_BUFFER buf = { 0 };
+ buf.AudioBytes = this->bufferLength;
+ buf.pAudioData = (const BYTE *) this->buffer;
+
+ return SourceVoice->SubmitSourceBuffer(&buf);
+ }
+
+ STDMETHOD_(void, OnVoiceProcessingPassStart)(UINT32) override
+ {
+ }
+
+ STDMETHOD_(void, OnVoiceProcessingPassEnd)() override
+ {
+ }
+
+ STDMETHOD_(void, OnStreamEnd)() override
+ {
+ }
+
+ STDMETHOD_(void, OnBufferStart)(void*) override
+ {
+ }
+
+ STDMETHOD_(void, OnBufferEnd)(void*) override
+ {
+ SubmitBuffer();
+ }
+
+ STDMETHOD_(void, OnLoopEnd)(void*) override
+ {
+ }
+
+ STDMETHOD_(void, OnVoiceError)(void*, HRESULT) override
+ {
+ }
+};
+
+static HMODULE _xaudio_dll_handle;
+static IXAudio2SourceVoice* _source_voice = nullptr;
+static IXAudio2MasteringVoice* _mastering_voice = nullptr;
+static ComPtr<IXAudio2> _xaudio2;
+static StreamingVoiceContext* _voice_context = nullptr;
+
+/**
+* Initialises the XAudio2 driver.
+*
+* @param parm Driver parameters.
+* @return An error message if unsuccessful, or NULL otherwise.
+*
+*/
+const char *SoundDriver_XAudio2::Start(const char * const *parm)
+{
+ HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
+
+ if (FAILED(hr))
+ {
+ DEBUG(driver, 0, "xaudio2_s: CoInitializeEx failed (%08x)", hr);
+ return "Failed to initialise COM";
+ }
+
+ _xaudio_dll_handle = LoadLibraryA(XAUDIO2_DLL_A);
+
+ if (_xaudio_dll_handle == NULL)
+ {
+ CoUninitialize();
+
+ DEBUG(driver, 0, "xaudio2_s: Unable to load " XAUDIO2_DLL_A);
+ return "Failed to load XAudio2 DLL";
+ }
+
+ API_XAudio2Create xAudio2Create = (API_XAudio2Create) GetProcAddress(_xaudio_dll_handle, "XAudio2Create");
+
+ if (xAudio2Create == NULL)
+ {
+ FreeLibrary(_xaudio_dll_handle);
+ CoUninitialize();
+
+ DEBUG(driver, 0, "xaudio2_s: Unable to find XAudio2Create function in DLL");
+ return "Failed to load XAudio2 DLL";
+ }
+
+ // Create the XAudio engine
+ UINT32 flags = 0;
+ hr = xAudio2Create(_xaudio2.GetAddressOf(), flags, XAUDIO2_DEFAULT_PROCESSOR);
+
+ if (FAILED(hr))
+ {
+ FreeLibrary(_xaudio_dll_handle);
+ CoUninitialize();
+
+ DEBUG(driver, 0, "xaudio2_s: XAudio2Create failed (%08x)", hr);
+ return "Failed to inititialise the XAudio2 engine";
+ }
+
+ // Create a mastering voice
+ hr = _xaudio2->CreateMasteringVoice(&_mastering_voice);
+
+ if (FAILED(hr))
+ {
+ _xaudio2.Reset();
+ FreeLibrary(_xaudio_dll_handle);
+ CoUninitialize();
+
+ DEBUG(driver, 0, "xaudio2_s: CreateMasteringVoice failed (%08x)", hr);
+ return "Failed to create a mastering voice";
+ }
+
+ // Create a source voice to stream our audio
+ WAVEFORMATEX wfex;
+
+ wfex.wFormatTag = WAVE_FORMAT_PCM;
+ wfex.nChannels = 2;
+ wfex.wBitsPerSample = 16;
+ wfex.nSamplesPerSec = GetDriverParamInt(parm, "hz", 44100);
+ wfex.nBlockAlign = (wfex.nChannels * wfex.wBitsPerSample) / 8;
+ wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign;
+
+ // Limit buffer size to prevent overflows
+ int bufsize = GetDriverParamInt(parm, "bufsize", 8192);
+ bufsize = min(bufsize, UINT16_MAX);
+
+ _voice_context = new StreamingVoiceContext(bufsize * 4);
+
+ if (_voice_context == nullptr)
+ {
+ _mastering_voice->DestroyVoice();
+ _xaudio2.Reset();
+ FreeLibrary(_xaudio_dll_handle);
+ CoUninitialize();
+
+ return "Failed to create streaming voice context";
+ }
+
+ hr = _xaudio2->CreateSourceVoice(&_source_voice, &wfex, 0, 1.0f, _voice_context);
+
+ if (FAILED(hr))
+ {
+ _mastering_voice->DestroyVoice();
+ _xaudio2.Reset();
+ FreeLibrary(_xaudio_dll_handle);
+ CoUninitialize();
+
+ DEBUG(driver, 0, "xaudio2_s: CreateSourceVoice failed (%08x)", hr);
+ return "Failed to create a source voice";
+ }
+
+ _voice_context->SourceVoice = _source_voice;
+ hr = _source_voice->Start(0, 0);
+
+ if (FAILED(hr))
+ {
+ DEBUG(driver, 0, "xaudio2_s: _source_voice->Start failed (%08x)", hr);
+
+ Stop();
+ return "Failed to start the source voice";
+ }
+
+ MxInitialize(wfex.nSamplesPerSec);
+
+ // Submit the first buffer
+ hr = _voice_context->SubmitBuffer();
+
+ if (FAILED(hr))
+ {
+ DEBUG(driver, 0, "xaudio2_s: _voice_context->SubmitBuffer failed (%08x)", hr);
+
+ Stop();
+ return "Failed to submit the first audio buffer";
+ }
+
+ return NULL;
+}
+
+/**
+* Terminates the XAudio2 driver.
+*/
+void SoundDriver_XAudio2::Stop()
+{
+ // Clean up XAudio2
+ _source_voice->DestroyVoice();
+
+ delete _voice_context;
+ _voice_context = nullptr;
+
+ _mastering_voice->DestroyVoice();
+
+ _xaudio2.Reset();
+
+ FreeLibrary(_xaudio_dll_handle);
+ CoUninitialize();
+}
+
+#endif
diff --git a/src/sound/xaudio2_s.h b/src/sound/xaudio2_s.h
new file mode 100644
index 000000000..2385f49ee
--- /dev/null
+++ b/src/sound/xaudio2_s.h
@@ -0,0 +1,33 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD 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 General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file xaudio2_s.h Base for XAudio2 sound handling. */
+
+#ifndef SOUND_XAUDIO2_H
+#define SOUND_XAUDIO2_H
+
+#include "sound_driver.hpp"
+
+/** Implementation of the XAudio2 sound driver. */
+class SoundDriver_XAudio2 : public SoundDriver {
+public:
+ /* virtual */ const char *Start(const char * const *param);
+
+ /* virtual */ void Stop();
+ /* virtual */ const char *GetName() const { return "xaudio2"; }
+};
+
+/** Factory for the XAudio2 sound driver. */
+class FSoundDriver_XAudio2 : public DriverFactoryBase {
+public:
+ FSoundDriver_XAudio2() : DriverFactoryBase(Driver::DT_SOUND, 10, "xaudio2", "XAudio2 Sound Driver") {}
+ /* virtual */ Driver *CreateInstance() const { return new SoundDriver_XAudio2(); }
+};
+
+#endif /* SOUND_XAUDIO2_H */