From: <sag...@us...> - 2014-10-11 13:46:33
|
Revision: 4418 http://sourceforge.net/p/modplug/code/4418 Author: saga-games Date: 2014-10-11 13:46:17 +0000 (Sat, 11 Oct 2014) Log Message: ----------- [Int] Apparently VS2013 also has some trouble with ksguid.lib. To keep things tidy, never link against ksguid.lib but always use PortAudio's built-in workaround. Modified Paths: -------------- trunk/OpenMPT/build/gen/portaudio.vcproj trunk/OpenMPT/build/gen/portaudio.vcxproj trunk/OpenMPT/include/portaudio/OpenMPT.txt trunk/OpenMPT/include/portaudio/src/os/win/pa_win_wdmks_utils.c trunk/OpenMPT/include/premake4.lua trunk/OpenMPT/mptrack/MPTrackLink.cpp Modified: trunk/OpenMPT/build/gen/portaudio.vcproj =================================================================== --- trunk/OpenMPT/build/gen/portaudio.vcproj 2014-10-11 13:22:18 UTC (rev 4417) +++ trunk/OpenMPT/build/gen/portaudio.vcproj 2014-10-11 13:46:17 UTC (rev 4418) @@ -45,7 +45,7 @@ AdditionalOptions="/wd4018 /wd4267" Optimization="0" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -61,7 +61,7 @@ /> <Tool Name="VCResourceCompilerTool" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" /> <Tool @@ -124,7 +124,7 @@ AdditionalOptions="/wd4018 /wd4267" Optimization="0" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -140,7 +140,7 @@ /> <Tool Name="VCResourceCompilerTool" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" /> <Tool @@ -202,7 +202,7 @@ AdditionalOptions="/wd4018 /wd4267 /MP" Optimization="3" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="true" @@ -218,7 +218,7 @@ /> <Tool Name="VCResourceCompilerTool" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" /> <Tool @@ -281,7 +281,7 @@ AdditionalOptions="/wd4018 /wd4267 /MP" Optimization="3" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="true" @@ -297,7 +297,7 @@ /> <Tool Name="VCResourceCompilerTool" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" /> <Tool @@ -359,7 +359,7 @@ AdditionalOptions="/wd4018 /wd4267 /GL- /MP" Optimization="3" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="true" @@ -375,7 +375,7 @@ /> <Tool Name="VCResourceCompilerTool" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" /> <Tool @@ -438,7 +438,7 @@ AdditionalOptions="/wd4018 /wd4267 /GL- /MP" Optimization="3" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="true" @@ -454,7 +454,7 @@ /> <Tool Name="VCResourceCompilerTool" - PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + PreprocessorDefinitions="PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" AdditionalIncludeDirectories="..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win" /> <Tool Modified: trunk/OpenMPT/build/gen/portaudio.vcxproj =================================================================== --- trunk/OpenMPT/build/gen/portaudio.vcxproj 2014-10-11 13:22:18 UTC (rev 4417) +++ trunk/OpenMPT/build/gen/portaudio.vcxproj 2014-10-11 13:46:17 UTC (rev 4418) @@ -114,7 +114,7 @@ <AdditionalOptions>/wd4018 /wd4267 %(AdditionalOptions)</AdditionalOptions> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> @@ -125,7 +125,7 @@ <CompileAs>CompileAsC</CompileAs> </ClCompile> <ResourceCompile> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> <Lib> @@ -142,7 +142,7 @@ <AdditionalOptions>/wd4018 /wd4267 %(AdditionalOptions)</AdditionalOptions> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> @@ -153,7 +153,7 @@ <CompileAs>CompileAsC</CompileAs> </ClCompile> <ResourceCompile> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;PA_ENABLE_DEBUG_OUTPUT;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> <Lib> @@ -170,7 +170,7 @@ <AdditionalOptions>/wd4018 /wd4267 /MP %(AdditionalOptions)</AdditionalOptions> <Optimization>Full</Optimization> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>false</MinimalRebuild> <StringPooling>true</StringPooling> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> @@ -182,7 +182,7 @@ <CompileAs>CompileAsC</CompileAs> </ClCompile> <ResourceCompile> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> <Lib> @@ -201,7 +201,7 @@ <AdditionalOptions>/wd4018 /wd4267 /MP %(AdditionalOptions)</AdditionalOptions> <Optimization>Full</Optimization> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>false</MinimalRebuild> <StringPooling>true</StringPooling> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> @@ -213,7 +213,7 @@ <CompileAs>CompileAsC</CompileAs> </ClCompile> <ResourceCompile> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> <Lib> @@ -232,7 +232,7 @@ <AdditionalOptions>/wd4018 /wd4267 /GL- /MP %(AdditionalOptions)</AdditionalOptions> <Optimization>Full</Optimization> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>false</MinimalRebuild> <StringPooling>true</StringPooling> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> @@ -244,7 +244,7 @@ <CompileAs>CompileAsC</CompileAs> </ClCompile> <ResourceCompile> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> <Lib> @@ -262,7 +262,7 @@ <AdditionalOptions>/wd4018 /wd4267 /GL- /MP %(AdditionalOptions)</AdditionalOptions> <Optimization>Full</Optimization> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>false</MinimalRebuild> <StringPooling>true</StringPooling> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> @@ -274,7 +274,7 @@ <CompileAs>CompileAsC</CompileAs> </ClCompile> <ResourceCompile> - <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>PAWIN_USE_WDMKS_DEVICE_INFO;PA_WDMKS_NO_KSGUID_LIB;PA_USE_ASIO=0;PA_USE_DS=0;PA_USE_WMME=1;PA_USE_WASAPI=1;PA_USE_WDMKS=1;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>..\..\include\portaudio\include;..\..\include\portaudio\src\common;..\..\include\portaudio\src\os\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> <Lib> Modified: trunk/OpenMPT/include/portaudio/OpenMPT.txt =================================================================== --- trunk/OpenMPT/include/portaudio/OpenMPT.txt 2014-10-11 13:22:18 UTC (rev 4417) +++ trunk/OpenMPT/include/portaudio/OpenMPT.txt 2014-10-11 13:46:17 UTC (rev 4418) @@ -1,9 +1,6 @@ - Portaudio version svn-r1910 as of 2013-09-07. - A small modification to portaudio code has been made in src/hostapi/wdmks/pa_win_wdmks.c to facilitate linking against strmiids.lib . Look for "OpenMPT" there. - - The VS2008 x64 SDK does not provide ksguid.lib. src/os/win/pa_win_wdmks_utils.c - has a work-around for this problem. Code has been added to automatically activate the work- - around in this case. Look for "OpenMPT". - Portaudio can freeze on Windows XP when intializing Kernel Streaming and the sound setup topology doesn't meet some assumptions Portaudio seems to make. There is no official fix for this yet, but a fix has been posted on the Audacity mailing list @@ -13,3 +10,7 @@ - For building, premake4 is used to generate Visual Studio project files. See ../premake4.lua for details. + NOTE: Various versions of the Windows SDK (such as the one provided with the VS2008 x64 compiler) + do not provide ksguid.lib. To simplify the build configuration, PA_WDMKS_NO_KSGUID_LIB + is defined in the premake projects to always use PortAudio's workaround, regardless of + the compiler version used. Modified: trunk/OpenMPT/include/portaudio/src/os/win/pa_win_wdmks_utils.c =================================================================== --- trunk/OpenMPT/include/portaudio/src/os/win/pa_win_wdmks_utils.c 2014-10-11 13:22:18 UTC (rev 4417) +++ trunk/OpenMPT/include/portaudio/src/os/win/pa_win_wdmks_utils.c 2014-10-11 13:46:17 UTC (rev 4418) @@ -66,15 +66,6 @@ #include "pa_util.h" #include "pa_win_wdmks_utils.h" -// OpenMPT -#if defined(_MSC_VER) -#if (_MSC_VER < 1600) // before VS2010 -#if defined(_M_X64) -#define PA_WDMKS_NO_KSGUID_LIB -#endif -#endif -#endif - #if !defined(PA_WDMKS_NO_KSGUID_LIB) && !defined(PAWIN_WDMKS_NO_KSGUID_LIB) && !defined(__GNUC__) #if (defined(WIN32) && (defined(_MSC_VER) && (_MSC_VER >= 1200))) /* MSC version 6 and above */ #pragma comment( lib, "ksguid.lib" ) Modified: trunk/OpenMPT/include/premake4.lua =================================================================== --- trunk/OpenMPT/include/premake4.lua 2014-10-11 13:22:18 UTC (rev 4417) +++ trunk/OpenMPT/include/premake4.lua 2014-10-11 13:46:17 UTC (rev 4418) @@ -359,6 +359,7 @@ includedirs { "../include/portaudio/include", "../include/portaudio/src/common", "../include/portaudio/src/os/win" } defines { "PAWIN_USE_WDMKS_DEVICE_INFO", + "PA_WDMKS_NO_KSGUID_LIB", "PA_USE_ASIO=0", "PA_USE_DS=0", "PA_USE_WMME=1", Modified: trunk/OpenMPT/mptrack/MPTrackLink.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTrackLink.cpp 2014-10-11 13:22:18 UTC (rev 4417) +++ trunk/OpenMPT/mptrack/MPTrackLink.cpp 2014-10-11 13:46:17 UTC (rev 4418) @@ -30,11 +30,6 @@ #pragma comment(lib, "winmm.lib") #pragma comment(lib, "ksuser.lib") -#if MPT_MSVC_BEFORE(2010,0) && defined(_M_X64) -// VS2008 x64 SDK has no ksguid.lib. Work-around in include\portaudio\src\os\win\pa_win_wdmks_utils.c . -#else -#pragma comment(lib, "ksguid.lib") -#endif #pragma comment(lib, "msacm32.lib") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-11 22:36:00
|
Revision: 4426 http://sourceforge.net/p/modplug/code/4426 Author: saga-games Date: 2014-10-11 22:35:48 +0000 (Sat, 11 Oct 2014) Log Message: ----------- [Fix] Playback: VST arpeggio could be executed on muted channels / instruments [Ref] Use Patterns.Size() instead of Patterns.GetNumPatterns() where it makes sense. Modified Paths: -------------- trunk/OpenMPT/mptrack/MPTHacks.cpp trunk/OpenMPT/mptrack/ModConvert.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/MPTHacks.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTHacks.cpp 2014-10-11 19:15:32 UTC (rev 4425) +++ trunk/OpenMPT/mptrack/MPTHacks.cpp 2014-10-11 22:35:48 UTC (rev 4426) @@ -243,7 +243,8 @@ foundHacks = true; if(autofix) { - for(PATTERNINDEX i = 0; i < m_SndFile.Patterns.GetNumPatterns(); i++) + const PATTERNINDEX numPats = m_SndFile.Patterns.GetNumPatterns(); + for(PATTERNINDEX i = 0; i < numPats; i++) { m_SndFile.Patterns[i].SetName(""); } @@ -400,7 +401,8 @@ if(!originalSpecs->hasPatternSignatures) { foundHere = false; - for(PATTERNINDEX i = 0; i < m_SndFile.Patterns.GetNumPatterns(); i++) + const PATTERNINDEX numPats = m_SndFile.Patterns.GetNumPatterns(); + for(PATTERNINDEX i = 0; i < numPats; i++) { if(m_SndFile.Patterns[i].GetOverrideSignature()) { @@ -436,7 +438,7 @@ } // Embedded MIDI configuration in XM files - if(m_SndFile.m_SongFlags[SONG_EMBEDMIDICFG] != 0 && m_SndFile.GetType() == MOD_TYPE_XM) + if(m_SndFile.m_SongFlags[SONG_EMBEDMIDICFG] && !(originalSpecs->songFlags & SONG_EMBEDMIDICFG)) { AddToLog("Found embedded MIDI macros"); foundHacks = true; Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2014-10-11 19:15:32 UTC (rev 4425) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2014-10-11 22:35:48 UTC (rev 4426) @@ -497,7 +497,7 @@ // Check for patterns with custom time signatures (fixing will be applied in the pattern container) if(!CSoundFile::GetModSpecifications(nNewType).hasPatternSignatures) { - for(PATTERNINDEX nPat = 0; nPat < m_SndFile.Patterns.GetNumPatterns(); nPat++) + for(PATTERNINDEX nPat = 0; nPat < m_SndFile.Patterns.Size(); nPat++) { if(m_SndFile.Patterns[nPat].GetOverrideSignature()) { Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-11 19:15:32 UTC (rev 4425) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-11 22:35:48 UTC (rev 4426) @@ -1536,7 +1536,7 @@ } SAMPLEINDEX nExt = 0; - for (PATTERNINDEX nPat = 0; nPat < Patterns.GetNumPatterns(); nPat++) if(Patterns.IsValidPat(nPat)) + for (PATTERNINDEX nPat = 0; nPat < Patterns.Size(); nPat++) if(Patterns.IsValidPat(nPat)) { CPattern::const_iterator pEnd = Patterns[nPat].End(); for(CPattern::const_iterator p = Patterns[nPat].Begin(); p != pEnd; p++) Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-10-11 19:15:32 UTC (rev 4425) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-10-11 22:35:48 UTC (rev 4426) @@ -1140,7 +1140,9 @@ #ifndef NO_VST // Plugin arpeggio - if(pChn->pModInstrument && pChn->pModInstrument->nMixPlug) + if(pChn->pModInstrument && pChn->pModInstrument->nMixPlug + && !pChn->pModInstrument->dwFlags[INS_MUTE] + && !pChn->dwFlags[CHN_MUTE | CHN_SYNCMUTE]) { const ModInstrument *pIns = pChn->pModInstrument; IMixPlugin *pPlugin = m_MixPlugins[pIns->nMixPlug - 1].pMixPlugin; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-11 23:24:46
|
Revision: 4427 http://sourceforge.net/p/modplug/code/4427 Author: saga-games Date: 2014-10-11 23:24:33 +0000 (Sat, 11 Oct 2014) Log Message: ----------- [New] S70/S71/S72 commands do now also work with instrument plugins. [Fix] Playback: NNA/DCA were not applied properly to plugins assigned to sample-less instruments [Mod] OpenMPT: Version is now 1.24.00.09 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-10-11 22:35:48 UTC (rev 4426) +++ trunk/OpenMPT/common/versionNumber.h 2014-10-11 23:24:33 UTC (rev 4427) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 00 -#define VER_MINORMINOR 08 +#define VER_MINORMINOR 09 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-10-11 22:35:48 UTC (rev 4426) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-10-11 23:24:33 UTC (rev 4427) @@ -973,7 +973,7 @@ pChn->nNewIns = 0; // IT Compatiblity: NNA is reset on every note change, not every instrument change (fixes s7xinsnum.it). - if (pIns && !IsCompatibleMode(TRK_IMPULSETRACKER) && (pIns->nMixPlug || pSmp)) //rewbs.VSTiNNA + if (pIns && ((!IsCompatibleMode(TRK_IMPULSETRACKER) && pSmp) || pIns->nMixPlug)) pChn->nNNA = pIns->nNNA; if (pSmp) @@ -1690,7 +1690,7 @@ IMixPlugin *pPlugin = m_MixPlugins[pIns->nMixPlug-1].pMixPlugin; if(pPlugin && p->nNote != NOTE_NONE) { - pPlugin->MidiCommand(GetBestMidiChannel(i), p->pModInstrument->nMidiProgram, p->pModInstrument->wMidiBank, p->nLastNote + NOTE_MAX_SPECIAL, 0, i); + pPlugin->MidiCommand(GetBestMidiChannel(i), p->pModInstrument->nMidiProgram, p->pModInstrument->wMidiBank, p->nNote + NOTE_MAX_SPECIAL, 0, i); } break; } @@ -1780,7 +1780,7 @@ case NNA_NOTEFADE: //switch off note played on this plugin, on this tracker channel and midi channel //pPlugin->MidiCommand(pChn->pModInstrument->nMidiChannel, pChn->pModInstrument->nMidiProgram, pChn->nNote + NOTE_MAX_SPECIAL, 0, n); - pPlugin->MidiCommand(GetBestMidiChannel(nChn), pChn->pModInstrument->nMidiProgram, pChn->pModInstrument->wMidiBank, /*pChn->nNote+*/NOTE_MAX_SPECIAL, 0, nChn); + pPlugin->MidiCommand(GetBestMidiChannel(nChn), pChn->pModInstrument->nMidiProgram, pChn->pModInstrument->wMidiBank, NOTE_KEYOFF, 0, nChn); break; } } @@ -3867,6 +3867,12 @@ bkp->dwFlags.set(CHN_NOTEFADE); bkp->nFadeOutVol = 0; } + const ModInstrument *pIns = bkp->pModInstrument; + IMixPlugin *pPlugin; + if(pIns != nullptr && pIns->nMixPlug && (pPlugin = m_MixPlugins[pIns->nMixPlug - 1].pMixPlugin) != nullptr) + { + pPlugin->MidiCommand(GetBestMidiChannel(nChn), pIns->nMidiProgram, pIns->wMidiBank, bkp->nNote + NOTE_MAX_SPECIAL, 0, nChn); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-13 08:07:13
|
Revision: 4429 http://sourceforge.net/p/modplug/code/4429 Author: manxorist Date: 2014-10-13 08:07:03 +0000 (Mon, 13 Oct 2014) Log Message: ----------- [Ref] build: Split premake files for external libraries into one per library. Modified Paths: -------------- trunk/OpenMPT/build/premake4.lua Added Paths: ----------- trunk/OpenMPT/include/UnRAR.premake4.lua trunk/OpenMPT/include/flac.premake4.lua trunk/OpenMPT/include/lhasa.premake4.lua trunk/OpenMPT/include/miniz.premake4.lua trunk/OpenMPT/include/minizip.premake4.lua trunk/OpenMPT/include/portaudio.premake4.lua trunk/OpenMPT/include/portmidi.premake4.lua trunk/OpenMPT/include/smbPitchShift.premake4.lua trunk/OpenMPT/include/soundtouch.premake4.lua trunk/OpenMPT/include/zlib.premake4.lua Removed Paths: ------------- trunk/OpenMPT/include/premake4.lua Modified: trunk/OpenMPT/build/premake4.lua =================================================================== --- trunk/OpenMPT/build/premake4.lua 2014-10-12 08:35:43 UTC (rev 4428) +++ trunk/OpenMPT/build/premake4.lua 2014-10-13 08:07:03 UTC (rev 4429) @@ -3,4 +3,13 @@ configurations { "Debug", "Release", "ReleaseNoLTCG" } platforms { "x32", "x64" } - dofile "../include/premake4.lua" + dofile "../include/flac.premake4.lua" + dofile "../include/lhasa.premake4.lua" + dofile "../include/miniz.premake4.lua" + dofile "../include/minizip.premake4.lua" + dofile "../include/portaudio.premake4.lua" + dofile "../include/portmidi.premake4.lua" + dofile "../include/smbPitchShift.premake4.lua" + dofile "../include/soundtouch.premake4.lua" + dofile "../include/UnRAR.premake4.lua" + dofile "../include/zlib.premake4.lua" Added: trunk/OpenMPT/include/UnRAR.premake4.lua =================================================================== --- trunk/OpenMPT/include/UnRAR.premake4.lua (rev 0) +++ trunk/OpenMPT/include/UnRAR.premake4.lua 2014-10-13 08:07:03 UTC (rev 4429) @@ -0,0 +1,130 @@ + + project "UnRAR" + uuid "95CC809B-03FC-4EDB-BB20-FD07A698C05F" + language "C++" + location "../build/gen" + objdir "../build/obj/unrar" + includedirs { "../include/unrar" } + files { + "../include/unrar/archive.cpp", + "../include/unrar/arcread.cpp", + "../include/unrar/blake2s.cpp", + "../include/unrar/cmddata.cpp", + "../include/unrar/consio.cpp", + "../include/unrar/crc.cpp", + "../include/unrar/crypt.cpp", + "../include/unrar/encname.cpp", + "../include/unrar/errhnd.cpp", + "../include/unrar/extinfo.cpp", + "../include/unrar/extract.cpp", + "../include/unrar/filcreat.cpp", + "../include/unrar/file.cpp", + "../include/unrar/filefn.cpp", + "../include/unrar/filestr.cpp", + "../include/unrar/find.cpp", + "../include/unrar/getbits.cpp", + "../include/unrar/global.cpp", + "../include/unrar/hash.cpp", + "../include/unrar/headers.cpp", + "../include/unrar/isnt.cpp", + "../include/unrar/list.cpp", + "../include/unrar/match.cpp", + "../include/unrar/options.cpp", + "../include/unrar/pathfn.cpp", + "../include/unrar/qopen.cpp", + "../include/unrar/rar.cpp", + "../include/unrar/rarpch.cpp", + "../include/unrar/rarvm.cpp", + "../include/unrar/rawread.cpp", + "../include/unrar/rdwrfn.cpp", + "../include/unrar/recvol.cpp", + "../include/unrar/resource.cpp", + "../include/unrar/rijndael.cpp", + "../include/unrar/rs.cpp", + "../include/unrar/rs16.cpp", + "../include/unrar/scantree.cpp", + "../include/unrar/secpassword.cpp", + "../include/unrar/sha1.cpp", + "../include/unrar/sha256.cpp", + "../include/unrar/smallfn.cpp", + "../include/unrar/strfn.cpp", + "../include/unrar/strlist.cpp", + "../include/unrar/system.cpp", + "../include/unrar/threadpool.cpp", + "../include/unrar/timefn.cpp", + "../include/unrar/ui.cpp", + "../include/unrar/unicode.cpp", + "../include/unrar/unpack.cpp", + "../include/unrar/volume.cpp", + } + files { + "../include/unrar/archive.hpp", + "../include/unrar/array.hpp", + "../include/unrar/blake2s.hpp", + "../include/unrar/cmddata.hpp", + "../include/unrar/coder.hpp", + "../include/unrar/compress.hpp", + "../include/unrar/consio.hpp", + "../include/unrar/crc.hpp", + "../include/unrar/crypt.hpp", + "../include/unrar/dll.hpp", + "../include/unrar/encname.hpp", + "../include/unrar/errhnd.hpp", + "../include/unrar/extinfo.hpp", + "../include/unrar/extract.hpp", + "../include/unrar/filcreat.hpp", + "../include/unrar/file.hpp", + "../include/unrar/filefn.hpp", + "../include/unrar/filestr.hpp", + "../include/unrar/find.hpp", + "../include/unrar/getbits.hpp", + "../include/unrar/global.hpp", + "../include/unrar/hash.hpp", + "../include/unrar/headers.hpp", + "../include/unrar/headers5.hpp", + "../include/unrar/isnt.hpp", + "../include/unrar/list.hpp", + "../include/unrar/loclang.hpp", + "../include/unrar/log.hpp", + "../include/unrar/match.hpp", + "../include/unrar/model.hpp", + "../include/unrar/openmpt.hpp", + "../include/unrar/openmpt-callback.hpp", + "../include/unrar/options.hpp", + "../include/unrar/os.hpp", + "../include/unrar/pathfn.hpp", + "../include/unrar/qopen.hpp", + "../include/unrar/rar.hpp", + "../include/unrar/rardefs.hpp", + "../include/unrar/rarlang.hpp", + "../include/unrar/raros.hpp", + "../include/unrar/rartypes.hpp", + "../include/unrar/rarvm.hpp", + "../include/unrar/rawread.hpp", + "../include/unrar/rdwrfn.hpp", + "../include/unrar/recvol.hpp", + "../include/unrar/resource.hpp", + "../include/unrar/rijndael.hpp", + "../include/unrar/rs.hpp", + "../include/unrar/rs16.hpp", + "../include/unrar/savepos.hpp", + "../include/unrar/scantree.hpp", + "../include/unrar/secpassword.hpp", + "../include/unrar/sha1.hpp", + "../include/unrar/sha256.hpp", + "../include/unrar/smallfn.hpp", + "../include/unrar/strfn.hpp", + "../include/unrar/strlist.hpp", + "../include/unrar/suballoc.hpp", + "../include/unrar/system.hpp", + "../include/unrar/threadpool.hpp", + "../include/unrar/timefn.hpp", + "../include/unrar/ulinks.hpp", + "../include/unrar/ui.hpp", + "../include/unrar/unicode.hpp", + "../include/unrar/unpack.hpp", + "../include/unrar/version.hpp", + "../include/unrar/volume.hpp", + } + dofile "../build/premake4-defaults-LIB.lua" + dofile "../build/premake4-defaults-static.lua" Property changes on: trunk/OpenMPT/include/UnRAR.premake4.lua ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/x-lua \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/include/flac.premake4.lua =================================================================== --- trunk/OpenMPT/include/flac.premake4.lua (rev 0) +++ trunk/OpenMPT/include/flac.premake4.lua 2014-10-13 08:07:03 UTC (rev 4429) @@ -0,0 +1,69 @@ + + project "flac" + uuid "E599F5AA-F9A3-46CC-8DB0-C8DEFCEB90C5" + language "C" + location "../build/gen" + objdir "../build/obj/flac" + includedirs { "../include/flac/include", "../include/flac/src/libFLAC/include" } + files { + "../include/flac/src/libFLAC/bitmath.c", + "../include/flac/src/libFLAC/bitreader.c", + "../include/flac/src/libFLAC/bitwriter.c", + "../include/flac/src/libFLAC/cpu.c", + "../include/flac/src/libFLAC/crc.c", + "../include/flac/src/libFLAC/fixed.c", + "../include/flac/src/libFLAC/float.c", + "../include/flac/src/libFLAC/format.c", + "../include/flac/src/libFLAC/lpc.c", + "../include/flac/src/libFLAC/md5.c", + "../include/flac/src/libFLAC/memory.c", + "../include/flac/src/libFLAC/metadata_iterators.c", + "../include/flac/src/libFLAC/metadata_object.c", + "../include/flac/src/libFLAC/stream_decoder.c", + "../include/flac/src/libFLAC/stream_encoder.c", + "../include/flac/src/libFLAC/stream_encoder_framing.c", + "../include/flac/src/libFLAC/window.c", + } + files { + "../include/flac/src/share/win_utf8_io/win_utf8_io.c", + } + files { + "../include/flac/src/libFLAC/include/private/all.h", + "../include/flac/src/libFLAC/include/private/bitmath.h", + "../include/flac/src/libFLAC/include/private/bitreader.h", + "../include/flac/src/libFLAC/include/private/bitwriter.h", + "../include/flac/src/libFLAC/include/private/cpu.h", + "../include/flac/src/libFLAC/include/private/crc.h", + "../include/flac/src/libFLAC/include/private/fixed.h", + "../include/flac/src/libFLAC/include/private/float.h", + "../include/flac/src/libFLAC/include/private/format.h", + "../include/flac/src/libFLAC/include/private/lpc.h", + "../include/flac/src/libFLAC/include/private/md5.h", + "../include/flac/src/libFLAC/include/private/memory.h", + "../include/flac/src/libFLAC/include/private/metadata.h", + "../include/flac/src/libFLAC/include/private/stream_encoder_framing.h", + "../include/flac/src/libFLAC/include/private/window.h", + "../include/flac/src/libFLAC/include/protected/all.h", + "../include/flac/src/libFLAC/include/protected/stream_decoder.h", + "../include/flac/src/libFLAC/include/protected/stream_encoder.h", + } + files { + "../include/flac/include/FLAC/all.h", + "../include/flac/include/FLAC/assert.h", + "../include/flac/include/FLAC/callback.h", + "../include/flac/include/FLAC/export.h", + "../include/flac/include/FLAC/format.h", + "../include/flac/include/FLAC/metadata.h", + "../include/flac/include/FLAC/ordinals.h", + "../include/flac/include/FLAC/stream_decoder.h", + "../include/flac/include/FLAC/stream_encoder.h", + } + buildoptions { "/wd4244", "/wd4267", "/wd4334" } + configuration "*Lib" + defines { "FLAC__NO_DLL" } + configuration "vs2010" + defines { "VERSION=\"1.3.0\"" } + configuration "vs2008" + defines { "VERSION=\\\"1.3.0\\\"" } + dofile "../build/premake4-defaults-LIB.lua" + dofile "../build/premake4-defaults-static.lua" Property changes on: trunk/OpenMPT/include/flac.premake4.lua ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/x-lua \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/include/lhasa.premake4.lua =================================================================== --- trunk/OpenMPT/include/lhasa.premake4.lua (rev 0) +++ trunk/OpenMPT/include/lhasa.premake4.lua 2014-10-13 08:07:03 UTC (rev 4429) @@ -0,0 +1,50 @@ + + project "lhasa" + uuid "6B11F6A8-B131-4D2B-80EF-5731A9016436" + language "C" + location "../build/gen" + objdir "../build/obj/lhasa" + includedirs { "../include/msinttypes/inttypes" } + files { + "../include/lhasa/lib/crc16.c", + "../include/lhasa/lib/ext_header.c", + "../include/lhasa/lib/lh1_decoder.c", + "../include/lhasa/lib/lh5_decoder.c", + "../include/lhasa/lib/lh6_decoder.c", + "../include/lhasa/lib/lh7_decoder.c", + "../include/lhasa/lib/lha_arch_unix.c", + "../include/lhasa/lib/lha_arch_win32.c", + "../include/lhasa/lib/lha_basic_reader.c", + "../include/lhasa/lib/lha_decoder.c", + "../include/lhasa/lib/lha_endian.c", + "../include/lhasa/lib/lha_file_header.c", + "../include/lhasa/lib/lha_input_stream.c", + "../include/lhasa/lib/lha_reader.c", + "../include/lhasa/lib/lhx_decoder.c", + "../include/lhasa/lib/lz5_decoder.c", + "../include/lhasa/lib/lzs_decoder.c", + "../include/lhasa/lib/macbinary.c", + "../include/lhasa/lib/null_decoder.c", + "../include/lhasa/lib/pm1_decoder.c", + "../include/lhasa/lib/pm2_decoder.c", + } + files { + "../include/lhasa/lib/crc16.h", + "../include/lhasa/lib/ext_header.h", + "../include/lhasa/lib/lha_arch.h", + "../include/lhasa/lib/lha_basic_reader.h", + "../include/lhasa/lib/lha_decoder.h", + "../include/lhasa/lib/lha_endian.h", + "../include/lhasa/lib/lha_file_header.h", + "../include/lhasa/lib/lha_input_stream.h", + "../include/lhasa/lib/macbinary.h", + "../include/lhasa/lib/public/lha_decoder.h", + "../include/lhasa/lib/public/lha_file_header.h", + "../include/lhasa/lib/public/lha_input_stream.h", + "../include/lhasa/lib/public/lha_reader.h", + "../include/lhasa/lib/public/lhasa.h", + } + configuration "vs2008" + includedirs { "../include/msinttypes/stdint" } + dofile "../build/premake4-defaults-LIB.lua" + dofile "../build/premake4-defaults-static.lua" Property changes on: trunk/OpenMPT/include/lhasa.premake4.lua ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/x-lua \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/include/miniz.premake4.lua =================================================================== --- trunk/OpenMPT/include/miniz.premake4.lua (rev 0) +++ trunk/OpenMPT/include/miniz.premake4.lua 2014-10-13 08:07:03 UTC (rev 4429) @@ -0,0 +1,11 @@ + + project "miniz" + uuid "B5E0C06B-8121-426A-8FFB-4293ECAAE29C" + language "C" + location "../build/gen" + objdir "../build/obj/miniz" + files { + "../include/miniz/miniz.c", + } + dofile "../build/premake4-defaults-LIB.lua" + dofile "../build/premake4-defaults-static.lua" Property changes on: trunk/OpenMPT/include/miniz.premake4.lua ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/x-lua \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/include/minizip.premake4.lua =================================================================== --- trunk/OpenMPT/include/minizip.premake4.lua (rev 0) +++ trunk/OpenMPT/include/minizip.premake4.lua 2014-10-13 08:07:03 UTC (rev 4429) @@ -0,0 +1,24 @@ + + project "minizip" + uuid "63AF9025-A6CE-4147-A05D-6E2CCFD3A0D7" + language "C" + location "../build/gen" + objdir "../build/obj/minizip" + includedirs { "../include/zlib", "../include/zlib/contrib/minizip" } + files { + "../include/zlib/contrib/minizip/ioapi.c", + "../include/zlib/contrib/minizip/iowin32.c", + "../include/zlib/contrib/minizip/mztools.c", + "../include/zlib/contrib/minizip/unzip.c", + "../include/zlib/contrib/minizip/zip.c", + } + files { + "../include/zlib/contrib/minizip/crypt.h", + "../include/zlib/contrib/minizip/ioapi.h", + "../include/zlib/contrib/minizip/iowin32.h", + "../include/zlib/contrib/minizip/mztools.h", + "../include/zlib/contrib/minizip/unzip.h", + "../include/zlib/contrib/minizip/zip.h", + } + dofile "../build/premake4-defaults-LIB.lua" + dofile "../build/premake4-defaults-static.lua" Property changes on: trunk/OpenMPT/include/minizip.premake4.lua ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/x-lua \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/include/portaudio.premake4.lua =================================================================== --- trunk/OpenMPT/include/portaudio.premake4.lua (rev 0) +++ trunk/OpenMPT/include/portaudio.premake4.lua 2014-10-13 08:07:03 UTC (rev 4429) @@ -0,0 +1,72 @@ + + project "portaudio" + uuid "189B867F-FF4B-45A1-B741-A97492EE69AF" + language "C" + location "../build/gen" + objdir "../build/obj/portaudio" + includedirs { "../include/portaudio/include", "../include/portaudio/src/common", "../include/portaudio/src/os/win" } + defines { + "PAWIN_USE_WDMKS_DEVICE_INFO", + "PA_WDMKS_NO_KSGUID_LIB", + "PA_USE_ASIO=0", + "PA_USE_DS=0", + "PA_USE_WMME=1", + "PA_USE_WASAPI=1", + "PA_USE_WDMKS=1", + } + files { + "../include/portaudio/src/common/pa_allocation.c", + "../include/portaudio/src/common/pa_allocation.h", + "../include/portaudio/src/common/pa_converters.c", + "../include/portaudio/src/common/pa_converters.h", + "../include/portaudio/src/common/pa_cpuload.c", + "../include/portaudio/src/common/pa_cpuload.h", + "../include/portaudio/src/common/pa_debugprint.c", + "../include/portaudio/src/common/pa_debugprint.h", + "../include/portaudio/src/common/pa_dither.c", + "../include/portaudio/src/common/pa_dither.h", + "../include/portaudio/src/common/pa_endianness.h", + "../include/portaudio/src/common/pa_front.c", + "../include/portaudio/src/common/pa_hostapi.h", + "../include/portaudio/src/common/pa_memorybarrier.h", + "../include/portaudio/src/common/pa_process.c", + "../include/portaudio/src/common/pa_process.h", + "../include/portaudio/src/common/pa_ringbuffer.c", + "../include/portaudio/src/common/pa_ringbuffer.h", + "../include/portaudio/src/common/pa_stream.c", + "../include/portaudio/src/common/pa_stream.h", + "../include/portaudio/src/common/pa_trace.c", + "../include/portaudio/src/common/pa_trace.h", + "../include/portaudio/src/common/pa_types.h", + "../include/portaudio/src/common/pa_util.h", + "../include/portaudio/src/hostapi/skeleton/pa_hostapi_skeleton.c", + "../include/portaudio/src/hostapi/wasapi/pa_win_wasapi.c", + "../include/portaudio/src/hostapi/wdmks/pa_win_wdmks.c", + "../include/portaudio/src/hostapi/wmme/pa_win_wmme.c", + "../include/portaudio/src/os/win/pa_win_coinitialize.c", + "../include/portaudio/src/os/win/pa_win_coinitialize.h", + "../include/portaudio/src/os/win/pa_win_hostapis.c", + "../include/portaudio/src/os/win/pa_win_util.c", + "../include/portaudio/src/os/win/pa_win_waveformat.c", + "../include/portaudio/src/os/win/pa_win_wdmks_utils.c", + "../include/portaudio/src/os/win/pa_win_wdmks_utils.h", + "../include/portaudio/src/os/win/pa_x86_plain_converters.c", + "../include/portaudio/src/os/win/pa_x86_plain_converters.h", + } + files { + "../include/portaudio/include/pa_asio.h", + "../include/portaudio/include/pa_jack.h", + "../include/portaudio/include/pa_linux_alsa.h", + "../include/portaudio/include/pa_mac_core.h", + "../include/portaudio/include/pa_win_ds.h", + "../include/portaudio/include/pa_win_wasapi.h", + "../include/portaudio/include/pa_win_waveformat.h", + "../include/portaudio/include/pa_win_wdmks.h", + "../include/portaudio/include/pa_win_wmme.h", + "../include/portaudio/include/portaudio.h", + } + buildoptions { "/wd4018", "/wd4267" } + configuration "Debug*" + defines { "PA_ENABLE_DEBUG_OUTPUT" } + dofile "../build/premake4-defaults-LIB.lua" + dofile "../build/premake4-defaults-static.lua" Property changes on: trunk/OpenMPT/include/portaudio.premake4.lua ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/x-lua \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/include/portmidi.premake4.lua =================================================================== --- trunk/OpenMPT/include/portmidi.premake4.lua (rev 0) +++ trunk/OpenMPT/include/portmidi.premake4.lua 2014-10-13 08:07:03 UTC (rev 4429) @@ -0,0 +1,24 @@ + + project "portmidi" + uuid "2512E2CA-578A-4F10-9363-4BFC9A5EF960" + language "C" + location "../build/gen" + objdir "../build/obj/portmidi" + includedirs { "../include/portmidi/porttime", "../include/portmidi/pm_common", "../include/portmidi/pm_win" } + files { + "../include/portmidi/porttime/porttime.c", + "../include/portmidi/porttime/ptwinmm.c", + "../include/portmidi/pm_common/pmutil.c", + "../include/portmidi/pm_common/portmidi.c", + "../include/portmidi/pm_win/pmwin.c", + "../include/portmidi/pm_win/pmwinmm.c", + } + files { + "../include/portmidi/porttime/porttime.h", + "../include/portmidi/pm_common/pminternal.h", + "../include/portmidi/pm_common/pmutil.h", + "../include/portmidi/pm_common/portmidi.h", + "../include/portmidi/pm_win/pmwinmm.h", + } + dofile "../build/premake4-defaults-LIB.lua" + dofile "../build/premake4-defaults-static.lua" Property changes on: trunk/OpenMPT/include/portmidi.premake4.lua ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/x-lua \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Deleted: trunk/OpenMPT/include/premake4.lua =================================================================== --- trunk/OpenMPT/include/premake4.lua 2014-10-12 08:35:43 UTC (rev 4428) +++ trunk/OpenMPT/include/premake4.lua 2014-10-13 08:07:03 UTC (rev 4429) @@ -1,505 +0,0 @@ - - project "UnRAR" - uuid "95CC809B-03FC-4EDB-BB20-FD07A698C05F" - language "C++" - location "../build/gen" - objdir "../build/obj/unrar" - includedirs { "../include/unrar" } - files { - "../include/unrar/archive.cpp", - "../include/unrar/arcread.cpp", - "../include/unrar/blake2s.cpp", - "../include/unrar/cmddata.cpp", - "../include/unrar/consio.cpp", - "../include/unrar/crc.cpp", - "../include/unrar/crypt.cpp", - "../include/unrar/encname.cpp", - "../include/unrar/errhnd.cpp", - "../include/unrar/extinfo.cpp", - "../include/unrar/extract.cpp", - "../include/unrar/filcreat.cpp", - "../include/unrar/file.cpp", - "../include/unrar/filefn.cpp", - "../include/unrar/filestr.cpp", - "../include/unrar/find.cpp", - "../include/unrar/getbits.cpp", - "../include/unrar/global.cpp", - "../include/unrar/hash.cpp", - "../include/unrar/headers.cpp", - "../include/unrar/isnt.cpp", - "../include/unrar/list.cpp", - "../include/unrar/match.cpp", - "../include/unrar/options.cpp", - "../include/unrar/pathfn.cpp", - "../include/unrar/qopen.cpp", - "../include/unrar/rar.cpp", - "../include/unrar/rarpch.cpp", - "../include/unrar/rarvm.cpp", - "../include/unrar/rawread.cpp", - "../include/unrar/rdwrfn.cpp", - "../include/unrar/recvol.cpp", - "../include/unrar/resource.cpp", - "../include/unrar/rijndael.cpp", - "../include/unrar/rs.cpp", - "../include/unrar/rs16.cpp", - "../include/unrar/scantree.cpp", - "../include/unrar/secpassword.cpp", - "../include/unrar/sha1.cpp", - "../include/unrar/sha256.cpp", - "../include/unrar/smallfn.cpp", - "../include/unrar/strfn.cpp", - "../include/unrar/strlist.cpp", - "../include/unrar/system.cpp", - "../include/unrar/threadpool.cpp", - "../include/unrar/timefn.cpp", - "../include/unrar/ui.cpp", - "../include/unrar/unicode.cpp", - "../include/unrar/unpack.cpp", - "../include/unrar/volume.cpp", - } - files { - "../include/unrar/archive.hpp", - "../include/unrar/array.hpp", - "../include/unrar/blake2s.hpp", - "../include/unrar/cmddata.hpp", - "../include/unrar/coder.hpp", - "../include/unrar/compress.hpp", - "../include/unrar/consio.hpp", - "../include/unrar/crc.hpp", - "../include/unrar/crypt.hpp", - "../include/unrar/dll.hpp", - "../include/unrar/encname.hpp", - "../include/unrar/errhnd.hpp", - "../include/unrar/extinfo.hpp", - "../include/unrar/extract.hpp", - "../include/unrar/filcreat.hpp", - "../include/unrar/file.hpp", - "../include/unrar/filefn.hpp", - "../include/unrar/filestr.hpp", - "../include/unrar/find.hpp", - "../include/unrar/getbits.hpp", - "../include/unrar/global.hpp", - "../include/unrar/hash.hpp", - "../include/unrar/headers.hpp", - "../include/unrar/headers5.hpp", - "../include/unrar/isnt.hpp", - "../include/unrar/list.hpp", - "../include/unrar/loclang.hpp", - "../include/unrar/log.hpp", - "../include/unrar/match.hpp", - "../include/unrar/model.hpp", - "../include/unrar/openmpt.hpp", - "../include/unrar/openmpt-callback.hpp", - "../include/unrar/options.hpp", - "../include/unrar/os.hpp", - "../include/unrar/pathfn.hpp", - "../include/unrar/qopen.hpp", - "../include/unrar/rar.hpp", - "../include/unrar/rardefs.hpp", - "../include/unrar/rarlang.hpp", - "../include/unrar/raros.hpp", - "../include/unrar/rartypes.hpp", - "../include/unrar/rarvm.hpp", - "../include/unrar/rawread.hpp", - "../include/unrar/rdwrfn.hpp", - "../include/unrar/recvol.hpp", - "../include/unrar/resource.hpp", - "../include/unrar/rijndael.hpp", - "../include/unrar/rs.hpp", - "../include/unrar/rs16.hpp", - "../include/unrar/savepos.hpp", - "../include/unrar/scantree.hpp", - "../include/unrar/secpassword.hpp", - "../include/unrar/sha1.hpp", - "../include/unrar/sha256.hpp", - "../include/unrar/smallfn.hpp", - "../include/unrar/strfn.hpp", - "../include/unrar/strlist.hpp", - "../include/unrar/suballoc.hpp", - "../include/unrar/system.hpp", - "../include/unrar/threadpool.hpp", - "../include/unrar/timefn.hpp", - "../include/unrar/ulinks.hpp", - "../include/unrar/ui.hpp", - "../include/unrar/unicode.hpp", - "../include/unrar/unpack.hpp", - "../include/unrar/version.hpp", - "../include/unrar/volume.hpp", - } - dofile "../build/premake4-defaults-LIB.lua" - dofile "../build/premake4-defaults-static.lua" - - - - project "zlib" - uuid "1654FB18-FDE6-406F-9D84-BA12BFBD67B2" - language "C" - location "../build/gen" - objdir "../build/obj/zlib" - includedirs { "../include/zlib" } - files { - "../include/zlib/adler32.c", - "../include/zlib/compress.c", - "../include/zlib/crc32.c", - "../include/zlib/deflate.c", - "../include/zlib/gzclose.c", - "../include/zlib/gzlib.c", - "../include/zlib/gzread.c", - "../include/zlib/gzwrite.c", - "../include/zlib/infback.c", - "../include/zlib/inffast.c", - "../include/zlib/inflate.c", - "../include/zlib/inftrees.c", - "../include/zlib/trees.c", - "../include/zlib/uncompr.c", - "../include/zlib/zutil.c", - } - files { - "../include/zlib/crc32.h", - "../include/zlib/deflate.h", - "../include/zlib/gzguts.h", - "../include/zlib/inffast.h", - "../include/zlib/inffixed.h", - "../include/zlib/inflate.h", - "../include/zlib/inftrees.h", - "../include/zlib/trees.h", - "../include/zlib/zconf.h", - "../include/zlib/zlib.h", - "../include/zlib/zutil.h", - } - dofile "../build/premake4-defaults-LIB.lua" - dofile "../build/premake4-defaults-static.lua" - - - - project "minizip" - uuid "63AF9025-A6CE-4147-A05D-6E2CCFD3A0D7" - language "C" - location "../build/gen" - objdir "../build/obj/minizip" - includedirs { "../include/zlib", "../include/zlib/contrib/minizip" } - files { - "../include/zlib/contrib/minizip/ioapi.c", - "../include/zlib/contrib/minizip/iowin32.c", - "../include/zlib/contrib/minizip/mztools.c", - "../include/zlib/contrib/minizip/unzip.c", - "../include/zlib/contrib/minizip/zip.c", - } - files { - "../include/zlib/contrib/minizip/crypt.h", - "../include/zlib/contrib/minizip/ioapi.h", - "../include/zlib/contrib/minizip/iowin32.h", - "../include/zlib/contrib/minizip/mztools.h", - "../include/zlib/contrib/minizip/unzip.h", - "../include/zlib/contrib/minizip/zip.h", - } - dofile "../build/premake4-defaults-LIB.lua" - dofile "../build/premake4-defaults-static.lua" - - - - project "miniz" - uuid "B5E0C06B-8121-426A-8FFB-4293ECAAE29C" - language "C" - location "../build/gen" - objdir "../build/obj/miniz" - files { - "../include/miniz/miniz.c", - } - dofile "../build/premake4-defaults-LIB.lua" - dofile "../build/premake4-defaults-static.lua" - - - - project "smbPitchShift" - uuid "89AF16DD-32CC-4A7E-B219-5F117D761F9F" - language "C++" - location "../build/gen" - objdir "../build/obj/smbPitchShift" - includedirs { } - files { - "../include/smbPitchShift/smbPitchShift.cpp", - } - files { - "../include/smbPitchShift/smbPitchShift.h", - } - dofile "../build/premake4-defaults-LIB.lua" - dofile "../build/premake4-defaults-static.lua" - - - - project "lhasa" - uuid "6B11F6A8-B131-4D2B-80EF-5731A9016436" - language "C" - location "../build/gen" - objdir "../build/obj/lhasa" - includedirs { "../include/msinttypes/inttypes" } - files { - "../include/lhasa/lib/crc16.c", - "../include/lhasa/lib/ext_header.c", - "../include/lhasa/lib/lh1_decoder.c", - "../include/lhasa/lib/lh5_decoder.c", - "../include/lhasa/lib/lh6_decoder.c", - "../include/lhasa/lib/lh7_decoder.c", - "../include/lhasa/lib/lha_arch_unix.c", - "../include/lhasa/lib/lha_arch_win32.c", - "../include/lhasa/lib/lha_basic_reader.c", - "../include/lhasa/lib/lha_decoder.c", - "../include/lhasa/lib/lha_endian.c", - "../include/lhasa/lib/lha_file_header.c", - "../include/lhasa/lib/lha_input_stream.c", - "../include/lhasa/lib/lha_reader.c", - "../include/lhasa/lib/lhx_decoder.c", - "../include/lhasa/lib/lz5_decoder.c", - "../include/lhasa/lib/lzs_decoder.c", - "../include/lhasa/lib/macbinary.c", - "../include/lhasa/lib/null_decoder.c", - "../include/lhasa/lib/pm1_decoder.c", - "../include/lhasa/lib/pm2_decoder.c", - } - files { - "../include/lhasa/lib/crc16.h", - "../include/lhasa/lib/ext_header.h", - "../include/lhasa/lib/lha_arch.h", - "../include/lhasa/lib/lha_basic_reader.h", - "../include/lhasa/lib/lha_decoder.h", - "../include/lhasa/lib/lha_endian.h", - "../include/lhasa/lib/lha_file_header.h", - "../include/lhasa/lib/lha_input_stream.h", - "../include/lhasa/lib/macbinary.h", - "../include/lhasa/lib/public/lha_decoder.h", - "../include/lhasa/lib/public/lha_file_header.h", - "../include/lhasa/lib/public/lha_input_stream.h", - "../include/lhasa/lib/public/lha_reader.h", - "../include/lhasa/lib/public/lhasa.h", - } - configuration "vs2008" - includedirs { "../include/msinttypes/stdint" } - dofile "../build/premake4-defaults-LIB.lua" - dofile "../build/premake4-defaults-static.lua" - - - - project "flac" - uuid "E599F5AA-F9A3-46CC-8DB0-C8DEFCEB90C5" - language "C" - location "../build/gen" - objdir "../build/obj/flac" - includedirs { "../include/flac/include", "../include/flac/src/libFLAC/include" } - files { - "../include/flac/src/libFLAC/bitmath.c", - "../include/flac/src/libFLAC/bitreader.c", - "../include/flac/src/libFLAC/bitwriter.c", - "../include/flac/src/libFLAC/cpu.c", - "../include/flac/src/libFLAC/crc.c", - "../include/flac/src/libFLAC/fixed.c", - "../include/flac/src/libFLAC/float.c", - "../include/flac/src/libFLAC/format.c", - "../include/flac/src/libFLAC/lpc.c", - "../include/flac/src/libFLAC/md5.c", - "../include/flac/src/libFLAC/memory.c", - "../include/flac/src/libFLAC/metadata_iterators.c", - "../include/flac/src/libFLAC/metadata_object.c", - "../include/flac/src/libFLAC/stream_decoder.c", - "../include/flac/src/libFLAC/stream_encoder.c", - "../include/flac/src/libFLAC/stream_encoder_framing.c", - "../include/flac/src/libFLAC/window.c", - } - files { - "../include/flac/src/share/win_utf8_io/win_utf8_io.c", - } - files { - "../include/flac/src/libFLAC/include/private/all.h", - "../include/flac/src/libFLAC/include/private/bitmath.h", - "../include/flac/src/libFLAC/include/private/bitreader.h", - "../include/flac/src/libFLAC/include/private/bitwriter.h", - "../include/flac/src/libFLAC/include/private/cpu.h", - "../include/flac/src/libFLAC/include/private/crc.h", - "../include/flac/src/libFLAC/include/private/fixed.h", - "../include/flac/src/libFLAC/include/private/float.h", - "../include/flac/src/libFLAC/include/private/format.h", - "../include/flac/src/libFLAC/include/private/lpc.h", - "../include/flac/src/libFLAC/include/private/md5.h", - "../include/flac/src/libFLAC/include/private/memory.h", - "../include/flac/src/libFLAC/include/private/metadata.h", - "../include/flac/src/libFLAC/include/private/stream_encoder_framing.h", - "../include/flac/src/libFLAC/include/private/window.h", - "../include/flac/src/libFLAC/include/protected/all.h", - "../include/flac/src/libFLAC/include/protected/stream_decoder.h", - "../include/flac/src/libFLAC/include/protected/stream_encoder.h", - } - files { - "../include/flac/include/FLAC/all.h", - "../include/flac/include/FLAC/assert.h", - "../include/flac/include/FLAC/callback.h", - "../include/flac/include/FLAC/export.h", - "../include/flac/include/FLAC/format.h", - "../include/flac/include/FLAC/metadata.h", - "../include/flac/include/FLAC/ordinals.h", - "../include/flac/include/FLAC/stream_decoder.h", - "../include/flac/include/FLAC/stream_encoder.h", - } - buildoptions { "/wd4244", "/wd4267", "/wd4334" } - configuration "*Lib" - defines { "FLAC__NO_DLL" } - configuration "vs2010" - defines { "VERSION=\"1.3.0\"" } - configuration "vs2008" - defines { "VERSION=\\\"1.3.0\\\"" } - dofile "../build/premake4-defaults-LIB.lua" - dofile "../build/premake4-defaults-static.lua" - - - - project "portaudio" - uuid "189B867F-FF4B-45A1-B741-A97492EE69AF" - language "C" - location "../build/gen" - objdir "../build/obj/portaudio" - includedirs { "../include/portaudio/include", "../include/portaudio/src/common", "../include/portaudio/src/os/win" } - defines { - "PAWIN_USE_WDMKS_DEVICE_INFO", - "PA_WDMKS_NO_KSGUID_LIB", - "PA_USE_ASIO=0", - "PA_USE_DS=0", - "PA_USE_WMME=1", - "PA_USE_WASAPI=1", - "PA_USE_WDMKS=1", - } - files { - "../include/portaudio/src/common/pa_allocation.c", - "../include/portaudio/src/common/pa_allocation.h", - "../include/portaudio/src/common/pa_converters.c", - "../include/portaudio/src/common/pa_converters.h", - "../include/portaudio/src/common/pa_cpuload.c", - "../include/portaudio/src/common/pa_cpuload.h", - "../include/portaudio/src/common/pa_debugprint.c", - "../include/portaudio/src/common/pa_debugprint.h", - "../include/portaudio/src/common/pa_dither.c", - "../include/portaudio/src/common/pa_dither.h", - "../include/portaudio/src/common/pa_endianness.h", - "../include/portaudio/src/common/pa_front.c", - "../include/portaudio/src/common/pa_hostapi.h", - "../include/portaudio/src/common/pa_memorybarrier.h", - "../include/portaudio/src/common/pa_process.c", - "../include/portaudio/src/common/pa_process.h", - "../include/portaudio/src/common/pa_ringbuffer.c", - "../include/portaudio/src/common/pa_ringbuffer.h", - "../include/portaudio/src/common/pa_stream.c", - "../include/portaudio/src/common/pa_stream.h", - "../include/portaudio/src/common/pa_trace.c", - "../include/portaudio/src/common/pa_trace.h", - "../include/portaudio/src/common/pa_types.h", - "../include/portaudio/src/common/pa_util.h", - "../include/portaudio/src/hostapi/skeleton/pa_hostapi_skeleton.c", - "../include/portaudio/src/hostapi/wasapi/pa_win_wasapi.c", - "../include/portaudio/src/hostapi/wdmks/pa_win_wdmks.c", - "../include/portaudio/src/hostapi/wmme/pa_win_wmme.c", - "../include/portaudio/src/os/win/pa_win_coinitialize.c", - "../include/portaudio/src/os/win/pa_win_coinitialize.h", - "../include/portaudio/src/os/win/pa_win_hostapis.c", - "../include/portaudio/src/os/win/pa_win_util.c", - "../include/portaudio/src/os/win/pa_win_waveformat.c", - "../include/portaudio/src/os/win/pa_win_wdmks_utils.c", - "../include/portaudio/src/os/win/pa_win_wdmks_utils.h", - "../include/portaudio/src/os/win/pa_x86_plain_converters.c", - "../include/portaudio/src/os/win/pa_x86_plain_converters.h", - } - files { - "../include/portaudio/include/pa_asio.h", - "../include/portaudio/include/pa_jack.h", - "../include/portaudio/include/pa_linux_alsa.h", - "../include/portaudio/include/pa_mac_core.h", - "../include/portaudio/include/pa_win_ds.h", - "../include/portaudio/include/pa_win_wasapi.h", - "../include/portaudio/include/pa_win_waveformat.h", - "../include/portaudio/include/pa_win_wdmks.h", - "../include/portaudio/include/pa_win_wmme.h", - "../include/portaudio/include/portaudio.h", - } - buildoptions { "/wd4018", "/wd4267" } - configuration "Debug*" - defines { "PA_ENABLE_DEBUG_OUTPUT" } - dofile "../build/premake4-defaults-LIB.lua" - dofile "../build/premake4-defaults-static.lua" - - - - project "portmidi" - uuid "2512E2CA-578A-4F10-9363-4BFC9A5EF960" - language "C" - location "../build/gen" - objdir "../build/obj/portmidi" - includedirs { "../include/portmidi/porttime", "../include/portmidi/pm_common", "../include/portmidi/pm_win" } - files { - "../include/portmidi/porttime/porttime.c", - "../include/portmidi/porttime/ptwinmm.c", - "../include/portmidi/pm_common/pmutil.c", - "../include/portmidi/pm_common/portmidi.c", - "../include/portmidi/pm_win/pmwin.c", - "../include/portmidi/pm_win/pmwinmm.c", - } - files { - "../include/portmidi/porttime/porttime.h", - "../include/portmidi/pm_common/pminternal.h", - "../include/portmidi/pm_common/pmutil.h", - "../include/portmidi/pm_common/portmidi.h", - "../include/portmidi/pm_win/pmwinmm.h", - } - dofile "../build/premake4-defaults-LIB.lua" - dofile "../build/premake4-defaults-static.lua" - - - - project "soundtouch" - uuid "F5F8F6DE-84CF-4E9D-91EA-D9B5E2AA36CD" - language "C++" - location "../build/gen" - objdir "../build/obj/soundtouch" - targetname "OpenMPT_SoundTouch_f32" - includedirs { "../include/soundtouch/include" } - files { - "../include/soundtouch/include/BPMDetect.h", - "../include/soundtouch/include/FIFOSampleBuffer.h", - "../include/soundtouch/include/FIFOSamplePipe.h", - "../include/soundtouch/include/SoundTouch.h", - "../include/soundtouch/include/STTypes.h", - } - files { - "../include/soundtouch/source/SoundTouch/AAFilter.cpp", - "../include/soundtouch/source/SoundTouch/BPMDetect.cpp", - "../include/soundtouch/source/SoundTouch/cpu_detect_x86.cpp", - "../include/soundtouch/source/SoundTouch/FIFOSampleBuffer.cpp", - "../include/soundtouch/source/SoundTouch/FIRFilter.cpp", - "../include/soundtouch/source/SoundTouch/InterpolateCubic.cpp", - "../include/soundtouch/source/SoundTouch/InterpolateLinear.cpp", - "../include/soundtouch/source/SoundTouch/InterpolateShannon.cpp", - "../include/soundtouch/source/SoundTouch/mmx_optimized.cpp", - "../include/soundtouch/source/SoundTouch/PeakFinder.cpp", - "../include/soundtouch/source/SoundTouch/RateTransposer.cpp", - "../include/soundtouch/source/SoundTouch/SoundTouch.cpp", - "../include/soundtouch/source/SoundTouch/sse_optimized.cpp", - "../include/soundtouch/source/SoundTouch/TDStretch.cpp", - } - files { - "../include/soundtouch/source/SoundTouch/AAFilter.h", - "../include/soundtouch/source/SoundTouch/cpu_detect.h", - "../include/soundtouch/source/SoundTouch/FIRFilter.h", - "../include/soundtouch/source/SoundTouch/InterpolateCubic.h", - "../include/soundtouch/source/SoundTouch/InterpolateLinear.h", - "../include/soundtouch/source/SoundTouch/InterpolateShannon.h", - "../include/soundtouch/source/SoundTouch/PeakFinder.h", - "../include/soundtouch/source/SoundTouch/RateTransposer.h", - "../include/soundtouch/source/SoundTouch/TDStretch.h", - } - files { - "../include/soundtouch/source/SoundTouchDLL/SoundTouchDLL.cpp", - "../include/soundtouch/source/SoundTouchDLL/SoundTouchDLL.h", - } - defines { "DLL_EXPORTS" } - dofile "../build/premake4-defaults-DLL.lua" - dofile "../build/premake4-defaults-static.lua" - - - - \ No newline at end of file Added: trunk/OpenMPT/include/smbPitchShift.premake4.lua =================================================================== --- trunk/OpenMPT/include/smbPitchShift.premake4.lua (rev 0) +++ trunk/OpenMPT/include/smbPitchShift.premake4.lua 2014-10-13 08:07:03 UTC (rev 4429) @@ -0,0 +1,15 @@ + + project "smbPitchShift" + uuid "89AF16DD-32CC-4A7E-B219-5F117D761F9F" + language "C++" + location "../build/gen" + objdir "../build/obj/smbPitchShift" + includedirs { } + files { + "../include/smbPitchShift/smbPitchShift.cpp", + } + files { + "../include/smbPitchShift/smbPitchShift.h", + } + dofile "../build/premake4-defaults-LIB.lua" + dofile "../build/premake4-defaults-static.lua" Property changes on: trunk/OpenMPT/include/smbPitchShift.premake4.lua ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/x-lua \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/include/soundtouch.premake4.lua =================================================================== --- trunk/OpenMPT/include/soundtouch.premake4.lua (rev 0) +++ trunk/OpenMPT/include/soundtouch.premake4.lua 2014-10-13 08:07:03 UTC (rev 4429) @@ -0,0 +1,50 @@ + + project "soundtouch" + uuid "F5F8F6DE-84CF-4E9D-91EA-D9B5E2AA36CD" + language "C++" + location "../build/gen" + objdir "../build/obj/soundtouch" + targetname "OpenMPT_SoundTouch_f32" + includedirs { "../include/soundtouch/include" } + files { + "../include/soundtouch/include/BPMDetect.h", + "../include/soundtouch/include/FIFOSampleBuffer.h", + "../include/soundtouch/include/FIFOSamplePipe.h", + "../include/soundtouch/include/SoundTouch.h", + "../include/soundtouch/include/STTypes.h", + } + files { + "../include/soundtouch/source/SoundTouch/AAFilter.cpp", + "../include/soundtouch/source/SoundTouch/BPMDetect.cpp", + "../include/soundtouch/source/SoundTouch/cpu_detect_x86.cpp", + "../include/soundtouch/source/SoundTouch/FIFOSampleBuffer.cpp", + "../include/soundtouch/source/SoundTouch/FIRFilter.cpp", + "../include/soundtouch/source/SoundTouch/InterpolateCubic.cpp", + "../include/soundtouch/source/SoundTouch/InterpolateLinear.cpp", + "../include/soundtouch/source/SoundTouch/InterpolateShannon.cpp", + "../include/soundtouch/source/SoundTouch/mmx_optimized.cpp", + "../include/soundtouch/source/SoundTouch/PeakFinder.cpp", + "../include/soundtouch/source/SoundTouch/RateTransposer.cpp", + "../include/soundtouch/source/SoundTouch/SoundTouch.cpp", + "../include/soundtouch/source/SoundTouch/sse_optimized.cpp", + "../include/soundtouch/source/SoundTouch/TDStretch.cpp", + } + files { + "../include/soundtouch/source/SoundTouch/AAFilter.h", + "../include/soundtouch/source/SoundTouch/cpu_detect.h", + "../include/soundtouch/source/SoundTouch/FIRFilter.h", + "../include/soundtouch/source/SoundTouch/InterpolateCubic.h", + "../include/soundtouch/source/SoundTouch/InterpolateLinear.h", + "../include/soundtouch/source/SoundTouch/InterpolateShannon.h", + "../include/soundtouch/source/SoundTouch/PeakFinder.h", + "../include/soundtouch/source/SoundTouch/RateTransposer.h", + "../include/soundtouch/source/SoundTouch/TDStretch.h", + } + files { + "../include/soundtouch/source/SoundTouchDLL/SoundTouchDLL.cpp", + "../include/soundtouch/source/SoundTouchDLL/SoundTouchDLL.h", + } + defines { "DLL_EXPORTS" } + dofile "../build/premake4-defaults-DLL.lua" + dofile "../build/premake4-defaults-static.lua" + \ No newline at end of file Property changes on: trunk/OpenMPT/include/soundtouch.premake4.lua ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/x-lua \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/include/zlib.premake4.lua =================================================================== --- trunk/OpenMPT/include/zlib.premake4.lua (rev 0) +++ trunk/OpenMPT/include/zlib.premake4.lua 2014-10-13 08:07:03 UTC (rev 4429) @@ -0,0 +1,40 @@ + + project "zlib" + uuid "1654FB18-FDE6-406F-9D84-BA12BFBD67B2" + language "C" + location "../build/gen" + objdir "../build/obj/zlib" + includedirs { "../include/zlib" } + files { + "../include/zlib/adler32.c", + "../include/zlib/compress.c", + "../include/zlib/crc32.c", + "../include/zlib/deflate.c", + "../include/zlib/gzclose.c", + "../include/zlib/gzlib.c", + "../include/zlib/gzread.c", + "../include/zlib/gzwrite.c", + "../include/zlib/infback.c", + "../include/zlib/inffast.c", + "../include/zlib/inflate.c", + "../include/zlib/inftrees.c", + "../include/zlib/trees.c", + "../include/zlib/uncompr.c", + "../include/zlib/zutil.c", + } + files { + "../include/zlib/crc32.h", + "../include/zlib/deflate.h", + "../include/zlib/gzguts.h", + "../include/zlib/inffast.h", + "../include/zlib/inffixed.h", + "../include/zlib/inflate.h", + "../include/zlib/inftrees.h", + "../include/zlib/trees.h", + "../include/zlib/zconf.h", + "../include/zlib/zlib.h", + "../include/zlib/zutil.h", + } + dofile "../build/premake4-defaults-LIB.lua" + dofile "../build/premake4-defaults-static.lua" + \ No newline at end of file Property changes on: trunk/OpenMPT/include/zlib.premake4.lua ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/x-lua \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-15 14:47:40
|
Revision: 4433 http://sourceforge.net/p/modplug/code/4433 Author: manxorist Date: 2014-10-15 14:47:23 +0000 (Wed, 15 Oct 2014) Log Message: ----------- [Ref] Rename mpt::thread to mpt::UnmanagedThread because its lifetime and management semantics differ considerably from C++11 std::thread. [Ref] Add mpt::thread, a subset implementation of std::thread. The biggest difference is that it is not moveable and thus not useable in all situations where std::thread would be useable. [Ref] Remove the priority parameter to mpt::UnmanagedThread. Provide a free SetThreadPriority() function instead. [Ref] Add MPT_DELEGATE macro which allows for an easy syntax for providing a pointer-to-member and instance tuple to the mpt::thread constructor. [Ref] Convert the update check thread to mpt::thread and MPT_DELEGATE. Modified Paths: -------------- trunk/OpenMPT/common/thread.h trunk/OpenMPT/mptrack/Autotune.cpp trunk/OpenMPT/mptrack/UpdateCheck.cpp trunk/OpenMPT/mptrack/UpdateCheck.h trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/View_tre.h trunk/OpenMPT/pluginBridge/Bridge.cpp trunk/OpenMPT/pluginBridge/BridgeCommon.h trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp Modified: trunk/OpenMPT/common/thread.h =================================================================== --- trunk/OpenMPT/common/thread.h 2014-10-15 09:35:38 UTC (rev 4432) +++ trunk/OpenMPT/common/thread.h 2014-10-15 14:47:23 UTC (rev 4433) @@ -9,46 +9,368 @@ #pragma once + +#if defined(MODPLUG_TRACKER) + +#if MPT_OS_WINDOWS && MPT_MSVC_BEFORE(2012,0) +// our own +#else +#include <thread> +#endif + OPENMPT_NAMESPACE_BEGIN namespace mpt { -#if defined(WIN32) -// Default WinAPI thread +#if MPT_OS_WINDOWS + +enum ThreadPriority +{ + ThreadPriorityLowest = THREAD_PRIORITY_LOWEST, + ThreadPriorityLower = THREAD_PRIORITY_BELOW_NORMAL, + ThreadPriorityNormal = THREAD_PRIORITY_NORMAL, + ThreadPriorityHigh = THREAD_PRIORITY_ABOVE_NORMAL, + ThreadPriorityHighest = THREAD_PRIORITY_HIGHEST +}; + +#else + +enum ThreadPriority +{ + ThreadPriorityLowest = -2, + ThreadPriorityLower = -1, + ThreadPriorityNormal = 0, + ThreadPriorityHigh = 1, + ThreadPriorityHighest = 2 +}; + +#endif + + + +#if MPT_OS_WINDOWS && MPT_MSVC_BEFORE(2012,0) + + + +typedef HANDLE native_handle_type; + +// std::thread +// NOTE: This implementation is not movable and prevents copying. +// Therefore, it is not as versatile as a full C++11 std::thread implementation. +// It is only a strict subset. class thread { + +private: + + thread(const thread &) {} // = delete + thread & operator = (const thread &) { return *this; } // = delete + +private: + + class functor_helper_base { + protected: + functor_helper_base() {} + public: + virtual ~functor_helper_base() {} + public: + virtual void operator () () = 0; + }; + + template<typename Tfunc> + class functor_helper : public functor_helper_base { + private: + Tfunc func; + public: + functor_helper(Tfunc func_) : func(func_) { return; } + virtual ~functor_helper() { return; } + virtual void operator () () { func(); } + }; + + enum FunctionMode + { + FunctionModeNone = 0, + FunctionModeParamNone = 1, + FunctionModeParamPointer = 2, + FunctionModeFunctor = 3, + }; + + native_handle_type threadHandle; + + // Thread startup accesses members of mpt::thread. + // If the mpt::thread instanced gets detached and destroyed directly after initialization, + // there is a race between thread startup and detach/destroy. + // startupDoneEvent protects against this race. + HANDLE startupDoneEvent; + + FunctionMode functionMode; + union { + struct { + void (*function)(void); + } ModeParamNone; + struct { + void (*function)(void*); + void * userdata; + } ModeParamPointer; + struct { + functor_helper_base * pfunctor; + } ModeFunctor; + } modeState; + +private: + + std::uintptr_t ThreadFuntion() + { + switch(functionMode) + { + case FunctionModeNone: + SetEvent(startupDoneEvent); + return 0; + break; + case FunctionModeParamNone: + { + void (*f)(void) = modeState.ModeParamNone.function; + SetEvent(startupDoneEvent); + f(); + } + return 0; + break; + case FunctionModeParamPointer: + { + void (*f)(void*) = modeState.ModeParamPointer.function; + void * d = modeState.ModeParamPointer.userdata; + SetEvent(startupDoneEvent); + f(d); + } + return 0; + break; + case FunctionModeFunctor: + { + functor_helper_base * pf = modeState.ModeFunctor.pfunctor; + SetEvent(startupDoneEvent); + (*pf)(); + delete pf; + } + return 0; + break; + default: + SetEvent(startupDoneEvent); + return 0; + break; + } + SetEvent(startupDoneEvent); + return 0; + } + + static DWORD WINAPI ThreadFunctionWrapper(LPVOID param) + { + reinterpret_cast<mpt::thread*>(param)->ThreadFuntion(); + return 0; + } + +public: + + mpt::native_handle_type native_handle() + { + return threadHandle; + } + + bool joinable() const + { + return (threadHandle != nullptr); + } + + void join() + { + if(!joinable()) + { + throw std::invalid_argument("thread::joinable() == false"); + } + WaitForSingleObject(threadHandle, INFINITE); + CloseHandle(threadHandle); + threadHandle = nullptr; + } + + void detach() + { + if(!joinable()) + { + throw std::invalid_argument("thread::joinable() == false"); + } + CloseHandle(threadHandle); + threadHandle = nullptr; + } + + thread() + : threadHandle(nullptr) + , startupDoneEvent(nullptr) + , functionMode(FunctionModeNone) + { + std::memset(&modeState, 0, sizeof(modeState)); + } + + thread(void (*function)(void)) + : threadHandle(nullptr) + , startupDoneEvent(nullptr) + , functionMode(FunctionModeParamNone) + { + std::memset(&modeState, 0, sizeof(modeState)); + modeState.ModeParamNone.function = function; + startupDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + if(!startupDoneEvent) { throw std::runtime_error("unable to start thread"); } + DWORD dummy = 0; // For Win9x + threadHandle = CreateThread(NULL, 0, ThreadFunctionWrapper, this, 0, &dummy); + if(threadHandle) + { + WaitForSingleObject(startupDoneEvent, INFINITE); + } + CloseHandle(startupDoneEvent); + startupDoneEvent = nullptr; + if(!threadHandle) { throw std::runtime_error("unable to start thread"); } + } + + thread(void (*function)(void*), void * userdata) + : threadHandle(nullptr) + , startupDoneEvent(nullptr) + , functionMode(FunctionModeParamPointer) + { + std::memset(&modeState, 0, sizeof(modeState)); + modeState.ModeParamPointer.function = function; + modeState.ModeParamPointer.userdata = userdata; + startupDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + if(!startupDoneEvent) { throw std::runtime_error("unable to start thread"); } + DWORD dummy = 0; // For Win9x + threadHandle = CreateThread(NULL, 0, ThreadFunctionWrapper, this, 0, &dummy); + if(threadHandle) + { + WaitForSingleObject(startupDoneEvent, INFINITE); + } + CloseHandle(startupDoneEvent); + startupDoneEvent = nullptr; + if(!threadHandle) { throw std::runtime_error("unable to start thread"); } + } + + template<typename Tfunctor> + thread(Tfunctor functor) + : threadHandle(nullptr) + , startupDoneEvent(nullptr) + , functionMode(FunctionModeFunctor) + { + std::memset(&modeState, 0, sizeof(modeState)); + modeState.ModeFunctor.pfunctor = new functor_helper<Tfunctor>(functor); + startupDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + if(!startupDoneEvent) { throw std::runtime_error("unable to start thread"); } + DWORD dummy = 0; // For Win9x + threadHandle = CreateThread(NULL, 0, ThreadFunctionWrapper, this, 0, &dummy); + if(threadHandle) + { + WaitForSingleObject(startupDoneEvent, INFINITE); + } + CloseHandle(startupDoneEvent); + startupDoneEvent = nullptr; + if(!threadHandle) { throw std::runtime_error("unable to start thread"); } + } + + ~thread() + { + ASSERT(!joinable()); + } + +}; + + + +#else // !(MPT_OS_WINDOWS && MPT_MSVC_BEFORE(2012,0)) + + + +typedef std::thread thread; + + + +#endif // MPT_OS_WINDOWS && MPT_MSVC_BEFORE(2012,0) + + + +template<typename T, void (T::*Func)(void)> +class pointer_to_member_functor { +private: + T *that; +public: + void operator () () + { + (that->*Func)(); + } + pointer_to_member_functor(T *that) + : that(that) + { + return; + } +}; + +// MPT_DELEGATE is a helper to use member functions of classes as thread entry +// points. +// Implementing generic support in the mpt::thread constructor would result +// in horribly unreadable template code when not making use of at least some +// C++11 features. +#define MPT_DELEGATE(type, func, inst) mpt::pointer_to_member_functor< type , & type :: func >( inst ) + + + +#if MPT_OS_WINDOWS + +inline void SetThreadPriority(mpt::thread &t, mpt::ThreadPriority priority) +{ + ::SetThreadPriority(t.native_handle(), priority); +} + +inline void SetCurrentThreadPriority(mpt::ThreadPriority priority) +{ + ::SetThreadPriority(GetCurrentThread(), priority); +} + +#else // !MPT_OS_WINDOWS + +inline void SetThreadPriority(mpt::thread & /*t*/ , mpt::ThreadPriority /*priority*/ ) +{ + // nothing +} + +inline void SetCurrentThreadPriority(mpt::ThreadPriority /*priority*/ ) +{ + // nothing +} + +#endif // MPT_OS_WINDOWS + + + +#if defined(MODPLUG_TRACKER) + +// Default WinAPI thread +class UnmanagedThread +{ protected: HANDLE threadHandle; public: - enum Priority - { - lowest = THREAD_PRIORITY_LOWEST, - lower = THREAD_PRIORITY_BELOW_NORMAL, - normal = THREAD_PRIORITY_NORMAL, - high = THREAD_PRIORITY_ABOVE_NORMAL, - highest = THREAD_PRIORITY_HIGHEST - }; - operator HANDLE& () { return threadHandle; } operator bool () const { return threadHandle != nullptr; } - thread() : threadHandle(nullptr) { } - thread(LPTHREAD_START_ROUTINE function, void *userData = nullptr, Priority priority = normal) + UnmanagedThread() : threadHandle(nullptr) { } + UnmanagedThread(LPTHREAD_START_ROUTINE function, void *userData = nullptr) { - DWORD dummy; // For Win9x + DWORD dummy = 0; // For Win9x threadHandle = CreateThread(NULL, 0, function, userData, 0, &dummy); - SetThreadPriority(threadHandle, priority); } }; - // Thread that operates on a member function template<typename T, void (T::*Fun)()> -class thread_member : public thread +class UnmanagedThreadMember : public mpt::UnmanagedThread { protected: static DWORD WINAPI wrapperFunc(LPVOID param) @@ -59,15 +381,20 @@ public: - thread_member(T *instance, Priority priority = normal) : thread(wrapperFunc, instance, priority) { } + UnmanagedThreadMember(T *instance) : mpt::UnmanagedThread(wrapperFunc, instance) { } }; -#else // !WIN32 +inline void SetThreadPriority(mpt::UnmanagedThread &t, mpt::ThreadPriority priority) +{ + ::SetThreadPriority(t, priority); +} -#error "thread.h is unimplemented on non-WIN32" +#endif // MODPLUG_TRACKER -#endif // !WIN32 + } // namespace mpt OPENMPT_NAMESPACE_END + +#endif // MODPLUG_TRACKER Modified: trunk/OpenMPT/mptrack/Autotune.cpp =================================================================== --- trunk/OpenMPT/mptrack/Autotune.cpp 2014-10-15 09:35:38 UTC (rev 4432) +++ trunk/OpenMPT/mptrack/Autotune.cpp 2014-10-15 14:47:23 UTC (rev 4433) @@ -257,7 +257,7 @@ if(p == numProcs - 1) threadInfo[p].endNote = END_NOTE; - threadHandles[p] = mpt::thread(AutotuneThread, &threadInfo[p]); + threadHandles[p] = mpt::UnmanagedThread(AutotuneThread, &threadInfo[p]); ASSERT(threadHandles[p] != INVALID_HANDLE_VALUE); } Modified: trunk/OpenMPT/mptrack/UpdateCheck.cpp =================================================================== --- trunk/OpenMPT/mptrack/UpdateCheck.cpp 2014-10-15 09:35:38 UTC (rev 4432) +++ trunk/OpenMPT/mptrack/UpdateCheck.cpp 2014-10-15 14:47:23 UTC (rev 4433) @@ -39,8 +39,7 @@ CUpdateCheck *that = new (std::nothrow) CUpdateCheck(autoUpdate); if(that != nullptr) { - mpt::thread threadHandle = mpt::thread_member<CUpdateCheck, &CUpdateCheck::UpdateThread>(that, autoUpdate ? mpt::thread::lower : mpt::thread::normal); - CloseHandle(threadHandle); + mpt::thread(MPT_DELEGATE(CUpdateCheck, UpdateThread, that)).detach(); } } @@ -49,6 +48,12 @@ void CUpdateCheck::UpdateThread() //------------------------------- { + + if(isAutoUpdate) + { + mpt::SetCurrentThreadPriority(mpt::ThreadPriorityLower); + } + const time_t now = time(nullptr); if(isAutoUpdate) Modified: trunk/OpenMPT/mptrack/UpdateCheck.h =================================================================== --- trunk/OpenMPT/mptrack/UpdateCheck.h 2014-10-15 09:35:38 UTC (rev 4432) +++ trunk/OpenMPT/mptrack/UpdateCheck.h 2014-10-15 14:47:23 UTC (rev 4433) @@ -53,7 +53,7 @@ HINTERNET internetHandle, connectionHandle; // Force creation via "new" as we're using "delete this". Use CUpdateCheck::DoUpdateCheck to create an object. - CUpdateCheck::CUpdateCheck(bool autoUpdate) : internetHandle(nullptr), connectionHandle(nullptr), isAutoUpdate(autoUpdate) { } + CUpdateCheck(bool autoUpdate) : internetHandle(nullptr), connectionHandle(nullptr), isAutoUpdate(autoUpdate) { } void UpdateThread(); void Die(CString errorMessage); Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2014-10-15 09:35:38 UTC (rev 4432) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2014-10-15 14:47:23 UTC (rev 4433) @@ -148,7 +148,7 @@ { // Set up instrument library monitoring thread m_hWatchDirKillThread = CreateEvent(NULL, FALSE, FALSE, NULL); - watchDirThread = mpt::thread_member<CModTree, &CModTree::MonitorInstrumentLibrary>(this, mpt::thread::lowest); + watchDirThread = mpt::UnmanagedThreadMember<CModTree, &CModTree::MonitorInstrumentLibrary>(this); } MemsetZero(m_tiMidi); MemsetZero(m_tiPerc); @@ -1839,6 +1839,7 @@ void CModTree::MonitorInstrumentLibrary() //--------------------------------------- { + mpt::SetCurrentThreadPriority(mpt::ThreadPriorityLowest); DWORD result; do { Modified: trunk/OpenMPT/mptrack/View_tre.h =================================================================== --- trunk/OpenMPT/mptrack/View_tre.h 2014-10-15 09:35:38 UTC (rev 4432) +++ trunk/OpenMPT/mptrack/View_tre.h 2014-10-15 14:47:23 UTC (rev 4433) @@ -161,7 +161,7 @@ HWND m_hDropWnd; volatile HANDLE m_hWatchDir; HANDLE m_hWatchDirKillThread; - mpt::thread watchDirThread; + mpt::UnmanagedThread watchDirThread; ModItem m_itemDrag; DWORD m_dwStatus; UINT m_nDocNdx, m_nDragDocNdx; Modified: trunk/OpenMPT/pluginBridge/Bridge.cpp =================================================================== --- trunk/OpenMPT/pluginBridge/Bridge.cpp 2014-10-15 09:35:38 UTC (rev 4432) +++ trunk/OpenMPT/pluginBridge/Bridge.cpp 2014-10-15 14:47:23 UTC (rev 4433) @@ -152,9 +152,9 @@ otherProcess.DuplicateFrom(otherProcess_); sigThreadExit.Create(true); - otherThread = mpt::thread_member<PluginBridge, &PluginBridge::RenderThread>(this); + otherThread = mpt::UnmanagedThreadMember<PluginBridge, &PluginBridge::RenderThread>(this); - mpt::thread_member<PluginBridge, &PluginBridge::MessageThread>(this); + mpt::UnmanagedThreadMember<PluginBridge, &PluginBridge::MessageThread>(this); } Modified: trunk/OpenMPT/pluginBridge/BridgeCommon.h =================================================================== --- trunk/OpenMPT/pluginBridge/BridgeCommon.h 2014-10-15 09:35:38 UTC (rev 4432) +++ trunk/OpenMPT/pluginBridge/BridgeCommon.h 2014-10-15 14:47:23 UTC (rev 4433) @@ -434,7 +434,7 @@ // Signals for internal communication (wake up waiting threads). Confirm() => OK, Send() => Failure Signal ackSignals[SharedMemLayout::queueSize]; - mpt::thread otherThread; // Handle of the "other" thread (host side: message thread, bridge side: process thread) + mpt::UnmanagedThread otherThread; // Handle of the "other" thread (host side: message thread, bridge side: process thread) Event otherProcess; // Handle of "other" process (host handle in the bridge and vice versa) Event sigThreadExit; // Signal to kill helper thread Modified: trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp =================================================================== --- trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp 2014-10-15 09:35:38 UTC (rev 4432) +++ trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp 2014-10-15 14:47:23 UTC (rev 4433) @@ -209,7 +209,7 @@ sigThreadExit.Create(true); sigAutomation.Create(true); - otherThread = mpt::thread_member<BridgeWrapper, &BridgeWrapper::MessageThread>(this); + otherThread = mpt::UnmanagedThreadMember<BridgeWrapper, &BridgeWrapper::MessageThread>(this); BridgeMessage initMsg; initMsg.Init(pluginPath.ToWide().c_str(), MIXBUFFERSIZE, ExceptionHandler::fullMemDump); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-15 20:26:11
|
Revision: 4435 http://sourceforge.net/p/modplug/code/4435 Author: saga-games Date: 2014-10-15 20:25:57 +0000 (Wed, 15 Oct 2014) Log Message: ----------- [Fix] Playback: Since the period refactoring, arpeggios were going down rather than up in IT compatible mode. [Mod] OpenMPT: Version is now 1.24.00.10 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-10-15 16:38:24 UTC (rev 4434) +++ trunk/OpenMPT/common/versionNumber.h 2014-10-15 20:25:57 UTC (rev 4435) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 00 -#define VER_MINORMINOR 09 +#define VER_MINORMINOR 10 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-10-15 16:38:24 UTC (rev 4434) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-10-15 20:25:57 UTC (rev 4435) @@ -51,23 +51,7 @@ }; #endif -typedef CTuning::RATIOTYPE RATIOTYPE; -static const RATIOTYPE TwoToPowerXOver12Table[16] = -{ - 1.0F , 1.059463094359F, 1.122462048309F, 1.1892071150027F, - 1.259921049895F, 1.334839854170F, 1.414213562373F, 1.4983070768767F, - 1.587401051968F, 1.681792830507F, 1.781797436281F, 1.8877486253634F, - 2.0F , 2.118926188719F, 2.244924096619F, 2.3784142300054F -}; - -inline RATIOTYPE TwoToPowerXOver12(const BYTE i) -//------------------------------------------- -{ - return (i < 16) ? TwoToPowerXOver12Table[i] : 1; -} - - void CSoundFile::SetMixerSettings(const MixerSettings &mixersettings) //------------------------------------------------------------------- { @@ -712,7 +696,7 @@ { pChn->nTremorCount--; } - + pChn->dwFlags.set(CHN_FASTVOLRAMP); } @@ -817,7 +801,7 @@ int envValueAtReleaseNode = pIns->VolEnv.Values[pIns->VolEnv.nReleaseNode] * 4; //If we have just hit the release node, force the current env value - //to be that of the release node. This works around the case where + //to be that of the release node. This works around the case where // we have another node at the same position as the release node. if(envpos == pIns->VolEnv.Ticks[pIns->VolEnv.nReleaseNode]) envval = envValueAtReleaseNode; @@ -1196,7 +1180,7 @@ case 0: arpeggioSteps = 0; break; - case 1: + case 1: arpeggioSteps = pChn->nArpeggio >> 4; // >> 4 <-> division by 16. This gives the first number in the parameter. break; case 2: @@ -1217,8 +1201,8 @@ { switch(tick % 3) { - case 1: period = Util::Round<int>(period / TwoToPowerXOver12(pChn->nArpeggio >> 4)); break; - case 2: period = Util::Round<int>(period / TwoToPowerXOver12(pChn->nArpeggio & 0x0F)); break; + case 1: period *= LinearSlideUpTable[(pChn->nArpeggio >> 4) * 16]; break; + case 2: period *= LinearSlideUpTable[(pChn->nArpeggio & 0x0F) * 16]; break; } } } else if(IsCompatibleMode(TRK_FASTTRACKER2)) @@ -1589,7 +1573,7 @@ // apply FT2-style super-soft volume ramping (5ms), overriding openmpt settings rampLength = globalRampLength = Util::muldivr(5, m_MixerSettings.gdwMixingFreq, 1000); } - + if(pChn->pModInstrument != nullptr && rampUp) { instrRampLength = pChn->pModInstrument->nVolRampUp; @@ -1700,7 +1684,7 @@ DWORD nMasterVol; { CHANNELINDEX nchn32 = Clamp(m_nChannels, CHANNELINDEX(1), CHANNELINDEX(31)); - + DWORD mastervol; if (m_PlayConfig.getUseGlobalPreAmp()) @@ -1822,7 +1806,7 @@ { // IMPORTANT: pChn->nRealVolume is 14 bits !!! // -> Util::muldiv( 14+8, 6+6, 18); => RealVolume: 14-bit result (22+12-20) - + if(pChn->dwFlags[CHN_SYNCMUTE]) { pChn->nRealVolume = 0; @@ -1842,7 +1826,7 @@ if (pChn->nPeriod < m_nMinPeriod) pChn->nPeriod = m_nMinPeriod; if(IsCompatibleMode(TRK_FASTTRACKER2)) Clamp(pChn->nPeriod, 1, 31999); period = pChn->nPeriod; - + // When glissando mode is set to semitones, clamp to the next halftone. if((pChn->dwFlags[CHN_GLISSANDO] && IsCompatibleMode(TRK_ALLTRACKERS)) || ((pChn->dwFlags & (CHN_GLISSANDO | CHN_PORTAMENTO)) == (CHN_GLISSANDO | CHN_PORTAMENTO) && !IsCompatibleMode(TRK_ALLTRACKERS))) @@ -1897,7 +1881,7 @@ // Plugins may also receive vibrato ProcessVibrato(nChn, period, vibratoFactor); - + if(samplePlaying) { int nPeriodFrac = 0; @@ -1923,7 +1907,7 @@ period = m_nMaxPeriod; nPeriodFrac = 0; }*/ - + if(GetType() == MOD_TYPE_MPT && pIns != nullptr && pIns->pTuning != nullptr) { // In this case: GetType() == MOD_TYPE_MPT and using custom tunings. @@ -2010,7 +1994,7 @@ // Extra attenuation required here if we're bypassing pre-amp. realvol = (pChn->nRealVolume * kChnMasterVol) >> 8; } - + const forcePanningMode panningMode = m_PlayConfig.getForcePanningMode(); if(panningMode == forceSoftPanning || (panningMode == dontForcePanningMode && (m_MixerSettings.MixerFlags & SNDMIX_SOFTPANNING))) { @@ -2195,7 +2179,7 @@ } const uint32 defaultVolume = pIns->nGlobalVol; - + //If new note, determine notevelocity to use. if(note != NOTE_NONE) { @@ -2215,7 +2199,7 @@ pPlugin->MidiCommand(GetBestMidiChannel(nChn), pIns->nMidiProgram, pIns->wMidiBank, realNote, velocity, nChn); } - + const bool processVolumeAlsoOnNote = (pIns->nPluginVelocityHandling == PLUGIN_VELOCITYHANDLING_VOLUME); if((hasVolCommand && !note) || (note && processVolumeAlsoOnNote)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-17 09:07:09
|
Revision: 4442 http://sourceforge.net/p/modplug/code/4442 Author: manxorist Date: 2014-10-17 09:07:01 +0000 (Fri, 17 Oct 2014) Log Message: ----------- [Fix] test: Support running the libopenmpt test suite when %srcdir% is set to a unicode path (also silences a mpt::PathString conversion warning). Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt_test.cpp trunk/OpenMPT/test/test.cpp trunk/OpenMPT/test/test.h Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_test.cpp 2014-10-16 19:55:31 UTC (rev 4441) +++ trunk/OpenMPT/libopenmpt/libopenmpt_test.cpp 2014-10-17 09:07:01 UTC (rev 4442) @@ -35,23 +35,14 @@ #endif try { - // prefix for test suite - std::string pathprefix = std::string(); - - // set path prefix for test files (if provided) - std::string env_srcdir = std::getenv( "srcdir" ) ? std::getenv( "srcdir" ) : std::string(); - if ( !env_srcdir.empty() ) { - pathprefix = env_srcdir; - } - // run test with "C" / classic() locale - Test::DoTests( pathprefix ); + Test::DoTests(); // try setting the C locale to the user locale setlocale( LC_ALL, "" ); // run all tests again with a set C locale - Test::DoTests( pathprefix ); + Test::DoTests(); // try to set the C and C++ locales to the user locale try { @@ -62,7 +53,7 @@ } // and now, run all tests once again - Test::DoTests( pathprefix ); + Test::DoTests(); } catch ( const std::exception & e ) { std::cerr << "TEST ERROR: exception: " << ( e.what() ? e.what() : "" ) << std::endl; Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2014-10-16 19:55:31 UTC (rev 4441) +++ trunk/OpenMPT/test/test.cpp 2014-10-17 09:07:01 UTC (rev 4442) @@ -91,14 +91,37 @@ } -void DoTests(std::string pathprefix) -//---------------------------------- +void DoTests() +//------------ { #if MPT_OS_WINDOWS - PathPrefix = new mpt::PathString(mpt::PathString::FromLocale(pathprefix)); + + // prefix for test suite + std::wstring pathprefix = std::wstring(); + + // set path prefix for test files (if provided) + std::vector<WCHAR> buf(GetEnvironmentVariableW(L"srcdir", NULL, 0) + 1); + if(GetEnvironmentVariableW(L"srcdir", &buf[0], buf.size()) > 0) + { + pathprefix = &buf[0]; + } + + PathPrefix = new mpt::PathString(mpt::PathString::FromNative(pathprefix)); + #else + + // prefix for test suite + std::string pathprefix = std::string(); + + // set path prefix for test files (if provided) + std::string env_srcdir = std::getenv( "srcdir" ) ? std::getenv( "srcdir" ) : std::string(); + if ( !env_srcdir.empty() ) { + pathprefix = env_srcdir; + } + PathPrefix = new mpt::PathString(mpt::PathString::FromNative(pathprefix)); + #endif DO_TEST(TestVersion); @@ -2392,8 +2415,8 @@ namespace Test { -void DoTests(std::string /*pathprefix*/ ) -//-----------------------------....------ +void DoTests() +//------------ { return; } Modified: trunk/OpenMPT/test/test.h =================================================================== --- trunk/OpenMPT/test/test.h 2014-10-16 19:55:31 UTC (rev 4441) +++ trunk/OpenMPT/test/test.h 2014-10-17 09:07:01 UTC (rev 4442) @@ -15,7 +15,7 @@ namespace Test { -void DoTests(std::string prefix = std::string()); +void DoTests(); } // namespace Test This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-19 15:19:48
|
Revision: 4446 http://sourceforge.net/p/modplug/code/4446 Author: manxorist Date: 2014-10-19 15:19:34 +0000 (Sun, 19 Oct 2014) Log Message: ----------- [Ref] Cleanup ASSERT(). Provide properly namespace-prefixed MPT_ASSERT, MPT_ASSERT_MSG, MPT_ASSERT_ALWAYS, MPT_ASSERT_ALWAYS_MSG macros that do not depend on or possibly conflict with platform or framework provided ASSERT macros. For MFC builds, this stays as a synonym for the MFC-provided ASSERT macro, thus this commit does not change any functionality at all. [Ref] Replace all occurences of ASSERT with MPT_ASSERT in code used by libopenmpt (i.e. common/ and soundlib/ ). [Ref] sounddev: Replace ASSERT with MPT_ASSERT. Modified Paths: -------------- trunk/OpenMPT/common/AudioCriticalSection.h trunk/OpenMPT/common/StringFixer.h trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/common/mptIO.h trunk/OpenMPT/common/mptString.cpp trunk/OpenMPT/common/serialization_utils.h trunk/OpenMPT/common/thread.h trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/mptrack/Globals.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp trunk/OpenMPT/sounddev/SoundDeviceThread.cpp trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp trunk/OpenMPT/sounddsp/EQ.cpp trunk/OpenMPT/soundlib/AudioReadTarget.h trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/FileReader.h trunk/OpenMPT/soundlib/ITCompression.cpp trunk/OpenMPT/soundlib/Load_amf.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_mod.cpp trunk/OpenMPT/soundlib/Load_okt.cpp trunk/OpenMPT/soundlib/Load_psm.cpp trunk/OpenMPT/soundlib/Load_s3m.cpp trunk/OpenMPT/soundlib/Load_umx.cpp trunk/OpenMPT/soundlib/Load_wav.cpp trunk/OpenMPT/soundlib/ModSequence.h trunk/OpenMPT/soundlib/RowVisitor.cpp trunk/OpenMPT/soundlib/SampleFormatConverters.h trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/SampleIO.cpp trunk/OpenMPT/soundlib/Snd_flt.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp trunk/OpenMPT/soundlib/Tables.cpp trunk/OpenMPT/soundlib/WAVTools.cpp trunk/OpenMPT/soundlib/load_j2b.cpp trunk/OpenMPT/soundlib/tuning.cpp trunk/OpenMPT/soundlib/tuningbase.h trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/common/AudioCriticalSection.h =================================================================== --- trunk/OpenMPT/common/AudioCriticalSection.h 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/common/AudioCriticalSection.h 2014-10-19 15:19:34 UTC (rev 4446) @@ -66,7 +66,7 @@ static void AssertUnlocked() { // asserts that the critical section is currently not hold by THIS thread - ALWAYS_ASSERT(!IsLocked()); + MPT_ASSERT_ALWAYS(!IsLocked()); } }; Modified: trunk/OpenMPT/common/StringFixer.h =================================================================== --- trunk/OpenMPT/common/StringFixer.h 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/common/StringFixer.h 2014-10-19 15:19:34 UTC (rev 4446) @@ -34,7 +34,7 @@ inline void SetNullTerminator(char *buffer, size_t size) //------------------------------------------------------ { - ASSERT(size > 0); + MPT_ASSERT(size > 0); buffer[size - 1] = 0; } @@ -49,7 +49,7 @@ inline void SetNullTerminator(wchar_t *buffer, size_t size) //--------------------------------------------------------- { - ASSERT(size > 0); + MPT_ASSERT(size > 0); buffer[size - 1] = 0; } @@ -271,7 +271,7 @@ void Write(char *destBuffer, const size_t destSize, const char *srcBuffer, const size_t srcSize) //---------------------------------------------------------------------------------------------- { - ASSERT(destSize > 0); + MPT_ASSERT(destSize > 0); const size_t maxSize = MIN(destSize, srcSize); char *dst = destBuffer; @@ -314,7 +314,7 @@ void Write(std::vector<char> &destBuffer, const char *srcBuffer, const size_t srcSize) //------------------------------------------------------------------------------------ { - ASSERT(destBuffer.size() > 0); + MPT_ASSERT(destBuffer.size() > 0); Write<mode>(&destBuffer[0], destBuffer.size(), srcBuffer, srcSize); } @@ -345,7 +345,7 @@ void Write(char *destBuffer, const size_t destSize, const std::string &src) //------------------------------------------------------------------------- { - ASSERT(destSize > 0); + MPT_ASSERT(destSize > 0); Write<mode>(destBuffer, destSize, src.c_str(), src.length()); } @@ -353,7 +353,7 @@ void Write(std::vector<char> &destBuffer, const std::string &src) //--------------------------------------------------------------- { - ASSERT(destBuffer.size() > 0); + MPT_ASSERT(destBuffer.size() > 0); Write<mode>(destBuffer, src.c_str(), src.length()); } Modified: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/common/misc_util.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -179,7 +179,7 @@ if(timeEndPeriod(m_CurrentPeriod) != MMSYSERR_NOERROR) { // should not happen - ASSERT(false); + MPT_ASSERT(false); } m_CurrentPeriod = 0; } Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/common/misc_util.h 2014-10-19 15:19:34 UTC (rev 4446) @@ -392,7 +392,7 @@ { static_assert(std::numeric_limits<T>::is_integer == true, "Type is a not an integer"); const double valRounded = Round(val); - ASSERT(valRounded >= (std::numeric_limits<T>::min)() && valRounded <= (std::numeric_limits<T>::max)()); + MPT_ASSERT(valRounded >= (std::numeric_limits<T>::min)() && valRounded <= (std::numeric_limits<T>::max)()); const T intval = static_cast<T>(valRounded); return intval; } @@ -401,7 +401,7 @@ { static_assert(std::numeric_limits<T>::is_integer == true, "Type is a not an integer"); const float valRounded = Round(val); - ASSERT(valRounded >= (std::numeric_limits<T>::min)() && valRounded <= (std::numeric_limits<T>::max)()); + MPT_ASSERT(valRounded >= (std::numeric_limits<T>::min)() && valRounded <= (std::numeric_limits<T>::max)()); const T intval = static_cast<T>(valRounded); return intval; } Modified: trunk/OpenMPT/common/mptIO.h =================================================================== --- trunk/OpenMPT/common/mptIO.h 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/common/mptIO.h 2014-10-19 15:19:34 UTC (rev 4446) @@ -289,9 +289,9 @@ template <typename Tfile> inline bool WriteAdaptiveInt16LE(Tfile & f, const uint16 & v, std::size_t minSize = 0, std::size_t maxSize = 0) { - ASSERT(minSize == 0 || minSize == 1 || minSize == 2); - ASSERT(maxSize == 0 || maxSize == 1 || maxSize == 2); - ASSERT(maxSize == 0 || maxSize >= minSize); + MPT_ASSERT(minSize == 0 || minSize == 1 || minSize == 2); + MPT_ASSERT(maxSize == 0 || maxSize == 1 || maxSize == 2); + MPT_ASSERT(maxSize == 0 || maxSize >= minSize); if(v < 0x80 && minSize <= 1 && (1 <= maxSize || maxSize == 0)) { return IO::WriteIntLE<uint8>(f, static_cast<uint8>(v << 1) | 0x00); @@ -300,7 +300,7 @@ return IO::WriteIntLE<uint16>(f, static_cast<uint16>(v << 1) | 0x01); } else { - ASSERT(false); + MPT_ASSERT(false); return false; } } @@ -308,9 +308,9 @@ template <typename Tfile> inline bool WriteAdaptiveInt32LE(Tfile & f, const uint32 & v, std::size_t minSize = 0, std::size_t maxSize = 0) { - ASSERT(minSize == 0 || minSize == 1 || minSize == 2 || minSize == 3 || minSize == 4); - ASSERT(maxSize == 0 || maxSize == 1 || maxSize == 2 || maxSize == 3 || maxSize == 4); - ASSERT(maxSize == 0 || maxSize >= minSize); + MPT_ASSERT(minSize == 0 || minSize == 1 || minSize == 2 || minSize == 3 || minSize == 4); + MPT_ASSERT(maxSize == 0 || maxSize == 1 || maxSize == 2 || maxSize == 3 || maxSize == 4); + MPT_ASSERT(maxSize == 0 || maxSize >= minSize); if(v < 0x40 && minSize <= 1 && (1 <= maxSize || maxSize == 0)) { return IO::WriteIntLE<uint8>(f, static_cast<uint8>(v << 2) | 0x00); @@ -330,7 +330,7 @@ return IO::WriteIntLE<uint32>(f, static_cast<uint32>(v << 2) | 0x03); } else { - ASSERT(false); + MPT_ASSERT(false); return false; } } @@ -338,9 +338,9 @@ template <typename Tfile> inline bool WriteAdaptiveInt64LE(Tfile & f, const uint64 & v, std::size_t minSize = 0, std::size_t maxSize = 0) { - ASSERT(minSize == 0 || minSize == 1 || minSize == 2 || minSize == 4 || minSize == 8); - ASSERT(maxSize == 0 || maxSize == 1 || maxSize == 2 || maxSize == 4 || maxSize == 8); - ASSERT(maxSize == 0 || maxSize >= minSize); + MPT_ASSERT(minSize == 0 || minSize == 1 || minSize == 2 || minSize == 4 || minSize == 8); + MPT_ASSERT(maxSize == 0 || maxSize == 1 || maxSize == 2 || maxSize == 4 || maxSize == 8); + MPT_ASSERT(maxSize == 0 || maxSize >= minSize); if(v < 0x40 && minSize <= 1 && (1 <= maxSize || maxSize == 0)) { return IO::WriteIntLE<uint8>(f, static_cast<uint8>(v << 2) | 0x00); @@ -355,7 +355,7 @@ return IO::WriteIntLE<uint64>(f, static_cast<uint64>(v << 2) | 0x03); } else { - ASSERT(false); + MPT_ASSERT(false); return false; } } Modified: trunk/OpenMPT/common/mptString.cpp =================================================================== --- trunk/OpenMPT/common/mptString.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/common/mptString.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -441,7 +441,7 @@ { // nothing } - ASSERT(false); + MPT_ASSERT(false); return String::FromAscii(str, replacement); // fallback } @@ -472,7 +472,7 @@ { // nothing } - ASSERT(false); + MPT_ASSERT(false); return String::ToAscii(str, replacement); // fallback } @@ -1305,7 +1305,7 @@ template<typename Tchar> inline Format ParseFormatStringFloat(const Tchar * str) { - ASSERT(str); + MPT_ASSERT(str); FormatFlags f = FormatFlags(); std::size_t width = 0; int precision = -1; Modified: trunk/OpenMPT/common/serialization_utils.h =================================================================== --- trunk/OpenMPT/common/serialization_utils.h 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/common/serialization_utils.h 2014-10-19 15:19:34 UTC (rev 4446) @@ -465,7 +465,7 @@ inline SsbRead::ReadIterator SsbRead::GetReadBegin() //------------------------------------------ { - ASSERT(GetFlag(RwfRMapHasId) && (GetFlag(RwfRMapHasStartpos) || GetFlag(RwfRMapHasSize) || m_nFixedEntrySize > 0)); + MPT_ASSERT(GetFlag(RwfRMapHasId) && (GetFlag(RwfRMapHasStartpos) || GetFlag(RwfRMapHasSize) || m_nFixedEntrySize > 0)); if (GetFlag(RwfRMapCached) == false) CacheMap(); return mapData.begin(); Modified: trunk/OpenMPT/common/thread.h =================================================================== --- trunk/OpenMPT/common/thread.h 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/common/thread.h 2014-10-19 15:19:34 UTC (rev 4446) @@ -275,7 +275,7 @@ ~thread() { - ASSERT(!joinable()); + MPT_ASSERT(!joinable()); } }; Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/common/typedefs.h 2014-10-19 15:19:34 UTC (rev 4446) @@ -195,72 +195,70 @@ #if !defined(ASSERT) #error "MFC is expected to #define ASSERT" #endif // !defined(ASERRT) -#define MPT_ASSERT_IS_DEFINED +#define MPT_FRAMEWORK_ASSERT_IS_DEFINED #if defined(_DEBUG) - #define MPT_ASSERT_IS_ACTIVE 1 + #define MPT_FRAMEWORK_ASSERT_IS_ACTIVE 1 #else // !_DEBUG - #define MPT_ASSERT_IS_ACTIVE 0 + #define MPT_FRAMEWORK_ASSERT_IS_ACTIVE 0 #endif // _DEBUG +// let MFC handle our asserts +#define MPT_ASSERT_USE_FRAMEWORK 1 + #else // !_MFC_VER #if defined(ASSERT) -#error "ASSERT(expr) is expected to NOT be defined by any other header" +#define MPT_FRAMEWORK_ASSERT_IS_DEFINED +#if defined(_DEBUG) + #define MPT_FRAMEWORK_ASSERT_IS_ACTIVE 1 +#else // !_DEBUG + #define MPT_FRAMEWORK_ASSERT_IS_ACTIVE 0 +#endif // _DEBUG #endif // !defined(ASERRT) +// handle assert in our own way without relying on some platform-/framework-specific assert implementation +#define MPT_ASSERT_USE_FRAMEWORK 0 + #endif // _MFC_VER -#if defined(MPT_ASSERT_IS_DEFINED) +#if defined(MPT_FRAMEWORK_ASSERT_IS_DEFINED) && (MPT_ASSERT_USE_FRAMEWORK == 1) -//#define ASSERT // already defined -#define ASSERT_WARN_MESSAGE(expr,msg) ASSERT(expr) +#define MPT_ASSERT(expr) ASSERT((expr)) +#define MPT_ASSERT_MSG(expr, msg) ASSERT((expr) && (msg)) +#if (MPT_FRAMEWORK_ASSERT_IS_ACTIVE == 1) +#define MPT_ASSERT_ALWAYS(expr) ASSERT((expr)) +#define MPT_ASSERT_ALWAYS_MSG(expr, msg) ASSERT((expr) && (msg)) +#else +#define MPT_ASSERT_ALWAYS(expr) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr); } } while(0) +#define MPT_ASSERT_ALWAYS_MSG(expr, msg) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr, msg); } } while(0) +#ifndef MPT_ASSERT_HANDLER_NEEDED +#define MPT_ASSERT_HANDLER_NEEDED +#endif +#endif #elif defined(NO_ASSERTS) -#define MPT_ASSERT_IS_DEFINED -#define MPT_ASSERT_IS_ACTIVE 0 -#define ASSERT(expr) do { } while(0) -#define ASSERT_WARN_MESSAGE(expr,msg) do { } while(0) - -#else // !NO_ASSERTS - -#define MPT_ASSERT_IS_DEFINED -#define MPT_ASSERT_IS_ACTIVE 1 -#define ASSERT(expr) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr); } } while(0) -#define ASSERT_WARN_MESSAGE(expr,msg) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr, msg); } } while(0) +#define MPT_ASSERT(expr) do { } while(0) +#define MPT_ASSERT_MSG(expr, msg) do { } while(0) +#define MPT_ASSERT_ALWAYS(expr) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr); } } while(0) +#define MPT_ASSERT_ALWAYS_MSG(expr, msg) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr, msg); } } while(0) #ifndef MPT_ASSERT_HANDLER_NEEDED #define MPT_ASSERT_HANDLER_NEEDED #endif -#endif // NO_ASSERTS +#else // !NO_ASSERTS -// error checking -#if !defined(MPT_ASSERT_IS_DEFINED) -#error "ASSERT(expr) has to be defined" -#endif // !MPT_ASSERT_IS_DEFINED -#if MPT_ASSERT_IS_ACTIVE && defined(NO_ASSERTS) -#error "ASSERT is active but NO_ASSERT is defined" -#elif !MPT_ASSERT_IS_ACTIVE && !defined(NO_ASSERTS) -#error "NO_ASSERT is not defined but ASSERTs are not active" -#endif - - -#if (MPT_ASSERT_IS_ACTIVE == 1) - -#define ALWAYS_ASSERT(expr) ASSERT(expr) -#define ALWAYS_ASSERT_WARN_MESSAGE(expr,msg) ASSERT_WARN_MESSAGE(expr,msg) - -#else // (MPT_ASSERT_IS_ACTIVE != 1) - -#define ALWAYS_ASSERT(expr) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr); } } while(0) -#define ALWAYS_ASSERT_WARN_MESSAGE(expr,msg) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr, msg); } } while(0) +#define MPT_ASSERT(expr) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr); } } while(0) +#define MPT_ASSERT_MSG(expr, msg) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr, msg); } } while(0) +#define MPT_ASSERT_ALWAYS(expr) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr); } } while(0) +#define MPT_ASSERT_ALWAYS_MSG(expr, msg) do { if(!(expr)) { AssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr, msg); } } while(0) #ifndef MPT_ASSERT_HANDLER_NEEDED #define MPT_ASSERT_HANDLER_NEEDED #endif -#endif // MPT_ASSERT_IS_ACTIVE +#endif // NO_ASSERTS #if defined(MPT_ASSERT_HANDLER_NEEDED) Modified: trunk/OpenMPT/mptrack/Globals.cpp =================================================================== --- trunk/OpenMPT/mptrack/Globals.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/mptrack/Globals.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -357,7 +357,7 @@ pDlg = m_Pages[nIndex]; } else //Ctrl window is not created yet - creating one. { - ALWAYS_ASSERT(GetDocument() != nullptr); + MPT_ASSERT_ALWAYS(GetDocument() != nullptr); switch(nID) { //rewbs.graph Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -676,7 +676,7 @@ { MPT_TRACE(); CriticalSection cs; - ALWAYS_ASSERT(m_pSndFile != nullptr); + MPT_ASSERT_ALWAYS(m_pSndFile != nullptr); m_AudioThreadId = GetCurrentThreadId(); mpt::log::Trace::SetThreadId(mpt::log::Trace::ThreadKindAudio, m_AudioThreadId); callback.FillAudioBuffer(); @@ -701,7 +701,7 @@ , dither(dither_) , buffer(buffer_) { - ALWAYS_ASSERT(sampleFormat.IsValid()); + MPT_ASSERT_ALWAYS(sampleFormat.IsValid()); } virtual void DataCallback(int *MixSoundBuffer, std::size_t channels, std::size_t countChunk) { Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -247,7 +247,7 @@ { MPT_TRACE(); - ASSERT(!IsDriverOpen()); + MPT_ASSERT(!IsDriverOpen()); InitMembers(); @@ -356,7 +356,7 @@ } } else { // should not happen - ASSERT(false); + MPT_ASSERT(false); } m_BufferInfo.resize(m_Settings.Channels); @@ -370,7 +370,7 @@ m_Callbacks.sampleRateDidChange = CallbackSampleRateDidChange; m_Callbacks.asioMessage = CallbackAsioMessage; m_Callbacks.bufferSwitchTimeInfo = CallbackBufferSwitchTimeInfo; - ALWAYS_ASSERT(g_CallbacksInstance == nullptr); + MPT_ASSERT_ALWAYS(g_CallbacksInstance == nullptr); g_CallbacksInstance = this; Log(mpt::String::Print("ASIO: createBuffers(numChannels=%1, bufferSize=%2)", m_Settings.Channels, m_nAsioBufferLen)); asioCall(createBuffers(&m_BufferInfo[0], m_Settings.Channels, m_nAsioBufferLen, &m_Callbacks)); @@ -383,7 +383,7 @@ m_ChannelInfo[channel].isInput = ASIOFalse; m_ChannelInfo[channel].channel = m_Settings.ChannelMapping.ToDevice(channel); asioCall(getChannelInfo(&m_ChannelInfo[channel])); - ASSERT(m_ChannelInfo[channel].isActive); + MPT_ASSERT(m_ChannelInfo[channel].isActive); mpt::String::SetNullTerminator(m_ChannelInfo[channel].name); Log(mpt::String::Print("ASIO: getChannelInfo(isInput=%1 channel=%2) => isActive=%3 channelGroup=%4 type=%5 name='%6'" , ASIOFalse @@ -519,19 +519,19 @@ { if(CriticalSection::IsLocked()) { - ASSERT_WARN_MESSAGE(false, "AudioCriticalSection locked while stopping ASIO"); + MPT_ASSERT_MSG(false, "AudioCriticalSection locked while stopping ASIO"); } else { - ASSERT_WARN_MESSAGE(false, "waiting for asio failed in Stop()"); + MPT_ASSERT_MSG(false, "waiting for asio failed in Stop()"); } } else { if(CriticalSection::IsLocked()) { - ASSERT_WARN_MESSAGE(false, "AudioCriticalSection locked while starting ASIO"); + MPT_ASSERT_MSG(false, "AudioCriticalSection locked while starting ASIO"); } else { - ASSERT_WARN_MESSAGE(false, "waiting for asio failed in Start()"); + MPT_ASSERT_MSG(false, "waiting for asio failed in Start()"); } } break; @@ -545,7 +545,7 @@ //------------------------------- { MPT_TRACE(); - ALWAYS_ASSERT_WARN_MESSAGE(!CriticalSection::IsLocked(), "AudioCriticalSection locked while starting ASIO"); + MPT_ASSERT_ALWAYS_MSG(!CriticalSection::IsLocked(), "AudioCriticalSection locked while starting ASIO"); if(m_Settings.KeepDeviceRunning) { @@ -589,7 +589,7 @@ //-------------------------------------------- { MPT_TRACE(); - ALWAYS_ASSERT_WARN_MESSAGE(!CriticalSection::IsLocked(), "AudioCriticalSection locked while stopping ASIO"); + MPT_ASSERT_ALWAYS_MSG(!CriticalSection::IsLocked(), "AudioCriticalSection locked while stopping ASIO"); if(m_Settings.KeepDeviceRunning && !force) { @@ -648,7 +648,7 @@ } if(g_CallbacksInstance) { - ALWAYS_ASSERT(g_CallbacksInstance == this); + MPT_ASSERT_ALWAYS(g_CallbacksInstance == this); g_CallbacksInstance = nullptr; } MemsetZero(m_Callbacks); @@ -869,7 +869,7 @@ std::memset(&m_SampleBufferInt32[0], 0, countChunk * channels * sizeof(int32)); } else { - ASSERT(false); + MPT_ASSERT(false); } } else { @@ -888,7 +888,7 @@ SourceAudioRead(&m_SampleBufferInt32[0], countChunk); } else { - ASSERT(false); + MPT_ASSERT(false); } } for(int channel = 0; channel < channels; ++channel) @@ -913,7 +913,7 @@ CopyInterleavedToChannel<SC::Convert<double, float> >(reinterpret_cast<double*>(dst), srcFloat, channels, countChunk, channel); break; default: - ASSERT(false); + MPT_ASSERT(false); break; } } else if(m_Settings.sampleFormat == SampleFormatInt16) @@ -926,7 +926,7 @@ CopyInterleavedToChannel<SC::Convert<int16, int16> >(reinterpret_cast<int16*>(dst), srcInt16, channels, countChunk, channel); break; default: - ASSERT(false); + MPT_ASSERT(false); break; } } else if(m_Settings.sampleFormat == SampleFormatInt24) @@ -939,7 +939,7 @@ CopyInterleavedToChannel<SC::Convert<int24, int24> >(reinterpret_cast<int24*>(dst), srcInt24, channels, countChunk, channel); break; default: - ASSERT(false); + MPT_ASSERT(false); break; } } else if(m_Settings.sampleFormat == SampleFormatInt32) @@ -984,12 +984,12 @@ CopyInterleavedToChannel<SC::ConvertShift<int32, int32, 8> >(reinterpret_cast<int32*>(dst), srcInt32, channels, countChunk, channel); break; default: - ASSERT(false); + MPT_ASSERT(false); break; } } else { - ASSERT(false); + MPT_ASSERT(false); } if(IsSampleTypeBigEndian(m_ChannelInfo[channel].type)) { @@ -1090,7 +1090,7 @@ //----------------------------------------------------------------------------------------------------------- { MPT_TRACE(); - ASSERT(directProcess); // !directProcess is not handled correctly in OpenMPT, would require a separate thread and potentially additional buffering + MPT_ASSERT(directProcess); // !directProcess is not handled correctly in OpenMPT, would require a separate thread and potentially additional buffering if(!directProcess) { m_UsedFeatures.set(AsioFeatureNoDirectProcess); @@ -1306,7 +1306,7 @@ //------------------------------------------------------------------------------------------ { MPT_TRACE(); - ALWAYS_ASSERT(g_CallbacksInstance); + MPT_ASSERT_ALWAYS(g_CallbacksInstance); if(!g_CallbacksInstance) return 0; return g_CallbacksInstance->AsioMessage(selector, value, message, opt); } @@ -1316,7 +1316,7 @@ //----------------------------------------------------------------- { MPT_TRACE(); - ALWAYS_ASSERT(g_CallbacksInstance); + MPT_ASSERT_ALWAYS(g_CallbacksInstance); if(!g_CallbacksInstance) return; g_CallbacksInstance->SampleRateDidChange(sRate); } @@ -1326,7 +1326,7 @@ //------------------------------------------------------------------------------------ { MPT_TRACE(); - ALWAYS_ASSERT(g_CallbacksInstance); + MPT_ASSERT_ALWAYS(g_CallbacksInstance); if(!g_CallbacksInstance) return; g_CallbacksInstance->BufferSwitch(doubleBufferIndex, directProcess); } @@ -1336,7 +1336,7 @@ //------------------------------------------------------------------------------------------------------------------- { MPT_TRACE(); - ALWAYS_ASSERT(g_CallbacksInstance); + MPT_ASSERT_ALWAYS(g_CallbacksInstance); if(!g_CallbacksInstance) return params; return g_CallbacksInstance->BufferSwitchTimeInfo(params, doubleBufferIndex, directProcess); } Modified: trunk/OpenMPT/sounddev/SoundDeviceThread.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceThread.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/sounddev/SoundDeviceThread.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -352,7 +352,7 @@ { if(InterlockedExchangeAdd(&m_AudioThreadActive, 0)) { - ALWAYS_ASSERT(false); + MPT_ASSERT_ALWAYS(false); return; } ResetEvent(m_hAudioThreadGoneIdle); @@ -366,7 +366,7 @@ { if(!InterlockedExchangeAdd(&m_AudioThreadActive, 0)) { - ALWAYS_ASSERT(false); + MPT_ASSERT_ALWAYS(false); return; } InterlockedExchange(&m_AudioThreadActive, 0); Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -204,7 +204,7 @@ waveOutUnprepareHeader(m_hWaveOut, &m_WaveBuffers[m_nPreparedHeaders], sizeof(WAVEHDR)); } MMRESULT err = waveOutClose(m_hWaveOut); - ALWAYS_ASSERT(err == MMSYSERR_NOERROR); + MPT_ASSERT_ALWAYS(err == MMSYSERR_NOERROR); m_hWaveOut = NULL; } if(m_ThreadWakeupEvent) Modified: trunk/OpenMPT/sounddsp/EQ.cpp =================================================================== --- trunk/OpenMPT/sounddsp/EQ.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/sounddsp/EQ.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -393,8 +393,8 @@ //-------- { #if defined(ENABLE_SSE) || defined(ENABLE_X86_AMD) - ALWAYS_ASSERT(((uintptr_t)&(gEQ[0])) % 4 == 0); - ALWAYS_ASSERT(((uintptr_t)&(gEQ[1])) % 4 == 0); + MPT_ASSERT_ALWAYS(((uintptr_t)&(gEQ[0])) % 4 == 0); + MPT_ASSERT_ALWAYS(((uintptr_t)&(gEQ[1])) % 4 == 0); #endif // ENABLE_SSE || ENABLE_X86_AMD memcpy(gEQ, gEQDefaults, sizeof(gEQ)); } Modified: trunk/OpenMPT/soundlib/AudioReadTarget.h =================================================================== --- trunk/OpenMPT/soundlib/AudioReadTarget.h 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/AudioReadTarget.h 2014-10-19 15:19:34 UTC (rev 4446) @@ -36,7 +36,7 @@ , outputBuffer(buffer) , outputBuffers(buffers) { - ASSERT(SampleFormat(SampleFormatTraits<Tsample>::sampleFormat).IsValid()); + MPT_ASSERT(SampleFormat(SampleFormatTraits<Tsample>::sampleFormat).IsValid()); } virtual ~AudioReadTargetBuffer() { } std::size_t GetRenderedCount() const { return countRendered; } Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -442,7 +442,7 @@ uint32 targetpos = chn.nPos + (BufferLengthToSamples(nSmpCount, chn) >> 16); MixFuncTable::Functions[functionNdx | (chn.nRampLength ? MixFuncTable::ndxRamp : 0)](chn, m_Resampler, pbuffer, nSmpCount); - ASSERT(chn.nPos == targetpos); + MPT_ASSERT(chn.nPos == targetpos); chn.nROfs += *(pbufmax-2); chn.nLOfs += *(pbufmax-1); Modified: trunk/OpenMPT/soundlib/FileReader.h =================================================================== --- trunk/OpenMPT/soundlib/FileReader.h 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/FileReader.h 2014-10-19 15:19:34 UTC (rev 4446) @@ -286,7 +286,7 @@ T ReadTruncatedIntLE(off_t size) { static_assert(std::numeric_limits<T>::is_integer == true, "Target type is a not an integer"); - ASSERT(sizeof(T) >= size); + MPT_ASSERT(sizeof(T) >= size); if(size == 0) { return 0; Modified: trunk/OpenMPT/soundlib/ITCompression.cpp =================================================================== --- trunk/OpenMPT/soundlib/ITCompression.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/ITCompression.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -153,7 +153,7 @@ if(width <= 6) { // Mode A: 1 to 6 bits - ASSERT(width); + MPT_ASSERT(width); WriteBits(width, (1 << (width - 1))); WriteBits(Properties::fetchA, ConvertWidth(width, bwt[i])); } else if(width < defWidth) @@ -164,7 +164,7 @@ } else { // Mode C: 9 / 17 bits - ASSERT((bwt[i] - 1) >= 0); + MPT_ASSERT((bwt[i] - 1) >= 0); WriteBits(width, (1 << (width - 1)) + bwt[i] - 1); } @@ -183,7 +183,7 @@ int ITCompression::GetWidthChangeSize(int w, bool is16) //----------------------------------------------------- { - ASSERT(w > 0 && static_cast<unsigned int>(w) <= CountOf(ITWidthChangeSize)); + MPT_ASSERT(w > 0 && static_cast<unsigned int>(w) <= CountOf(ITWidthChangeSize)); int wcs = ITWidthChangeSize[w - 1]; if(w <= 6 && is16) wcs++; @@ -202,7 +202,7 @@ return; } - ASSERT(width >= 0 && static_cast<unsigned int>(width) < CountOf(Properties::lowerTab)); + MPT_ASSERT(width >= 0 && static_cast<unsigned int>(width) < CountOf(Properties::lowerTab)); SmpLength i = offset; SmpLength end = offset + length; @@ -265,7 +265,7 @@ { curWidth--; newWidth--; - ASSERT(newWidth != curWidth); + MPT_ASSERT(newWidth != curWidth); if(newWidth > curWidth) newWidth--; return newWidth; @@ -304,7 +304,7 @@ } else { // How could this happen, anyway? - ASSERT(false); + MPT_ASSERT(false); } } @@ -390,7 +390,7 @@ if(width >= curWidth) width++; - ASSERT(curWidth != width); + MPT_ASSERT(curWidth != width); curWidth = width; } Modified: trunk/OpenMPT/soundlib/Load_amf.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_amf.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/Load_amf.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -423,7 +423,7 @@ } } // To check: Was the channel table introduced in revision 1.0 or 0.9? I only have 0.8 files, in which it is missing... - ASSERT(fileHeader.version != 9); + MPT_ASSERT(fileHeader.version != 9); // Get Tempo/Speed if(fileHeader.version >= 13) Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -799,7 +799,7 @@ { chnMask.resize(ch + 1, 0); lastValue.resize(ch + 1, ModCommand::Empty()); - ASSERT(chnMask.size() <= GetNumChannels()); + MPT_ASSERT(chnMask.size() <= GetNumChannels()); } if(b & IT_bitmask_patternChanEnabled_c) // 0x80 @@ -1619,7 +1619,7 @@ const uint32 MPTStartPos = (uint32)fout.tellp(); // catch standard library truncating files - ALWAYS_ASSERT(MPTStartPos > 0); + MPT_ASSERT_ALWAYS(MPTStartPos > 0); srlztn::SsbWrite ssb(fout); ssb.BeginWrite("mptm", MptVersion::num); @@ -1984,7 +1984,7 @@ { \ const uint32 code = MAGIC4BE(c1, c2, c3, c4); \ mpt::IO::WriteIntLE<uint32>(f, code); \ - ASSERT(fsize <= uint16_max); \ + MPT_ASSERT(fsize <= uint16_max); \ const uint16 size = fsize; \ mpt::IO::WriteIntLE<uint16>(f, size); \ } Modified: trunk/OpenMPT/soundlib/Load_mod.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -623,7 +623,7 @@ // Files that have restart pos == 0x78: action's batman by DJ Uno (M.K.), 3ddance.mod (M15, so handled by ReadM15), // VALLEY.MOD (M.K.), WormsTDC.MOD (M.K.), ZWARTZ.MOD (M.K.) // Files that have an order list longer than 0x78 with restart pos = 0x78: my_shoe_is_barking.mod, papermix.mod - ASSERT(m_nRestartPos != 0x78 || m_nRestartPos + 1u >= realOrders); + MPT_ASSERT(m_nRestartPos != 0x78 || m_nRestartPos + 1u >= realOrders); if(m_nRestartPos >= 128 || m_nRestartPos + 1u >= realOrders || m_nRestartPos == 0x78) { m_nRestartPos = 0; @@ -839,7 +839,7 @@ { return false; } - ASSERT(sampleHeader.finetune == 0); + MPT_ASSERT(sampleHeader.finetune == 0); totalSampleLen += Samples[smp].nLength; Modified: trunk/OpenMPT/soundlib/Load_okt.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_okt.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/Load_okt.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -274,7 +274,7 @@ default: m->command = m->param = 0; - //ASSERT(false); + //MPT_ASSERT(false); break; } } Modified: trunk/OpenMPT/soundlib/Load_psm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_psm.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/Load_psm.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -531,7 +531,7 @@ } case PSMChunk::idPPAN: // PPAN - Channel panning table (used in Sinaria) // In some Sinaria tunes, this is actually longer than 2 * channels... - ASSERT(subChunkHead.length >= m_nChannels * 2u); + MPT_ASSERT(subChunkHead.length >= m_nChannels * 2u); for(CHANNELINDEX chn = 0; chn < m_nChannels; chn++) { if(!subChunk.CanRead(2)) Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -701,7 +701,7 @@ size_t curPos = ftell(f); if(curPos < sampleHeaderOffset) { - ASSERT(sampleHeaderOffset - curPos < 16); + MPT_ASSERT(sampleHeaderOffset - curPos < 16); fwrite(filler, sampleHeaderOffset - curPos, 1, f); } @@ -717,7 +717,7 @@ continue; } - ASSERT((ftell(f) % 16) == 0); + MPT_ASSERT((ftell(f) % 16) == 0); patternOffsets[pat] = static_cast<uint16>(ftell(f) / 16); SwapBytesLE(patternOffsets[pat]); Modified: trunk/OpenMPT/soundlib/Load_umx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_umx.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/Load_umx.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -273,7 +273,7 @@ // Can't bother to implement property reading, as no UMX files I've seen so far use properties for the relevant objects, // and only the UAX files in the Unreal 1997/98 beta seem to use this and still load just fine when ignoring it. // If it should be necessary to implement this, check CUnProperty.cpp in http://ut-files.com/index.php?dir=Utilities/&file=utcms_source.zip - ASSERT(false); + MPT_ASSERT(false); continue; } #else Modified: trunk/OpenMPT/soundlib/Load_wav.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_wav.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/Load_wav.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -26,8 +26,8 @@ bool CopyWavChannel(ModSample &sample, const FileReader &file, size_t channelIndex, size_t numChannels, SampleConversion conv = SampleConversion()) //------------------------------------------------------------------------------------------------------------------------------------------------- { - ASSERT(sample.GetNumChannels() == 1); - ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t)); + MPT_ASSERT(sample.GetNumChannels() == 1); + MPT_ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t)); const size_t offset = channelIndex * sizeof(typename SampleConversion::input_t) * SampleConversion::input_inc; Modified: trunk/OpenMPT/soundlib/ModSequence.h =================================================================== --- trunk/OpenMPT/soundlib/ModSequence.h 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/ModSequence.h 2014-10-19 15:19:34 UTC (rev 4446) @@ -38,13 +38,13 @@ // Initialize default sized sequence. void Init(); - PATTERNINDEX& operator[](const size_t i) {ASSERT(i < m_nSize); return m_pArray[i];} - const PATTERNINDEX& operator[](const size_t i) const {ASSERT(i < m_nSize); return m_pArray[i];} + PATTERNINDEX& operator[](const size_t i) {MPT_ASSERT(i < m_nSize); return m_pArray[i];} + const PATTERNINDEX& operator[](const size_t i) const {MPT_ASSERT(i < m_nSize); return m_pArray[i];} PATTERNINDEX& At(const size_t i) {return (*this)[i];} const PATTERNINDEX& At(const size_t i) const {return (*this)[i];} - PATTERNINDEX& Last() {ASSERT(m_nSize > 0); return m_pArray[m_nSize-1];} - const PATTERNINDEX& Last() const {ASSERT(m_nSize > 0); return m_pArray[m_nSize-1];} + PATTERNINDEX& Last() {MPT_ASSERT(m_nSize > 0); return m_pArray[m_nSize-1];} + const PATTERNINDEX& Last() const {MPT_ASSERT(m_nSize > 0); return m_pArray[m_nSize-1];} // Returns last accessible index, i.e. GetLength() - 1. Behaviour is undefined if length is zero. ORDERINDEX GetLastIndex() const {return m_nSize - 1;} Modified: trunk/OpenMPT/soundlib/RowVisitor.cpp =================================================================== --- trunk/OpenMPT/soundlib/RowVisitor.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/RowVisitor.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -175,7 +175,7 @@ void RowVisitor::ResetPatternLoop(ORDERINDEX order, ROWINDEX startRow) //-------------------------------------------------------------------- { - ASSERT(order == currentOrder); // Shouldn't trigger, unless we're jumping around in the GUI during a pattern loop. + MPT_ASSERT(order == currentOrder); // Shouldn't trigger, unless we're jumping around in the GUI during a pattern loop. // Unvisit all rows that are in the visited row buffer, until we hit the start row for this pattern loop. ROWINDEX row = ROWINDEX_INVALID; Modified: trunk/OpenMPT/soundlib/SampleFormatConverters.h =================================================================== --- trunk/OpenMPT/soundlib/SampleFormatConverters.h 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/SampleFormatConverters.h 2014-10-19 15:19:34 UTC (rev 4446) @@ -733,7 +733,7 @@ void CopyInterleavedSampleStreams(typename SampleConversion::output_t * MPT_RESTRICT outBuf, const typename SampleConversion::input_t * MPT_RESTRICT inBuf, size_t numFrames, size_t numChannels, std::vector<SampleConversion> &conv) //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ { - ASSERT(conv.size() >= numChannels); + MPT_ASSERT(conv.size() >= numChannels); CopyInterleavedSampleStreams(outBuf, inBuf, numFrames, numChannels, &(conv[0])); } @@ -743,8 +743,8 @@ size_t CopyMonoSample(ModSample &sample, const char *sourceBuffer, size_t sourceSize, SampleConversion conv = SampleConversion()) //------------------------------------------------------------------------------------------------------------------------------- { - ASSERT(sample.GetNumChannels() == 1); - ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t)); + MPT_ASSERT(sample.GetNumChannels() == 1); + MPT_ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t)); const size_t frameSize = SampleConversion::input_inc; const size_t countFrames = std::min<size_t>(sourceSize / frameSize, sample.nLength); @@ -767,8 +767,8 @@ size_t CopyStereoInterleavedSample(ModSample &sample, const char *sourceBuffer, size_t sourceSize, SampleConversion conv = SampleConversion()) //-------------------------------------------------------------------------------------------------------------------------------------------- { - ASSERT(sample.GetNumChannels() == 2); - ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t)); + MPT_ASSERT(sample.GetNumChannels() == 2); + MPT_ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t)); const size_t frameSize = 2 * SampleConversion::input_inc; const size_t countFrames = std::min<size_t>(sourceSize / frameSize, sample.nLength); @@ -795,8 +795,8 @@ size_t CopyStereoSplitSample(ModSample &sample, const char *sourceBuffer, size_t sourceSize, SampleConversion conv = SampleConversion()) //-------------------------------------------------------------------------------------------------------------------------------------- { - ASSERT(sample.GetNumChannels() == 2); - ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t)); + MPT_ASSERT(sample.GetNumChannels() == 2); + MPT_ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t)); const size_t sampleSize = SampleConversion::input_inc; const size_t sourceSizeLeft = std::min<size_t>(sample.nLength * SampleConversion::input_inc, sourceSize); @@ -837,7 +837,7 @@ { const size_t inSize = sizeof(typename SampleConversion::input_t); - ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t)); + MPT_ASSERT(sample.GetElementarySampleSize() == sizeof(typename SampleConversion::output_t)); size_t numSamples = sample.nLength * sample.GetNumChannels(); LimitMax(numSamples, sourceSize / inSize); Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -1950,9 +1950,9 @@ int8 *sampleData8 = static_cast<int8 *>(sample.pSample) + offset; int16 *sampleData16 = static_cast<int16 *>(sample.pSample) + offset; - ASSERT((bps <= 8 && sample.GetElementarySampleSize() == 1) || (bps > 8 && sample.GetElementarySampleSize() == 2)); - ASSERT(modChannels <= FLAC__stream_decoder_get_channels(decoder)); - ASSERT(bps == FLAC__stream_decoder_get_bits_per_sample(decoder)); + MPT_ASSERT((bps <= 8 && sample.GetElementarySampleSize() == 1) || (bps > 8 && sample.GetElementarySampleSize() == 2)); + MPT_ASSERT(modChannels <= FLAC__stream_decoder_get_channels(decoder)); + MPT_ASSERT(bps == FLAC__stream_decoder_get_bits_per_sample(decoder)); MPT_UNREFERENCED_PARAMETER(decoder); // decoder is unused if ASSERTs are compiled out // Do the sample conversion @@ -2232,7 +2232,7 @@ SampleToFLAC32<int16>(sampleData, sample.pSample, numSamples); } else { - ASSERT(false); + MPT_ASSERT(false); } // Do the actual conversion. Modified: trunk/OpenMPT/soundlib/SampleIO.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleIO.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/SampleIO.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -63,7 +63,7 @@ return 0; } - ASSERT(sampleSize >= sample.GetSampleSizeInBytes()); + MPT_ASSERT(sampleSize >= sample.GetSampleSizeInBytes()); ////////////////////////////////////////////////////// // 8-Bit / Mono / PCM @@ -577,7 +577,7 @@ } } - ASSERT(filePosition + bytesRead <= file.GetLength()); + MPT_ASSERT(filePosition + bytesRead <= file.GetLength()); file.Seek(filePosition + bytesRead); return bytesRead; } Modified: trunk/OpenMPT/soundlib/Snd_flt.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_flt.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/Snd_flt.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -31,7 +31,7 @@ //----------------------------------------------------------------------- { float Fc; - ASSERT(nCutOff < 128); + MPT_ASSERT(nCutOff < 128); if(m_SongFlags[SONG_EXFILTERRANGE]) Fc = 110.0f * pow(2.0f, 0.25f + ((float)(nCutOff * (flt_modifier + 256))) / (20.0f * 512.0f)); else Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -1494,7 +1494,7 @@ if(IsCompatibleMode(TRK_IMPULSETRACKER)) { // I think this is not necessary, so let's check if it is actually called. - ASSERT(pChn->nVibratoPos == 0); + MPT_ASSERT(pChn->nVibratoPos == 0); pChn->nVibratoPos = 0; } } @@ -4229,7 +4229,7 @@ float CSoundFile::CalculateSmoothParamChange(float currentValue, float param) const //--------------------------------------------------------------------------------- { - ASSERT(GetNumTicksOnCurrentRow() > m_PlayState.m_nTickCount); + MPT_ASSERT(GetNumTicksOnCurrentRow() > m_PlayState.m_nTickCount); const UINT ticksLeft = GetNumTicksOnCurrentRow() - m_PlayState.m_nTickCount; if(ticksLeft > 1) { Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -195,7 +195,7 @@ mpt::IO::WriteIntLE<int16>(file, fsize); \ } else if(only_this_code == fcode)\ { \ - ASSERT(fixedsize == fsize); \ + MPT_ASSERT(fixedsize == fsize); \ } \ if(only_this_code == fcode || only_this_code == Util::MaxValueOfType(only_this_code)) \ { \ @@ -224,7 +224,7 @@ /* hackish workaround to resolve mismatched size values: */ \ /* nResampling was a long time declared as uint32 but these macro tables used uint16 and UINT. */ \ /* This worked fine on little-endian, on big-endian not so much. Thus support writing size-mismatched fields. */ \ - ASSERT(fixedsize >= fsize); \ + MPT_ASSERT(fixedsize >= fsize); \ type tmp = (type)(input-> name ); \ tmp = SwapBytesReturnLE(tmp); \ fwrite(&tmp , 1 , fsize , file); \ @@ -244,7 +244,7 @@ // ------------------------------------------------------------------------ #define WRITE_MPTHEADER_array_member(name,type,code,arraysize) \ STATIC_ASSERT(sizeof(type) == sizeof(input-> name [0])); \ - ASSERT(sizeof(input->name) >= sizeof(type) * arraysize);\ + MPT_ASSERT(sizeof(input->name) >= sizeof(type) * arraysize);\ fcode = MULTICHAR_STRING_TO_INT(#code);\ fsize = sizeof( type ) * arraysize;\ if(only_this_code == Util::MaxValueOfType(only_this_code)) \ @@ -253,7 +253,7 @@ mpt::IO::WriteIntLE<int16>(file, fsize); \ } else if(only_this_code == fcode)\ { \ - /* ASSERT(fixedsize <= fsize); */ \ + /* MPT_ASSERT(fixedsize <= fsize); */ \ fsize = fixedsize; /* just trust the size we got passed */ \ } \ if(only_this_code == fcode || only_this_code == Util::MaxValueOfType(only_this_code)) \ @@ -299,7 +299,7 @@ if(only_this_code != Util::MaxValueOfType(only_this_code)) { - ASSERT(fixedsize > 0); + MPT_ASSERT(fixedsize > 0); } WRITE_MPTHEADER_sized_member( nFadeOut , UINT , FO.. ) @@ -1430,7 +1430,7 @@ const char *CSoundFile::GetSampleName(SAMPLEINDEX nSample) const //-------------------------------------------------------------- { - ASSERT(nSample <= GetNumSamples()); + MPT_ASSERT(nSample <= GetNumSamples()); if (nSample < MAX_SAMPLES) { return m_szNames[nSample]; @@ -1447,7 +1447,7 @@ if((nInstr >= MAX_INSTRUMENTS) || (!Instruments[nInstr])) return ""; - ASSERT(nInstr <= GetNumInstruments()); + MPT_ASSERT(nInstr <= GetNumInstruments()); return Instruments[nInstr]->name; } @@ -1696,7 +1696,7 @@ } if(s_pTuningsSharedBuiltIn->GetNumTunings() == 0) { - ASSERT(false); + MPT_ASSERT(false); CTuningRTI* pT = new CTuningRTI; //Note: Tuning collection class handles deleting. pT->CreateGeometric(1,1); @@ -1919,7 +1919,7 @@ bufferCount--; m_PlayState.m_dBufferDiff++; } - ASSERT(abs(m_PlayState.m_dBufferDiff) < 1); + MPT_ASSERT(abs(m_PlayState.m_dBufferDiff) < 1); retval = bufferCount; } break; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/Sndfile.h 2014-10-19 15:19:34 UTC (rev 4446) @@ -881,8 +881,8 @@ UINT GetPeriodFromNote(UINT note, int nFineTune, UINT nC5Speed) const; UINT GetFreqFromPeriod(UINT period, int nPeriodFrac = 0) const; // Misc functions - ModSample &GetSample(SAMPLEINDEX sample) { ASSERT(sample <= m_nSamples && sample < CountOf(Samples)); return Samples[sample]; } - const ModSample &GetSample(SAMPLEINDEX sample) const { ASSERT(sample <= m_nSamples && sample < CountOf(Samples)); return Samples[sample]; } + ModSample &GetSample(SAMPLEINDEX sample) { MPT_ASSERT(sample <= m_nSamples && sample < CountOf(Samples)); return Samples[sample]; } + const ModSample &GetSample(SAMPLEINDEX sample) const { MPT_ASSERT(sample <= m_nSamples && sample < CountOf(Samples)); return Samples[sample]; } UINT MapMidiInstrument(DWORD dwProgram, UINT nChannel, UINT nNote); size_t ITInstrToMPT(FileReader &file, ModInstrument &ins, uint16 trkvers); Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -130,7 +130,7 @@ CSoundFile::samplecount_t CSoundFile::Read(samplecount_t count, IAudioReadTarget &target) //--------------------------------------------------------------------------------------- { - ALWAYS_ASSERT(m_MixerSettings.IsValid()); + MPT_ASSERT_ALWAYS(m_MixerSettings.IsValid()); bool mixPlugins = false; for(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; ++i) @@ -158,7 +158,7 @@ m_SongFlags.set(SONG_ENDREACHED); } else if(ReadNote()) { // render next tick (normal progress) - ASSERT(m_PlayState.m_nBufferCount > 0); + MPT_ASSERT(m_PlayState.m_nBufferCount > 0); #ifdef MODPLUG_TRACKER // Save pattern cue points for WAV rendering here (if we reached a new pattern, that is.) if(IsRenderingToDisc() && (m_PatternCuePoints.empty() || m_PlayState.m_nCurrentOrder != m_PatternCuePoints.back().order)) @@ -185,7 +185,7 @@ { // end of song reached, fade it out if(FadeSong(FADESONGDELAY)) // sets m_nBufferCount xor returns false { // FadeSong sets m_nBufferCount here - ASSERT(m_PlayState.m_nBufferCount > 0); + MPT_ASSERT(m_PlayState.m_nBufferCount > 0); m_SongFlags.set(SONG_FADINGSONG); } else { @@ -201,7 +201,7 @@ break; // mix done } - ASSERT(m_PlayState.m_nBufferCount > 0); // assert that we have actually something to do + MPT_ASSERT(m_PlayState.m_nBufferCount > 0); // assert that we have actually something to do const samplecount_t countChunk = std::min<samplecount_t>(MIXBUFFERSIZE, std::min<samplecount_t>(m_PlayState.m_nBufferCount, countToRender)); Modified: trunk/OpenMPT/soundlib/Tables.cpp =================================================================== --- trunk/OpenMPT/soundlib/Tables.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/Tables.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -863,8 +863,8 @@ double coeff = fsinc * lowpass_factor; #ifdef MPT_INTMIXER int n = (int)std::floor(coeff * (1<<SINC_QUANTSHIFT) + 0.5); - ASSERT(n <= int16_max); - ASSERT(n > int16_min); + MPT_ASSERT(n <= int16_max); + MPT_ASSERT(n > int16_min); *psinc++ = static_cast<SINC_TYPE>(n); #else *psinc++ = static_cast<SINC_TYPE>(coeff); Modified: trunk/OpenMPT/soundlib/WAVTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/WAVTools.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/WAVTools.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -334,7 +334,7 @@ #ifdef _DEBUG fseek(f, 0, SEEK_END); size_t realSize = static_cast<size_t>(ftell(f)); - ASSERT(totalSize == realSize); + MPT_ASSERT(totalSize == realSize); #endif if(fileOwned) { @@ -425,7 +425,7 @@ } else { // Should never happen - did we calculate a wrong memory size? - ASSERT(false); + MPT_ASSERT(false); } } position += numBytes; Modified: trunk/OpenMPT/soundlib/load_j2b.cpp =================================================================== --- trunk/OpenMPT/soundlib/load_j2b.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/load_j2b.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -798,7 +798,7 @@ else madeWithTracker += "old version)"; - ASSERT(mainChunk.unknown == LittleEndian(0xFF0001C5) || mainChunk.unknown == LittleEndian(0x35800716) || mainChunk.unknown == LittleEndian(0xFF00FFFF)); + MPT_ASSERT(mainChunk.unknown == LittleEndian(0xFF0001C5) || mainChunk.unknown == LittleEndian(0x35800716) || mainChunk.unknown == LittleEndian(0xFF00FFFF)); mpt::String::Read<mpt::String::maybeNullTerminated>(songName, mainChunk.songname); @@ -918,7 +918,7 @@ { continue; } - ASSERT(instrHeader.headSize + 4 == sizeof(instrHeader)); + MPT_ASSERT(instrHeader.headSize + 4 == sizeof(instrHeader)); const INSTRUMENTINDEX instr = instrHeader.index + 1; if(instr >= MAX_INSTRUMENTS) @@ -936,7 +936,7 @@ // Read sample sub-chunks (RIFF nesting ftw) ChunkReader::ChunkList<AMFFRiffChunk> sampleChunkFile = chunk.ReadChunks<AMFFRiffChunk>(2); std::vector<FileReader> sampleChunks = sampleChunkFile.GetAllChunks(AMFFRiffChunk::idRIFF); - ASSERT(sampleChunks.size() == instrHeader.numSamples); + MPT_ASSERT(sampleChunks.size() == instrHeader.numSamples); for(std::vector<FileReader>::iterator smpIter = sampleChunks.begin(); smpIter != sampleChunks.end(); smpIter++) { Modified: trunk/OpenMPT/soundlib/tuning.cpp =================================================================== --- trunk/OpenMPT/soundlib/tuning.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/tuning.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -255,7 +255,7 @@ if(GetType() == TT_GROUPGEOMETRIC) return m_RatioTableFine[GetRefNote(note) * GetFineStepCount() + sd - 1]; - ASSERT(false); + MPT_ASSERT(false); return m_RatioTableFine[0]; //Shouldn't happen. } else //Calculating ratio 'on the fly'. Modified: trunk/OpenMPT/soundlib/tuningbase.h =================================================================== --- trunk/OpenMPT/soundlib/tuningbase.h 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/soundlib/tuningbase.h 2014-10-19 15:19:34 UTC (rev 4446) @@ -307,7 +307,7 @@ { { // avoid integer overload //if(vrp.first == STEPINDEXTYPE_MIN && vrp.second == STEPINDEXTYPE_MAX) return true; - ASSERT(NOTEINDEXTYPE_MIN / 2 < vrp.first && vrp.second < NOTEINDEXTYPE_MAX / 2); + MPT_ASSERT(NOTEINDEXTYPE_MIN / 2 < vrp.first && vrp.second < NOTEINDEXTYPE_MAX / 2); if(NOTEINDEXTYPE_MIN / 2 >= vrp.first || vrp.second >= NOTEINDEXTYPE_MAX / 2) return true; } if(fs > static_cast<USTEPINDEXTYPE>(STEPINDEXTYPE_MAX) / (vrp.second - vrp.first + 1)) return false; Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2014-10-19 12:41:02 UTC (rev 4445) +++ trunk/OpenMPT/test/test.cpp 2014-10-19 15:19:34 UTC (rev 4446) @@ -877,7 +877,7 @@ template <> inline Test::CustomSettingsTestType FromSettingValue(const SettingValue &val) { - ASSERT(val.GetTypeTag() == "myType"); + MPT_ASSERT(val.GetTypeTag() == "myType"); std::string xy = val.as<std::string>(); if(xy.empty()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-19 19:26:49
|
Revision: 4447 http://sourceforge.net/p/modplug/code/4447 Author: saga-games Date: 2014-10-19 19:26:33 +0000 (Sun, 19 Oct 2014) Log Message: ----------- [Imp] IT Loader: Add support for reading encrypted edit time (discovered through today's IT source release, yay!). Modified Paths: -------------- trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/soundlib/ITTools.h trunk/OpenMPT/soundlib/Load_it.cpp Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2014-10-19 15:19:34 UTC (rev 4446) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2014-10-19 19:26:33 UTC (rev 4447) @@ -1079,7 +1079,10 @@ // Date TCHAR szDate[32]; - _tcsftime(szDate, CountOf(szDate), _T("%d %b %Y, %H:%M:%S"), &hist->loadDate); + if(hist->loadDate.tm_mday != 0) + _tcsftime(szDate, CountOf(szDate), _T("%d %b %Y, %H:%M:%S"), &hist->loadDate); + else + _tcscpy(szDate, _T("<unknown date>")); // Time + stuff uint32 duration = (uint32)((double)(hist->openTime) / HISTORY_TIMER_PRECISION); s.AppendFormat(_T("Loaded %s, open for %luh %02lum %02lus\r\n"), Modified: trunk/OpenMPT/soundlib/ITTools.h =================================================================== --- trunk/OpenMPT/soundlib/ITTools.h 2014-10-19 15:19:34 UTC (rev 4446) +++ trunk/OpenMPT/soundlib/ITTools.h 2014-10-19 19:26:33 UTC (rev 4447) @@ -65,7 +65,7 @@ uint8 pwd; // Pitch Wheel Depth uint16 msglength; // Length of Song Message uint32 msgoffset; // Offset of Song Message in File (IT crops message after first null) - char reserved[4]; // ChibiTracker writes "CHBI" here. OpenMPT writes "OMPT" here in some cases, see Load_it.cpp + char reserved[4]; // Some IT versions save an edit timer here. ChibiTracker writes "CHBI" here. OpenMPT writes "OMPT" here in some cases, see Load_it.cpp uint8 chnpan[64]; // Initial Channel Panning uint8 chnvol[64]; // Initial Channel Volume Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-19 15:19:34 UTC (rev 4446) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-19 19:26:33 UTC (rev 4447) @@ -960,6 +960,23 @@ { madeWithTracker = mpt::String::Print("Impulse Tracker %1.%2", (fileHeader.cwtv & 0x0F00) >> 8, mpt::fmt::hex0<2>((fileHeader.cwtv & 0xFF))); } + if(m_FileHistory.empty() && memcmp(fileHeader.reserved, "\0\0\0\0", 4)) + { + // IT encrypts the total edit time of a module in the "reserved" fild + uint32 editTime; + memcpy(&editTime, fileHeader.reserved, 4); + SwapBytesLE(editTime); + editTime ^= 0x4954524B; // 'ITRK' + editTime = (editTime >> 7) | (editTime << (32 - 7)); + editTime = -(int32)editTime; + editTime = (editTime << 4) | (editTime >> (32 - 4)); + editTime ^= 0x4A54484C; // 'JTHL' + + FileHistory hist; + MemsetZero(hist); + hist.openTime = static_cast<uint32>(editTime * (HISTORY_TIMER_PRECISION / 18.2f)); + m_FileHistory.push_back(hist); + } } break; case 1: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-19 20:48:08
|
Revision: 4448 http://sourceforge.net/p/modplug/code/4448 Author: saga-games Date: 2014-10-19 20:47:50 +0000 (Sun, 19 Oct 2014) Log Message: ----------- [New] Sample tab: Support resampling to any arbitrary sampling rate using r8brain-free. [New] Sample tab: As upsampling no longer automatically converts the sample to 16-bit, 16-bit conversion is now a separate option (same shortcut as 8-bit conversion) [Mod] OpenMPT: Version is now 1.24.00.11 Modified Paths: -------------- trunk/OpenMPT/build/premake4.lua trunk/OpenMPT/common/version.cpp trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/installer/packageTemplate/readme.txt trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Ctrl_smp.h trunk/OpenMPT/mptrack/MPTRACK_08.sln trunk/OpenMPT/mptrack/MPTRACK_10.sln trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp trunk/OpenMPT/mptrack/SampleEditorDialogs.h trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_smp.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/packageTemplate/readme.txt trunk/OpenMPT/soundlib/SampleFormatConverters.h Added Paths: ----------- trunk/OpenMPT/build/gen/r8brain.vcproj trunk/OpenMPT/build/gen/r8brain.vcxproj trunk/OpenMPT/build/gen/r8brain.vcxproj.filters trunk/OpenMPT/include/r8brain/ trunk/OpenMPT/include/r8brain/CDSPBlockConvolver.h trunk/OpenMPT/include/r8brain/CDSPFIRFilter.h trunk/OpenMPT/include/r8brain/CDSPFracInterpolator.h trunk/OpenMPT/include/r8brain/CDSPProcessor.h trunk/OpenMPT/include/r8brain/CDSPRealFFT.h trunk/OpenMPT/include/r8brain/CDSPResampler.h trunk/OpenMPT/include/r8brain/CDSPSincFilterGen.h trunk/OpenMPT/include/r8brain/OpenMPT.txt trunk/OpenMPT/include/r8brain/fft4g.h trunk/OpenMPT/include/r8brain/other/ trunk/OpenMPT/include/r8brain/other/License.txt trunk/OpenMPT/include/r8brain/other/calcCorrTable.cpp trunk/OpenMPT/include/r8brain/other/calcErrorTable.cpp trunk/OpenMPT/include/r8brain/other/r8bdoxy.txt trunk/OpenMPT/include/r8brain/r8bbase.cpp trunk/OpenMPT/include/r8brain/r8bbase.h trunk/OpenMPT/include/r8brain/r8bconf.h trunk/OpenMPT/include/r8brain/r8butil.h trunk/OpenMPT/include/r8brain.premake4.lua Added: trunk/OpenMPT/build/gen/r8brain.vcproj =================================================================== --- trunk/OpenMPT/build/gen/r8brain.vcproj (rev 0) +++ trunk/OpenMPT/build/gen/r8brain.vcproj 2014-10-19 20:47:50 UTC (rev 4448) @@ -0,0 +1,549 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="r8brain" + ProjectGUID="{BC116B29-9958-4389-B294-7529BB7C7D37}" + RootNamespace="r8brain" + Keyword="Win32Proj" + > + <Platforms> + <Platform + Name="Win32" + /> + <Platform + Name="x64" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="..\lib\x32\Debug" + IntermediateDirectory="..\obj\r8brain\x32\Debug" + ConfigurationType="4" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\include\r8brain" + PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="1" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + ProgramDataBaseFileName="$(OutDir)\r8brain.pdb" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + AdditionalIncludeDirectories="..\..\include\r8brain" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)\r8brain.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug|x64" + OutputDirectory="..\lib\x64\Debug" + IntermediateDirectory="..\obj\r8brain\x64\Debug" + ConfigurationType="4" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\include\r8brain" + PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="1" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + ProgramDataBaseFileName="$(OutDir)\r8brain.pdb" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + AdditionalIncludeDirectories="..\..\include\r8brain" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)\r8brain.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="..\lib\x32\Release" + IntermediateDirectory="..\obj\r8brain\x32\Release" + ConfigurationType="4" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/MP" + Optimization="3" + AdditionalIncludeDirectories="..\..\include\r8brain" + PreprocessorDefinitions="NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + StringPooling="true" + RuntimeLibrary="0" + EnableFunctionLevelLinking="true" + FloatingPointModel="2" + UsePrecompiledHeader="0" + WarningLevel="3" + ProgramDataBaseFileName="$(OutDir)\r8brain.pdb" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + AdditionalIncludeDirectories="..\..\include\r8brain" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)\r8brain.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|x64" + OutputDirectory="..\lib\x64\Release" + IntermediateDirectory="..\obj\r8brain\x64\Release" + ConfigurationType="4" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/MP" + Optimization="3" + AdditionalIncludeDirectories="..\..\include\r8brain" + PreprocessorDefinitions="NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + StringPooling="true" + RuntimeLibrary="0" + EnableFunctionLevelLinking="true" + FloatingPointModel="2" + UsePrecompiledHeader="0" + WarningLevel="3" + ProgramDataBaseFileName="$(OutDir)\r8brain.pdb" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + AdditionalIncludeDirectories="..\..\include\r8brain" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)\r8brain.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="ReleaseNoLTCG|Win32" + OutputDirectory="..\lib\x32\ReleaseNoLTCG" + IntermediateDirectory="..\obj\r8brain\x32\ReleaseNoLTCG" + ConfigurationType="4" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/GL- /MP" + Optimization="3" + AdditionalIncludeDirectories="..\..\include\r8brain" + PreprocessorDefinitions="NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + StringPooling="true" + RuntimeLibrary="0" + EnableFunctionLevelLinking="true" + FloatingPointModel="2" + UsePrecompiledHeader="0" + WarningLevel="3" + ProgramDataBaseFileName="$(OutDir)\r8brain.pdb" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + AdditionalIncludeDirectories="..\..\include\r8brain" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)\r8brain.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="ReleaseNoLTCG|x64" + OutputDirectory="..\lib\x64\ReleaseNoLTCG" + IntermediateDirectory="..\obj\r8brain\x64\ReleaseNoLTCG" + ConfigurationType="4" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/GL- /MP" + Optimization="3" + AdditionalIncludeDirectories="..\..\include\r8brain" + PreprocessorDefinitions="NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + StringPooling="true" + RuntimeLibrary="0" + EnableFunctionLevelLinking="true" + FloatingPointModel="2" + UsePrecompiledHeader="0" + WarningLevel="3" + ProgramDataBaseFileName="$(OutDir)\r8brain.pdb" + DebugInformationFormat="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" + AdditionalIncludeDirectories="..\..\include\r8brain" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)\r8brain.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="include" + Filter="" + > + <Filter + Name="r8brain" + Filter="" + > + <File + RelativePath="..\..\include\r8brain\r8bbase.cpp" + > + </File> + <File + RelativePath="..\..\include\r8brain\CDSPBlockConvolver.h" + > + </File> + <File + RelativePath="..\..\include\r8brain\CDSPFIRFilter.h" + > + </File> + <File + RelativePath="..\..\include\r8brain\CDSPFracInterpolator.h" + > + </File> + <File + RelativePath="..\..\include\r8brain\CDSPProcessor.h" + > + </File> + <File + RelativePath="..\..\include\r8brain\CDSPRealFFT.h" + > + </File> + <File + RelativePath="..\..\include\r8brain\CDSPResampler.h" + > + </File> + <File + RelativePath="..\..\include\r8brain\CDSPSincFilterGen.h" + > + </File> + <File + RelativePath="..\..\include\r8brain\fft4g.h" + > + </File> + <File + RelativePath="..\..\include\r8brain\r8bbase.h" + > + </File> + <File + RelativePath="..\..\include\r8brain\r8bconf.h" + > + </File> + <File + RelativePath="..\..\include\r8brain\r8butil.h" + > + </File> + </Filter> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> Property changes on: trunk/OpenMPT/build/gen/r8brain.vcproj ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-ms-vcproj \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +CRLF \ No newline at end of property Added: trunk/OpenMPT/build/gen/r8brain.vcxproj =================================================================== --- trunk/OpenMPT/build/gen/r8brain.vcxproj (rev 0) +++ trunk/OpenMPT/build/gen/r8brain.vcxproj 2014-10-19 20:47:50 UTC (rev 4448) @@ -0,0 +1,302 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="ReleaseNoLTCG|Win32"> + <Configuration>ReleaseNoLTCG</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="ReleaseNoLTCG|x64"> + <Configuration>ReleaseNoLTCG</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{BC116B29-9958-4389-B294-7529BB7C7D37}</ProjectGuid> + <RootNamespace>r8brain</RootNamespace> + <Keyword>Win32Proj</Keyword> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <UseDebugLibraries>true</UseDebugLibraries> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <UseDebugLibraries>true</UseDebugLibraries> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <WholeProgramOptimization>true</WholeProgramOptimization> + <UseDebugLibraries>false</UseDebugLibraries> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <WholeProgramOptimization>true</WholeProgramOptimization> + <UseDebugLibraries>false</UseDebugLibraries> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <WholeProgramOptimization>true</WholeProgramOptimization> + <UseDebugLibraries>false</UseDebugLibraries> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|x64'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <WholeProgramOptimization>true</WholeProgramOptimization> + <UseDebugLibraries>false</UseDebugLibraries> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\lib\x32\Debug\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\obj\r8brain\x32\Debug\</IntDir> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">r8brain</TargetName> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\lib\x64\Debug\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\obj\r8brain\x64\Debug\</IntDir> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">r8brain</TargetName> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\lib\x32\Release\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\obj\r8brain\x32\Release\</IntDir> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">r8brain</TargetName> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\lib\x64\Release\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\obj\r8brain\x64\Release\</IntDir> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">r8brain</TargetName> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'">..\lib\x32\ReleaseNoLTCG\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'">..\obj\r8brain\x32\ReleaseNoLTCG\</IntDir> + <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'">r8brain</TargetName> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|x64'">..\lib\x64\ReleaseNoLTCG\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|x64'">..\obj\r8brain\x64\ReleaseNoLTCG\</IntDir> + <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|x64'">r8brain</TargetName> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..\..\include\r8brain;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <PrecompiledHeader></PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..\..\include\r8brain;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + </ResourceCompile> + <Lib> + <OutputFile>$(OutDir)r8brain.lib</OutputFile> + </Lib> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDataBaseFileName>$(OutDir)r8brain.pdb</ProgramDataBaseFileName> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..\..\include\r8brain;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <PrecompiledHeader></PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat>OldStyle</DebugInformationFormat> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..\..\include\r8brain;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + </ResourceCompile> + <Lib> + <OutputFile>$(OutDir)r8brain.lib</OutputFile> + </Lib> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDataBaseFileName>$(OutDir)r8brain.pdb</ProgramDataBaseFileName> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions> + <Optimization>Full</Optimization> + <AdditionalIncludeDirectories>..\..\include\r8brain;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>false</MinimalRebuild> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <PrecompiledHeader></PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <FloatingPointModel>Fast</FloatingPointModel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..\..\include\r8brain;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + </ResourceCompile> + <Lib> + <OutputFile>$(OutDir)r8brain.lib</OutputFile> + </Lib> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <ProgramDataBaseFileName>$(OutDir)r8brain.pdb</ProgramDataBaseFileName> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions> + <Optimization>Full</Optimization> + <AdditionalIncludeDirectories>..\..\include\r8brain;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>false</MinimalRebuild> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <PrecompiledHeader></PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <FloatingPointModel>Fast</FloatingPointModel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..\..\include\r8brain;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + </ResourceCompile> + <Lib> + <OutputFile>$(OutDir)r8brain.lib</OutputFile> + </Lib> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <ProgramDataBaseFileName>$(OutDir)r8brain.pdb</ProgramDataBaseFileName> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|Win32'"> + <ClCompile> + <AdditionalOptions>/GL- /MP %(AdditionalOptions)</AdditionalOptions> + <Optimization>Full</Optimization> + <AdditionalIncludeDirectories>..\..\include\r8brain;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>false</MinimalRebuild> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <PrecompiledHeader></PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <FloatingPointModel>Fast</FloatingPointModel> + <DebugInformationFormat></DebugInformationFormat> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..\..\include\r8brain;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + </ResourceCompile> + <Lib> + <OutputFile>$(OutDir)r8brain.lib</OutputFile> + </Lib> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>false</GenerateDebugInformation> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseNoLTCG|x64'"> + <ClCompile> + <AdditionalOptions>/GL- /MP %(AdditionalOptions)</AdditionalOptions> + <Optimization>Full</Optimization> + <AdditionalIncludeDirectories>..\..\include\r8brain;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>false</MinimalRebuild> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <PrecompiledHeader></PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <FloatingPointModel>Fast</FloatingPointModel> + <DebugInformationFormat></DebugInformationFormat> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..\..\include\r8brain;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + </ResourceCompile> + <Lib> + <OutputFile>$(OutDir)r8brain.lib</OutputFile> + </Lib> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>false</GenerateDebugInformation> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClInclude Include="..\..\include\r8brain\CDSPBlockConvolver.h" /> + <ClInclude Include="..\..\include\r8brain\CDSPFIRFilter.h" /> + <ClInclude Include="..\..\include\r8brain\CDSPFracInterpolator.h" /> + <ClInclude Include="..\..\include\r8brain\CDSPProcessor.h" /> + <ClInclude Include="..\..\include\r8brain\CDSPRealFFT.h" /> + <ClInclude Include="..\..\include\r8brain\CDSPResampler.h" /> + <ClInclude Include="..\..\include\r8brain\CDSPSincFilterGen.h" /> + <ClInclude Include="..\..\include\r8brain\fft4g.h" /> + <ClInclude Include="..\..\include\r8brain\r8bbase.h" /> + <ClInclude Include="..\..\include\r8brain\r8bconf.h" /> + <ClInclude Include="..\..\include\r8brain\r8butil.h" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\..\include\r8brain\r8bbase.cpp"> + </ClCompile> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project> Property changes on: trunk/OpenMPT/build/gen/r8brain.vcxproj ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-ms-vcproj \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +CRLF \ No newline at end of property Added: trunk/OpenMPT/build/gen/r8brain.vcxproj.filters =================================================================== --- trunk/OpenMPT/build/gen/r8brain.vcxproj.filters (rev 0) +++ trunk/OpenMPT/build/gen/r8brain.vcxproj.filters 2014-10-19 20:47:50 UTC (rev 4448) @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="include"> + <UniqueIdentifier>{50A0CB9A-E943-1041-8162-5106A9BC81BE}</UniqueIdentifier> + </Filter> + <Filter Include="include\r8brain"> + <UniqueIdentifier>{32431A0D-396E-9643-AE4D-180AA97B39DB}</UniqueIdentifier> + </Filter> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\..\include\r8brain\CDSPBlockConvolver.h"> + <Filter>include\r8brain</Filter> + </ClInclude> + <ClInclude Include="..\..\include\r8brain\CDSPFIRFilter.h"> + <Filter>include\r8brain</Filter> + </ClInclude> + <ClInclude Include="..\..\include\r8brain\CDSPFracInterpolator.h"> + <Filter>include\r8brain</Filter> + </ClInclude> + <ClInclude Include="..\..\include\r8brain\CDSPProcessor.h"> + <Filter>include\r8brain</Filter> + </ClInclude> + <ClInclude Include="..\..\include\r8brain\CDSPRealFFT.h"> + <Filter>include\r8brain</Filter> + </ClInclude> + <ClInclude Include="..\..\include\r8brain\CDSPResampler.h"> + <Filter>include\r8brain</Filter> + </ClInclude> + <ClInclude Include="..\..\include\r8brain\CDSPSincFilterGen.h"> + <Filter>include\r8brain</Filter> + </ClInclude> + <ClInclude Include="..\..\include\r8brain\fft4g.h"> + <Filter>include\r8brain</Filter> + </ClInclude> + <ClInclude Include="..\..\include\r8brain\r8bbase.h"> + <Filter>include\r8brain</Filter> + </ClInclude> + <ClInclude Include="..\..\include\r8brain\r8bconf.h"> + <Filter>include\r8brain</Filter> + </ClInclude> + <ClInclude Include="..\..\include\r8brain\r8butil.h"> + <Filter>include\r8brain</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\..\include\r8brain\r8bbase.cpp"> + <Filter>include\r8brain</Filter> + </ClCompile> + </ItemGroup> +</Project> Property changes on: trunk/OpenMPT/build/gen/r8brain.vcxproj.filters ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-ms-vcproj \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +CRLF \ No newline at end of property Modified: trunk/OpenMPT/build/premake4.lua =================================================================== --- trunk/OpenMPT/build/premake4.lua 2014-10-19 19:26:33 UTC (rev 4447) +++ trunk/OpenMPT/build/premake4.lua 2014-10-19 20:47:50 UTC (rev 4448) @@ -9,6 +9,7 @@ dofile "../include/minizip.premake4.lua" dofile "../include/portaudio.premake4.lua" dofile "../include/portmidi.premake4.lua" + dofile "../include/r8brain.premake4.lua" dofile "../include/smbPitchShift.premake4.lua" dofile "../include/soundtouch.premake4.lua" dofile "../include/UnRAR.premake4.lua" Modified: trunk/OpenMPT/common/version.cpp =================================================================== --- trunk/OpenMPT/common/version.cpp 2014-10-19 19:26:33 UTC (rev 4447) +++ trunk/OpenMPT/common/version.cpp 2014-10-19 20:47:50 UTC (rev 4448) @@ -422,8 +422,8 @@ #ifdef MODPLUG_TRACKER "Stephan M. Bernsee for pitch shifting source code\n" "http://www.dspdimension.com/\n" -#endif -#ifdef MODPLUG_TRACKER + "Aleksey Vaneev of Voxengo for r8brain sample rate converter\n" + "https://code.google.com/p/r8brain-free-src/\n" "Olli Parviainen for SoundTouch Library (time stretching)\n" "http://www.surina.net/soundtouch/\n" #endif Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-10-19 19:26:33 UTC (rev 4447) +++ trunk/OpenMPT/common/versionNumber.h 2014-10-19 20:47:50 UTC (rev 4448) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 00 -#define VER_MINORMINOR 10 +#define VER_MINORMINOR 11 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Index: trunk/OpenMPT/include/r8brain =================================================================== --- trunk/OpenMPT/include/r8brain 2014-10-19 19:26:33 UTC (rev 4447) +++ trunk/OpenMPT/include/r8brain 2014-10-19 20:47:50 UTC (rev 4448) Property changes on: trunk/OpenMPT/include/r8brain ___________________________________________________________________ Added: tsvn:logminsize ## -0,0 +1 ## +10 \ No newline at end of property Added: trunk/OpenMPT/include/r8brain/CDSPBlockConvolver.h =================================================================== --- trunk/OpenMPT/include/r8brain/CDSPBlockConvolver.h (rev 0) +++ trunk/OpenMPT/include/r8brain/CDSPBlockConvolver.h 2014-10-19 20:47:50 UTC (rev 4448) @@ -0,0 +1,635 @@ +//$ nocpp + +/** + * @file CDSPBlockConvolver.h + * + * @brief Single-block overlap-save convolution processor class. + * + * This file includes single-block overlap-save convolution processor class. + * + * r8brain-free-src Copyright (c) 2013-2014 Aleksey Vaneev + * See the "License.txt" file for license. + */ + +#ifndef R8B_CDSPBLOCKCONVOLVER_INCLUDED +#define R8B_CDSPBLOCKCONVOLVER_INCLUDED + +#include "CDSPFIRFilter.h" +#include "CDSPProcessor.h" + +namespace r8b { + +/** + * @brief Single-block overlap-save convolution processing class. + * + * Class that implements single-block overlap-save convolution processing. The + * length of a single FFT block used depends on the length of the filter + * kernel. + * + * The rationale behind "single-block" processing is that increasing the FFT + * block length by 2 is more efficient than performing convolution at the same + * FFT block length but using two blocks. + * + * This class also implements a built-in resampling by any whole-number + * factor, which simplifies the overall resampling objects topology. + */ + +class CDSPBlockConvolver : public CDSPProcessor +{ +public: + /** + * Constructor initializes internal variables and constants of *this + * object. + * + * @param aFilter Pre-calculated filter data. Reference to this object is + * inhertied by *this object, and the object will be released when *this + * object is destroyed. If upsampling is used, filter's gain should be + * equal to the upsampling factor. + * @param aUpFactor The upsampling factor, positive value. E.g. value of 2 + * means 2x upsampling should be performed over the input data. + * @param aDownFactor The downsampling factor, positive value. E.g. value + * of 2 means 2x downsampling should be performed over the output data. + * @param PrevLatency Latency, in samples (any value >=0), which was left + * in the output signal by a previous process. This value is usually + * non-zero if the minimum-phase filters are in use. This value is always + * zero if the linear-phase filters are in use. + * @param aDoConsumeLatency "True" if the output latency should be + * consumed. Does not apply to the fractional part of the latency (if such + * part is available). + */ + + CDSPBlockConvolver( CDSPFIRFilter& aFilter, const int aUpFactor, + const int aDownFactor, const double PrevLatency = 0.0, + const bool aDoConsumeLatency = true ) + : Filter( &aFilter ) + , UpFactor( aUpFactor ) + , DownFactor( aDownFactor ) + , DoConsumeLatency( aDoConsumeLatency ) + , BlockLen2( 2 << Filter -> getBlockLenBits() ) + { + R8BASSERT( UpFactor > 0 ); + R8BASSERT( DownFactor > 0 ); + R8BASSERT( PrevLatency >= 0.0 ); + + int fftinBits; + UpShift = getBitOccupancy( UpFactor ) - 1; + + if(( 1 << UpShift ) == UpFactor ) + { + fftinBits = Filter -> getBlockLenBits() + 1 - UpShift; + PrevInputLen = ( Filter -> getKernelLen() - 1 ) / UpFactor; + InputLen = BlockLen2 - PrevInputLen * UpFactor; + } + else + { + UpShift = -1; + fftinBits = Filter -> getBlockLenBits() + 1; + PrevInputLen = Filter -> getKernelLen() - 1; + InputLen = BlockLen2 - PrevInputLen; + } + + OutOffset = Filter -> getLatency(); + LatencyFrac = Filter -> getLatencyFrac() + PrevLatency * UpFactor; + Latency = (int) LatencyFrac; + LatencyFrac -= Latency; + LatencyFrac /= DownFactor; + + Latency += InputLen + OutOffset; + + int fftoutBits; + InputDelay = 0; + UpSkipInit = 0; + DownSkipInit = 0; + DownShift = getBitOccupancy( DownFactor ) - 1; + + if(( 1 << DownShift ) == DownFactor ) + { + fftoutBits = Filter -> getBlockLenBits() + 1 - DownShift; + + if( DownFactor > 1 ) + { + if( UpShift > 0 ) + { + // This case never happens in practice due to mutual + // exclusion of "power of 2" DownFactor and UpFactor + // values. + + R8BASSERT( UpShift == 0 ); + } + else + { + int Delay = Latency & ( DownFactor - 1 ); + + if( Delay > 0 ) + { + Delay = DownFactor - Delay; + Latency += Delay; + + if( Delay < UpFactor ) + { + UpSkipInit = Delay; + } + else + { + UpSkipInit = UpFactor - 1; + InputDelay = Delay - UpSkipInit; + } + } + + if( !DoConsumeLatency ) + { + Latency /= DownFactor; + } + } + } + } + else + { + fftoutBits = Filter -> getBlockLenBits() + 1; + DownShift = -1; + + if( !DoConsumeLatency && DownFactor > 1 ) + { + DownSkipInit = Latency % DownFactor; + Latency /= DownFactor; + } + } + + fftin = new CDSPRealFFTKeeper( fftinBits ); + + if( fftoutBits == fftinBits ) + { + fftout = fftin; + } + else + { + ffto2 = new CDSPRealFFTKeeper( fftoutBits ); + fftout = ffto2; + } + + WorkBlocks.alloc( BlockLen2 * 2 + PrevInputLen ); + CurInput = &WorkBlocks[ 0 ]; + CurOutput = &WorkBlocks[ BlockLen2 ]; + PrevInput = &WorkBlocks[ BlockLen2 * 2 ]; + + clear(); + + R8BCONSOLE( "CDSPBlockConvolver: flt_len=%i in_len=%i io=%i/%i " + "fft=%i/%i latency=%i\n", Filter -> getKernelLen(), InputLen, + UpFactor, DownFactor, (*fftin) -> getLen(), (*fftout) -> getLen(), + getLatency() ); + } + + virtual ~CDSPBlockConvolver() + { + Filter -> unref(); + } + + virtual int getLatency() const + { + return( DoConsumeLatency ? 0 : Latency ); + } + + virtual double getLatencyFrac() const + { + return( LatencyFrac ); + } + + virtual int getInLenBeforeOutStart( const int NextInLen ) const + { + return(( InputLen - InputDelay + NextInLen * DownFactor ) / + UpFactor ); + } + + virtual int getMaxOutLen( const int MaxInLen ) const + { + R8BASSERT( MaxInLen >= 0 ); + + return(( MaxInLen * UpFactor + InputDelay + DownFactor - 1 ) / + DownFactor ); + } + + virtual void clear() + { + memset( &PrevInput[ 0 ], 0, PrevInputLen * sizeof( double )); + + if( DoConsumeLatency ) + { + LatencyLeft = Latency; + } + else + { + LatencyLeft = 0; + + if( DownShift > 0 ) + { + memset( &CurOutput[ 0 ], 0, ( BlockLen2 >> DownShift ) * + sizeof( double )); + } + else + { + memset( &CurOutput[ BlockLen2 - OutOffset ], 0, OutOffset * + sizeof( double )); + + memset( &CurOutput[ 0 ], 0, ( InputLen - OutOffset ) * + sizeof( double )); + } + } + + memset( CurInput, 0, InputDelay * sizeof( double )); + + InDataLeft = InputLen - InputDelay; + UpSkip = UpSkipInit; + DownSkip = DownSkipInit; + } + + virtual int process( double* ip, int l0, double*& op0 ) + { + R8BASSERT( l0 >= 0 ); + R8BASSERT( UpFactor / DownFactor <= 1 || ip != op0 || l0 == 0 ); + + double* op = op0; + int l = l0 * UpFactor; + l0 = 0; + + while( l > 0 ) + { + const int Offs = InputLen - InDataLeft; + + if( l < InDataLeft ) + { + InDataLeft -= l; + + if( UpShift >= 0 ) + { + memcpy( &CurInput[ Offs >> UpShift ], ip, + ( l >> UpShift ) * sizeof( double )); + } + else + { + copyUpsample( ip, &CurInput[ Offs ], l ); + } + + copyToOutput( Offs - OutOffset, op, l, l0 ); + break; + } + + const int b = InDataLeft; + l -= b; + InDataLeft = InputLen; + int ilu; + + if( UpShift >= 0 ) + { + const int bu = b >> UpShift; + memcpy( &CurInput[ Offs >> UpShift ], ip, + bu * sizeof( double )); + + ip += bu; + ilu = InputLen >> UpShift; + } + else + { + copyUpsample( ip, &CurInput[ Offs ], b ); + ilu = InputLen; + } + + const int pil = PrevInputLen * sizeof( double ); + memcpy( &CurInput[ ilu ], PrevInput, pil ); + memcpy( PrevInput, &CurInput[ ilu - PrevInputLen ], pil ); + + (*fftin) -> forward( CurInput ); + + if( UpShift > 0 ) + { + mirrorInputSpectrum(); + } + + if( Filter -> isZeroPhase() ) + { + (*fftout) -> multiplyBlocksZ( Filter -> getKernelBlock(), + CurInput ); + } + else + { + (*fftout) -> multiplyBlocks( Filter -> getKernelBlock(), + CurInput ); + } + + if( DownShift > 0 ) + { + const int z = BlockLen2 >> DownShift; + CurInput[ 1 ] = Filter -> getKernelBlock()[ z ] * + CurInput[ z ]; + } + + (*fftout) -> inverse( CurInput ); + + copyToOutput( Offs - OutOffset, op, b, l0 ); + + double* const tmp = CurInput; + CurInput = CurOutput; + CurOutput = tmp; + } + + return( l0 ); + } + +private: + CDSPFIRFilter* Filter; ///< Filter in use. + ///< + CPtrKeeper< CDSPRealFFTKeeper* > fftin; ///< FFT object 1, used to produce + ///< the input spectrum (can embed the "power of 2" upsampling). + ///< + CPtrKeeper< CDSPRealFFTKeeper* > ffto2; ///< FFT object 2 (can be NULL). + ///< + CDSPRealFFTKeeper* fftout; ///< FFT object used to produce the output + ///< signal (can embed the "power of 2" downsampling), may point to + ///< either "fftin" or "ffto2". + ///< + int UpFactor; ///< Upsampling factor. + ///< + int DownFactor; ///< Downsampling factor. + ///< + bool DoConsumeLatency; ///< "True" if the output latency should be + ///< consumed. Does not apply to the fractional part of the latency + ///< (if such part is available). + ///< + int BlockLen2; ///< Equals block length * 2. + ///< + int OutOffset; ///< Output offset, depends on filter's introduced latency. + ///< + int PrevInputLen; ///< The length of previous input data saved, used for + ///< overlap. + ///< + int InputLen; ///< The number of input samples that should be accumulated + ///< before the input block is processed. + ///< + int Latency; ///< Processing latency, in samples. + ///< + double LatencyFrac; ///< Fractional latency, in samples, that is left in + ///< the output signal. + ///< + int UpShift; ///< "Power of 2" upsampling shift. Equals -1 if UpFactor is + ///< not a "power of 2" value. Equals 0 if UpFactor equals 1. + ///< + int DownShift; ///< "Power of 2" downsampling shift. Equals -1 if + ///< DownFactor is not a "power of 2". Equals 0 if DownFactor equals + ///< 1. + ///< + int InputDelay; ///< Additional input delay, in samples. Used to make the + ///< output latency divisible by DownShift. Used only if UpShift <= 0 + ///< and DownShift > 0. + ///< + CFixedBuffer< double > WorkBlocks; ///< Previous input data, input and + ///< output data blocks, overall capacity = BlockLen2 * 2 + + ///< PrevInputLen. Used in the flip-flop manner. + ///< + double* PrevInput; ///< Previous input data buffer, capacity = BlockLen. + ///< + double* CurInput; ///< Input data buffer, capacity = BlockLen2. + ///< + double* CurOutput; ///< Output data buffer, capacity = BlockLen2. + ///< + int InDataLeft; ///< Samples left before processing input and output FFT + ///< blocks. Initialized to InputLen on clear. + ///< + int LatencyLeft; ///< Latency in samples left to skip. + ///< + int UpSkip; ///< The current upsampling sample skip (value in the range + ///< 0 to UpFactor - 1). + ///< + int UpSkipInit; ///< The initial UpSkip value after clear(). + ///< + int DownSkip; ///< The current downsampling sample skip (value in the + ///< range 0 to DownFactor - 1). Not used if DownShift > 0. + ///< + int DownSkipInit; ///< The initial DownSkip value after clear(). + ///< + + /** + * Function copies samples from the input buffer to the output buffer + * while inserting zeros inbetween them to perform the whole-numbered + * upsampling. + * + * @param[in,out] ip0 Input buffer. Will be advanced on function's return. + * @param[out] op Output buffer. + * @param l0 The number of samples to fill in the output buffer, including + * both input samples and interpolation (zero) samples. + */ + + void copyUpsample( double*& ip0, double* op, int l0 ) + { + int b = min( UpSkip, l0 ); + + if( b > 0 ) + { + l0 -= b; + UpSkip -= b; + *op = 0.0; + op++; + b--; + + while( b > 0 ) + { + *op = 0.0; + op++; + b--; + } + } + + double* ip = ip0; + int l = l0 / UpFactor; + int lz = l0 - l * UpFactor; + + if( UpFactor == 3 ) + { + while( l > 0 ) + { + op[ 0 ] = *ip; + op[ 1 ] = 0.0; + op[ 2 ] = 0.0; + ip++; + op += UpFactor; + l--; + } + } + else + if( UpFactor == 5 ) + { + while( l > 0 ) + { + op[ 0 ] = *ip; + op[ 1 ] = 0.0; + op[ 2 ] = 0.0; + op[ 3 ] = 0.0; + op[ 4 ] = 0.0; + ip++; + op += UpFactor; + l--; + } + } + else + { + while( l > 0 ) + { + op[ 0 ] = *ip; + int j; + + for( j = 1; j < UpFactor; j++ ) + { + op[ j ] = 0.0; + } + + ip++; + op += UpFactor; + l--; + } + } + + if( lz > 0 ) + { + *op = *ip; + op++; + ip++; + UpSkip = UpFactor - lz; + + while( lz > 1 ) + { + *op = 0.0; + op++; + lz--; + } + } + + ip0 = ip; + } + + /** + * Function copies sample data from the CurOutput buffer to the specified + * output buffer and advances its position. If necessary, this function + * "consumes" latency and performs downsampling. + * + * @param Offs CurOutput buffer offset, can be negative. + * @param[out] op0 Output buffer pointer, will be advanced. + * @param b The number of output samples available, including those which + * are discarded during whole-number downsampling. + * @param l0 The overall output sample count, will be increased. + */ + + void copyToOutput( int Offs, double*& op0, int b, int& l0 ) + { + if( Offs < 0 ) + { + if( Offs + b <= 0 ) + { + Offs += BlockLen2; + } + else + { + copyToOutput( Offs + BlockLen2, op0, -Offs, l0 ); + b += Offs; + Offs = 0; + } + } + + if( LatencyLeft > 0 ) + { + if( LatencyLeft >= b ) + { + LatencyLeft -= b; + return; + } + + Offs += LatencyLeft; + b -= LatencyLeft; + LatencyLeft = 0; + } + + const int df = DownFactor; + + if( DownShift > 0 ) + { + int Skip = Offs & ( df - 1 ); + + if( Skip > 0 ) + { + Skip = df - Skip; + b -= Skip; + Offs += Skip; + } + + if( b > 0 ) + { + b = ( b + df - 1 ) >> DownShift; + memcpy( op0, &CurOutput[ Offs >> DownShift ], + b * sizeof( double )); + + op0 += b; + l0 += b; + } + } + else + { + if( df > 1 ) + { + const double* ip = &CurOutput[ Offs + DownSkip ]; + int l = ( b + df - 1 - DownSkip ) / df; + DownSkip += l * df - b; + + double* op = op0; + l0 += l; + op0 += l; + + while( l > 0 ) + { + *op = *ip; + op++; + ip += df; + l--; + } + } + else + { + memcpy( op0, &CurOutput[ Offs ], b * sizeof( double )); + op0 += b; + l0 += b; + } + } + } + + /** + * Function performs input spectrum mirroring which is used to perform a + * fast "power of 2" upsampling. Such mirroring is equivalent to insertion + * of zeros into the input signal. + */ + + void mirrorInputSpectrum() + { + const int bl1 = BlockLen2 >> UpShift; + const int bl2 = bl1 + bl1; + + int i; + + for( i = bl1 + 2; i < bl2; i += 2 ) + { + CurInput[ i ] = CurInput[ bl2 - i ]; + CurInput[ i + 1 ] = -CurInput[ bl2 - i + 1 ]; + } + + CurInput[ bl1 ] = CurInput[ 1 ]; + CurInput[ bl1 + 1 ] = 0.0; + CurInput[ 1 ] = CurInput[ 0 ]; + + for( i = 1; i < UpShift; i++ ) + { + const int z = bl1 << i; + memcpy( &CurInput[ z ], CurInput, z * sizeof( double )); + CurInput[ z + 1 ] = 0.0; + } + } +}; + +} // namespace r8b + +#endif // R8B_CDSPBLOCKCONVOLVER_INCLUDED Property changes on: trunk/OpenMPT/include/r8brain/CDSPBlockConvolver.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/include/r8brain/CDSPFIRFilter.h =================================================================== --- trunk/OpenMPT/include/r8brain/CDSPFIRFilter.h (rev 0) +++ trunk/OpenMPT/include/r8brain/CDSPFIRFilter.h 2014-10-19 20:47:50 UTC (rev 4448) @@ -0,0 +1,708 @@ +//$ nocpp + +/** + * @file CDSPFIRFilter.h + * + * @brief FIR filter generator and filter cache classes. + * + * This file includes low-pass FIR filter generator and filter cache. + * + * r8brain-free-src Copyright (c) 2013-2014 Aleksey Vaneev + * See the "License.txt" file for license. + */ + +#ifndef R8B_CDSPFIRFILTER_INCLUDED +#define R8B_CDSPFIRFILTER_INCLUDED + +#include "CDSPSincFilterGen.h" +#include "CDSPRealFFT.h" + +namespace r8b { + +/** + * Enumeration of filter's phase responses. + */ + +enum EDSPFilterPhaseResponse +{ + fprLinearPhase = 0 ///< Linear-phase response. Features a linear-phase + ///< high-latency response, with the latency expressed as integer + ///< value. +// fprMinPhase ///< Minimum-phase response. Features a minimal latency + ///< response, but the response's phase is non-linear. The latency is + ///< usually expressed as non-integer value, and usually is small, but + ///< is never equal to zero. The minimum-phase filter is transformed + ///< from the linear-phase filter. The transformation has precision + ///< limits which may skew both the -3 dB point and attenuation of the + ///< filter being transformed: as it was measured, the skew happens + ///< purely at random, and in most cases it is within tolerable range. + ///< In a small (1%) random subset of cases the skew is bigger and + ///< cannot be predicted. +}; + +/** + * @brief Calculation and storage class for FIR filters. + * + * Class that implements calculation and storing of a FIR filter (currently + * contains low-pass filter calculation routine designed for sample rate + * conversion). Objects of this class cannot be created directly, but can be + * obtained via the CDSPFilterCache::getLPFilter() static function. + */ + +class CDSPFIRFilter : public R8B_BASECLASS +{ + R8BNOCTOR( CDSPFIRFilter ); + + friend class CDSPFIRFilterCache; + +public: + ~CDSPFIRFilter() + { + R8BASSERT( RefCount == 0 ); + + delete Next; + } + + /** + * @return The minimal allowed low-pass filter's transition band, in + * percent. + */ + + static double getLPMinTransBand() + { + return( 0.5 ); + } + + /** + * @return The maximal allowed low-pass filter's transition band, in + * percent. + */ + + static double getLPMaxTransBand() + { + return( 45.0 ); + } + + /** + * @return The minimal allowed low-pass filter's stop-band attenuation, in + * decibel. + */ + + static double getLPMinAtten() + { + return( 49.0 ); + } + + /** + * @return The maximal allowed low-pass filter's stop-band attenuation, in + * decibel. + */ + + static double getLPMaxAtten() + { + return( 218.0 ); + } + + /** + * @return "True" if kernel block of *this filter has zero-phase response. + */ + + bool isZeroPhase() const + { + return( IsZeroPhase ); + } + + /** + * @return Filter's latency, in samples (integer part). + */ + + int getLatency() const + { + return( Latency ); + } + + /** + * @return Filter's latency, in samples (fractional part). Always zero for + * linear-phase filters. + */ + + double getLatencyFrac() const + { + return( LatencyFrac ); + } + + /** + * @return Filter kernel length, in samples. Not to be confused with the + * block length. + */ + + int getKernelLen() const + { + return( KernelLen ); + } + + /** + * @return Filter's block length, espressed as Nth power of 2. The actual + * length is twice as large due to zero-padding. + */ + + int getBlockLenBits() const + { + return( BlockLenBits ); + } + + /** + * @return Filter's kernel block, in complex-numbered form obtained via + * the CDSPRealFFT::forward() function call, zero-padded, gain-adjusted + * with the CDSPRealFFT::getInvMulConst() * ReqGain constant, immediately + * suitable for convolution. Kernel block may have "zero-phase" response, + * depending on the isZeroPhase() function's result. + */ + + const double* getKernelBlock() const + { + return( KernelBlock ); + } + + /** + * This function should be called when the filter obtained via the + * filter cache is no longer needed. + */ + + void unref(); + +private: + double ReqNormFreq; ///< Required normalized frequency, 0 to 1 inclusive. + ///< + double ReqTransBand; ///< Required transition band in percent, as passed + ///< by the user. + ///< + double ReqAtten; ///< Required stop-band attenuation in decibel, as passed + ///< by the user (positive value). + ///< + EDSPFilterPhaseResponse ReqPhase; ///< Required filter's phase response. + ///< + double ReqGain; ///< Required overall filter's gain. + ///< + CDSPFIRFilter* Next; ///< Next FIR filter in cache's list. + ///< + int RefCount; ///< The number of references made to *this FIR filter. + ///< + bool IsZeroPhase; ///< "True" if kernel block of *this filter has + ///< zero-phase response. + ///< + int Latency; ///< Filter's latency in samples (integer part). + ///< + double LatencyFrac; ///< Filter's latency in samples (fractional part). + ///< + int KernelLen; ///< Filter kernel length, in samples. + ///< + int BlockLenBits; ///< Block length used to store *this FIR filter, + ///< expressed as Nth power of 2. This value is used directly by the + ///< convolver. + ///< + CFixedBuffer< double > KernelBlock; ///< FIR filter buffer, capacity + ///< equals to 1 << ( BlockLenBits + 1 ). Second part of the buffer + ///< contains zero-padding to allow alias-free convolution. + ///< + + CDSPFIRFilter() + : RefCount( 1 ) + { + } + + /** + * Function builds filter kernel based on the "Req" parameters. + * + * @param ExtAttenCorrs External attentuation correction table, for + * internal use. + */ + + void buildLPFilter( const double* const ExtAttenCorrs ) + { + const double tb = ReqTransBand * 0.01; + double pwr; + double fo1; + double hl; + double atten = -ReqAtten; + + if( tb >= 0.25 ) + { + if( ReqAtten >= 117.0 ) + { + atten -= 1.60; + } + else + if( ReqAtten >= 60.0 ) + { + atten -= 1.91; + } + else + { + atten -= 2.25; + } + } + else + if( tb >= 0.10 ) + ... [truncated message content] |
From: <man...@us...> - 2014-10-20 13:33:11
|
Revision: 4452 http://sourceforge.net/p/modplug/code/4452 Author: manxorist Date: 2014-10-20 13:32:53 +0000 (Mon, 20 Oct 2014) Log Message: ----------- [Ref] If applicable, make CMappedFile and FileReader aware of the filename they are currently representing. Modified Paths: -------------- trunk/OpenMPT/mptrack/MemoryMappedFile.cpp trunk/OpenMPT/mptrack/MemoryMappedFile.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/soundlib/FileReader.h trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp Modified: trunk/OpenMPT/mptrack/MemoryMappedFile.cpp =================================================================== --- trunk/OpenMPT/mptrack/MemoryMappedFile.cpp 2014-10-20 13:31:38 UTC (rev 4451) +++ trunk/OpenMPT/mptrack/MemoryMappedFile.cpp 2014-10-20 13:32:53 UTC (rev 4452) @@ -38,6 +38,7 @@ m_hFile = nullptr; return false; } + m_FileName = filename; return true; } @@ -45,6 +46,7 @@ void CMappedFile::Close() //----------------------- { + m_FileName = mpt::PathString(); // Unlock file if(m_hFMap) { @@ -141,7 +143,7 @@ FileReader CMappedFile::GetFile() //------------------------------- { - return FileReader(Lock(), GetLength()); + return FileReader(Lock(), GetLength(), &m_FileName); } Modified: trunk/OpenMPT/mptrack/MemoryMappedFile.h =================================================================== --- trunk/OpenMPT/mptrack/MemoryMappedFile.h 2014-10-20 13:31:38 UTC (rev 4451) +++ trunk/OpenMPT/mptrack/MemoryMappedFile.h 2014-10-20 13:32:53 UTC (rev 4452) @@ -25,6 +25,7 @@ HANDLE m_hFile; HANDLE m_hFMap; void *m_pData; + mpt::PathString m_FileName; public: CMappedFile() : m_hFile(nullptr), m_hFMap(nullptr), m_pData(nullptr) { } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-10-20 13:31:38 UTC (rev 4451) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-10-20 13:32:53 UTC (rev 4452) @@ -221,7 +221,7 @@ BeginWaitCursor(); #if defined(MPT_FILEREADER_STD_ISTREAM) mpt::ifstream f(filename, std::ios_base::binary); - m_SndFile.Create(FileReader(&f), CSoundFile::loadCompleteModule, this); + m_SndFile.Create(FileReader(&f, &filename), CSoundFile::loadCompleteModule, this); #else { CMappedFile f; Modified: trunk/OpenMPT/soundlib/FileReader.h =================================================================== --- trunk/OpenMPT/soundlib/FileReader.h 2014-10-20 13:31:38 UTC (rev 4451) +++ trunk/OpenMPT/soundlib/FileReader.h 2014-10-20 13:32:53 UTC (rev 4452) @@ -57,42 +57,82 @@ off_t streamPos; // Cursor location in the file +#if defined(MODPLUG_TRACKER) + mpt::PathString *fileName; // Filename that corresponds to this FileReader. It is only set if this FileReader represents the whole contents of fileName. May be nullptr. + #define MPT_FILEREADER_INIT_FILENAME ,fileName(nullptr) +#else + #define MPT_FILEREADER_INIT_FILENAME +#endif + public: #if defined(MPT_FILEREADER_STD_ISTREAM) // Initialize invalid file reader object. - FileReader() : data(new FileDataContainerDummy()), streamPos(0) { } + FileReader() : data(new FileDataContainerDummy()), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } // Initialize file reader object with pointer to data and data length. - FileReader(const void *voiddata, off_t length) : data(new FileDataContainerMemory(static_cast<const char *>(voiddata), length)), streamPos(0) { } - FileReader(const char *chardata, off_t length) : data(new FileDataContainerMemory(chardata, length)), streamPos(0) { } - FileReader(const uint8 *uint8data, off_t length) : data(new FileDataContainerMemory(reinterpret_cast<const char *>(uint8data), length)), streamPos(0) { } + FileReader(const void *voiddata, off_t length) : data(new FileDataContainerMemory(static_cast<const char *>(voiddata), length)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } + FileReader(const char *chardata, off_t length) : data(new FileDataContainerMemory(chardata, length)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } + FileReader(const uint8 *uint8data, off_t length) : data(new FileDataContainerMemory(reinterpret_cast<const char *>(uint8data), length)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } +#if defined(MODPLUG_TRACKER) + FileReader(const void *voiddata, off_t length, mpt::PathString *filename) : data(new FileDataContainerMemory(static_cast<const char *>(voiddata), length)), streamPos(0), fileName(filename) { } + FileReader(const char *chardata, off_t length, mpt::PathString *filename) : data(new FileDataContainerMemory(chardata, length)), streamPos(0), fileName(filename) { } + FileReader(const uint8 *uint8data, off_t length, mpt::PathString *filename) : data(new FileDataContainerMemory(reinterpret_cast<const char *>(uint8data), length)), streamPos(0), fileName(filename) { } +#endif // Initialize file reader object with a std::istream. - FileReader(std::istream *s) : data(new FileDataContainerStdStream(s)), streamPos(0) { } + FileReader(std::istream *s) : data(new FileDataContainerStdStream(s)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } +#if defined(MODPLUG_TRACKER) + FileReader(std::istream *s, mpt::PathString *filename) : data(new FileDataContainerStdStream(s)), streamPos(0), fileName(filename) { } +#endif // Initialize file reader object based on an existing file reader object window. - FileReader(MPT_SHARED_PTR<IFileDataContainer> other) : data(other), streamPos(0) { } + FileReader(MPT_SHARED_PTR<IFileDataContainer> other) : data(other), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } // Initialize file reader object based on an existing file reader object. The other object's stream position is copied. - FileReader(const FileReader &other) : data(other.data), streamPos(other.streamPos) { } + FileReader(const FileReader &other) : data(other.data), streamPos(other.streamPos) +#if defined(MODPLUG_TRACKER) + , fileName(other.fileName) +#endif + { } #else // Initialize invalid file reader object. - FileReader() : data(nullptr, 0), streamPos(0) { } + FileReader() : data(nullptr, 0), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } // Initialize file reader object with pointer to data and data length. - FileReader(const void *voiddata, off_t length) : data(static_cast<const char *>(voiddata), length), streamPos(0) { } - FileReader(const char *chardata, off_t length) : data(chardata, length), streamPos(0) { } - FileReader(const uint8 *uint8data, off_t length) : data(reinterpret_cast<const char *>(uint8data), length), streamPos(0) { } + FileReader(const void *voiddata, off_t length) : data(static_cast<const char *>(voiddata), length), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } + FileReader(const char *chardata, off_t length) : data(chardata, length), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } + FileReader(const uint8 *uint8data, off_t length) : data(reinterpret_cast<const char *>(uint8data), length), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } +#if defined(MODPLUG_TRACKER) + FileReader(const void *voiddata, off_t length, mpt::PathString *filename) : data(static_cast<const char *>(voiddata), length), streamPos(0), fileName(filename) { } + FileReader(const char *chardata, off_t length, mpt::PathString *filename) : data(chardata, length), streamPos(0), fileName(filename) { } + FileReader(const uint8 *uint8data, off_t length, mpt::PathString *filename) : data(reinterpret_cast<const char *>(uint8data), length), streamPos(0), fileName(filename) { } +#endif // Initialize file reader object based on an existing file reader object. The other object's stream position is copied. - FileReader(const FileReader &other) : data(other.data), streamPos(other.streamPos) { } + FileReader(const FileReader &other) : data(other.data), streamPos(other.streamPos) +#if defined(MODPLUG_TRACKER) + , fileName(other.fileName) +#endif + { } #endif + +#if defined(MODPLUG_TRACKER) + mpt::PathString GetFileName() const + { + if(!fileName) + { + return mpt::PathString(); + } + return *fileName; + } +#endif + // Returns true if the object points to a valid stream. bool IsValid() const { Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-20 13:31:38 UTC (rev 4451) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-20 13:32:53 UTC (rev 4452) @@ -166,8 +166,11 @@ } m_szInstrumentPath[ins] = mpt::PathString::FromUTF8(path); - if(GetpModDoc() != nullptr) + if(!file.GetFileName().empty()) { + m_szInstrumentPath[ins] = m_szInstrumentPath[ins].RelativePathToAbsolute(file.GetFileName().GetPath()); + } else if(GetpModDoc() != nullptr) + { m_szInstrumentPath[ins] = m_szInstrumentPath[ins].RelativePathToAbsolute(GetpModDoc()->GetPathNameMpt().GetPath()); } } @@ -264,7 +267,7 @@ mpt::ifstream f(m_szInstrumentPath[ins], std::ios_base::binary); if(!f.good()) continue; - FileReader file(&f); + FileReader file(&f, &m_szInstrumentPath[ins]); #else CMappedFile f; if(!f.Open(m_szInstrumentPath[ins])) Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-20 13:31:38 UTC (rev 4451) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-20 13:32:53 UTC (rev 4452) @@ -1060,8 +1060,16 @@ #ifdef MODPLUG_TRACKER mpt::PathString path(mpt::PathString::FromLocale(filename)); - if(GetpModDoc() != nullptr) + mpt::PathString mt2FileName; + if(!file.GetFileName().empty()) { + mt2FileName = file.GetFileName(); + } else if(GetpModDoc() != nullptr) + { + mt2FileName = GetpModDoc()->GetPathNameMpt(); + } + if(!mt2FileName.empty()) + { std::wstring pathStart = path.ToWide().substr(0, 2); if(pathStart.length() >= 2 && pathStart.at(0) != L'\\' @@ -1070,13 +1078,13 @@ // Relative path in sub directory path = MPT_PATHSTRING(".\\") + path; } - path = path.RelativePathToAbsolute(GetpModDoc()->GetPathNameMpt().GetPath()); + path = path.RelativePathToAbsolute(mt2FileName.GetPath()); } #if defined(MPT_FILEREADER_STD_ISTREAM) mpt::ifstream f(path, std::ios_base::binary); if(f.good()) - sampleFile = FileReader(&f); + sampleFile = FileReader(&f, &path); #else CMappedFile f; FileReader sampleFile; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-21 10:59:02
|
Revision: 4455 http://sourceforge.net/p/modplug/code/4455 Author: manxorist Date: 2014-10-21 10:58:54 +0000 (Tue, 21 Oct 2014) Log Message: ----------- [Ref] To order to make the code look more C++11-ish, add mpt::make_shared<T> that mimics C++11 std::make_shared<T>. mpt::make_shared sacrifices perfect forwarding and does not make use of variadic templates in order to keep things simple and compatible. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/soundlib/FileReader.h trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp 2014-10-20 14:38:52 UTC (rev 4454) +++ trunk/OpenMPT/common/misc_util.cpp 2014-10-21 10:58:54 UTC (rev 4455) @@ -1040,7 +1040,7 @@ Library::Library(const mpt::LibraryPath &path) //-------------------------------------------- { - m_Handle = MPT_SHARED_PTR<LibraryHandle>(new LibraryHandle(path)); + m_Handle = mpt::make_shared<LibraryHandle>(path); } Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2014-10-20 14:38:52 UTC (rev 4454) +++ trunk/OpenMPT/common/typedefs.h 2014-10-21 10:58:54 UTC (rev 4455) @@ -179,13 +179,35 @@ +// For mpt::make_shared<T>, we sacrifice perfect forwarding in order to keep things simple here. +// Templated for up to 4 parameters. Add more when required. + OPENMPT_NAMESPACE_END #include <memory> OPENMPT_NAMESPACE_BEGIN + #if MPT_COMPILER_MSVC && MPT_MSVC_BEFORE(2010,0) + #define MPT_SHARED_PTR std::tr1::shared_ptr +namespace mpt { +template <typename T> inline MPT_SHARED_PTR<T> make_shared() { return MPT_SHARED_PTR<T>(new T()); } +template <typename T, typename T1> inline MPT_SHARED_PTR<T> make_shared(const T1 &x1) { return MPT_SHARED_PTR<T>(new T(x1)); } +template <typename T, typename T1, typename T2> inline MPT_SHARED_PTR<T> make_shared(const T1 &x1, const T2 &x2) { return MPT_SHARED_PTR<T>(new T(x1, x2)); } +template <typename T, typename T1, typename T2, typename T3> inline MPT_SHARED_PTR<T> make_shared(const T1 &x1, const T2 &x2, const T3 &x3) { return MPT_SHARED_PTR<T>(new T(x1, x2, x3)); } +template <typename T, typename T1, typename T2, typename T3, typename T4> inline MPT_SHARED_PTR<T> make_shared(const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4) { return MPT_SHARED_PTR<T>(new T(x1, x2, x3, x4)); } +} // namespace mpt + #else + #define MPT_SHARED_PTR std::shared_ptr +namespace mpt { +template <typename T> inline MPT_SHARED_PTR<T> make_shared() { return std::make_shared<T>(); } +template <typename T, typename T1> inline MPT_SHARED_PTR<T> make_shared(const T1 &x1) { return std::make_shared<T>(x1); } +template <typename T, typename T1, typename T2> inline MPT_SHARED_PTR<T> make_shared(const T1 &x1, const T2 &x2) { return std::make_shared<T>(x1, x2); } +template <typename T, typename T1, typename T2, typename T3> inline MPT_SHARED_PTR<T> make_shared(const T1 &x1, const T2 &x2, const T3 &x3) { return std::make_shared<T>(x1, x2, x3); } +template <typename T, typename T1, typename T2, typename T3, typename T4> inline MPT_SHARED_PTR<T> make_shared(const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4) { return std::make_shared<T>(x1, x2, x3, x4); } +} // namespace mpt + #endif Modified: trunk/OpenMPT/soundlib/FileReader.h =================================================================== --- trunk/OpenMPT/soundlib/FileReader.h 2014-10-20 14:38:52 UTC (rev 4454) +++ trunk/OpenMPT/soundlib/FileReader.h 2014-10-21 10:58:54 UTC (rev 4455) @@ -69,22 +69,22 @@ #if defined(MPT_FILEREADER_STD_ISTREAM) // Initialize invalid file reader object. - FileReader() : data(new FileDataContainerDummy()), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } + FileReader() : data(mpt::make_shared<FileDataContainerDummy>()), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } // Initialize file reader object with pointer to data and data length. - FileReader(const void *voiddata, off_t length) : data(new FileDataContainerMemory(static_cast<const char *>(voiddata), length)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } - FileReader(const char *chardata, off_t length) : data(new FileDataContainerMemory(chardata, length)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } - FileReader(const uint8 *uint8data, off_t length) : data(new FileDataContainerMemory(reinterpret_cast<const char *>(uint8data), length)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } + FileReader(const void *voiddata, off_t length) : data(mpt::make_shared<FileDataContainerMemory>(static_cast<const char *>(voiddata), length)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } + FileReader(const char *chardata, off_t length) : data(mpt::make_shared<FileDataContainerMemory>(chardata, length)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } + FileReader(const uint8 *uint8data, off_t length) : data(mpt::make_shared<FileDataContainerMemory>(reinterpret_cast<const char *>(uint8data), length)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } #if defined(MODPLUG_TRACKER) - FileReader(const void *voiddata, off_t length, mpt::PathString *filename) : data(new FileDataContainerMemory(static_cast<const char *>(voiddata), length)), streamPos(0), fileName(filename) { } - FileReader(const char *chardata, off_t length, mpt::PathString *filename) : data(new FileDataContainerMemory(chardata, length)), streamPos(0), fileName(filename) { } - FileReader(const uint8 *uint8data, off_t length, mpt::PathString *filename) : data(new FileDataContainerMemory(reinterpret_cast<const char *>(uint8data), length)), streamPos(0), fileName(filename) { } + FileReader(const void *voiddata, off_t length, mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerMemory>(static_cast<const char *>(voiddata), length)), streamPos(0), fileName(filename) { } + FileReader(const char *chardata, off_t length, mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerMemory>(chardata, length)), streamPos(0), fileName(filename) { } + FileReader(const uint8 *uint8data, off_t length, mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerMemory>(reinterpret_cast<const char *>(uint8data), length)), streamPos(0), fileName(filename) { } #endif // Initialize file reader object with a std::istream. - FileReader(std::istream *s) : data(new FileDataContainerStdStream(s)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } + FileReader(std::istream *s) : data(mpt::make_shared<FileDataContainerStdStream>(s)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } #if defined(MODPLUG_TRACKER) - FileReader(std::istream *s, mpt::PathString *filename) : data(new FileDataContainerStdStream(s)), streamPos(0), fileName(filename) { } + FileReader(std::istream *s, mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerStdStream>(s)), streamPos(0), fileName(filename) { } #endif // Initialize file reader object based on an existing file reader object window. @@ -240,7 +240,7 @@ return FileReader(); } #if defined(MPT_FILEREADER_STD_ISTREAM) - return FileReader(MPT_SHARED_PTR<IFileDataContainer>(new FileDataContainerWindow(data, position, std::min(length, DataContainer().GetLength() - position)))); + return FileReader(mpt::make_shared<FileDataContainerWindow>(data, position, std::min(length, DataContainer().GetLength() - position))); #else return FileReader(DataContainer().GetRawData() + position, std::min(length, DataContainer().GetLength() - position)); #endif Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2014-10-20 14:38:52 UTC (rev 4454) +++ trunk/OpenMPT/test/test.cpp 2014-10-21 10:58:54 UTC (rev 4455) @@ -1943,7 +1943,7 @@ //-------------------------------------------- { FileReader file; - MPT_SHARED_PTR<CSoundFile> pSndFile(new CSoundFile()); + MPT_SHARED_PTR<CSoundFile> pSndFile = mpt::make_shared<CSoundFile>(); CSoundFile &sndFile = *pSndFile.get(); sndFile.ChangeModTypeTo(MOD_TYPE_MPT); sndFile.Patterns.DestroyPatterns(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-21 16:37:52
|
Revision: 4457 http://sourceforge.net/p/modplug/code/4457 Author: saga-games Date: 2014-10-21 16:37:44 +0000 (Tue, 21 Oct 2014) Log Message: ----------- [Imp] Playback: Smooth MIDI macros do now, to some extent, work with external MIDI messages. They always rely on previous Zxx or \xx commands from the same channel. [Mod] OpenMPT: Version is now 1.24.00.12 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/soundlib/ModChannel.cpp trunk/OpenMPT/soundlib/ModChannel.h trunk/OpenMPT/soundlib/Snd_fx.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-10-21 15:08:04 UTC (rev 4456) +++ trunk/OpenMPT/common/versionNumber.h 2014-10-21 16:37:44 UTC (rev 4457) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 00 -#define VER_MINORMINOR 11 +#define VER_MINORMINOR 12 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/soundlib/ModChannel.cpp =================================================================== --- trunk/OpenMPT/soundlib/ModChannel.cpp 2014-10-21 15:08:04 UTC (rev 4456) +++ trunk/OpenMPT/soundlib/ModChannel.cpp 2014-10-21 16:37:44 UTC (rev 4457) @@ -38,6 +38,7 @@ nTremorCount = 0; nEFxSpeed = 0; proTrackerOffset = 0; + lastZxxParam = 0xFF; isFirstTick = false; } Modified: trunk/OpenMPT/soundlib/ModChannel.h =================================================================== --- trunk/OpenMPT/soundlib/ModChannel.h 2014-10-21 15:08:04 UTC (rev 4456) +++ trunk/OpenMPT/soundlib/ModChannel.h 2014-10-21 16:37:44 UTC (rev 4457) @@ -111,6 +111,7 @@ uint8 nActiveMacro, nFilterMode; uint8 nEFxSpeed, nEFxDelay; // memory for Invert Loop (EFx, .MOD only) uint8 nNoteSlideCounter, nNoteSlideSpeed, nNoteSlideStep; // IMF / PTM Note Slide + uint8 lastZxxParam; // Memory for \xx slides bool isFirstTick; ModCommand rowCommand; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-10-21 15:08:04 UTC (rev 4456) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-10-21 16:37:44 UTC (rev 4457) @@ -4050,11 +4050,12 @@ void CSoundFile::ProcessMIDIMacro(CHANNELINDEX nChn, bool isSmooth, char *macro, uint8 param, PLUGINDEX plugin) //------------------------------------------------------------------------------------------------------------- { - const ModChannel *pChn = &m_PlayState.Chn[nChn]; + ModChannel *pChn = &m_PlayState.Chn[nChn]; const ModInstrument *pIns = GetNumInstruments() ? pChn->pModInstrument : nullptr; unsigned char out[MACRO_LENGTH]; size_t outPos = 0; // output buffer position, which also equals the number of complete bytes + const uint8 lastZxxParam = pChn->lastZxxParam; bool firstNibble = true; for(size_t pos = 0; pos < (MACRO_LENGTH - 1) && macro[pos]; pos++) @@ -4121,7 +4122,15 @@ } } else if(macro[pos] == 'z') // z: macro data { - data = (unsigned char)(param & 0x7F); + data = param & 0x7F; + if(isSmooth && pChn->lastZxxParam < 0x80 + && (outPos < 3 || out[outPos - 3] != 0xF0 || out[outPos - 2] < 0xF0)) + { + // Interpolation for external MIDI messages - interpolation for internal messages + // is handled separately to allow for more than 7-bit granularity where it's possible + data = (uint8)CalculateSmoothParamChange((float)lastZxxParam, (float)data); + } + pChn->lastZxxParam = data; } else // unrecognized byte (e.g. space char) { continue; @@ -4230,7 +4239,7 @@ //--------------------------------------------------------------------------------- { MPT_ASSERT(GetNumTicksOnCurrentRow() > m_PlayState.m_nTickCount); - const UINT ticksLeft = GetNumTicksOnCurrentRow() - m_PlayState.m_nTickCount; + const uint32 ticksLeft = GetNumTicksOnCurrentRow() - m_PlayState.m_nTickCount; if(ticksLeft > 1) { // Slide param This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-22 10:36:13
|
Revision: 4461 http://sourceforge.net/p/modplug/code/4461 Author: manxorist Date: 2014-10-22 10:36:01 +0000 (Wed, 22 Oct 2014) Log Message: ----------- [Imp] Add ComponentManager that handles loading of all optional OpenMPT components in a generic way. When introducing mpt::Library, most external libraries had been converted to be loaded (and unloaded) on demand for each and every use. This is inefficient, especially for browsing a folder containing mp3 samples. Now, each component class inherits from IComponent (or a subclass thereof). Each component can contain multiple mpt::Library-s. Additionally, each component defines MPT_REGISTERED_COMPONENT(ComponentImplClass) in a cpp file, which globally registers the component in a list of components that the ComponentManager knows about and initializes when starting up. The list is built pre-main(). Two settings affect the behaviour of ComponentManager: [Components]LoadOnStartup (default false) and [Components]KeepLoaded (default true). Setting both to false results in the same behaviour in respect to loading components as before this commit. Additionally, each individual component can be blocked completely from being loaded (which restores the functionalty of being able to block MP3 ACM codecs). For libopenmpt builds, the ComponentManager is not included because libopenmpt is not allowed to contain global state. The interface for accessing components (required for unmo3), however, is the same. A component is accessed via MPT_SHARED_PTR<ComponentImplClass> comp = MPT_GET_COMPONENT(ComponentImplClass); if(IsComponentAvailable(comp)) { dostuff(); }. If the component had not been preloaded before reaching MPT_GET_COMPONENT, it gets loaded right there (which is always the behaviour for libopenmpt). [Ref] Convert from mpt::Library to IComponent for the following optional components: SoundTouch, Lame, Blade, MP3 ACM, Vorbis, Opus, UXTheme, MPG123, UnMO3. [Ref] Convert uxtheme.dll to be delay loaded. [Mod] OpenMPT: Version is now 1.24.00.13 Modified Paths: -------------- trunk/OpenMPT/build/android_ndk/Android.mk trunk/OpenMPT/build/autotools/Makefile.am trunk/OpenMPT/build/vs2008/libopenmpt/libopenmpt.vcproj trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/MPTrackLink.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp trunk/OpenMPT/mptrack/StreamEncoderMP3.h trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp trunk/OpenMPT/mptrack/StreamEncoderOpus.h trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp trunk/OpenMPT/mptrack/StreamEncoderVorbis.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/soundlib/Load_mo3.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp Added Paths: ----------- trunk/OpenMPT/common/ComponentManager.cpp trunk/OpenMPT/common/ComponentManager.h Modified: trunk/OpenMPT/build/android_ndk/Android.mk =================================================================== --- trunk/OpenMPT/build/android_ndk/Android.mk 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/build/android_ndk/Android.mk 2014-10-22 10:36:01 UTC (rev 4461) @@ -15,8 +15,9 @@ LOCAL_LDLIBS := -lz LOCAL_SRC_FILES := \ + common/stdafx.cpp \ common/AudioCriticalSection.cpp \ - common/stdafx.cpp \ + common/ComponentManager.cpp \ common/Logging.cpp \ common/misc_util.cpp \ common/mptIO.cpp \ Modified: trunk/OpenMPT/build/autotools/Makefile.am =================================================================== --- trunk/OpenMPT/build/autotools/Makefile.am 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/build/autotools/Makefile.am 2014-10-22 10:36:01 UTC (rev 4461) @@ -78,6 +78,8 @@ libopenmpt_la_SOURCES += common/AudioCriticalSection.h libopenmpt_la_SOURCES += common/BuildSettings.h libopenmpt_la_SOURCES += common/CompilerDetect.h +libopenmpt_la_SOURCES += common/ComponentManager.cpp +libopenmpt_la_SOURCES += common/ComponentManager.h libopenmpt_la_SOURCES += common/Endianness.h libopenmpt_la_SOURCES += common/FlagSet.h libopenmpt_la_SOURCES += common/Logging.cpp @@ -276,6 +278,8 @@ libopenmpttest_SOURCES += common/AudioCriticalSection.h libopenmpttest_SOURCES += common/BuildSettings.h libopenmpttest_SOURCES += common/CompilerDetect.h +libopenmpttest_SOURCES += common/ComponentManager.cpp +libopenmpttest_SOURCES += common/ComponentManager.h libopenmpttest_SOURCES += common/Endianness.h libopenmpttest_SOURCES += common/FlagSet.h libopenmpttest_SOURCES += common/Logging.cpp Modified: trunk/OpenMPT/build/vs2008/libopenmpt/libopenmpt.vcproj =================================================================== --- trunk/OpenMPT/build/vs2008/libopenmpt/libopenmpt.vcproj 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/build/vs2008/libopenmpt/libopenmpt.vcproj 2014-10-22 10:36:01 UTC (rev 4461) @@ -162,6 +162,14 @@ > </File> <File + RelativePath="..\..\..\common\ComponentManager.cpp" + > + </File> + <File + RelativePath="..\..\..\common\ComponentManager.h" + > + </File> + <File RelativePath="..\..\..\common\Endianness.h" > </File> Added: trunk/OpenMPT/common/ComponentManager.cpp =================================================================== --- trunk/OpenMPT/common/ComponentManager.cpp (rev 0) +++ trunk/OpenMPT/common/ComponentManager.cpp 2014-10-22 10:36:01 UTC (rev 4461) @@ -0,0 +1,356 @@ +/* + * ComponentManager.cpp + * -------------------- + * Purpose: Manages loading of optional components. + * Notes : (currently none) + * Authors: Joern Heusipp + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#include "stdafx.h" +#include "ComponentManager.h" + +#include "mutex.h" + +OPENMPT_NAMESPACE_BEGIN + + +#if defined(MPT_WITH_DYNBIND) + + +ComponentBase::ComponentBase(ComponentType type, bool delayLoaded) +//---------------------------------------------------------------- + : m_Type(type) + , m_DelayLoaded(delayLoaded) + , m_Initialized(false) + , m_Available(false) + , m_BindFailed(false) +{ + return; +} + + +ComponentBase::~ComponentBase() +//----------------------------- +{ + return; +} + + +void ComponentBase::SetName(const std::string &name) +//-------------------------------------------------- +{ + m_Name = name; +} + + +void ComponentBase::SetInitialized() +//---------------------------------- +{ + m_Initialized = true; +} + + +void ComponentBase::SetAvailable() +//-------------------------------- +{ + m_Available = true; +} + + +bool ComponentBase::AddLibrary(const std::string &libName, const mpt::LibraryPath &libPath) +//----------------------------------------------------------------------------------------- +{ + if(m_Libraries[libName].IsValid()) + { + // prefer previous + return true; + } + mpt::Library lib(libPath); + if(!lib.IsValid()) + { + return false; + } + m_Libraries[libName] = lib; + return true; +} + + +void ComponentBase::ClearLibraries() +//---------------------------------- +{ + m_Libraries.clear(); +} + + +void ComponentBase::SetBindFailed() +//--------------------------------- +{ + m_BindFailed = true; +} + + +void ComponentBase::ClearBindFailed() +//----------------------------------- +{ + m_BindFailed = false; +} + + +bool ComponentBase::HasBindFailed() const +//--------------------------------------- +{ + return m_BindFailed; +} + + +std::string ComponentBase::GetName() const +//---------------------------------------- +{ + return m_Name; +} + + +ComponentType ComponentBase::GetType() const +//------------------------------------------ +{ + return m_Type; +} + + +bool ComponentBase::IsDelayLoaded() const +//--------------------------------------- +{ + return m_DelayLoaded; +} + + +bool ComponentBase::IsInitialized() const +//--------------------------------------- +{ + return m_Initialized; +} + + +bool ComponentBase::IsAvailable() const +//------------------------------------- +{ + return m_Initialized && m_Available; +} + + +mpt::ustring ComponentBase::GetVersion() const +//-------------------------------------------- +{ + return mpt::ustring(); +} + + +mpt::Library ComponentBase::GetLibrary(const std::string &libName) const +//---------------------------------------------------------------------- +{ + TLibraryMap::const_iterator it = m_Libraries.find(libName); + if(it == m_Libraries.end()) + { + return mpt::Library(); + } + return it->second; +} + + +void ComponentBase::Initialize() +//------------------------------ +{ + if(IsInitialized()) + { + return; + } + if(DoInitialize()) + { + SetAvailable(); + } + SetInitialized(); +} + + +#if MPT_COMPONENT_MANAGER + + +ComponentFactoryBase::ComponentFactoryBase(const std::string &name) +//----------------------------------------------------------------- + : m_Name(name) +{ + return; +} + + +ComponentFactoryBase::~ComponentFactoryBase() +//------------------------------------------- +{ + return; +} + + +std::string ComponentFactoryBase::GetName() const +{ + return m_Name; +} + + +MPT_SHARED_PTR<IComponent> ComponentFactoryBase::Construct() const +//---------------------------------------------------------------- +{ + MPT_SHARED_PTR<IComponent> result = DoConstruct(); + if(result) + { + result->SetName(GetName()); + } + return result; +} + + +// Global list of component register functions. +// We do not use a global scope static list head because the corresponding +// mutex would be no POD type and would thus not be safe to be usable in +// zero-initialized state. +// Function scope static initialization is guaranteed to be thread safe +// in C++11. +// We use this implementation to be future-proof. +// MSVC currently does not exploit the possibility of using multiple threads +// for global lifetime object's initialization. +// An implementation with a simple global list head and no mutex at all would +// thus work fine for MSVC (currently). + +static Util::mutex & ComponentListMutex() +//--------------------------------------- +{ + static Util::mutex g_ComponentListMutex; + return g_ComponentListMutex; +} + +static ComponentListEntry * & ComponentListHead() +//----------------------------------------------- +{ + static ComponentListEntry *g_ComponentListHead = nullptr; + return g_ComponentListHead; +} + +bool ComponentListPush(ComponentListEntry *entry) +//----------------------------------------------- +{ + Util::lock_guard<Util::mutex> guard(ComponentListMutex()); + entry->next = ComponentListHead(); + ComponentListHead() = entry; + return true; +} + + +static MPT_SHARED_PTR<ComponentManager> g_ComponentManager; + + +void ComponentManager::Init(const IComponentManagerSettings &settings) +//-------------------------------------------------------------------- +{ + // cannot use make_shared because the constructor is private + g_ComponentManager = MPT_SHARED_PTR<ComponentManager>(new ComponentManager(settings)); +} + + +void ComponentManager::Release() +//------------------------------ +{ + g_ComponentManager = MPT_SHARED_PTR<ComponentManager>(); +} + + +MPT_SHARED_PTR<ComponentManager> ComponentManager::Instance() +//----------------------------------------------------------- +{ + return g_ComponentManager; +} + + +ComponentManager::ComponentManager(const IComponentManagerSettings &settings) +//--------------------------------------------------------------------------- + : m_Settings(settings) +{ + return; +} + + +void ComponentManager::Register(const IComponentFactory &componentFactory) +//------------------------------------------------------------------------ +{ + std::string name = componentFactory.GetName(); + TComponentMap::const_iterator it = m_Components.find(name); + if(it != m_Components.end()) + { + return; + } + m_Components.insert(std::make_pair(name, componentFactory.Construct())); +} + + +void ComponentManager::InitializeComponent(MPT_SHARED_PTR<IComponent> component) const +//------------------------------------------------------------------------------------ +{ + if(!component) + { + return; + } + if(component->IsInitialized()) + { + return; + } + if(m_Settings.IsBlocked(component->GetSettingsKey())) + { + return; + } + component->Initialize(); +} + + +void ComponentManager::Startup() +//------------------------------ +{ + if(m_Settings.LoadOnStartup() || m_Settings.KeepLoaded()) + { + Util::lock_guard<Util::mutex> guard(ComponentListMutex()); + for(ComponentListEntry *entry = ComponentListHead(); entry; entry = entry->next) + { + entry->reg(this); + } + } + if(m_Settings.LoadOnStartup()) + { + for(TComponentMap::iterator it = m_Components.begin(); it != m_Components.end(); ++it) + { + InitializeComponent((*it).second); + } + } + if(!m_Settings.KeepLoaded()) + { + m_Components.clear(); + } +} + + +MPT_SHARED_PTR<IComponent> ComponentManager::GetComponent(const IComponentFactory &componentFactory) const +//-------------------------------------------------------------------------------------------------------- +{ + TComponentMap::const_iterator it = m_Components.find(componentFactory.GetName()); + MPT_SHARED_PTR<IComponent> component = (it != m_Components.end()) ? it->second : componentFactory.Construct(); + ASSERT(component); + InitializeComponent(component); + return component; +} + + +#endif // MPT_COMPONENT_MANAGER + + +#endif // MPT_WITH_DYNBIND + + +OPENMPT_NAMESPACE_END Property changes on: trunk/OpenMPT/common/ComponentManager.cpp ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-c++src \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/OpenMPT/common/ComponentManager.h =================================================================== --- trunk/OpenMPT/common/ComponentManager.h (rev 0) +++ trunk/OpenMPT/common/ComponentManager.h 2014-10-22 10:36:01 UTC (rev 4461) @@ -0,0 +1,335 @@ +/* + * ComponentManager.h + * ------------------ + * Purpose: Manages loading of optional components. + * Notes : (currently none) + * Authors: Joern Heusipp + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#pragma once + +#include <map> +#include <vector> +#include "../common/misc_util.h" + + +OPENMPT_NAMESPACE_BEGIN + + +#if defined(MPT_WITH_DYNBIND) + + +#ifdef MODPLUG_TRACKER +#define MPT_COMPONENT_MANAGER 1 +#else +#define MPT_COMPONENT_MANAGER 0 +#endif + + +enum ComponentType +{ + ComponentTypeSystem, // uxtheme.dll, mf.dll + ComponentTypeSystemInstallable, // acm mp3 codec + ComponentTypeBundled, // libsoundtouch + ComponentTypeForeign, // libmp3lame +}; + + +class ComponentFactoryBase; + + +class IComponent +{ + + friend class ComponentFactoryBase; + +protected: + + IComponent() { } + +public: + + virtual ~IComponent() { } + +protected: + + virtual void SetName(const std::string &name) = 0; + +public: + + virtual std::string GetName() const = 0; + virtual std::string GetSettingsKey() const = 0; + virtual ComponentType GetType() const = 0; + virtual bool IsDelayLoaded() const = 0; // openmpt is linked against the component dlls which get delay loaded + + virtual bool IsInitialized() const = 0; // Initialize() has been called + virtual bool IsAvailable() const = 0; // Initialize() has been successfull + virtual mpt::ustring GetVersion() const = 0; + + virtual void Initialize() = 0; // try to load the component + + virtual mpt::Library GetLibrary(const std::string &libName) const = 0; + +}; + + +class ComponentBase + : public IComponent +{ + +private: + std::string m_Name; + ComponentType m_Type; + bool m_DelayLoaded; + + bool m_Initialized; + bool m_Available; + typedef std::map<std::string, mpt::Library> TLibraryMap; + TLibraryMap m_Libraries; + + bool m_BindFailed; + +protected: + + ComponentBase(ComponentType type, bool delayLoaded = false); + +public: + + virtual ~ComponentBase(); + +protected: + + void SetName(const std::string &name); + void SetInitialized(); + void SetAvailable(); + bool AddLibrary(const std::string &libName, const mpt::LibraryPath &libPath); + void ClearLibraries(); + void SetBindFailed(); + void ClearBindFailed(); + bool HasBindFailed() const; + +public: + + virtual std::string GetName() const; + virtual ComponentType GetType() const; + virtual bool IsDelayLoaded() const; + virtual bool IsInitialized() const; + virtual bool IsAvailable() const; + + virtual mpt::ustring GetVersion() const; + + virtual mpt::Library GetLibrary(const std::string &libName) const; + + virtual void Initialize(); + + template <typename Tfunc> + bool Bind(Tfunc * & f, const std::string &libName, const std::string &symbol) const + { + return GetLibrary(libName).Bind(f, symbol); + } + +protected: + + virtual bool DoInitialize() = 0; + +}; + +#define MPT_COMPONENT_BIND(libName, func) do { if(!Bind( func , libName , #func )) { SetBindFailed(); } } while(0) +#define MPT_COMPONENT_BIND_OPTIONAL(libName, func) Bind( func , libName , #func ) +#define MPT_COMPONENT_BIND_SYMBOL(libName, symbol, func) do { if(!Bind( func , libName , symbol )) { SetBindFailed(); } } while(0) +#define MPT_COMPONENT_BIND_SYMBOL_OPTIONAL(libName, symbol, func) Bind( func , libName , symbol ) + + +class ComponentSystemDLL : public ComponentBase +{ +private: + mpt::PathString m_BaseName; +public: + ComponentSystemDLL(const mpt::PathString &baseName, bool delayLoaded = false) + : ComponentBase(ComponentTypeSystem, delayLoaded) + , m_BaseName(baseName) + { + return; + } + virtual bool DoInitialize() + { + AddLibrary(m_BaseName.ToUTF8(), mpt::LibraryPath::System(m_BaseName)); + return GetLibrary(m_BaseName.ToUTF8()).IsValid(); + } +}; + + +class ComponentDelayLoadedBundledDLL : public ComponentBase +{ +private: + mpt::PathString m_FullName; +public: + ComponentDelayLoadedBundledDLL(const mpt::PathString &fullName) + : ComponentBase(ComponentTypeBundled, true) + , m_FullName(fullName) + { + return; + } + virtual bool DoInitialize() + { + AddLibrary(m_FullName.ToUTF8(), mpt::LibraryPath::AppFullName(m_FullName)); + return GetLibrary(m_FullName.ToUTF8()).IsValid(); + } +}; + + +#if MPT_COMPONENT_MANAGER + + +class IComponentFactory +{ +protected: + IComponentFactory() { } +public: + virtual ~IComponentFactory() { } +public: + virtual std::string GetName() const = 0; + virtual MPT_SHARED_PTR<IComponent> Construct() const = 0; +}; + + +class ComponentFactoryBase + : public IComponentFactory +{ +private: + std::string m_Name; +protected: + ComponentFactoryBase(const std::string &name); +public: + virtual ~ComponentFactoryBase(); + virtual std::string GetName() const; + virtual MPT_SHARED_PTR<IComponent> Construct() const; + virtual MPT_SHARED_PTR<IComponent> DoConstruct() const = 0; +}; + + +template <typename T> +class ComponentFactory + : public ComponentFactoryBase +{ +public: + ComponentFactory(const std::string &name) + : ComponentFactoryBase(name) + { + return; + } + virtual ~ComponentFactory() + { + return; + } +public: + virtual MPT_SHARED_PTR<IComponent> DoConstruct() const + { + return mpt::make_shared<T>(); + } +}; + + +class IComponentManagerSettings +{ +public: + virtual bool LoadOnStartup() const = 0; + virtual bool KeepLoaded() const = 0; + virtual bool IsBlocked(const std::string &key) const = 0; +}; + + +class ComponentManagerSettingsDefault + : public IComponentManagerSettings +{ +public: + virtual bool LoadOnStartup() const { return false; } + virtual bool KeepLoaded() const { return true; } + virtual bool IsBlocked(const std::string & /*key*/ ) const { return false; } +}; + + +class ComponentManager +{ +public: + static void Init(const IComponentManagerSettings &settings); + static void Release(); + static MPT_SHARED_PTR<ComponentManager> Instance(); +private: + ComponentManager(const IComponentManagerSettings &settings); +private: + typedef std::map<std::string, MPT_SHARED_PTR<IComponent> > TComponentMap; + const IComponentManagerSettings &m_Settings; + TComponentMap m_Components; +private: + void InitializeComponent(MPT_SHARED_PTR<IComponent> component) const; +public: + void Register(const IComponentFactory &componentFactory); + void Startup(); + MPT_SHARED_PTR<IComponent> GetComponent(const IComponentFactory &componentFactory) const; +}; + + +struct ComponentListEntry +{ + ComponentListEntry *next; + void (*reg)(ComponentManager *componentManager); +}; + +bool ComponentListPush(ComponentListEntry *entry); + +#define MPT_REGISTERED_COMPONENT(name) \ + static void RegisterComponent ## name (ComponentManager *componentManager) \ + { \ + componentManager->Register(ComponentFactory< name >( #name )); \ + } \ + static ComponentListEntry Component ## name ## ListEntry = { nullptr, & RegisterComponent ## name }; \ + static bool Component ## name ## Registered = ComponentListPush(& Component ## name ## ListEntry ); +/**/ + + +template <typename type> +MPT_SHARED_PTR<type> GetComponent(const std::string &name) +{ + return MPT_DYNAMIC_POINTER_CAST<type>(ComponentManager::Instance()->GetComponent(ComponentFactory<type>(name))); +} + + +#else // !MPT_COMPONENT_MANAGER + + +#define MPT_REGISTERED_COMPONENT(name) + + +template <typename type> +MPT_SHARED_PTR<type> GetComponent(const std::string &name) +{ + MPT_SHARED_PTR<type> component = mpt::make_shared<type>(); + if(!component) + { + return component; + } + component->Initialize(); + return component; +} + + +#endif // MPT_COMPONENT_MANAGER + + +#define MPT_GET_COMPONENT(name) GetComponent< name >( #name ) + + +template <typename T> +bool IsComponentAvailable(MPT_SHARED_PTR<T> component) +{ + return component && component->IsAvailable(); +} + + +#endif // MPT_WITH_DYNBIND + + +OPENMPT_NAMESPACE_END Property changes on: trunk/OpenMPT/common/ComponentManager.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-chdr \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/common/versionNumber.h 2014-10-22 10:36:01 UTC (rev 4461) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 00 -#define VER_MINORMINOR 12 +#define VER_MINORMINOR 13 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2014-10-22 10:36:01 UTC (rev 4461) @@ -179,6 +179,7 @@ <ClInclude Include="..\common\AudioCriticalSection.h" /> <ClInclude Include="..\common\BuildSettings.h" /> <ClInclude Include="..\common\CompilerDetect.h" /> + <ClInclude Include="..\common\ComponentManager.h" /> <ClInclude Include="..\common\Endianness.h" /> <ClInclude Include="..\common\FlagSet.h" /> <ClInclude Include="..\common\Logging.h" /> @@ -257,6 +258,7 @@ </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp" /> + <ClCompile Include="..\common\ComponentManager.cpp" /> <ClCompile Include="..\common\Logging.cpp" /> <ClCompile Include="..\common\misc_util.cpp" /> <ClCompile Include="..\common\mptIO.cpp" /> Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2014-10-22 10:36:01 UTC (rev 4461) @@ -266,6 +266,9 @@ <ClInclude Include="..\common\mptIO.h"> <Filter>Header Files\common</Filter> </ClInclude> + <ClInclude Include="..\common\ComponentManager.h"> + <Filter>Header Files\common</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp"> @@ -517,6 +520,9 @@ <ClCompile Include="..\test\TestToolsLib.cpp"> <Filter>Source Files\test</Filter> </ClCompile> + <ClCompile Include="..\common\ComponentManager.cpp"> + <Filter>Source Files\common</Filter> + </ClCompile> <ClCompile Include="..\common\mptIO.cpp"> <Filter>Source Files\common</Filter> </ClCompile> Modified: trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2014-10-22 10:36:01 UTC (rev 4461) @@ -187,6 +187,7 @@ <ClInclude Include="..\common\AudioCriticalSection.h" /> <ClInclude Include="..\common\BuildSettings.h" /> <ClInclude Include="..\common\CompilerDetect.h" /> + <ClInclude Include="..\common\ComponentManager.h" /> <ClInclude Include="..\common\Endianness.h" /> <ClInclude Include="..\common\FlagSet.h" /> <ClInclude Include="..\common\Logging.h" /> @@ -267,6 +268,7 @@ </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp" /> + <ClCompile Include="..\common\ComponentManager.cpp" /> <ClCompile Include="..\common\Logging.cpp" /> <ClCompile Include="..\common\misc_util.cpp" /> <ClCompile Include="..\common\mptIO.cpp" /> Modified: trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters 2014-10-22 10:36:01 UTC (rev 4461) @@ -272,6 +272,9 @@ <ClInclude Include="..\common\mptIO.h"> <Filter>Header Files\common</Filter> </ClInclude> + <ClInclude Include="..\common\ComponentManager.h"> + <Filter>Header Files\common</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp"> @@ -523,6 +526,9 @@ <ClCompile Include="..\test\TestToolsLib.cpp"> <Filter>Source Files\test</Filter> </ClCompile> + <ClCompile Include="..\common\ComponentManager.cpp"> + <Filter>Source Files\common</Filter> + </ClCompile> <ClCompile Include="..\common\mptIO.cpp"> <Filter>Source Files\common</Filter> </ClCompile> Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj 2014-10-22 10:36:01 UTC (rev 4461) @@ -183,6 +183,7 @@ <ClInclude Include="..\common\AudioCriticalSection.h" /> <ClInclude Include="..\common\BuildSettings.h" /> <ClInclude Include="..\common\CompilerDetect.h" /> + <ClInclude Include="..\common\ComponentManager.h" /> <ClInclude Include="..\common\Endianness.h" /> <ClInclude Include="..\common\FlagSet.h" /> <ClInclude Include="..\common\Logging.h" /> @@ -261,6 +262,7 @@ </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp" /> + <ClCompile Include="..\common\ComponentManager.cpp" /> <ClCompile Include="..\common\Logging.cpp" /> <ClCompile Include="..\common\misc_util.cpp" /> <ClCompile Include="..\common\mptIO.cpp" /> Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters 2014-10-22 10:36:01 UTC (rev 4461) @@ -266,6 +266,9 @@ <ClInclude Include="..\common\mptIO.h"> <Filter>Header Files\common</Filter> </ClInclude> + <ClInclude Include="..\common\ComponentManager.h"> + <Filter>Header Files\common</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp"> @@ -520,6 +523,9 @@ <ClCompile Include="..\test\TestToolsLib.cpp"> <Filter>Source Files\test</Filter> </ClCompile> + <ClCompile Include="..\common\ComponentManager.cpp"> + <Filter>Source Files\common</Filter> + </ClCompile> <ClCompile Include="..\common\mptIO.cpp"> <Filter>Source Files\common</Filter> </ClCompile> Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-10-22 10:36:01 UTC (rev 4461) @@ -31,6 +31,7 @@ #include "../soundlib/FileReader.h" #include "../soundlib/SampleFormatConverters.h" #include "FileDialog.h" +#include "../common/ComponentManager.h" #ifdef _DEBUG #include <math.h> #endif @@ -1735,6 +1736,22 @@ } +//======================= +class ComponentSoundTouch +//======================= + : public ComponentDelayLoadedBundledDLL +{ +public: + ComponentSoundTouch() + : ComponentDelayLoadedBundledDLL(MPT_PATHSTRING("OpenMPT_SoundTouch_f32")) + { + return; + } + std::string GetSettingsKey() const { return "SoundTouch"; } +}; +MPT_REGISTERED_COMPONENT(ComponentSoundTouch) + + int CCtrlSamples::TimeStretch(float ratio) //---------------------------------------- { @@ -1753,12 +1770,13 @@ if(pitch > 2.0f) return 2 + (2<<8); // Check whether the DLL file exists. - mpt::Library libSoundTouch = mpt::Library(mpt::LibraryPath::AppFullName(MPT_PATHSTRING("OpenMPT_SoundTouch_f32"))); - if(!libSoundTouch.IsValid()) + MPT_SHARED_PTR<ComponentSoundTouch> soundTouch = MPT_GET_COMPONENT(ComponentSoundTouch); + if(!IsComponentAvailable(soundTouch)) { MsgBox(IDS_SOUNDTOUCH_LOADFAILURE); return -1; } + HANDLE handleSt = soundtouch_createInstance(); if(handleSt == NULL) { Modified: trunk/OpenMPT/mptrack/MPTrackLink.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTrackLink.cpp 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/mptrack/MPTrackLink.cpp 2014-10-22 10:36:01 UTC (rev 4461) @@ -20,6 +20,7 @@ #pragma comment(lib, "rpcrt4.lib") #pragma comment(lib, "wininet.lib") #pragma comment(lib, "htmlhelp.lib") +#pragma comment(lib, "uxtheme.lib") #pragma comment(lib, "dmoguids.lib") #pragma comment(lib, "strmiids.lib") Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2014-10-22 10:36:01 UTC (rev 4461) @@ -30,6 +30,7 @@ #include "AutoSaver.h" #include "FileDialog.h" #include "PNG.h" +#include "../common/ComponentManager.h" // rewbs.memLeak #define _CRTDBG_MAP_ALLOC @@ -640,10 +641,10 @@ //-------------------- : m_GuiThreadId(0) , m_pTrackerDirectories(nullptr) - , m_pUXThemeDLL(nullptr) , m_pSettingsIniFile(nullptr) , m_pSettings(nullptr) , m_pTrackerSettings(nullptr) + , m_pComponentManagerSettings(nullptr) , m_pPluginCache(nullptr) { #if MPT_COMPILER_MSVC @@ -711,6 +712,38 @@ ///////////////////////////////////////////////////////////////////////////// // CTrackApp initialization + +//============================ +class ComponentManagerSettings +//============================ + : public IComponentManagerSettings +{ +private: + mutable TrackerSettings &conf; +public: + ComponentManagerSettings(TrackerSettings &conf) + : conf(conf) + { + return; + } + virtual bool LoadOnStartup() const + { + return conf.ComponentsLoadOnStartup; + } + virtual bool KeepLoaded() const + { + return conf.ComponentsKeepLoaded; + } + virtual bool IsBlocked(const std::string &key) const + { + return conf.IsComponentBlocked(key); + } +}; + + +MPT_REGISTERED_COMPONENT(ComponentUXTheme) + + #ifdef WIN32 // Legacy stuff // Move a config file called sFileName from the App's directory (or one of its sub directories specified by sSubDir) to // %APPDATA%. If specified, it will be renamed to sNewFileName. Existing files are never overwritten. @@ -889,10 +922,6 @@ // Set up paths to store configuration in SetupPaths(cmdInfo.m_bPortable); - // Load UXTheme.DLL - m_pUXThemeDLL = new mpt::Library(mpt::LibraryPath::System(MPT_PATHSTRING("uxtheme"))); - m_pUXThemeDLL->Bind(m_pEnableThemeDialogTexture, "EnableThemeDialogTexture"); - // Construct auto saver instance, class TrackerSettings expects it being available. CMainFrame::m_pAutoSaver = new CAutoSaver(); @@ -909,10 +938,18 @@ } MPT_TRACE(); + m_pComponentManagerSettings = new ComponentManagerSettings(TrackerSettings::Instance()); + m_pPluginCache = new IniFileSettingsContainer(m_szPluginCacheFileName); LoadStdProfileSettings(0); // Load standard INI file options (without MRU) + // create component manager + ComponentManager::Init(*m_pComponentManagerSettings); + + // load components + ComponentManager::Instance()->Startup(); + // Register document templates m_pModTemplate = new CModDocTemplate( IDR_MODULETYPE, @@ -1021,17 +1058,18 @@ // Uninitialize Plugins UninitializeDXPlugins(); + ComponentManager::Release(); + delete m_pPluginCache; m_pPluginCache = nullptr; + delete m_pComponentManagerSettings; + m_pComponentManagerSettings = nullptr; delete m_pTrackerSettings; m_pTrackerSettings = nullptr; delete m_pSettings; m_pSettings = nullptr; delete m_pSettingsIniFile; m_pSettingsIniFile = nullptr; - m_pEnableThemeDialogTexture = nullptr; - delete m_pUXThemeDLL; - m_pUXThemeDLL = nullptr; delete m_pTrackerDirectories; m_pTrackerDirectories = nullptr; Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/mptrack/Mptrack.h 2014-10-22 10:36:01 UTC (rev 4461) @@ -17,6 +17,7 @@ #include "../mptrack/Reporting.h" #include "../soundlib/MIDIMacros.h" #include "../soundlib/modcommand.h" +#include "../common/ComponentManager.h" #include <vector> OPENMPT_NAMESPACE_BEGIN @@ -29,7 +30,9 @@ class CDLSBank; class TrackerDirectories; class TrackerSettings; +class ComponentManagerSettings; + ///////////////////////////////////////////////////////////////////////////// // 16-colors DIB typedef struct MODPLUGDIB @@ -144,6 +147,13 @@ // See mptrack.cpp for the implementation of this class // +class ComponentUXTheme : public ComponentSystemDLL +{ +public: + ComponentUXTheme() : ComponentSystemDLL(MPT_PATHSTRING("uxtheme"), true) { } + std::string GetSettingsKey() const { return "UXTheme"; } +}; + //============================= class CTrackApp: public CWinApp //============================= @@ -193,12 +203,10 @@ DWORD m_GuiThreadId; TrackerDirectories *m_pTrackerDirectories; - mpt::Library *m_pUXThemeDLL; - typedef HRESULT (WINAPI * pfEnableThemeDialogTexture)(HWND, DWORD); - pfEnableThemeDialogTexture m_pEnableThemeDialogTexture; IniFileSettingsBackend *m_pSettingsIniFile; SettingsContainer *m_pSettings; TrackerSettings *m_pTrackerSettings; + ComponentManagerSettings *m_pComponentManagerSettings; IniFileSettingsContainer *m_pPluginCache; CModDocTemplate *m_pModTemplate; CVstPluginManager *m_pPluginManager; @@ -248,7 +256,6 @@ public: bool InGuiThread() const { return GetCurrentThreadId() == m_GuiThreadId; } - HRESULT EnableThemeDialogTexture(HWND hwnd, DWORD dwFlags) { if(m_pEnableThemeDialogTexture) return m_pEnableThemeDialogTexture(hwnd, dwFlags); else return S_OK; } CModDocTemplate *GetModDocTemplate() const { return m_pModTemplate; } CVstPluginManager *GetPluginManager() const { return m_pPluginManager; } SoundDevice::Manager *GetSoundDevicesManager() const { return m_pSoundDevicesManager; } Modified: trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2014-10-22 10:36:01 UTC (rev 4461) @@ -13,6 +13,8 @@ #include "StreamEncoder.h" #include "StreamEncoderMP3.h" +#include "../common/ComponentManager.h" + #include "Mptrack.h" #include "../soundlib/Sndfile.h" @@ -252,10 +254,11 @@ typedef struct lame_global_struct lame_global_flags; typedef lame_global_flags *lame_t; -struct LameDynBind +class ComponentLame + : public ComponentBase { - mpt::Library hLame; +public: const char* (CDECL * get_lame_version)(); const char* (CDECL * get_lame_short_version)(); @@ -314,89 +317,109 @@ int (CDECL * lame_close) (lame_global_flags *); +private: + void Reset() { + ClearLibraries(); + } + +public: + + ComponentLame() + : ComponentBase(ComponentTypeForeign, false) + { return; } - LameDynBind() + + std::string GetSettingsKey() const { return "LibMP3Lame"; } + +protected: + + bool DoInitialize() { Reset(); - if(!hLame.IsValid()) TryLoad(MPT_PATHSTRING("libmp3lame"), true); - if(!hLame.IsValid()) TryLoad(MPT_PATHSTRING("liblame"), true); - if(!hLame.IsValid()) TryLoad(MPT_PATHSTRING("mp3lame"), true); - if(!hLame.IsValid()) TryLoad(MPT_PATHSTRING("lame"), true); - if(!hLame.IsValid()) TryLoad(MPT_PATHSTRING("lame_enc"), false); + struct dll_names_t { + const char *lame; + }; + static const dll_names_t dll_names[] = { + { "libmp3lame" }, + { "liblame" }, + { "mp3lame" }, + { "lame" }, + { "lame_enc" }, + }; + bool ok = false; + for(std::size_t i=0; i<CountOf(dll_names); ++i) + { + if(TryLoad(mpt::PathString::FromUTF8(dll_names[i].lame))) + { + ok = true; + break; + } + } + return ok; } - void TryLoad(const mpt::PathString &filename, bool warn) + +private: + + bool TryLoad(const mpt::PathString &filename) { - hLame = mpt::Library(mpt::LibraryPath::AppFullName(filename)); - if(!hLame.IsValid()) + Reset(); + ClearBindFailed(); + if(!AddLibrary("libmp3lame", mpt::LibraryPath::AppFullName(filename))) { - return; + Reset(); + return false; } - bool ok = true; - #define LAME_BIND(f) do { \ - if(!hLame.Bind( f , #f )) \ - { \ - ok = false; \ - if(warn) \ - { \ - Reporting::Error(mpt::String::PrintW(L"Your '%1' is missing '%2'.\n\nPlease copy a newer 'libmp3lame.dll' into OpenMPT's root directory.", filename.ToWide(), L ## #f ).c_str(), L"OpenMPT - MP3 Export"); \ - } \ - } \ - } while(0) - LAME_BIND(get_lame_version); - LAME_BIND(get_lame_short_version); - LAME_BIND(get_lame_very_short_version); - LAME_BIND(get_psy_version); - LAME_BIND(get_lame_url); - LAME_BIND(lame_init); - LAME_BIND(lame_set_in_samplerate); - LAME_BIND(lame_set_num_channels); - LAME_BIND(lame_get_num_channels); - LAME_BIND(lame_get_quality); - LAME_BIND(lame_set_quality); - LAME_BIND(lame_set_out_samplerate); - LAME_BIND(lame_set_brate); - LAME_BIND(lame_set_VBR_quality); - LAME_BIND(lame_set_VBR); - LAME_BIND(lame_set_bWriteVbrTag); - LAME_BIND(lame_set_strict_ISO); - LAME_BIND(lame_set_disable_reservoir); - LAME_BIND(id3tag_genre_list); - LAME_BIND(id3tag_init); - LAME_BIND(id3tag_v1_only); - LAME_BIND(id3tag_add_v2); - LAME_BIND(id3tag_v2_only); - LAME_BIND(lame_set_write_id3tag_automatic); - LAME_BIND(id3tag_set_title); - LAME_BIND(id3tag_set_artist); - LAME_BIND(id3tag_set_album); - LAME_BIND(id3tag_set_year); - LAME_BIND(id3tag_set_comment); - LAME_BIND(id3tag_set_track); - LAME_BIND(id3tag_set_genre); - LAME_BIND(lame_init_params); - LAME_BIND(lame_encode_buffer_ieee_float); - LAME_BIND(lame_encode_buffer_interleaved_ieee_float); - LAME_BIND(lame_encode_flush); - LAME_BIND(lame_get_lametag_frame); - LAME_BIND(lame_get_id3v2_tag); - LAME_BIND(lame_close); - #undef LAME_BIND - if(!ok) + MPT_COMPONENT_BIND("libmp3lame", get_lame_version); + MPT_COMPONENT_BIND("libmp3lame", get_lame_short_version); + MPT_COMPONENT_BIND("libmp3lame", get_lame_very_short_version); + MPT_COMPONENT_BIND("libmp3lame", get_psy_version); + MPT_COMPONENT_BIND("libmp3lame", get_lame_url); + MPT_COMPONENT_BIND("libmp3lame", lame_init); + MPT_COMPONENT_BIND("libmp3lame", lame_set_in_samplerate); + MPT_COMPONENT_BIND("libmp3lame", lame_set_num_channels); + MPT_COMPONENT_BIND("libmp3lame", lame_get_num_channels); + MPT_COMPONENT_BIND("libmp3lame", lame_get_quality); + MPT_COMPONENT_BIND("libmp3lame", lame_set_quality); + MPT_COMPONENT_BIND("libmp3lame", lame_set_out_samplerate); + MPT_COMPONENT_BIND("libmp3lame", lame_set_brate); + MPT_COMPONENT_BIND("libmp3lame", lame_set_VBR_quality); + MPT_COMPONENT_BIND("libmp3lame", lame_set_VBR); + MPT_COMPONENT_BIND("libmp3lame", lame_set_bWriteVbrTag); + MPT_COMPONENT_BIND("libmp3lame", lame_set_strict_ISO); + MPT_COMPONENT_BIND("libmp3lame", lame_set_disable_reservoir); + MPT_COMPONENT_BIND("libmp3lame", id3tag_genre_list); + MPT_COMPONENT_BIND("libmp3lame", id3tag_init); + MPT_COMPONENT_BIND("libmp3lame", id3tag_v1_only); + MPT_COMPONENT_BIND("libmp3lame", id3tag_add_v2); + MPT_COMPONENT_BIND("libmp3lame", id3tag_v2_only); + MPT_COMPONENT_BIND("libmp3lame", lame_set_write_id3tag_automatic); + MPT_COMPONENT_BIND("libmp3lame", id3tag_set_title); + MPT_COMPONENT_BIND("libmp3lame", id3tag_set_artist); + MPT_COMPONENT_BIND("libmp3lame", id3tag_set_album); + MPT_COMPONENT_BIND("libmp3lame", id3tag_set_year); + MPT_COMPONENT_BIND("libmp3lame", id3tag_set_comment); + MPT_COMPONENT_BIND("libmp3lame", id3tag_set_track); + MPT_COMPONENT_BIND("libmp3lame", id3tag_set_genre); + MPT_COMPONENT_BIND("libmp3lame", lame_init_params); + MPT_COMPONENT_BIND("libmp3lame", lame_encode_buffer_ieee_float); + MPT_COMPONENT_BIND("libmp3lame", lame_encode_buffer_interleaved_ieee_float); + MPT_COMPONENT_BIND("libmp3lame", lame_encode_flush); + MPT_COMPONENT_BIND("libmp3lame", lame_get_lametag_frame); + MPT_COMPONENT_BIND("libmp3lame", lame_get_id3v2_tag); + MPT_COMPONENT_BIND("libmp3lame", lame_close); + if(HasBindFailed()) { - hLame.Unload(); Reset(); - return; + return false; } + return true; } - operator bool () const { return hLame.IsValid() ? true : false; } - ~LameDynBind() - { - hLame.Unload(); - Reset(); - } + +public: + static void GenreEnumCallback(int num, const char *name, void *cookie) { MPT_UNREFERENCED_PARAMETER(num); @@ -409,7 +432,7 @@ Encoder::Traits BuildTraits() { Encoder::Traits traits; - if(!*this) + if(!IsAvailable()) { return traits; } @@ -445,16 +468,17 @@ return traits; } }; +MPT_REGISTERED_COMPONENT(ComponentLame) class MP3LameStreamWriter : public StreamWriterBase { private: - LameDynBind &lame; + ComponentLame &lame; Encoder::Mode Mode; bool gfp_inited; lame_t gfp; public: - MP3LameStreamWriter(LameDynBind &lame_, std::ostream &stream) + MP3LameStreamWriter(ComponentLame &lame_, std::ostream &stream) : StreamWriterBase(stream) , lame(lame_) { @@ -618,10 +642,11 @@ #ifdef MPT_MP3ENCODER_BLADE -struct BladeDynBind +class ComponentBlade + : public ComponentBase { - mpt::Library hBlade; +public: int lame; @@ -631,61 +656,71 @@ BE_ERR (*beDeinitStream) (HBE_STREAM, PBYTE, PDWORD); BE_ERR (*beCloseStream) (HBE_STREAM); +private: + void Reset() { + ClearLibraries(); lame = 0; } - BladeDynBind() + +public: + + ComponentBlade() + : ComponentBase(ComponentTypeForeign, false) { + return; + } + + std::string GetSettingsKey() const { return "BladeEnc"; } + +protected: + + bool DoInitialize() + { Reset(); - if(!hBlade.IsValid()) + if(TryLoad(MPT_PATHSTRING("lame_enc"))) { - TryLoad(MPT_PATHSTRING("lame_enc")); - if(hBlade.IsValid()) lame = 1; - } - if(!hBlade.IsValid()) + lame = 1; + return true; + } else if(TryLoad(MPT_PATHSTRING("bladeenc"))) { - TryLoad(MPT_PATHSTRING("bladeenc")); - if(hBlade.IsValid()) lame = 0; + lame = 0; + return true; } + return false; } - void TryLoad(const mpt::PathString &filename) + +private: + + bool TryLoad(const mpt::PathString &filename) { - hBlade = mpt::Library(mpt::LibraryPath::AppFullName(filename)); - if(!hBlade.IsValid()) + Reset(); + ClearBindFailed(); + if(!AddLibrary("BladeEnc", mpt::LibraryPath::AppFullName(filename))) { - return; + Reset(); + return false; } - bool ok = true; - #define BLADE_BIND(f) do { \ - if(!hBlade.Bind( f , #f )) \ - { \ - ok = false; \ - } \ - } while(0) - BLADE_BIND(beVersion); - BLADE_BIND(beInitStream); - BLADE_BIND(beEncodeChunk); - BLADE_BIND(beDeinitStream); - BLADE_BIND(beCloseStream); - #undef BLADE_BIND - if(!ok) + MPT_COMPONENT_BIND("BladeEnc", beVersion); + MPT_COMPONENT_BIND("BladeEnc", beInitStream); + MPT_COMPONENT_BIND("BladeEnc", beEncodeChunk); + MPT_COMPONENT_BIND("BladeEnc", beDeinitStream); + MPT_COMPONENT_BIND("BladeEnc", beCloseStream); + if(HasBindFailed()) { - hBlade.Unload(); Reset(); - return; + return false; } + return true; } - operator bool () const { return hBlade.IsValid(); } - ~BladeDynBind() - { - hBlade.Unload(); - Reset(); - } + +public: + Encoder::Traits BuildTraits() { Encoder::Traits traits; - if(!*this) + if(!IsAvailable()) { return traits; } @@ -718,11 +753,12 @@ return traits; } }; +MPT_REGISTERED_COMPONENT(ComponentBlade) class MP3BladeStreamWriter : public StreamWriterBase { private: - BladeDynBind &blade; + ComponentBlade &blade; DWORD blade_inputsamples; DWORD blade_outputbytes; SC::Convert<int16,float> sampleConv[2]; @@ -733,7 +769,7 @@ std::vector<float> interleaved; std::vector<SHORT> samples; public: - MP3BladeStreamWriter(BladeDynBind &blade_, std::ostream &stream) + MP3BladeStreamWriter(ComponentBlade &blade_, std::ostream &stream) : StreamWriterBase(stream) , blade(blade_) { @@ -866,8 +902,12 @@ #ifdef MPT_MP3ENCODER_ACM -struct AcmDynBind +class ComponentAcmMP3 + : public ComponentBase { + +public: + bool found_codec; int samplerates[CountOf(layer3_samplerates)]; @@ -876,6 +916,8 @@ std::vector<std::vector<char> > formats_waveformats; std::set<std::string> drivers; +private: + void Reset() { found_codec = false; @@ -884,14 +926,30 @@ formats_driverids.clear(); formats_waveformats.clear(); } - AcmDynBind() + +public: + + ComponentAcmMP3() + : ComponentBase(ComponentTypeSystemInstallable, false) { + return; + } + + std::string GetSettingsKey() const { return "ACM_MP3"; } + +protected: + + bool DoInitialize() + { Reset(); - TryLoad(); + return TryLoad(); } + +private: + static BOOL CALLBACK AcmFormatEnumCallback(HACMDRIVERID driver, LPACMFORMATDETAILS pafd, DWORD_PTR inst, DWORD fdwSupport) { - return reinterpret_cast<AcmDynBind*>(inst)->AcmFormatEnumCB(driver, pafd, fdwSupport); + return reinterpret_cast<ComponentAcmMP3*>(inst)->AcmFormatEnumCB(driver, pafd, fdwSupport); } template<size_t size> static void AppendField(std::string &s, const std::string &field, const CHAR(&val)[size]) @@ -1073,12 +1131,15 @@ pwfx->nAvgBytesPerSec = pwfx->nSamplesPerSec * pwfx->nBlockAlign; acmFormatEnum(NULL, &afd, AcmFormatEnumCallback, reinterpret_cast<DWORD_PTR>(this), ACM_FORMATENUMF_CONVERT); } - void TryLoad() + +private: + + bool TryLoad() { if(acmGetVersion() <= 0x03320000) { Reset(); - return; + return false; } try { @@ -1103,18 +1164,17 @@ if(!found_codec) { Reset(); - return; + return false; } + return true; } - operator bool () const { return found_codec ? true : false; } - ~AcmDynBind() - { - Reset(); - } + +public: + Encoder::Traits BuildTraits() { Encoder::Traits traits; - if(!*this) + if(!IsAvailable()) { return traits; } @@ -1154,11 +1214,12 @@ return traits; } }; +MPT_REGISTERED_COMPONENT(ComponentAcmMP3) class MP3AcmStreamWriter : public StreamWriterBase { private: - AcmDynBind &acm; + ComponentAcmMP3 &acm; static const size_t acmBufSize = 1024; int acmChannels; SC::Convert<int16,float> sampleConv[2]; @@ -1172,7 +1233,7 @@ std::vector<float> interleaved; std::vector<int16> samples; public: - MP3AcmStreamWriter(AcmDynBind &acm_, std::ostream &stream) + MP3AcmStreamWriter(ComponentAcmMP3 &acm_, std::ostream &stream) : StreamWriterBase(stream) , acm(acm_) { @@ -1354,22 +1415,13 @@ MP3Encoder::MP3Encoder(MP3EncoderType type) //----------------------------------------- -#ifdef MPT_MP3ENCODER_LAME - : m_Lame(nullptr) -#endif // MPT_MP3ENCODER_LAME -#ifdef MPT_MP3ENCODER_BLADE - , m_Blade(nullptr) -#endif // MPT_MP3ENCODER_BLADE -#ifdef MPT_MP3ENCODER_ACM - , m_Acm(nullptr) -#endif // MPT_MP3ENCODER_ACM - , m_Type(MP3EncoderDefault) + : m_Type(MP3EncoderDefault) { #ifdef MPT_MP3ENCODER_LAME if(type == MP3EncoderDefault || type == MP3EncoderLame) { - m_Lame = new LameDynBind(); - if(*m_Lame) + m_Lame = MPT_GET_COMPONENT(ComponentLame); + if(IsComponentAvailable(m_Lame)) { m_Type = MP3EncoderLame; SetTraits(m_Lame->BuildTraits()); @@ -1380,8 +1432,8 @@ #ifdef MPT_MP3ENCODER_BLADE if(type == MP3EncoderDefault || type == MP3EncoderBlade) { - m_Blade = new BladeDynBind(); - if(*m_Blade) + m_Blade = MPT_GET_COMPONENT(ComponentBlade); + if(IsComponentAvailable(m_Blade)) { m_Type = MP3EncoderBlade; SetTraits(m_Blade->BuildTraits()); @@ -1392,8 +1444,8 @@ #ifdef MPT_MP3ENCODER_ACM if(type == MP3EncoderDefault || type == MP3EncoderACM) { - m_Acm = new AcmDynBind(); - if(*m_Acm) + m_Acm = MPT_GET_COMPONENT(ComponentAcmMP3); + if(IsComponentAvailable(m_Acm)) { m_Type = MP3EncoderACM; SetTraits(m_Acm->BuildTraits()); @@ -1409,13 +1461,13 @@ { return false #ifdef MPT_MP3ENCODER_LAME - || (m_Lame && *m_Lame) + || IsComponentAvailable(m_Lame) #endif // MPT_MP3ENCODER_ACM #ifdef MPT_MP3ENCODER_BLADE - || (m_Blade && *m_Blade) + || IsComponentAvailable(m_Blade) #endif // MPT_MP3ENCODER_BLADE #ifdef MPT_MP3ENCODER_ACM - || (m_Acm && *m_Acm) + || IsComponentAvailable(m_Acm) #endif // MPT_MP3ENCODER_ACM ; } @@ -1424,27 +1476,7 @@ MP3Encoder::~MP3Encoder() //----------------------- { -#ifdef MPT_MP3ENCODER_ACM - if(m_Acm) - { - delete m_Acm; - m_Acm = nullptr; - } -#endif // MPT_MP3ENCODER_ACM -#ifdef MPT_MP3ENCODER_BLADE - if(m_Blade) - { - delete m_Blade; - m_Blade = nullptr; - } -#endif // MPT_MP3ENCODER_BLADE -#ifdef MPT_MP3ENCODER_LAME - if(m_Lame) - { - delete m_Lame; - m_Lame = nullptr; - } -#endif // MPT_MP3ENCODER_LAME + return; } Modified: trunk/OpenMPT/mptrack/StreamEncoderMP3.h =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderMP3.h 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/mptrack/StreamEncoderMP3.h 2014-10-22 10:36:01 UTC (rev 4461) @@ -22,13 +22,13 @@ #ifdef MPT_MP3ENCODER_LAME -struct LameDynBind; +class ComponentLame; #endif #ifdef MPT_MP3ENCODER_BLADE -struct BladeDynBind; +class ComponentBlade; #endif #ifdef MPT_MP3ENCODER_ACM -struct AcmDynBind; +class ComponentAcmMP3; #endif enum MP3EncoderType @@ -45,13 +45,13 @@ private: #ifdef MPT_MP3ENCODER_LAME - LameDynBind *m_Lame; + MPT_SHARED_PTR<ComponentLame> m_Lame; #endif #ifdef MPT_MP3ENCODER_BLADE - BladeDynBind *m_Blade; + MPT_SHARED_PTR<ComponentBlade> m_Blade; #endif #ifdef MPT_MP3ENCODER_ACM - AcmDynBind *m_Acm; + MPT_SHARED_PTR<ComponentAcmMP3> m_Acm; #endif MP3EncoderType m_Type; Modified: trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp 2014-10-22 10:36:01 UTC (rev 4461) @@ -13,6 +13,8 @@ #include "StreamEncoder.h" #include "StreamEncoderOpus.h" +#include "../common/ComponentManager.h" + #include "Mptrack.h" #include <deque> @@ -38,11 +40,11 @@ -struct OpusDynBind +class ComponentOpus + : public ComponentBase { - mpt::Library hOgg; - mpt::Library hOpus; +public: // ogg int (*ogg_stream_init)(ogg_stream_state *os,int serialno); @@ -64,11 +66,26 @@ // 1.1 OpusMSEncoder * (*opus_multistream_surround_encoder_create)(opus_int32 Fs, int channels, int mapping_family, int *streams, int *coupled_streams, unsigned char *mapping, int application, int *error); +private: + void Reset() { + ClearLibraries(); + } + +public: + + ComponentOpus() + : ComponentBase(ComponentTypeForeign, false) + { return; } - OpusDynBind() + + std::string GetSettingsKey() const { return "Opus"; } + +protected: + + bool DoInitialize() { Reset(); struct dll_names_t { @@ -84,70 +101,59 @@ { "libogg" , "libopus" }, { "ogg" , "opus" } }; + bool ok = false; for(std::size_t i=0; i<CountOf(dll_names); ++i) { if(TryLoad(mpt::PathString::FromUTF8(dll_names[i].ogg), mpt::PathString::FromUTF8(dll_names[i].opus))) { - // success + ok = true; break; } } + return ok; } + +private: + bool TryLoad(const mpt::PathString &Ogg_fn, const mpt::PathString &Opus_fn) { - hOgg = mpt::Library(mpt::LibraryPath::AppFullName(Ogg_fn)); - if(!hOgg.IsValid()) + Reset(); + ClearBindFailed(); + if(!AddLibrary("ogg", mpt::LibraryPath::AppFullName(Ogg_fn))) { - if(hOgg.IsValid()) { hOgg.Unload(); } - if(hOpus.IsValid()) { hOpus.Unload(); } + Reset(); return false; } - hOpus = mpt::Library(mpt::LibraryPath::AppFullName(Opus_fn)); - if(!hOpus.IsValid()) + if(!AddLibrary("opus", mpt::LibraryPath::AppFullName(Opus_fn))) { - if(hOgg.IsValid()) { hOgg.Unload(); } - if(hOpus.IsValid()) { hOpus.Unload(); } + Reset(); return false; } - bool ok = true; - #define OPUS_BIND(l,f,req) do { \ - if(!l.Bind( f , #f ) && req) \ - { \ - ok = false; \ - } \ - } while(0) - OPUS_BIND(hOgg,ogg_stream_init,true); - OPUS_BIND(hOgg,ogg_stream_packetin,true); - OPUS_BIND(hOgg,ogg_stream_flush,true); - OPUS_BIND(hOgg,ogg_stream_pageout,true); - OPUS_BIND(hOgg,ogg_stream_clear,true); - OPUS_BIND(hOpus,opus_get_version_string,false); - OPUS_BIND(hOpus,opus_multistream_encoder_ctl,true); - OPUS_BIND(hOpus,opus_multistream_encode_float,true); - OPUS_BIND(hOpus,opus_multistream_encoder_destroy,true); - OPUS_BIND(hOpus,opus_multistream_encoder_create,true); - OPUS_BIND(hOpus,opus_multistream_surround_encoder_create,false); - #undef OPUS_BIND - if(!ok) + MPT_COMPONENT_BIND("ogg", ogg_stream_init); + MPT_COMPONENT_BIND("ogg", ogg_stream_packetin); + MPT_COMPONENT_BIND("ogg", ogg_stream_flush); + MPT_COMPONENT_BIND("ogg", ogg_stream_pageout); + MPT_COMPONENT_BIND("ogg", ogg_stream_clear); + MPT_COMPONENT_BIND_OPTIONAL("opus", opus_get_version_string); + MPT_COMPONENT_BIND("opus", opus_multistream_encoder_ctl); + MPT_COMPONENT_BIND("opus", opus_multistream_encode_float); + MPT_COMPONENT_BIND("opus", opus_multistream_encoder_destroy); + MPT_COMPONENT_BIND("opus", opus_multistream_encoder_create); + MPT_COMPONENT_BIND_OPTIONAL("opus", opus_multistream_surround_encoder_create); + if(HasBindFailed()) { - if(hOgg.IsValid()) { hOgg.Unload(); } - if(hOpus.IsValid()) { hOpus.Unload(); } Reset(); return false; } return true; } - operator bool () const { return hOgg.IsValid() && hOpus.IsValid(); } - ~OpusDynBind() - { - if(hOgg.IsValid()) { hOgg.Unload(); } - if(hOpus.IsValid()) { hOpus.Unload(); } - Reset(); - } + +public: + Encoder::Traits BuildTraits() { Encoder::Traits traits; - if(!*this) + if(!IsAvailable()) { return traits; } @@ -170,14 +176,16 @@ traits.defaultBitrate = 128; return traits; } + }; +MPT_REGISTERED_COMPONENT(ComponentOpus) class OpusStreamWriter : public StreamWriterBase { private: - OpusDynBind &opus; + ComponentOpus &opus; ogg_stream_state os; ogg_page og; ogg_packet op; @@ -330,7 +338,7 @@ } } public: - OpusStreamWriter(OpusDynBind &opus_, std::ostream &stream) + OpusStreamWriter(ComponentOpus &opus_, std::ostream &stream) : StreamWriterBase(stream) , opus(opus_) { @@ -555,10 +563,9 @@ OggOpusEncoder::OggOpusEncoder() //------------------------------ - : m_Opus(nullptr) { - m_Opus = new OpusDynBind(); - if(*m_Opus) + m_Opus = MPT_GET_COMPONENT(ComponentOpus); + if(IsComponentAvailable(m_Opus)) { SetTraits(m_Opus->BuildTraits()); } @@ -568,18 +575,14 @@ bool OggOpusEncoder::IsAvailable() const //-------------------------------------- { - return m_Opus && *m_Opus; + return IsComponentAvailable(m_Opus); } OggOpusEncoder::~OggOpusEncoder() //------------------------------- { - if(m_Opus) - { - delete m_Opus; - m_Opus = nullptr; - } + return; } Modified: trunk/OpenMPT/mptrack/StreamEncoderOpus.h =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderOpus.h 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/mptrack/StreamEncoderOpus.h 2014-10-22 10:36:01 UTC (rev 4461) @@ -16,14 +16,14 @@ OPENMPT_NAMESPACE_BEGIN -struct OpusDynBind; +class ComponentOpus; class OggOpusEncoder : public EncoderFactoryBase { private: - OpusDynBind *m_Opus; + MPT_SHARED_PTR<ComponentOpus> m_Opus; public: Modified: trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp 2014-10-22 10:32:52 UTC (rev 4460) +++ trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp 2014-10-22 10:36:01 UTC (rev 4461) @@ -13,6 +13,8 @@ #include "StreamEncoder.h" #include "StreamEncoderVorbis.h" +#include "../common/ComponentManager.h" + #include "Mptrack.h" #include <vorbis/vorbisenc.h> @@ -23,12 +25,11 @@ -struct VorbisDynBind +class ComponentVorbis + : public ComponentBase { - mpt::Library hOgg; - mpt::Library hVorbis; - mpt::Library hVorbisEnc; +public: // ogg int (*ogg_stream_init)(ogg_stream_state *os,int serialno); @@ -61,11 +62,26 @@ int (*vorbis_encode_init)(vorbis_info *vi, long channels, long rate, long max_bitrate, long nominal_bitrate, long min_bitrate); int (*vorbis_encode_init_vbr)(vorbis_info *vi, long channels, long rate, float base_quality); +private: + void Reset() { + ClearLibraries(); + } + +public: + + ComponentVorbis() + : ComponentBase(ComponentTypeForeign, false) + { return; } - VorbisDynBind() + + std::string GetSettingsKey() const { return "Vorbis"; } + +protected: + + bool DoInitialize() { Reset(); struct dll_names_t { @@ -85,100 +101,75 @@ { "libogg-0" , "libvorbis-0", "libvorbisenc-0"}, // mingw builds { "libogg-0" , "libvorbis-0", "libvorbisenc-2"} // mingw 64-bit builds }; + bool ok = false; for(std::size_t i=0; i<CountOf(dll_names); ++i) { if(TryLoad(mpt::PathString::FromUTF8(dll_names[i].ogg), mpt::PathString::FromUTF8(dll_names[i].vorbis), mpt::PathString::FromUTF8(dll_names[i].vorbisenc))) { - // success + ok = true; break; } } + return ok; } bool TryLoad(const mpt::PathString &Ogg_fn, const mpt::PathString &Vorbis_fn, const mpt::PathString &VorbisEnc_fn) { - hOgg = mpt::Library(mpt::LibraryPath::AppFullName(Ogg_fn)); - if(!hOgg.IsValid()) + Reset(); + ClearBindFailed(); + if(!AddLibrary("ogg", mpt::LibraryPath::AppFullName(Ogg_fn))) { - if(hOgg.IsValid()) { hOgg.Unload(); } - if(hVorbis.IsValid()) { hVorbis.Unload(); } - if(hVorbisEnc.IsValid()) { hVorbisEnc.Unload(); } + Reset(); return false; } - hVorbis = mpt::Library(mpt::LibraryPath::AppFullName(Vorbis_fn)); - if(!hVorbis.IsValid()) + if(!AddLibrary("vorbis", mpt::LibraryPath::App... [truncated message content] |
From: <man...@us...> - 2014-10-23 09:41:29
|
Revision: 4471 http://sourceforge.net/p/modplug/code/4471 Author: manxorist Date: 2014-10-23 09:41:22 +0000 (Thu, 23 Oct 2014) Log Message: ----------- [Ref] test: Do not build the libopenmpt public interface into the libopenmpt test suite when building with Makefile. Modified Paths: -------------- trunk/OpenMPT/Makefile trunk/OpenMPT/libopenmpt/libopenmpt_test.cpp Modified: trunk/OpenMPT/Makefile =================================================================== --- trunk/OpenMPT/Makefile 2014-10-23 09:12:11 UTC (rev 4470) +++ trunk/OpenMPT/Makefile 2014-10-23 09:41:22 UTC (rev 4471) @@ -398,7 +398,6 @@ LIBOPENMPT_CXX_SOURCES += \ $(SOUNDLIB_CXX_SOURCES) \ - $(wildcard test/*.cpp) \ libopenmpt/libopenmpt_c.cpp \ libopenmpt/libopenmpt_cxx.cpp \ libopenmpt/libopenmpt_impl.cpp \ @@ -442,9 +441,13 @@ LIBOPENMPTTEST_CXX_SOURCES += \ libopenmpt/libopenmpt_test.cpp \ + $(SOUNDLIB_CXX_SOURCES) \ + $(wildcard test/*.cpp) \ -LIBOPENMPTTEST_CXX_SOURCES += $(LIBOPENMPT_CXX_SOURCES) -LIBOPENMPTTEST_C_SOURCES += $(LIBOPENMPT_C_SOURCES) +ifeq ($(NO_ZLIB),1) +LIBOPENMPTTEST_C_SOURCES += include/miniz/miniz.c +endif + LIBOPENMPTTEST_OBJECTS = $(LIBOPENMPTTEST_CXX_SOURCES:.cpp=.test.o) $(LIBOPENMPTTEST_C_SOURCES:.c=.test.o) LIBOPENMPTTEST_DEPENDS = $(LIBOPENMPTTEST_CXX_SOURCES:.cpp=.test.d) $(LIBOPENMPTTEST_C_SOURCES:.c=.test.d) ALL_OBJECTS += $(LIBOPENMPTTEST_OBJECTS) Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_test.cpp 2014-10-23 09:12:11 UTC (rev 4470) +++ trunk/OpenMPT/libopenmpt/libopenmpt_test.cpp 2014-10-23 09:41:22 UTC (rev 4471) @@ -10,11 +10,10 @@ #include "BuildSettings.h" #include "libopenmpt_internal.h" -#include "libopenmpt.hpp" -#include "libopenmpt.h" #include "test/test.h" +#include <iostream> #include <locale> #include <clocale> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-23 19:50:18
|
Revision: 4478 http://sourceforge.net/p/modplug/code/4478 Author: manxorist Date: 2014-10-23 19:50:04 +0000 (Thu, 23 Oct 2014) Log Message: ----------- [New] build: Add ANCIENT=1 option to Makefile that adds support for older pre-C++0x GCC versions. Modified Paths: -------------- trunk/OpenMPT/Makefile trunk/OpenMPT/build/make/Makefile.config.gcc Modified: trunk/OpenMPT/Makefile =================================================================== --- trunk/OpenMPT/Makefile 2014-10-23 19:41:50 UTC (rev 4477) +++ trunk/OpenMPT/Makefile 2014-10-23 19:50:04 UTC (rev 4478) @@ -46,6 +46,7 @@ # OPTIMIZE=1 Build optimized binaries # TEST=1 Include test suite in default target. # ONLY_TEST=0 Only build the test suite. +# ANCIENT=0 Use a pre-C++0x compiler (i.e. GCC before 4.3) # # # Build flags for libopenmpt (provide on each `make` invocation) @@ -127,6 +128,7 @@ OPTIMIZE=1 TEST=1 ONLY_TEST=0 +ANCIENT=0 SOSUFFIX=.so Modified: trunk/OpenMPT/build/make/Makefile.config.gcc =================================================================== --- trunk/OpenMPT/build/make/Makefile.config.gcc 2014-10-23 19:41:50 UTC (rev 4477) +++ trunk/OpenMPT/build/make/Makefile.config.gcc 2014-10-23 19:50:04 UTC (rev 4478) @@ -4,12 +4,21 @@ LD = g++ AR = ar +ifeq ($(ANCIENT),1) CPPFLAGS += +CXXFLAGS += -std=gnu++98 -fPIC +CFLAGS += -std=c99 -fPIC +LDFLAGS += +LDLIBS += -lm +ARFLAGS := rcs +else +CPPFLAGS += CXXFLAGS += -std=c++0x -fPIC CFLAGS += -std=c99 -fPIC LDFLAGS += LDLIBS += -lm ARFLAGS := rcs +endif EXESUFFIX= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-25 01:52:02
|
Revision: 4481 http://sourceforge.net/p/modplug/code/4481 Author: saga-games Date: 2014-10-25 01:51:48 +0000 (Sat, 25 Oct 2014) Log Message: ----------- [Ref] Instead of checking for MPT_FILEREADER_STD_ISTREAM at every site, use the new mpt::IO::Open to wrap stream vs memory-mapped file open calls for FileReader. Modified Paths: -------------- trunk/OpenMPT/common/mptIO.cpp trunk/OpenMPT/common/mptIO.h trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp Modified: trunk/OpenMPT/common/mptIO.cpp =================================================================== --- trunk/OpenMPT/common/mptIO.cpp 2014-10-24 09:34:51 UTC (rev 4480) +++ trunk/OpenMPT/common/mptIO.cpp 2014-10-25 01:51:48 UTC (rev 4481) @@ -22,6 +22,10 @@ #include <stdio.h> +#include "../soundlib/FileReader.h" +#ifndef MPT_FILEREADER_STD_ISTREAM +#include "../mptrack/MemoryMappedFile.h" +#endif OPENMPT_NAMESPACE_BEGIN @@ -30,7 +34,23 @@ namespace IO { +FileReader Open(const mpt::PathString &filename) +{ +#ifdef MPT_FILEREADER_STD_ISTREAM + mpt::ifstream f(filename, std::ios_base::binary); + if(f.good()) + return (&f, &filename); + else + return FileReader(); +#else + CMappedFile f; + if(f.Open(filename)) + return f.GetFile(); + else + return FileReader(); +#endif +} //STATIC_ASSERT(sizeof(std::streamoff) == 8); // Assert 64bit file support. bool IsValid(std::ostream & f) { return !f.fail(); } Modified: trunk/OpenMPT/common/mptIO.h =================================================================== --- trunk/OpenMPT/common/mptIO.h 2014-10-24 09:34:51 UTC (rev 4480) +++ trunk/OpenMPT/common/mptIO.h 2014-10-25 01:51:48 UTC (rev 4481) @@ -31,9 +31,12 @@ OPENMPT_NAMESPACE_BEGIN +class FileReader; namespace mpt { +class PathString; + namespace IO { typedef int64 Offset; @@ -47,8 +50,9 @@ return (static_cast<IO::Offset>(mpt::saturate_cast<Toff>(off)) == off); } +// Open a file (either stream or memory-mapped, depending on program configuration) and immediately return FileReader for the file +FileReader Open(const mpt::PathString &filename); - bool IsValid(std::ostream & f); bool IsValid(std::istream & f); bool IsValid(std::iostream & f); @@ -194,7 +198,7 @@ { byte = 0; if(!IO::ReadIntLE<uint8>(f, byte)) result = false; - v |= (static_cast<uint16>(byte) << (((i+1)*8) - 1)); + v |= (static_cast<uint16>(byte) << (((i+1)*8) - 1)); } return result; } @@ -214,7 +218,7 @@ { byte = 0; if(!IO::ReadIntLE<uint8>(f, byte)) result = false; - v |= (static_cast<uint32>(byte) << (((i+1)*8) - 2)); + v |= (static_cast<uint32>(byte) << (((i+1)*8) - 2)); } return result; } @@ -234,7 +238,7 @@ { byte = 0; if(!IO::ReadIntLE<uint8>(f, byte)) result = false; - v |= (static_cast<uint64>(byte) << (((i+1)*8) - 2)); + v |= (static_cast<uint64>(byte) << (((i+1)*8) - 2)); } return result; } @@ -262,7 +266,7 @@ } str.push_back(c); } - return true; + return true; } @@ -549,7 +553,7 @@ }; -#endif +#endif class FileDataContainerMemory @@ -631,4 +635,4 @@ -OPENMPT_NAMESPACE_END +OPENMPT_NAMESPACE_END \ No newline at end of file Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-24 09:34:51 UTC (rev 4480) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-25 01:51:48 UTC (rev 4481) @@ -20,9 +20,6 @@ #include "ITTools.h" #ifdef MODPLUG_TRACKER #include "../mptrack/TrackerSettings.h" -#if !defined(MPT_FILEREADER_STD_ISTREAM) -#include "../mptrack/MemoryMappedFile.h" -#endif #ifndef MODPLUG_NO_FILESAVE #include "../common/mptFstream.h" #endif @@ -263,18 +260,7 @@ { if(m_szInstrumentPath[ins].empty()) continue; -#if defined(MPT_FILEREADER_STD_ISTREAM) - mpt::ifstream f(m_szInstrumentPath[ins], std::ios_base::binary); - if(!f.good()) - continue; - FileReader file(&f, &m_szInstrumentPath[ins]); -#else - CMappedFile f; - if(!f.Open(m_szInstrumentPath[ins])) - continue; - FileReader file = f.GetFile(); -#endif - + FileReader file(mpt::IO::Open(m_szInstrumentPath[ins])); if(file.IsValid()) ReadInstrumentFromFile(ins + 1, file, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); } Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-24 09:34:51 UTC (rev 4480) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-25 01:51:48 UTC (rev 4481) @@ -12,12 +12,6 @@ #include "stdafx.h" #include "Loaders.h" #ifdef MODPLUG_TRACKER -// For loading external samples -#if defined(MPT_FILEREADER_STD_ISTREAM) -#include "../common/mptFstream.h" -#else -#include "../mptrack/MemoryMappedFile.h" -#endif #include "../mptrack/Moddoc.h" #endif @@ -1081,16 +1075,7 @@ path = path.RelativePathToAbsolute(mt2FileName.GetPath()); } -#if defined(MPT_FILEREADER_STD_ISTREAM) - mpt::ifstream f(path, std::ios_base::binary); - if(f.good()) - sampleFile = FileReader(&f, &path); -#else - CMappedFile f; - FileReader sampleFile; - if(f.Open(path)) - sampleFile = f.GetFile(); -#endif + FileReader sampleFile(mpt::IO::Open(path)); if(sampleFile.IsValid()) ReadSampleFromFile(i + 1, sampleFile, false); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-25 08:27:24
|
Revision: 4485 http://sourceforge.net/p/modplug/code/4485 Author: manxorist Date: 2014-10-25 08:27:16 +0000 (Sat, 25 Oct 2014) Log Message: ----------- [Fix] Revert r4481-r4484: class FileReader does not own the file contents it corresponds to. mpt::IO::Open introduces use-after-free for the whole file contents, either by referencing an on stack std::ifstream or by referencing already-unmapped file data in case of MemoryMappedFile. Revision Links: -------------- http://sourceforge.net/p/modplug/code/4481 http://sourceforge.net/p/modplug/code/4484 Modified Paths: -------------- trunk/OpenMPT/common/mptIO.cpp trunk/OpenMPT/common/mptIO.h trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp Modified: trunk/OpenMPT/common/mptIO.cpp =================================================================== --- trunk/OpenMPT/common/mptIO.cpp 2014-10-25 02:17:50 UTC (rev 4484) +++ trunk/OpenMPT/common/mptIO.cpp 2014-10-25 08:27:16 UTC (rev 4485) @@ -22,14 +22,6 @@ #include <stdio.h> -#ifdef MPT_WITH_PATHSTRING -#include "../soundlib/FileReader.h" -#ifdef MPT_FILEREADER_STD_ISTREAM -#include "mptFstream.h" -#else -#include "../mptrack/MemoryMappedFile.h" -#endif // MPT_FILEREADER_STD_ISTREAM -#endif // MPT_WITH_PATHSTRING OPENMPT_NAMESPACE_BEGIN @@ -38,31 +30,8 @@ namespace IO { -#ifdef MPT_WITH_PATHSTRING -FileReader Open(const mpt::PathString &filename) -{ -#ifdef MPT_FILEREADER_STD_ISTREAM - mpt::ifstream f(filename, std::ios_base::binary); - if(f.good()) -#ifdef MODPLUG_TRACKER - return FileReader(&f, &filename); -#else - return FileReader(&f); -#endif // MODPLUG_TRACKER - else - return FileReader(); -#else - CMappedFile f; - if(f.Open(filename)) - return f.GetFile(); - else - return FileReader(); -#endif // MPT_FILEREADER_STD_ISTREAM -} -#endif // MPT_WITH_PATHSTRING - //STATIC_ASSERT(sizeof(std::streamoff) == 8); // Assert 64bit file support. bool IsValid(std::ostream & f) { return !f.fail(); } bool IsValid(std::istream & f) { return !f.fail(); } Modified: trunk/OpenMPT/common/mptIO.h =================================================================== --- trunk/OpenMPT/common/mptIO.h 2014-10-25 02:17:50 UTC (rev 4484) +++ trunk/OpenMPT/common/mptIO.h 2014-10-25 08:27:16 UTC (rev 4485) @@ -31,12 +31,9 @@ OPENMPT_NAMESPACE_BEGIN -class FileReader; namespace mpt { -class PathString; - namespace IO { typedef int64 Offset; @@ -50,11 +47,8 @@ return (static_cast<IO::Offset>(mpt::saturate_cast<Toff>(off)) == off); } -#ifdef MPT_WITH_PATHSTRING -// Open a file (either stream or memory-mapped, depending on program configuration) and immediately return FileReader for the file -FileReader Open(const mpt::PathString &filename); -#endif // MPT_WITH_PATHSTRING + bool IsValid(std::ostream & f); bool IsValid(std::istream & f); bool IsValid(std::iostream & f); @@ -200,7 +194,7 @@ { byte = 0; if(!IO::ReadIntLE<uint8>(f, byte)) result = false; - v |= (static_cast<uint16>(byte) << (((i+1)*8) - 1)); + v |= (static_cast<uint16>(byte) << (((i+1)*8) - 1)); } return result; } @@ -220,7 +214,7 @@ { byte = 0; if(!IO::ReadIntLE<uint8>(f, byte)) result = false; - v |= (static_cast<uint32>(byte) << (((i+1)*8) - 2)); + v |= (static_cast<uint32>(byte) << (((i+1)*8) - 2)); } return result; } @@ -240,7 +234,7 @@ { byte = 0; if(!IO::ReadIntLE<uint8>(f, byte)) result = false; - v |= (static_cast<uint64>(byte) << (((i+1)*8) - 2)); + v |= (static_cast<uint64>(byte) << (((i+1)*8) - 2)); } return result; } @@ -268,7 +262,7 @@ } str.push_back(c); } - return true; + return true; } @@ -555,7 +549,7 @@ }; -#endif +#endif class FileDataContainerMemory @@ -637,4 +631,4 @@ -OPENMPT_NAMESPACE_END \ No newline at end of file +OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-25 02:17:50 UTC (rev 4484) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-25 08:27:16 UTC (rev 4485) @@ -20,6 +20,9 @@ #include "ITTools.h" #ifdef MODPLUG_TRACKER #include "../mptrack/TrackerSettings.h" +#if !defined(MPT_FILEREADER_STD_ISTREAM) +#include "../mptrack/MemoryMappedFile.h" +#endif #ifndef MODPLUG_NO_FILESAVE #include "../common/mptFstream.h" #endif @@ -260,7 +263,18 @@ { if(m_szInstrumentPath[ins].empty()) continue; - FileReader file(mpt::IO::Open(m_szInstrumentPath[ins])); +#if defined(MPT_FILEREADER_STD_ISTREAM) + mpt::ifstream f(m_szInstrumentPath[ins], std::ios_base::binary); + if(!f.good()) + continue; + FileReader file(&f, &m_szInstrumentPath[ins]); +#else + CMappedFile f; + if(!f.Open(m_szInstrumentPath[ins])) + continue; + FileReader file = f.GetFile(); +#endif + if(file.IsValid()) ReadInstrumentFromFile(ins + 1, file, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); } Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-25 02:17:50 UTC (rev 4484) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-25 08:27:16 UTC (rev 4485) @@ -12,6 +12,12 @@ #include "stdafx.h" #include "Loaders.h" #ifdef MODPLUG_TRACKER +// For loading external samples +#if defined(MPT_FILEREADER_STD_ISTREAM) +#include "../common/mptFstream.h" +#else +#include "../mptrack/MemoryMappedFile.h" +#endif #include "../mptrack/Moddoc.h" #endif @@ -1075,7 +1081,16 @@ path = path.RelativePathToAbsolute(mt2FileName.GetPath()); } - FileReader sampleFile(mpt::IO::Open(path)); +#if defined(MPT_FILEREADER_STD_ISTREAM) + mpt::ifstream f(path, std::ios_base::binary); + if(f.good()) + sampleFile = FileReader(&f, &path); +#else + CMappedFile f; + FileReader sampleFile; + if(f.Open(path)) + sampleFile = f.GetFile(); +#endif if(sampleFile.IsValid()) ReadSampleFromFile(i + 1, sampleFile, false); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-25 11:44:09
|
Revision: 4486 http://sourceforge.net/p/modplug/code/4486 Author: saga-games Date: 2014-10-25 11:43:51 +0000 (Sat, 25 Oct 2014) Log Message: ----------- [Ref] Add a union for 8-bit and 16-bit sample pointer in ModSample to avoid casts in many parts of the program. Modified Paths: -------------- trunk/OpenMPT/mptrack/Autotune.cpp trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Undo.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/ITCompression.cpp trunk/OpenMPT/soundlib/ITCompression.h trunk/OpenMPT/soundlib/Load_dbm.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/ModSample.h trunk/OpenMPT/soundlib/SampleFormatConverters.h trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/SampleIO.cpp trunk/OpenMPT/soundlib/modsmp_ctrl.cpp trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/mptrack/Autotune.cpp =================================================================== --- trunk/OpenMPT/mptrack/Autotune.cpp 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/mptrack/Autotune.cpp 2014-10-25 11:43:51 UTC (rev 4486) @@ -131,11 +131,11 @@ switch(sample.GetElementarySampleSize()) { case 1: - CopySamples(static_cast<int8 *>(sample.pSample) + sampleOffset * sample.GetNumChannels(), sampleLoopStart, sampleLoopEnd); + CopySamples(sample.pSample8 + sampleOffset * sample.GetNumChannels(), sampleLoopStart, sampleLoopEnd); return true; case 2: - CopySamples(static_cast<int16 *>(sample.pSample) + sampleOffset * sample.GetNumChannels(), sampleLoopStart, sampleLoopEnd); + CopySamples(sample.pSample16 + sampleOffset * sample.GetNumChannels(), sampleLoopStart, sampleLoopEnd); return true; } Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2014-10-25 11:43:51 UTC (rev 4486) @@ -536,13 +536,12 @@ // Check if the stereo channels of a sample contain identical data template<typename T> -static bool ComapreStereoChannels(SmpLength length, const void *sampleData) -//-------------------------------------------------------- +static bool ComapreStereoChannels(SmpLength length, const T *sampleData) +//---------------------------------------------------------------------- { - const T *data = static_cast<const T *>(sampleData); - for(SmpLength i = 0; i < length; i++, data += 2) + for(SmpLength i = 0; i < length; i++, sampleData += 2) { - if(data[0] != data[1]) + if(sampleData[0] != sampleData[1]) { return false; } @@ -580,10 +579,10 @@ bool identicalChannels = false; if(sample.GetElementarySampleSize() == 1) { - identicalChannels = ComapreStereoChannels<int8>(loopLength, sample.pSample); + identicalChannels = ComapreStereoChannels(loopLength, sample.pSample8); } else if(sample.GetElementarySampleSize() == 2) { - identicalChannels = ComapreStereoChannels<int16>(loopLength, sample.pSample); + identicalChannels = ComapreStereoChannels(loopLength, sample.pSample16); } if(identicalChannels) { Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-10-25 11:43:51 UTC (rev 4486) @@ -1216,7 +1216,7 @@ if(sample.uFlags[CHN_16BIT]) { - int16 *p = (int16 *)sample.pSample; + int16 *p = sample.pSample16; int max = 1; for (SmpLength i = selStart; i < selEnd; i++) { @@ -1235,7 +1235,7 @@ } } else { - int8 *p = (int8 *)sample.pSample; + int8 *p = sample.pSample8; int max = 1; for (SmpLength i = selStart; i < selEnd; i++) { @@ -1272,20 +1272,20 @@ template<typename T> -void ApplyAmplifyImpl(void *pSample, SmpLength start, SmpLength end, int32 amp, bool fadeIn, bool fadeOut) -//-------------------------------------------------------------------------------------------------------- +void ApplyAmplifyImpl(T *pSample, SmpLength start, SmpLength end, int32 amp, bool fadeIn, bool fadeOut) +//----------------------------------------------------------------------------------------------------- { - T *p = static_cast<T *>(pSample) + start; + pSample += start; SmpLength len = end - start; int64 l64 = static_cast<int64>(len); for(SmpLength i = 0; i < len; i++) { - int32 l = (p[i] * amp) / 100; + int32 l = (pSample[i] * amp) / 100; if(fadeIn) l = (int32)((l * (int64)i) / l64); if(fadeOut) l = (int32)((l * (int64)(len - i)) / l64); Limit(l, std::numeric_limits<T>::min(), std::numeric_limits<T>::max()); - p[i] = static_cast<T>(l); + pSample[i] = static_cast<T>(l); } } @@ -1306,10 +1306,10 @@ if ((fadeIn) && (fadeOut)) lAmp *= 4; if (sample.uFlags[CHN_16BIT]) { - ApplyAmplifyImpl<int16>(sample.pSample, selection.nStart, selection.nEnd, lAmp, fadeIn, fadeOut); + ApplyAmplifyImpl<int16>(sample.pSample16, selection.nStart, selection.nEnd, lAmp, fadeIn, fadeOut); } else { - ApplyAmplifyImpl<int8>(sample.pSample, selection.nStart, selection.nEnd, lAmp, fadeIn, fadeOut); + ApplyAmplifyImpl<int8>(sample.pSample8, selection.nStart, selection.nEnd, lAmp, fadeIn, fadeOut); } sample.PrecomputeLoops(m_sndFile, false); SetModified(HINT_SAMPLEDATA, false); @@ -1488,12 +1488,12 @@ switch(sample.GetElementarySampleSize()) { case 1: - firstVal = SC::Convert<double, int8>()(static_cast<const int8 *>(sample.pSample)[readOffset]); - lastVal = SC::Convert<double, int8>()(static_cast<const int8 *>(sample.pSample)[readOffset + selLength - numChannels]); + firstVal = SC::Convert<double, int8>()(sample.pSample8[readOffset]); + lastVal = SC::Convert<double, int8>()(sample.pSample8[readOffset + selLength - numChannels]); break; case 2: - firstVal = SC::Convert<double, int16>()(static_cast<const int16 *>(sample.pSample)[readOffset]); - lastVal = SC::Convert<double, int16>()(static_cast<const int16 *>(sample.pSample)[readOffset + selLength - numChannels]); + firstVal = SC::Convert<double, int16>()(sample.pSample16[readOffset]); + lastVal = SC::Convert<double, int16>()(sample.pSample16[readOffset + selLength - numChannels]); break; default: // When higher bit depth is added, feel free to also replace CDSPResampler16 by CDSPResampler24 above. @@ -1520,10 +1520,10 @@ switch(sample.GetElementarySampleSize()) { case 1: - CopySample<SC::ConversionChain<SC::Convert<double, int8>, SC::DecodeIdentity<int8> > >(&convBuffer[0], smpCount, 1, static_cast<const int8 *>(sample.pSample) + readOffset, sample.GetSampleSizeInBytes(), sample.GetNumChannels()); + CopySample<SC::ConversionChain<SC::Convert<double, int8>, SC::DecodeIdentity<int8> > >(&convBuffer[0], smpCount, 1, sample.pSample8 + readOffset, sample.GetSampleSizeInBytes(), sample.GetNumChannels()); break; case 2: - CopySample<SC::ConversionChain<SC::Convert<double, int16>, SC::DecodeIdentity<int16> > >(&convBuffer[0], smpCount, 1, static_cast<const int16 *>(sample.pSample) + readOffset, sample.GetSampleSizeInBytes(), sample.GetNumChannels()); + CopySample<SC::ConversionChain<SC::Convert<double, int16>, SC::DecodeIdentity<int16> > >(&convBuffer[0], smpCount, 1, sample.pSample16 + readOffset, sample.GetSampleSizeInBytes(), sample.GetNumChannels()); break; } readOffset += smpCount * numChannels; @@ -1933,10 +1933,10 @@ switch(smpsize) { case 1: - CopyInterleavedSampleStreams(&(buffer[0]), static_cast<int8 *>(sample.pSample) + inPos * nChn, inChunkSize, nChn, conv8f32); + CopyInterleavedSampleStreams(&(buffer[0]), sample.pSample8 + inPos * nChn, inChunkSize, nChn, conv8f32); break; case 2: - CopyInterleavedSampleStreams(&(buffer[0]), static_cast<int16 *>(sample.pSample) + inPos * nChn, inChunkSize, nChn, convf32); + CopyInterleavedSampleStreams(&(buffer[0]), sample.pSample16 + inPos * nChn, inChunkSize, nChn, convf32); break; } soundtouch_putSamples(handleSt, &(buffer[0]), inChunkSize); @@ -2115,7 +2115,7 @@ } // Convert current channel's data chunk to float - int8 *ptr = (int8 *)sample.pSample + pos * smpsize * nChn + i * smpsize; + int8 *ptr = sample.pSample8 + pos * smpsize * nChn + i * smpsize; switch(smpsize) { @@ -2134,7 +2134,7 @@ smbPitchShift(pitch, static_cast<long>(len + finaloffset), fft, ovs, sampleRate, buffer, buffer); // Restore pitched-shifted float sample into original sample buffer - ptr = (int8 *)sample.pSample + (pos - inneroffset) * smpsize * nChn + i * smpsize; + ptr = sample.pSample8 + (pos - inneroffset) * smpsize * nChn + i * smpsize; const SmpLength copyLength = len + finaloffset - startoffset + 1; switch(smpsize) @@ -2251,12 +2251,11 @@ if (sample.uFlags[CHN_STEREO]) { int smplsize = sample.GetBytesPerSample(); - signed char *p = ((signed char *)sample.pSample) + selection.nStart * smplsize; - memset(p, 0, len * smplsize); + memset(sample.pSample8 + selection.nStart * smplsize, 0, len * smplsize); } else if (sample.uFlags[CHN_16BIT]) { - short int *p = ((short int *)sample.pSample) + selection.nStart; + int16 *p = sample.pSample16 + selection.nStart; int dest = (selection.nEnd < sample.nLength) ? p[len-1] : 0; int base = (selection.nStart) ? p[0] : 0; int delta = dest - base; @@ -2267,7 +2266,7 @@ } } else { - signed char *p = ((signed char *)sample.pSample) + selection.nStart; + int8 *p = sample.pSample8 + selection.nStart; int dest = (selection.nEnd < sample.nLength) ? p[len-1] : 0; int base = (selection.nStart) ? p[0] : 0; int delta = dest - base; Modified: trunk/OpenMPT/mptrack/Undo.cpp =================================================================== --- trunk/OpenMPT/mptrack/Undo.cpp 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/mptrack/Undo.cpp 2014-10-25 11:43:51 UTC (rev 4486) @@ -380,7 +380,7 @@ undo.samplePtr = ModSample::AllocateSample(changeLen, bytesPerSample); if(undo.samplePtr == nullptr) return false; - memcpy(undo.samplePtr, static_cast<const char *>(oldSample.pSample) + changeStart * bytesPerSample, changeLen * bytesPerSample); + memcpy(undo.samplePtr, oldSample.pSample8 + changeStart * bytesPerSample, changeLen * bytesPerSample); #ifdef _DEBUG char s[64]; @@ -442,8 +442,8 @@ PrepareBuffer(toBuf, smp, redoType, undo.description, undo.changeStart, undo.changeEnd); ModSample &sample = sndFile.GetSample(smp); - char *pCurrentSample = static_cast<char *>(sample.pSample); - char *pNewSample = nullptr; // a new sample is possibly going to be allocated, depending on what's going to be undone. + int8 *pCurrentSample = sample.pSample8; + int8 *pNewSample = nullptr; // a new sample is possibly going to be allocated, depending on what's going to be undone. bool replace = false; uint8 bytesPerSample = undo.OldSample.GetBytesPerSample(); @@ -485,7 +485,7 @@ case sundo_delete: // insert deleted data - pNewSample = static_cast<char *>(ModSample::AllocateSample(undo.OldSample.nLength, bytesPerSample)); + pNewSample = static_cast<int8 *>(ModSample::AllocateSample(undo.OldSample.nLength, bytesPerSample)); if(pNewSample == nullptr) return false; replace = true; memcpy(pNewSample, pCurrentSample, undo.changeStart * bytesPerSample); @@ -495,7 +495,7 @@ case sundo_replace: // simply exchange sample pointer - pNewSample = static_cast<char *>(undo.samplePtr); + pNewSample = static_cast<int8 *>(undo.samplePtr); undo.samplePtr = nullptr; // prevent sample from being deleted replace = true; break; Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2014-10-25 11:43:51 UTC (rev 4486) @@ -1129,7 +1129,7 @@ { // Draw sample data in 1:1 ratio or higher (zoom in) SmpLength len = sample.nLength - nSmpScrollPos; - signed char *psample = ((signed char *)sample.pSample) + nSmpScrollPos * smplsize; + int8 *psample = sample.pSample8 + nSmpScrollPos * smplsize; if (sample.uFlags[CHN_STEREO]) { DrawSampleData1(offScreenDC, ymed-yrange/2, rect.right, yrange, len, sample.uFlags, psample); @@ -1148,7 +1148,7 @@ xscroll = nSmpScrollPos; len -= nSmpScrollPos; } - signed char *psample = ((signed char *)sample.pSample) + xscroll * smplsize; + int8 *psample = sample.pSample8 + xscroll * smplsize; if (sample.uFlags[CHN_STEREO]) { DrawSampleData2(offScreenDC, ymed-yrange/2, rect.right, yrange, len, sample.uFlags, psample); @@ -2016,8 +2016,7 @@ const SmpLength smpEnd = sample.nLength * sample.GetBytesPerSample(); sample.nLength -= (m_dwEndSel - m_dwBeginSel); - int8 *p = static_cast<int8 *>(sample.pSample); - memmove(p + selStart, p + selEnd, smpEnd - selEnd); + memmove(sample.pSample8 + selStart, sample.pSample8 + selEnd, smpEnd - selEnd); // adjust loop points AdjustLoopPoints(sample.nLoopStart, sample.nLoopEnd, sample.nLength); @@ -2110,7 +2109,7 @@ file.StartChunk(RIFFChunk::iddata); uint8 *sampleData = static_cast<uint8 *>(p) + file.GetPosition(); - memcpy(sampleData, static_cast<const char *>(sample.pSample) + smpOffset, smpSize); + memcpy(sampleData, sample.pSample8 + smpOffset, smpSize); if(sample.GetElementarySampleSize() == 1) { // 8-Bit samples have to be unsigned. @@ -2222,7 +2221,7 @@ CriticalSection cs; - int8 *p = (int8 *)(sample.pSample); + int8 *p = sample.pSample8; SmpLength len = (sample.nLength + 1) * sample.GetNumChannels(); for (SmpLength i=0; i<=len; i++) { @@ -2260,9 +2259,8 @@ int16 *newSample = static_cast<int16 *>(ModSample::AllocateSample(numSamples, 2)); if(newSample != nullptr) { - const int8 *oldSample = static_cast<const int8 *>(sample.pSample); pModDoc->GetSampleUndo().PrepareUndo(m_nSample, sundo_replace, "16-Bit Conversion"); - CopySample<SC::ConversionChain<SC::Convert<int16, int8>, SC::DecodeIdentity<int8> > >(newSample, numSamples, 1, oldSample, sample.GetSampleSizeInBytes(), 1); + CopySample<SC::ConversionChain<SC::Convert<int16, int8>, SC::DecodeIdentity<int8> > >(newSample, numSamples, 1, sample.pSample8, sample.GetSampleSizeInBytes(), 1); sample.uFlags.set(CHN_16BIT); ctrlSmp::ReplaceSample(sample, newSample, sample.nLength, sndFile); sample.PrecomputeLoops(sndFile, false); @@ -2377,8 +2375,7 @@ CriticalSection cs; // Note: Sample is overwritten in-place! Unused data is not deallocated! - int8 *p = static_cast<int8 *>(sample.pSample); - memmove(p, p + nStart * sample.GetBytesPerSample(), nEnd * sample.GetBytesPerSample()); + memmove(sample.pSample8, sample.pSample8 + nStart * sample.GetBytesPerSample(), nEnd * sample.GetBytesPerSample()); if (sample.nLoopStart >= nStart) sample.nLoopStart -= nStart; if (sample.nLoopEnd >= nStart) sample.nLoopEnd -= nStart; Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-10-25 11:43:51 UTC (rev 4486) @@ -1572,7 +1572,7 @@ SampleIO::signedPCM) .ReadSample(sample, chunk); } - bWaveForm = (sample.pSample) ? true : false; + bWaveForm = sample.pSample != nullptr; } else { FileReader file(pWaveForm, dwLen); Modified: trunk/OpenMPT/soundlib/ITCompression.cpp =================================================================== --- trunk/OpenMPT/soundlib/ITCompression.cpp 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/soundlib/ITCompression.cpp 2014-10-25 11:43:51 UTC (rev 4486) @@ -75,9 +75,9 @@ byteVal = 0; if(mptSample.GetElementarySampleSize() > 1) - Compress<IT16BitParams>(static_cast<const int16 *>(sample.pSample) + chn, offset, remain); + Compress<IT16BitParams>(sample.pSample16 + chn, offset, remain); else - Compress<IT8BitParams>(static_cast<const int8 *>(sample.pSample) + chn, offset, remain); + Compress<IT8BitParams>(sample.pSample8 + chn, offset, remain); if(file) mpt::IO::WriteRaw(*file, &packedData[0], packedLength); packedTotalLength += packedLength; @@ -330,17 +330,17 @@ mem1 = mem2 = 0; if(mptSample.GetElementarySampleSize() > 1) - Uncompress<IT16BitParams>(static_cast<int16 *>(mptSample.pSample) + chn); + Uncompress<IT16BitParams>(mptSample.pSample16 + chn); else - Uncompress<IT8BitParams>(static_cast<int8 *>(mptSample.pSample) + chn); + Uncompress<IT8BitParams>(mptSample.pSample8 + chn); } } } template<typename Properties> -void ITDecompression::Uncompress(void *target) -//-------------------------------------------- +void ITDecompression::Uncompress(typename Properties::sample_t *target) +//--------------------------------------------------------------------- { curLength = std::min(mptSample.nLength - writtenSamples, SmpLength(ITCompression::blockSize / sizeof(typename Properties::sample_t))); @@ -422,14 +422,14 @@ template<typename Properties> -void ITDecompression::Write(int v, int topBit, void *target) -//---------------------------------------------------------- +void ITDecompression::Write(int v, int topBit, typename Properties::sample_t *target) +//----------------------------------------------------------------------------------- { if(v & topBit) v -= (topBit << 1); mem1 += v; mem2 += mem1; - static_cast<typename Properties::sample_t *>(target)[writePos] = static_cast<typename Properties::sample_t>(is215 ? (int)mem2 : (int)mem1); + target[writePos] = static_cast<typename Properties::sample_t>(is215 ? (int)mem2 : (int)mem1); writtenSamples++; writePos += mptSample.GetNumChannels(); curLength--; Modified: trunk/OpenMPT/soundlib/ITCompression.h =================================================================== --- trunk/OpenMPT/soundlib/ITCompression.h 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/soundlib/ITCompression.h 2014-10-25 11:43:51 UTC (rev 4486) @@ -93,12 +93,12 @@ bool is215; // Use IT2.15 compression (double deltas) template<typename Properties> - void Uncompress(void *target); + void Uncompress(typename Properties::sample_t *target); static void ChangeWidth(int &curWidth, int width); int ReadBits(int width); template<typename Properties> - void Write(int v, int topbit, void *target); + void Write(int v, int topbit, typename Properties::sample_t *target); }; Modified: trunk/OpenMPT/soundlib/Load_dbm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_dbm.cpp 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/soundlib/Load_dbm.cpp 2014-10-25 11:43:51 UTC (rev 4486) @@ -567,7 +567,7 @@ if(ReadMP3Sample(0, chunk)) { ModSample &srcSample = Samples[0]; - const uint8 *smpData = static_cast<uint8 *>(srcSample.pSample); + const int8 *smpData = srcSample.pSample8; for(SAMPLEINDEX smp = 1; smp <= GetNumSamples(); smp++) { Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-25 11:43:51 UTC (rev 4486) @@ -1589,7 +1589,7 @@ fseek(f, smppos[nsmp - 1], SEEK_SET); fwrite(&itss, 1, sizeof(ITSample), f); fseek(f, dwPos, SEEK_SET); - if ((Samples[nsmp].pSample) && (Samples[nsmp].nLength)) + if (Samples[nsmp].HasSampleData()) { dwPos += itss.GetSampleFormat().WriteSample(f, Samples[nsmp]); } Modified: trunk/OpenMPT/soundlib/ModSample.h =================================================================== --- trunk/OpenMPT/soundlib/ModSample.h 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/soundlib/ModSample.h 2014-10-25 11:43:51 UTC (rev 4486) @@ -20,7 +20,12 @@ SmpLength nLength; // In samples, not bytes SmpLength nLoopStart, nLoopEnd; // Dito SmpLength nSustainStart, nSustainEnd; // Dito - void *pSample; // Pointer to sample data + union + { + void *pSample; // Pointer to sample data + int8 *pSample8; // Pointer to 8-bit sample data + int16 *pSample16; // Pointer to 16-bit sample data + }; uint32 nC5Speed; // Frequency of middle-C, in Hz (for IT/S3M/MPTM) uint16 nPan; // Default sample panning (if pan flag is set), 0...256 uint16 nVolume; // Default volume, 0...256 @@ -41,6 +46,8 @@ Initialize(type); } + bool HasSampleData() const { return pSample != nullptr && nLength != 0; } + // Return the size of one (elementary) sample in bytes. uint8 GetElementarySampleSize() const { return (uFlags & CHN_16BIT) ? 2 : 1; } Modified: trunk/OpenMPT/soundlib/SampleFormatConverters.h =================================================================== --- trunk/OpenMPT/soundlib/SampleFormatConverters.h 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/soundlib/SampleFormatConverters.h 2014-10-25 11:43:51 UTC (rev 4486) @@ -803,7 +803,7 @@ size_t numFrames = countFrames; SampleConversion sampleConv(conv); const char * MPT_RESTRICT inBuf = sourceBuffer; - typename SampleConversion::output_t * MPT_RESTRICT outBuf = reinterpret_cast<typename SampleConversion::output_t *>(sample.pSample); + typename SampleConversion::output_t * MPT_RESTRICT outBuf = static_cast<typename SampleConversion::output_t *>(sample.pSample); while(numFrames--) { *outBuf = sampleConv(inBuf); @@ -828,7 +828,7 @@ SampleConversion sampleConvLeft(conv); SampleConversion sampleConvRight(conv); const char * MPT_RESTRICT inBuf = sourceBuffer; - typename SampleConversion::output_t * MPT_RESTRICT outBuf = reinterpret_cast<typename SampleConversion::output_t *>(sample.pSample); + typename SampleConversion::output_t * MPT_RESTRICT outBuf = static_cast<typename SampleConversion::output_t *>(sample.pSample); while(numFrames--) { *outBuf = sampleConvLeft(inBuf); @@ -859,7 +859,7 @@ size_t numSamplesLeft = countSamplesLeft; SampleConversion sampleConvLeft(conv); const char * MPT_RESTRICT inBufLeft = sourceBuffer; - typename SampleConversion::output_t * MPT_RESTRICT outBufLeft = reinterpret_cast<typename SampleConversion::output_t *>(sample.pSample); + typename SampleConversion::output_t * MPT_RESTRICT outBufLeft = static_cast<typename SampleConversion::output_t *>(sample.pSample); while(numSamplesLeft--) { *outBufLeft = sampleConvLeft(inBufLeft); @@ -870,7 +870,7 @@ size_t numSamplesRight = countSamplesRight; SampleConversion sampleConvRight(conv); const char * MPT_RESTRICT inBufRight = sourceBuffer + sample.nLength * SampleConversion::input_inc; - typename SampleConversion::output_t * MPT_RESTRICT outBufRight = reinterpret_cast<typename SampleConversion::output_t *>(sample.pSample) + 1; + typename SampleConversion::output_t * MPT_RESTRICT outBufRight = static_cast<typename SampleConversion::output_t *>(sample.pSample) + 1; while(numSamplesRight--) { *outBufRight = sampleConvRight(inBufRight); Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-10-25 11:43:51 UTC (rev 4486) @@ -376,7 +376,7 @@ { return false; } - IMAADPCMUnpack16((int16 *)sample.pSample, sample.nLength, FileReader(sampleChunk.GetRawData(), sampleChunk.BytesLeft()), wavFile.GetBlockAlign()); + IMAADPCMUnpack16(sample.pSample16, sample.nLength, FileReader(sampleChunk.GetRawData(), sampleChunk.BytesLeft()), wavFile.GetBlockAlign()); sample.PrecomputeLoops(*this, false); } else if(wavFile.GetSampleFormat() == WAVFormatChunk::fmtMP3) { @@ -1948,8 +1948,8 @@ // Source bit depth const unsigned int bps = frame->header.bits_per_sample; - int8 *sampleData8 = static_cast<int8 *>(sample.pSample) + offset; - int16 *sampleData16 = static_cast<int16 *>(sample.pSample) + offset; + int8 *sampleData8 = sample.pSample8 + offset; + int16 *sampleData16 = sample.pSample16 + offset; MPT_ASSERT((bps <= 8 && sample.GetElementarySampleSize() == 1) || (bps > 8 && sample.GetElementarySampleSize() == 2)); MPT_ASSERT(modChannels <= FLAC__stream_decoder_get_channels(decoder)); @@ -2084,12 +2084,11 @@ #ifndef NO_FLAC // Helper function for copying OpenMPT's sample data to FLAC's int32 buffer. template<typename T> -inline static void SampleToFLAC32(FLAC__int32 *dst, const void *src, SmpLength numSamples) +inline static void SampleToFLAC32(FLAC__int32 *dst, const T *src, SmpLength numSamples) { - const T *in = reinterpret_cast<const T *>(src); for(SmpLength i = 0; i < numSamples; i++) { - dst[i] = in[i]; + dst[i] = src[i]; } }; @@ -2227,10 +2226,10 @@ if(sample.GetElementarySampleSize() == 1) { - SampleToFLAC32<int8>(sampleData, sample.pSample, numSamples); + SampleToFLAC32(sampleData, sample.pSample8, numSamples); } else if(sample.GetElementarySampleSize() == 2) { - SampleToFLAC32<int16>(sampleData, sample.pSample, numSamples); + SampleToFLAC32(sampleData, sample.pSample16, numSamples); } else { MPT_ASSERT(false); Modified: trunk/OpenMPT/soundlib/SampleIO.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleIO.cpp 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/soundlib/SampleIO.cpp 2014-10-25 11:43:51 UTC (rev 4486) @@ -468,7 +468,7 @@ LimitMax(readLength, file.BytesLeft()); const uint8 *inBuf = reinterpret_cast<const uint8*>(sourceBuf) + sizeof(compressionTable); - int8 *outBuf = static_cast<int8 *>(sample.pSample); + int8 *outBuf = sample.pSample8; int8 delta = 0; for(size_t i = readLength; i != 0; i--) @@ -511,8 +511,6 @@ { uint32 bitBuf = file.ReadUint32LE(), bitNum = 32; - uint8 *outBuf8 = static_cast<uint8 *>(sample.pSample); - uint16 *outBuf16 = static_cast<uint16 *>(sample.pSample); const uint8 *inBuf = reinterpret_cast<const uint8*>(sourceBuf) + 4; uint8 dlt = 0, lowbyte = 0; @@ -538,10 +536,10 @@ dlt += hibyte; if(GetBitDepth() != 16) { - outBuf8[j] = dlt; + sample.pSample8[j] = dlt; } else { - outBuf16[j] = lowbyte | (dlt << 8); + sample.pSample16[j] = lowbyte | (dlt << 8); } } @@ -562,17 +560,15 @@ // MT2 stereo samples (right channel is stored as a difference from the left channel) if(GetBitDepth() == 8) { - int8 *outBuf = static_cast<int8 *>(sample.pSample); for(SmpLength i = 0; i <= sample.nLength * 2; i += 2) { - outBuf[i + 1] += outBuf[i]; + sample.pSample8[i + 1] += sample.pSample8[i]; } } else { - int16 *outBuf = static_cast<int16 *>(sample.pSample); for(SmpLength i = 0; i <= sample.nLength * 2; i += 2) { - outBuf[i + 1] += outBuf[i]; + sample.pSample16[i + 1] += sample.pSample16[i]; } } } @@ -600,13 +596,13 @@ size_t len = 0, bufcount = 0; int8 buffer8[4096]; int16 buffer16[4096]; - const void *const pSampleVoid = (const void *)sample.pSample; - const int8 *const pSample8 = (const int8 *)sample.pSample; - const int16 *const pSample16 = (const int16 *)sample.pSample; + const void *const pSampleVoid = sample.pSample; + const int8 *const pSample8 = sample.pSample8; + const int16 *const pSample16 = sample.pSample16; SmpLength numSamples = sample.nLength; if(maxSamples && numSamples > maxSamples) numSamples = maxSamples; - if(sample.pSample == nullptr || numSamples == 0) return 0; + if(!sample.HasSampleData()) return 0; if(GetBitDepth() == 16 && GetChannelFormat() == mono && GetEndianness() == littleEndian && (GetEncoding() == signedPCM || GetEncoding() == unsignedPCM || GetEncoding() == deltaPCM)) Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.cpp =================================================================== --- trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2014-10-25 11:43:51 UTC (rev 4486) @@ -284,7 +284,7 @@ bool UpdateLoopPoints(const ModSample &smp, CSoundFile &sndFile) //-------------------------------------------------------------- { - if(!smp.nLength || !smp.pSample) + if(!smp.HasSampleData()) return false; CriticalSection cs; @@ -448,7 +448,7 @@ CSoundFile &sndFile) //--------------------------------------- { - if(smp.pSample == nullptr || smp.nLength < 1) + if(!smp.HasSampleData()) return 0; if (iEnd > smp.nLength) iEnd = smp.nLength; @@ -467,9 +467,9 @@ // step 1: Calculate offset. OffsetData oData = {0,0,0}; if(smp.GetElementarySampleSize() == 2) - oData = CalculateOffset(static_cast<int16 *>(smp.pSample) + iStart, iEnd - iStart); + oData = CalculateOffset(smp.pSample16 + iStart, iEnd - iStart); else if(smp.GetElementarySampleSize() == 1) - oData = CalculateOffset(static_cast<int8*>(smp.pSample) + iStart, iEnd - iStart); + oData = CalculateOffset(smp.pSample8 + iStart, iEnd - iStart); double dMin = oData.dMin, dMax = oData.dMax, dOffset = oData.dOffset; @@ -488,9 +488,9 @@ // step 2: centralize + normalize sample dOffset *= dMaxAmplitude * dAmplify; if(smp.GetElementarySampleSize() == 2) - RemoveOffsetAndNormalize( static_cast<int16 *>(smp.pSample) + iStart, iEnd - iStart, dOffset, dAmplify); + RemoveOffsetAndNormalize(smp.pSample16 + iStart, iEnd - iStart, dOffset, dAmplify); else if(smp.GetElementarySampleSize() == 1) - RemoveOffsetAndNormalize( static_cast<int8 *>(smp.pSample) + iStart, iEnd - iStart, dOffset, dAmplify); + RemoveOffsetAndNormalize(smp.pSample8 + iStart, iEnd - iStart, dOffset, dAmplify); // step 3: adjust global vol (if available) if((modtype & (MOD_TYPE_IT | MOD_TYPE_MPT)) && (iStart == 0) && (iEnd == smp.nLength * smp.GetNumChannels())) @@ -531,7 +531,7 @@ bool ReverseSample(ModSample &smp, SmpLength iStart, SmpLength iEnd, CSoundFile &sndFile) //--------------------------------------------------------------------------------------- { - if(smp.pSample == nullptr) return false; + if(!smp.HasSampleData()) return false; if(iEnd == 0 || iStart > smp.nLength || iEnd > smp.nLength) { iStart = 0; @@ -544,9 +544,9 @@ if(smp.GetBytesPerSample() == 4) // 16 bit stereo ReverseSampleImpl(static_cast<int32 *>(smp.pSample) + iStart, iEnd - iStart); else if(smp.GetBytesPerSample() == 2) // 16 bit mono / 8 bit stereo - ReverseSampleImpl(static_cast<int16 *>(smp.pSample) + iStart, iEnd - iStart); + ReverseSampleImpl(smp.pSample16 + iStart, iEnd - iStart); else if(smp.GetBytesPerSample() == 1) // 8 bit mono - ReverseSampleImpl(static_cast<int8 *>(smp.pSample) + iStart, iEnd - iStart); + ReverseSampleImpl(smp.pSample8 + iStart, iEnd - iStart); else return false; @@ -570,7 +570,7 @@ bool UnsignSample(ModSample &smp, SmpLength iStart, SmpLength iEnd, CSoundFile &sndFile) //-------------------------------------------------------------------------------------- { - if(smp.pSample == nullptr) return false; + if(!smp.HasSampleData()) return false; if(iEnd == 0 || iStart > smp.nLength || iEnd > smp.nLength) { iStart = 0; @@ -579,9 +579,9 @@ iStart *= smp.GetNumChannels(); iEnd *= smp.GetNumChannels(); if(smp.GetElementarySampleSize() == 2) - UnsignSampleImpl(static_cast<int16 *>(smp.pSample) + iStart, iEnd - iStart); + UnsignSampleImpl(smp.pSample16 + iStart, iEnd - iStart); else if(smp.GetElementarySampleSize() == 1) - UnsignSampleImpl(static_cast<int8 *>(smp.pSample) + iStart, iEnd - iStart); + UnsignSampleImpl(smp.pSample8 + iStart, iEnd - iStart); else return false; @@ -604,7 +604,7 @@ bool InvertSample(ModSample &smp, SmpLength iStart, SmpLength iEnd, CSoundFile &sndFile) //-------------------------------------------------------------------------------------- { - if(smp.pSample == nullptr) return false; + if(!smp.HasSampleData()) return false; if(iEnd == 0 || iStart > smp.nLength || iEnd > smp.nLength) { iStart = 0; @@ -613,9 +613,9 @@ iStart *= smp.GetNumChannels(); iEnd *= smp.GetNumChannels(); if(smp.GetElementarySampleSize() == 2) - InvertSampleImpl(static_cast<int16 *>(smp.pSample) + iStart, iEnd - iStart); + InvertSampleImpl(smp.pSample16 + iStart, iEnd - iStart); else if(smp.GetElementarySampleSize() == 1) - InvertSampleImpl(static_cast<int8 *>(smp.pSample) + iStart, iEnd - iStart); + InvertSampleImpl(smp.pSample8 + iStart, iEnd - iStart); else return false; @@ -639,7 +639,7 @@ bool XFadeSample(ModSample &smp, SmpLength iFadeLength, CSoundFile &sndFile) //-------------------------------------------------------------------------- { - if(smp.pSample == nullptr) return false; + if(!smp.HasSampleData()) return false; if(smp.nLoopEnd <= smp.nLoopStart || smp.nLoopEnd > smp.nLength) return false; if(smp.nLoopStart < iFadeLength) return false; @@ -650,9 +650,9 @@ iFadeLength *= smp.GetNumChannels(); if(smp.GetElementarySampleSize() == 2) - XFadeSampleImpl(static_cast<int16 *>(smp.pSample) + iStart, iEnd - iStart, iFadeLength); + XFadeSampleImpl(smp.pSample16 + iStart, iEnd - iStart, iFadeLength); else if(smp.GetElementarySampleSize() == 1) - XFadeSampleImpl(static_cast<int8 *>(smp.pSample) + iStart, iEnd - iStart, iFadeLength); + XFadeSampleImpl(smp.pSample8 + iStart, iEnd - iStart, iFadeLength); else return false; @@ -689,15 +689,15 @@ bool ConvertToMono(ModSample &smp, CSoundFile &sndFile, StereoToMonoMode conversionMode) //-------------------------------------------------------------------------------------- { - if(smp.pSample == nullptr || smp.nLength == 0 || smp.GetNumChannels() != 2) return false; + if(!smp.HasSampleData() || smp.GetNumChannels() != 2) return false; // Note: Sample is overwritten in-place! Unused data is not deallocated! if(conversionMode == mixChannels) { if(smp.GetElementarySampleSize() == 2) - ConvertStereoToMonoMixImpl(static_cast<int16 *>(smp.pSample), smp.nLength); + ConvertStereoToMonoMixImpl(smp.pSample16, smp.nLength); else if(smp.GetElementarySampleSize() == 1) - ConvertStereoToMonoMixImpl(static_cast<int8 *>(smp.pSample), smp.nLength); + ConvertStereoToMonoMixImpl(smp.pSample8, smp.nLength); else return false; } else @@ -707,9 +707,9 @@ conversionMode = onlyLeft; } if(smp.GetElementarySampleSize() == 2) - ConvertStereoToMonoOneChannelImpl(static_cast<int16 *>(smp.pSample) + (conversionMode == onlyLeft ? 0 : 1), smp.nLength); + ConvertStereoToMonoOneChannelImpl(smp.pSample16 + (conversionMode == onlyLeft ? 0 : 1), smp.nLength); else if(smp.GetElementarySampleSize() == 1) - ConvertStereoToMonoOneChannelImpl(static_cast<int8 *>(smp.pSample) + (conversionMode == onlyLeft ? 0 : 1), smp.nLength); + ConvertStereoToMonoOneChannelImpl(smp.pSample8 + (conversionMode == onlyLeft ? 0 : 1), smp.nLength); else return false; } Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2014-10-25 08:27:16 UTC (rev 4485) +++ trunk/OpenMPT/test/test.cpp 2014-10-25 11:43:51 UTC (rev 4486) @@ -1094,14 +1094,13 @@ VERIFY_EQUAL_NONCONT(sample.nVibDepth, 5); // Sample Data - const int8 *p8 = static_cast<const int8 *>(sample.pSample); for(size_t i = 0; i < 6; i++) { - VERIFY_EQUAL_NONCONT(p8[i], 18); + VERIFY_EQUAL_NONCONT(sample.pSample8[i], 18); } for(size_t i = 6; i < 16; i++) { - VERIFY_EQUAL_NONCONT(p8[i], 0); + VERIFY_EQUAL_NONCONT(sample.pSample8[i], 0); } // Instruments @@ -1307,14 +1306,13 @@ VERIFY_EQUAL_NONCONT(sample.nVibDepth, 5); // Sample Data - const int8 *p8 = static_cast<const int8 *>(sample.pSample); for(size_t i = 0; i < 6; i++) { - VERIFY_EQUAL_NONCONT(p8[i], 18); + VERIFY_EQUAL_NONCONT(sample.pSample8[i], 18); } for(size_t i = 6; i < 16; i++) { - VERIFY_EQUAL_NONCONT(p8[i], 0); + VERIFY_EQUAL_NONCONT(sample.pSample8[i], 0); } } @@ -1331,7 +1329,7 @@ // Sample Data (Stereo Interleaved) for(size_t i = 0; i < 7; i++) { - VERIFY_EQUAL_NONCONT(static_cast<int16 *>(sample.pSample)[4 + i], int16(-32768)); + VERIFY_EQUAL_NONCONT(sample.pSample16[4 + i], int16(-32768)); } } @@ -1530,14 +1528,13 @@ VERIFY_EQUAL_NONCONT(sample.nLoopEnd, 60); // Sample Data - const int8 *p8 = static_cast<const int8 *>(sample.pSample); for(size_t i = 0; i < 30; i++) { - VERIFY_EQUAL_NONCONT(p8[i], 127); + VERIFY_EQUAL_NONCONT(sample.pSample8[i], 127); } for(size_t i = 31; i < 60; i++) { - VERIFY_EQUAL_NONCONT(p8[i], -128); + VERIFY_EQUAL_NONCONT(sample.pSample8[i], -128); } } @@ -1566,7 +1563,7 @@ // Sample Data (Stereo Interleaved) for(size_t i = 0; i < 7; i++) { - VERIFY_EQUAL_NONCONT(static_cast<int16 *>(sample.pSample)[4 + i], int16(-32768)); + VERIFY_EQUAL_NONCONT(sample.pSample16[4 + i], int16(-32768)); } } @@ -2352,7 +2349,7 @@ for(size_t i = 0; i < 65536; i++) { - VERIFY_EQUAL_QUIET_NONCONT(static_cast<const int16 *>(sample.pSample)[i], static_cast<int16>(i)); + VERIFY_EQUAL_QUIET_NONCONT(sample.pSample16[i], static_cast<int16>(i)); VERIFY_EQUAL_QUIET_NONCONT(truncated16[i], static_cast<int16>(i)); } } @@ -2380,7 +2377,7 @@ for(size_t i = 0; i < 65536; i++) { - VERIFY_EQUAL_QUIET_NONCONT(static_cast<const int16 *>(sample.pSample)[i], static_cast<int16>(i - 0x8000u)); + VERIFY_EQUAL_QUIET_NONCONT(sample.pSample16[i], static_cast<int16>(i - 0x8000u)); if(abs(truncated16[i] - static_cast<int16>((i - 0x8000u) / 2)) > 1) { VERIFY_EQUAL_QUIET_NONCONT(true, false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-25 12:47:56
|
Revision: 4487 http://sourceforge.net/p/modplug/code/4487 Author: manxorist Date: 2014-10-25 12:47:41 +0000 (Sat, 25 Oct 2014) Log Message: ----------- [Ref] Move CMappedFile to mptFstream.h. [Ref] Add class Inputfile that wraps the differences of using either mpt::ifstream or CMappedFile. [Ref] Convert CMappedFile::GetFile() to GetFileReader(CMappedFile&) or GetFileReader(InputFile&). [Ref] Note: Work left to do (not done here in order to separate functional refactoring from moving files around): common/mptFstream.h should be renamed to commmon/mptFileIO.h. common/mptFileIO.cpp and soundlib/FileReader.cpp should be introduced. mptrack/MemoryMappedFile.* should be deleted. Modified Paths: -------------- trunk/OpenMPT/common/mptFstream.h trunk/OpenMPT/common/mptIO.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/MemoryMappedFile.cpp trunk/OpenMPT/mptrack/MemoryMappedFile.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/soundlib/FileReader.h trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/common/mptFstream.h =================================================================== --- trunk/OpenMPT/common/mptFstream.h 2014-10-25 11:43:51 UTC (rev 4486) +++ trunk/OpenMPT/common/mptFstream.h 2014-10-25 12:47:41 UTC (rev 4487) @@ -18,6 +18,7 @@ #include "../common/mptPathString.h" #if defined(MPT_WITH_PATHSTRING) #include "../common/mptIO.h" +#include <utility> #endif @@ -489,6 +490,64 @@ } // namespace mpt + +#ifdef MODPLUG_TRACKER +//=============== +class CMappedFile +//=============== +{ +protected: + HANDLE m_hFile; + HANDLE m_hFMap; + void *m_pData; + mpt::PathString m_FileName; + +public: + CMappedFile() : m_hFile(nullptr), m_hFMap(nullptr), m_pData(nullptr) { } + ~CMappedFile(); + +public: + bool Open(const mpt::PathString &filename); + bool IsOpen() const { return m_hFile != NULL && m_hFile != INVALID_HANDLE_VALUE; } + const mpt::PathString * GetpFilename() const { return &m_FileName; } + void Close(); + size_t GetLength(); + const void *Lock(); +}; +#endif // MODPLUG_TRACKER + + +//============= +class InputFile +//============= +{ +private: + mpt::PathString m_Filename; + #ifdef MPT_FILEREADER_STD_ISTREAM + mpt::ifstream m_File; + #else + CMappedFile m_File; + #endif +public: + InputFile(); + InputFile(const mpt::PathString &filename); + ~InputFile(); + bool Open(const mpt::PathString &filename); + bool IsValid() const; +#if defined(MPT_FILEREADER_STD_ISTREAM) + typedef std::pair<std::istream*, const mpt::PathString*> ContentsRef; +#else + struct Data + { + const char *data; + std::size_t size; + }; + typedef std::pair<InputFile::Data, const mpt::PathString*> ContentsRef; +#endif + InputFile::ContentsRef Get(); +}; + + #endif // MPT_WITH_PATHSTRING Modified: trunk/OpenMPT/common/mptIO.cpp =================================================================== --- trunk/OpenMPT/common/mptIO.cpp 2014-10-25 11:43:51 UTC (rev 4486) +++ trunk/OpenMPT/common/mptIO.cpp 2014-10-25 12:47:41 UTC (rev 4487) @@ -255,3 +255,219 @@ OPENMPT_NAMESPACE_END + + +// following ode should be moved to common/mptFileIO.cpp and common/mptFstream.h should be renamed to common/mptFileIO.h. + +#include "mptFstream.h" + + +OPENMPT_NAMESPACE_BEGIN + + +#ifdef MODPLUG_TRACKER + +CMappedFile::~CMappedFile() +//------------------------- +{ + Close(); +} + + +bool CMappedFile::Open(const mpt::PathString &filename) +//----------------------------------------------------- +{ + m_hFile = CreateFileW( + filename.AsNative().c_str(), + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if(m_hFile == INVALID_HANDLE_VALUE) + { + m_hFile = nullptr; + return false; + } + m_FileName = filename; + return true; +} + + +void CMappedFile::Close() +//----------------------- +{ + m_FileName = mpt::PathString(); + // Unlock file + if(m_hFMap) + { + if(m_pData) + { + UnmapViewOfFile(m_pData); + m_pData = nullptr; + } + CloseHandle(m_hFMap); + m_hFMap = nullptr; + } else if(m_pData) + { + free(m_pData); + m_pData = nullptr; + } + + // Close file handle + if(m_hFile) + { + CloseHandle(m_hFile); + m_hFile = nullptr; + } +} + + +size_t CMappedFile::GetLength() +//----------------------------- +{ + LARGE_INTEGER size; + if(GetFileSizeEx(m_hFile, &size) == FALSE) + { + return 0; + } + return mpt::saturate_cast<size_t>(size.QuadPart); +} + + +const void *CMappedFile::Lock() +//----------------------------- +{ + size_t length = GetLength(); + if(!length) return nullptr; + + void *lpStream; + + HANDLE hmf = CreateFileMapping( + m_hFile, + NULL, + PAGE_READONLY, + 0, 0, + NULL); + + // Try memory-mapping first + if(hmf) + { + lpStream = MapViewOfFile( + hmf, + FILE_MAP_READ, + 0, 0, + length); + if(lpStream) + { + m_hFMap = hmf; + m_pData = lpStream; + return lpStream; + } + CloseHandle(hmf); + hmf = nullptr; + } + + // Fallback if memory-mapping fails for some weird reason + if((lpStream = malloc(length)) == nullptr) return nullptr; + memset(lpStream, 0, length); + size_t bytesToRead = length; + size_t bytesRead = 0; + while(bytesToRead > 0) + { + DWORD chunkToRead = mpt::saturate_cast<DWORD>(length); + DWORD chunkRead = 0; + if(ReadFile(m_hFile, (char*)lpStream + bytesRead, chunkToRead, &chunkRead, NULL) == FALSE) + { + // error + free(lpStream); + return nullptr; + } + bytesRead += chunkRead; + bytesToRead -= chunkRead; + } + m_pData = lpStream; + return lpStream; +} + + +#endif // MODPLUG_TRACKER + + + +InputFile::InputFile() +{ + return; +} + +InputFile::InputFile(const mpt::PathString &filename) + : m_Filename(filename) +{ + #if defined(MPT_FILEREADER_STD_ISTREAM) + m_File.open(m_Filename, std::ios::binary | std::ios::in); + #else + m_File.Open(m_Filename); + #endif +} + +InputFile::~InputFile() +{ + return; +} + + +bool InputFile::Open(const mpt::PathString &filename) +{ + m_Filename = filename; + #if defined(MPT_FILEREADER_STD_ISTREAM) + m_File.open(m_Filename, std::ios::binary | std::ios::in); + return m_File.good(); + #else + return m_File.Open(m_Filename); + #endif +} + + +bool InputFile::IsValid() const +{ + #if defined(MPT_FILEREADER_STD_ISTREAM) + return m_File.good(); + #else + return m_File.IsOpen(); + #endif +} + +#if defined(MPT_FILEREADER_STD_ISTREAM) + +InputFile::ContentsRef InputFile::Get() +{ + InputFile::ContentsRef result; + result.first = &m_File; + result.second = m_File.good() ? &m_Filename : nullptr; + return result; +} + +#else + +InputFile::ContentsRef InputFile::Get() +{ + InputFile::ContentsRef result; + result.first.data = nullptr; + result.first.size = 0; + result.second = nullptr; + if(!m_File.IsOpen()) + { + return result; + } + result.first.data = reinterpret_cast<const char*>(m_File.Lock()); + result.first.size = m_File.GetLength(); + result.second = &m_Filename; + return result; +} + +#endif + + + +OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-10-25 11:43:51 UTC (rev 4486) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-10-25 12:47:41 UTC (rev 4487) @@ -1433,7 +1433,7 @@ } bFirst = FALSE; - FileReader file = f.GetFile(); + FileReader file = GetFileReader(f); bOk = FALSE; if (file.IsValid()) Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-10-25 11:43:51 UTC (rev 4486) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-10-25 12:47:41 UTC (rev 4487) @@ -786,7 +786,7 @@ return false; } - FileReader file = f.GetFile(); + FileReader file = GetFileReader(f); if(!file.IsValid()) { EndWaitCursor(); Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-10-25 11:43:51 UTC (rev 4486) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-10-25 12:47:41 UTC (rev 4487) @@ -1528,7 +1528,7 @@ if(f.Open(filename)) { - FileReader file = f.GetFile(); + FileReader file = GetFileReader(f); if(file.IsValid()) { InitPreview(); Modified: trunk/OpenMPT/mptrack/MemoryMappedFile.cpp =================================================================== --- trunk/OpenMPT/mptrack/MemoryMappedFile.cpp 2014-10-25 11:43:51 UTC (rev 4486) +++ trunk/OpenMPT/mptrack/MemoryMappedFile.cpp 2014-10-25 12:47:41 UTC (rev 4487) @@ -15,136 +15,6 @@ OPENMPT_NAMESPACE_BEGIN -CMappedFile::~CMappedFile() -//------------------------- -{ - Close(); -} -bool CMappedFile::Open(const mpt::PathString &filename) -//----------------------------------------------------- -{ - m_hFile = CreateFileW( - filename.AsNative().c_str(), - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - if(m_hFile == INVALID_HANDLE_VALUE) - { - m_hFile = nullptr; - return false; - } - m_FileName = filename; - return true; -} - - -void CMappedFile::Close() -//----------------------- -{ - m_FileName = mpt::PathString(); - // Unlock file - if(m_hFMap) - { - if(m_pData) - { - UnmapViewOfFile(m_pData); - m_pData = nullptr; - } - CloseHandle(m_hFMap); - m_hFMap = nullptr; - } else if(m_pData) - { - free(m_pData); - m_pData = nullptr; - } - - // Close file handle - if(m_hFile) - { - CloseHandle(m_hFile); - m_hFile = nullptr; - } -} - - -size_t CMappedFile::GetLength() -//----------------------------- -{ - LARGE_INTEGER size; - if(GetFileSizeEx(m_hFile, &size) == FALSE) - { - return 0; - } - return mpt::saturate_cast<size_t>(size.QuadPart); -} - - -const void *CMappedFile::Lock() -//----------------------------- -{ - size_t length = GetLength(); - if(!length) return nullptr; - - void *lpStream; - - HANDLE hmf = CreateFileMapping( - m_hFile, - NULL, - PAGE_READONLY, - 0, 0, - NULL); - - // Try memory-mapping first - if(hmf) - { - lpStream = MapViewOfFile( - hmf, - FILE_MAP_READ, - 0, 0, - length); - if(lpStream) - { - m_hFMap = hmf; - m_pData = lpStream; - return lpStream; - } - CloseHandle(hmf); - hmf = nullptr; - } - - // Fallback if memory-mapping fails for some weird reason - if((lpStream = malloc(length)) == nullptr) return nullptr; - memset(lpStream, 0, length); - size_t bytesToRead = length; - size_t bytesRead = 0; - while(bytesToRead > 0) - { - DWORD chunkToRead = mpt::saturate_cast<DWORD>(length); - DWORD chunkRead = 0; - if(ReadFile(m_hFile, (char*)lpStream + bytesRead, chunkToRead, &chunkRead, NULL) == FALSE) - { - // error - free(lpStream); - return nullptr; - } - bytesRead += chunkRead; - bytesToRead -= chunkRead; - } - m_pData = lpStream; - return lpStream; -} - - -FileReader CMappedFile::GetFile() -//------------------------------- -{ - return FileReader(Lock(), GetLength(), &m_FileName); -} - - OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/mptrack/MemoryMappedFile.h =================================================================== --- trunk/OpenMPT/mptrack/MemoryMappedFile.h 2014-10-25 11:43:51 UTC (rev 4486) +++ trunk/OpenMPT/mptrack/MemoryMappedFile.h 2014-10-25 12:47:41 UTC (rev 4487) @@ -11,32 +11,8 @@ #pragma once #include "../soundlib/FileReader.h" +#include "../common/mptFstream.h" OPENMPT_NAMESPACE_BEGIN -////////////////////////////////////////////////////////////////// -// File Mapping Class - -//=============== -class CMappedFile -//=============== -{ -protected: - HANDLE m_hFile; - HANDLE m_hFMap; - void *m_pData; - mpt::PathString m_FileName; - -public: - CMappedFile() : m_hFile(nullptr), m_hFMap(nullptr), m_pData(nullptr) { } - ~CMappedFile(); - -public: - bool Open(const mpt::PathString &filename); - void Close(); - size_t GetLength(); - const void *Lock(); - FileReader GetFile(); -}; - OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-10-25 11:43:51 UTC (rev 4486) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-10-25 12:47:41 UTC (rev 4487) @@ -219,25 +219,16 @@ if(filename.empty()) return OnNewDocument(); BeginWaitCursor(); - #if defined(MPT_FILEREADER_STD_ISTREAM) - mpt::ifstream f(filename, std::ios_base::binary); - m_SndFile.Create(FileReader(&f, &filename), CSoundFile::loadCompleteModule, this); - #else + + InputFile f(filename); + if(f.IsValid()) { - CMappedFile f; - if (f.Open(filename)) - { - FileReader file = f.GetFile(); - if(file.IsValid()) - { - ASSERT(GetPathNameMpt() == mpt::PathString()); - SetPathName(filename, FALSE); // Path is not set yet, but ITP loader needs this for relative paths. + FileReader file = GetFileReader(f); + ASSERT(GetPathNameMpt() == mpt::PathString()); + SetPathName(filename, FALSE); // Path is not set yet, but ITP loader needs this for relative paths. + m_SndFile.Create(file, CSoundFile::loadCompleteModule, this); + } - m_SndFile.Create(file, CSoundFile::loadCompleteModule, this); - } - } - } - #endif EndWaitCursor(); logcapturer.ShowLog(std::wstring() @@ -345,7 +336,7 @@ if(f.Open(pszMidiMapName)) { - FileReader file = f.GetFile(); + FileReader file = GetFileReader(f); if(file.IsValid()) { m_SndFile.ReadInstrumentFromFile(nIns, file, false); @@ -687,7 +678,7 @@ for(size_t counter = 0; counter < files.size(); counter++) { CMappedFile mappedFile; - if(mappedFile.Open(files[counter]) && source.Create(mappedFile.GetFile(), CSoundFile::loadCompleteModule)) + if(mappedFile.Open(files[counter]) && source.Create(GetFileReader(mappedFile), CSoundFile::loadCompleteModule)) { AppendModule(source); source.Destroy(); Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2014-10-25 11:43:51 UTC (rev 4486) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2014-10-25 12:47:41 UTC (rev 4487) @@ -364,7 +364,7 @@ if(f.Open(libPath + songName)) { - FileReader file = f.GetFile(); + FileReader file = GetFileReader(f); if(file.IsValid()) { if(m_SongFile != nullptr) Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2014-10-25 11:43:51 UTC (rev 4486) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2014-10-25 12:47:41 UTC (rev 4487) @@ -1048,7 +1048,7 @@ const char *errorStr = nullptr; if(f.Open(fileName)) { - FileReader file = f.GetFile(); + FileReader file = GetFileReader(f); errorStr = VSTPresets::GetErrorMessage(VSTPresets::LoadFile(file, *this)); } else { Modified: trunk/OpenMPT/soundlib/FileReader.h =================================================================== --- trunk/OpenMPT/soundlib/FileReader.h 2014-10-25 11:43:51 UTC (rev 4486) +++ trunk/OpenMPT/soundlib/FileReader.h 2014-10-25 12:47:41 UTC (rev 4487) @@ -58,7 +58,7 @@ off_t streamPos; // Cursor location in the file #if defined(MODPLUG_TRACKER) - mpt::PathString *fileName; // Filename that corresponds to this FileReader. It is only set if this FileReader represents the whole contents of fileName. May be nullptr. + const mpt::PathString *fileName; // Filename that corresponds to this FileReader. It is only set if this FileReader represents the whole contents of fileName. May be nullptr. #define MPT_FILEREADER_INIT_FILENAME ,fileName(nullptr) #else #define MPT_FILEREADER_INIT_FILENAME @@ -76,15 +76,15 @@ FileReader(const char *chardata, off_t length) : data(mpt::make_shared<FileDataContainerMemory>(chardata, length)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } FileReader(const uint8 *uint8data, off_t length) : data(mpt::make_shared<FileDataContainerMemory>(reinterpret_cast<const char *>(uint8data), length)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } #if defined(MODPLUG_TRACKER) - FileReader(const void *voiddata, off_t length, mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerMemory>(static_cast<const char *>(voiddata), length)), streamPos(0), fileName(filename) { } - FileReader(const char *chardata, off_t length, mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerMemory>(chardata, length)), streamPos(0), fileName(filename) { } - FileReader(const uint8 *uint8data, off_t length, mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerMemory>(reinterpret_cast<const char *>(uint8data), length)), streamPos(0), fileName(filename) { } + FileReader(const void *voiddata, off_t length, const mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerMemory>(static_cast<const char *>(voiddata), length)), streamPos(0), fileName(filename) { } + FileReader(const char *chardata, off_t length, const mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerMemory>(chardata, length)), streamPos(0), fileName(filename) { } + FileReader(const uint8 *uint8data, off_t length, const mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerMemory>(reinterpret_cast<const char *>(uint8data), length)), streamPos(0), fileName(filename) { } #endif // Initialize file reader object with a std::istream. FileReader(std::istream *s) : data(mpt::make_shared<FileDataContainerStdStream>(s)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } #if defined(MODPLUG_TRACKER) - FileReader(std::istream *s, mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerStdStream>(s)), streamPos(0), fileName(filename) { } + FileReader(std::istream *s, const mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerStdStream>(s)), streamPos(0), fileName(filename) { } #endif // Initialize file reader object based on an existing file reader object window. @@ -107,9 +107,9 @@ FileReader(const char *chardata, off_t length) : data(chardata, length), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } FileReader(const uint8 *uint8data, off_t length) : data(reinterpret_cast<const char *>(uint8data), length), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } #if defined(MODPLUG_TRACKER) - FileReader(const void *voiddata, off_t length, mpt::PathString *filename) : data(static_cast<const char *>(voiddata), length), streamPos(0), fileName(filename) { } - FileReader(const char *chardata, off_t length, mpt::PathString *filename) : data(chardata, length), streamPos(0), fileName(filename) { } - FileReader(const uint8 *uint8data, off_t length, mpt::PathString *filename) : data(reinterpret_cast<const char *>(uint8data), length), streamPos(0), fileName(filename) { } + FileReader(const void *voiddata, off_t length, const mpt::PathString *filename) : data(static_cast<const char *>(voiddata), length), streamPos(0), fileName(filename) { } + FileReader(const char *chardata, off_t length, const mpt::PathString *filename) : data(chardata, length), streamPos(0), fileName(filename) { } + FileReader(const uint8 *uint8data, off_t length, const mpt::PathString *filename) : data(reinterpret_cast<const char *>(uint8data), length), streamPos(0), fileName(filename) { } #endif // Initialize file reader object based on an existing file reader object. The other object's stream position is copied. @@ -775,4 +775,14 @@ }; +#if defined(MPT_WITH_PATHSTRING) +class InputFile; +FileReader GetFileReader(InputFile &file); +#ifdef MODPLUG_TRACKER +class CMappedFile; +FileReader GetFileReader(CMappedFile &file); +#endif +#endif // MPT_WITH_PATHSTRING + + OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-25 11:43:51 UTC (rev 4486) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-25 12:47:41 UTC (rev 4487) @@ -20,12 +20,7 @@ #include "ITTools.h" #ifdef MODPLUG_TRACKER #include "../mptrack/TrackerSettings.h" -#if !defined(MPT_FILEREADER_STD_ISTREAM) -#include "../mptrack/MemoryMappedFile.h" -#endif -#ifndef MODPLUG_NO_FILESAVE #include "../common/mptFstream.h" -#endif #include "../mptrack/Moddoc.h" #endif @@ -263,17 +258,10 @@ { if(m_szInstrumentPath[ins].empty()) continue; -#if defined(MPT_FILEREADER_STD_ISTREAM) - mpt::ifstream f(m_szInstrumentPath[ins], std::ios_base::binary); - if(!f.good()) + InputFile f(m_szInstrumentPath[ins]); + if(!f.IsValid()) continue; - FileReader file(&f, &m_szInstrumentPath[ins]); -#else - CMappedFile f; - if(!f.Open(m_szInstrumentPath[ins])) - continue; - FileReader file = f.GetFile(); -#endif + FileReader file = GetFileReader(f); if(file.IsValid()) ReadInstrumentFromFile(ins + 1, file, TrackerSettings::Instance().m_MayNormalizeSamplesOnLoad); Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-25 11:43:51 UTC (rev 4486) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-25 12:47:41 UTC (rev 4487) @@ -13,11 +13,7 @@ #include "Loaders.h" #ifdef MODPLUG_TRACKER // For loading external samples -#if defined(MPT_FILEREADER_STD_ISTREAM) #include "../common/mptFstream.h" -#else -#include "../mptrack/MemoryMappedFile.h" -#endif #include "../mptrack/Moddoc.h" #endif @@ -1081,19 +1077,16 @@ path = path.RelativePathToAbsolute(mt2FileName.GetPath()); } -#if defined(MPT_FILEREADER_STD_ISTREAM) - mpt::ifstream f(path, std::ios_base::binary); - if(f.good()) - sampleFile = FileReader(&f, &path); -#else - CMappedFile f; - FileReader sampleFile; - if(f.Open(path)) - sampleFile = f.GetFile(); + InputFile f(path); + if(f.IsValid()) + { + FileReader sampleFile = GetFileReader(f); + if(sampleFile.IsValid()) + { + ReadSampleFromFile(i + 1, sampleFile, false); + } + } #endif - if(sampleFile.IsValid()) - ReadSampleFromFile(i + 1, sampleFile, false); -#endif } mptSmp.nC5Speed = freq; mptSmp.nFineTune = 0; Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-25 11:43:51 UTC (rev 4486) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-25 12:47:41 UTC (rev 4487) @@ -24,6 +24,7 @@ #include "tuningcollection.h" #include "../common/StringFixer.h" #include "FileReader.h" +#include "../common/mptFstream.h" #include <sstream> #include <time.h> @@ -35,6 +36,56 @@ OPENMPT_NAMESPACE_BEGIN + +// Note: Following code should be moved to FileReader.cpp + +#ifdef MPT_WITH_PATHSTRING + +FileReader GetFileReader(InputFile &file) +{ + #if defined(MPT_FILEREADER_STD_ISTREAM) + InputFile::ContentsRef tmp = file.Get(); + if(!tmp.first) + { + return FileReader(); + } + if(!tmp.first->good()) + { + return FileReader(); + } + #ifdef MDPLUG_TRACKER + return FileReader(tmp.first, tmp.second); + #else + return FileReader(tmp.first); + #endif + #else + InputFile::ContentsRef tmp = file.Get(); + #ifdef MDPLUG_TRACKER + return FileReader(tmp.first.data, tmp.first.size, tmp.second); + #else + return FileReader(tmp.first.data, tmp.first.size); + #endif + #endif +} + +#ifdef MODPLUG_TRACKER + +FileReader GetFileReader(CMappedFile &file) +{ + if(!file.IsOpen()) + { + return FileReader(); + } + return FileReader(file.Lock(), file.GetLength(), file.GetpFilename()); +} + +#endif + +#endif // MPT_WITH_PATHSTRING + + + + // -> CODE#0027 // -> DESC="per-instrument volume ramping setup (refered as attack)" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-25 15:27:31
|
Revision: 4489 http://sourceforge.net/p/modplug/code/4489 Author: saga-games Date: 2014-10-25 15:27:10 +0000 (Sat, 25 Oct 2014) Log Message: ----------- [Ref] Move file handling code around as outlined in r4487. [Ref] Move CSoundFile upgrade code to own file, UpgradeModule.cpp Revision Links: -------------- http://sourceforge.net/p/modplug/code/4487 Modified Paths: -------------- trunk/OpenMPT/build/autotools/Makefile.am trunk/OpenMPT/common/Logging.cpp trunk/OpenMPT/common/mptIO.cpp trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Added Paths: ----------- trunk/OpenMPT/common/mptFileIO.cpp trunk/OpenMPT/common/mptFileIO.h trunk/OpenMPT/soundlib/UpgradeModule.cpp Removed Paths: ------------- trunk/OpenMPT/common/mptFstream.h trunk/OpenMPT/mptrack/MemoryMappedFile.cpp trunk/OpenMPT/mptrack/MemoryMappedFile.h Modified: trunk/OpenMPT/build/autotools/Makefile.am =================================================================== --- trunk/OpenMPT/build/autotools/Makefile.am 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/build/autotools/Makefile.am 2014-10-25 15:27:10 UTC (rev 4489) @@ -87,7 +87,8 @@ libopenmpt_la_SOURCES += common/misc_util.cpp libopenmpt_la_SOURCES += common/misc_util.h libopenmpt_la_SOURCES += common/mptAtomic.h -libopenmpt_la_SOURCES += common/mptFstream.h +libopenmpt_la_SOURCES += common/mptFileIO.h +libopenmpt_la_SOURCES += common/mptFileIO.cpp libopenmpt_la_SOURCES += common/mptIO.cpp libopenmpt_la_SOURCES += common/mptIO.h libopenmpt_la_SOURCES += common/mptPathString.cpp @@ -211,6 +212,7 @@ libopenmpt_la_SOURCES += soundlib/tuningcollection.h libopenmpt_la_SOURCES += soundlib/tuning.cpp libopenmpt_la_SOURCES += soundlib/tuning.h +libopenmpt_la_SOURCES += soundlib/UpgradeModule.cpp libopenmpt_la_SOURCES += soundlib/Wav.h libopenmpt_la_SOURCES += soundlib/WAVTools.cpp libopenmpt_la_SOURCES += soundlib/WAVTools.h Modified: trunk/OpenMPT/common/Logging.cpp =================================================================== --- trunk/OpenMPT/common/Logging.cpp 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/common/Logging.cpp 2014-10-25 15:27:10 UTC (rev 4489) @@ -11,7 +11,7 @@ #include "stdafx.h" #include "Logging.h" -#include "mptFstream.h" +#include "mptFileIO.h" #if defined(MODPLUG_TRACKER) #include "mptAtomic.h" #endif Added: trunk/OpenMPT/common/mptFileIO.cpp =================================================================== --- trunk/OpenMPT/common/mptFileIO.cpp (rev 0) +++ trunk/OpenMPT/common/mptFileIO.cpp 2014-10-25 15:27:10 UTC (rev 4489) @@ -0,0 +1,226 @@ +/* + * mptFileIO.cpp + * ------------- + * Purpose: File I/O wrappers + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "stdafx.h" +#include "mptFileIO.h" + + +OPENMPT_NAMESPACE_BEGIN + + +#ifdef MODPLUG_TRACKER + +CMappedFile::~CMappedFile() +//------------------------- +{ + Close(); +} + + +bool CMappedFile::Open(const mpt::PathString &filename) +//----------------------------------------------------- +{ + m_hFile = CreateFileW( + filename.AsNative().c_str(), + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if(m_hFile == INVALID_HANDLE_VALUE) + { + m_hFile = nullptr; + return false; + } + m_FileName = filename; + return true; +} + + +void CMappedFile::Close() +//----------------------- +{ + m_FileName = mpt::PathString(); + // Unlock file + if(m_hFMap) + { + if(m_pData) + { + UnmapViewOfFile(m_pData); + m_pData = nullptr; + } + CloseHandle(m_hFMap); + m_hFMap = nullptr; + } else if(m_pData) + { + free(m_pData); + m_pData = nullptr; + } + + // Close file handle + if(m_hFile) + { + CloseHandle(m_hFile); + m_hFile = nullptr; + } +} + + +size_t CMappedFile::GetLength() +//----------------------------- +{ + LARGE_INTEGER size; + if(GetFileSizeEx(m_hFile, &size) == FALSE) + { + return 0; + } + return mpt::saturate_cast<size_t>(size.QuadPart); +} + + +const void *CMappedFile::Lock() +//----------------------------- +{ + size_t length = GetLength(); + if(!length) return nullptr; + + void *lpStream; + + HANDLE hmf = CreateFileMapping( + m_hFile, + NULL, + PAGE_READONLY, + 0, 0, + NULL); + + // Try memory-mapping first + if(hmf) + { + lpStream = MapViewOfFile( + hmf, + FILE_MAP_READ, + 0, 0, + length); + if(lpStream) + { + m_hFMap = hmf; + m_pData = lpStream; + return lpStream; + } + CloseHandle(hmf); + hmf = nullptr; + } + + // Fallback if memory-mapping fails for some weird reason + if((lpStream = malloc(length)) == nullptr) return nullptr; + memset(lpStream, 0, length); + size_t bytesToRead = length; + size_t bytesRead = 0; + while(bytesToRead > 0) + { + DWORD chunkToRead = mpt::saturate_cast<DWORD>(length); + DWORD chunkRead = 0; + if(ReadFile(m_hFile, (char*)lpStream + bytesRead, chunkToRead, &chunkRead, NULL) == FALSE) + { + // error + free(lpStream); + return nullptr; + } + bytesRead += chunkRead; + bytesToRead -= chunkRead; + } + m_pData = lpStream; + return lpStream; +} + + +#endif // MODPLUG_TRACKER + + + +#if defined(MPT_WITH_PATHSTRING) + +InputFile::InputFile() +{ + return; +} + +InputFile::InputFile(const mpt::PathString &filename) + : m_Filename(filename) +{ +#if defined(MPT_FILEREADER_STD_ISTREAM) + m_File.open(m_Filename, std::ios::binary | std::ios::in); +#else + m_File.Open(m_Filename); +#endif +} + +InputFile::~InputFile() +{ + return; +} + + +bool InputFile::Open(const mpt::PathString &filename) +{ + m_Filename = filename; +#if defined(MPT_FILEREADER_STD_ISTREAM) + m_File.open(m_Filename, std::ios::binary | std::ios::in); + return m_File.good(); +#else + return m_File.Open(m_Filename); +#endif +} + + +bool InputFile::IsValid() const +{ +#if defined(MPT_FILEREADER_STD_ISTREAM) + return m_File.good(); +#else + return m_File.IsOpen(); +#endif +} + +#if defined(MPT_FILEREADER_STD_ISTREAM) + +InputFile::ContentsRef InputFile::Get() +{ + InputFile::ContentsRef result; + result.first = &m_File; + result.second = m_File.good() ? &m_Filename : nullptr; + return result; +} + +#else + +InputFile::ContentsRef InputFile::Get() +{ + InputFile::ContentsRef result; + result.first.data = nullptr; + result.first.size = 0; + result.second = nullptr; + if(!m_File.IsOpen()) + { + return result; + } + result.first.data = reinterpret_cast<const char*>(m_File.Lock()); + result.first.size = m_File.GetLength(); + result.second = &m_Filename; + return result; +} + +#endif + +#endif // MPT_WITH_PATHSTRING + + +OPENMPT_NAMESPACE_END Property changes on: trunk/OpenMPT/common/mptFileIO.cpp ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/x-c++src \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Copied: trunk/OpenMPT/common/mptFileIO.h (from rev 4488, trunk/OpenMPT/common/mptFstream.h) =================================================================== --- trunk/OpenMPT/common/mptFileIO.h (rev 0) +++ trunk/OpenMPT/common/mptFileIO.h 2014-10-25 15:27:10 UTC (rev 4489) @@ -0,0 +1,555 @@ +/* + * mptFileIO.h + * ----------- + * Purpose: A wrapper around std::fstream, fixing VS2008 charset conversion braindamage, and enforcing usage of mpt::PathString. + * Notes : You should only ever use these wrappers instead of plain std::fstream classes. + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#pragma once + +#include <fstream> +#include <ios> +#include <ostream> +#include <streambuf> + +#include "../common/mptString.h" +#include "../common/mptPathString.h" +#if defined(MPT_WITH_PATHSTRING) +#include "../common/mptIO.h" +#include <utility> +#endif + + +OPENMPT_NAMESPACE_BEGIN + + +#if defined(MPT_WITH_PATHSTRING) + + +static inline FILE * mpt_fopen(const mpt::PathString &filename, const char *mode) +//------------------------------------------------------------------------------- +{ + #if MPT_OS_WINDOWS + #if defined(MPT_WITH_CHARSET_LOCALE) + return _wfopen(filename.AsNative().c_str(), mode ? mpt::ToWide(mpt::CharsetLocale, mode).c_str() : nullptr); + #else + return _wfopen(filename.AsNative().c_str(), mode ? mpt::ToWide(mpt::CharsetUTF8, mode).c_str() : nullptr); + #endif + #else // !MPT_OS_WINDOWS + return fopen(filename.AsNative().c_str(), mode); + #endif // MPT_OS_WINDOWS +} + + +namespace mpt +{ + +#if MPT_COMPILER_MSVC && MPT_MSVC_BEFORE(2010,0) + +// VS2008 converts char filenames with CRT mbcs string conversion functions to wchar_t filenames. +// This is totally wrong for Win32 GUI applications because the C locale does not necessarily match the current windows ANSI codepage (CP_ACP). +// Work around this insanity by using our own string conversions for the std::fstream filenames. + +#define MPT_FSTREAM_DO_CONVERSIONS + +#elif MPT_COMPILER_GCC + +#if MPT_OS_WINDOWS +// GCC C++ library has no wchar_t overloads +#define MPT_FSTREAM_DO_CONVERSIONS +#define MPT_FSTREAM_DO_CONVERSIONS_ANSI +#endif + +#endif + +#ifdef MPT_FSTREAM_DO_CONVERSIONS +#define MPT_FSTREAM_OPEN(filename, mode) detail::fstream_open<Tbase>(*this, (filename), (mode)) +#else +#define MPT_FSTREAM_OPEN(filename, mode) Tbase::open((filename), (mode)) +#endif + +namespace detail +{ + +template<typename Tbase> +inline void fstream_open(Tbase & base, const mpt::PathString & filename, std::ios_base::openmode mode) +{ +#if defined( MPT_FSTREAM_DO_CONVERSIONS_ANSI) + base.open(mpt::ToLocale(filename.AsNative()).c_str(), mode); +#else + base.open(filename.AsNative().c_str(), mode); +#endif +} + +#ifdef MPT_FSTREAM_DO_CONVERSIONS + +template<typename Tbase> +inline void fstream_open(Tbase & base, const std::wstring & filename, std::ios_base::openmode mode) +{ + detail::fstream_open<Tbase>(base, mpt::PathString::FromWide(filename), mode); +} + +template<typename Tbase> +inline void fstream_open(Tbase & base, const wchar_t * filename, std::ios_base::openmode mode) +{ + detail::fstream_open<Tbase>(base, mpt::PathString::FromWide(filename ? std::wstring(filename) : std::wstring()), mode); +} + +template<typename Tbase> +inline void fstream_open(Tbase & base, const std::string & filename, std::ios_base::openmode mode) +{ + detail::fstream_open<Tbase>(base, mpt::PathString::FromWide(mpt::ToWide(mpt::CharsetLocale, filename)), mode); +} + +template<typename Tbase> +inline void fstream_open(Tbase & base, const char * filename, std::ios_base::openmode mode) +{ + detail::fstream_open<Tbase>(base, mpt::PathString::FromWide(mpt::ToWide(mpt::CharsetLocale, filename ? std::string(filename) : std::string())), mode); +} + +#endif + +} // namespace detail + +class fstream + : public std::fstream +{ +private: + typedef std::fstream Tbase; +public: + fstream() {} + fstream(const mpt::PathString & filename, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) + { + detail::fstream_open<Tbase>(*this, filename, mode); + } + void open(const mpt::PathString & filename, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) + { + detail::fstream_open<Tbase>(*this, filename, mode); + } + MPT_DEPRECATED_PATH void open(const char * filename, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) + { + MPT_FSTREAM_OPEN(filename, mode); + } + MPT_DEPRECATED_PATH void open(const std::string & filename, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) + { + MPT_FSTREAM_OPEN(filename.c_str(), mode); + } +#if MPT_OS_WINDOWS + MPT_DEPRECATED_PATH void open(const wchar_t * filename, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) + { + MPT_FSTREAM_OPEN(filename, mode); + } + MPT_DEPRECATED_PATH void open(const std::wstring & filename, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) + { + MPT_FSTREAM_OPEN(filename.c_str(), mode); + } +#endif +}; + +class ifstream + : public std::ifstream +{ +private: + typedef std::ifstream Tbase; +public: + ifstream() {} + ifstream(const mpt::PathString & filename, std::ios_base::openmode mode = std::ios_base::in) + { + detail::fstream_open<Tbase>(*this, filename, mode); + } + void open(const mpt::PathString & filename, std::ios_base::openmode mode = std::ios_base::in) + { + detail::fstream_open<Tbase>(*this, filename, mode); + } + MPT_DEPRECATED_PATH void open(const char * filename, std::ios_base::openmode mode = std::ios_base::in) + { + MPT_FSTREAM_OPEN(filename, mode); + } + MPT_DEPRECATED_PATH void open(const std::string & filename, std::ios_base::openmode mode = std::ios_base::in) + { + MPT_FSTREAM_OPEN(filename.c_str(), mode); + } +#if MPT_OS_WINDOWS + MPT_DEPRECATED_PATH void open(const wchar_t * filename, std::ios_base::openmode mode = std::ios_base::in) + { + MPT_FSTREAM_OPEN(filename, mode); + } + MPT_DEPRECATED_PATH void open(const std::wstring & filename, std::ios_base::openmode mode = std::ios_base::in) + { + MPT_FSTREAM_OPEN(filename.c_str(), mode); + } +#endif +}; + +class ofstream + : public std::ofstream +{ +private: + typedef std::ofstream Tbase; +public: + ofstream() {} + ofstream(const mpt::PathString & filename, std::ios_base::openmode mode = std::ios_base::out) + { + detail::fstream_open<Tbase>(*this, filename, mode); + } + void open(const mpt::PathString & filename, std::ios_base::openmode mode = std::ios_base::out) + { + detail::fstream_open<Tbase>(*this, filename, mode); + } + MPT_DEPRECATED_PATH void open(const char * filename, std::ios_base::openmode mode = std::ios_base::out) + { + MPT_FSTREAM_OPEN(filename, mode); + } + MPT_DEPRECATED_PATH void open(const std::string & filename, std::ios_base::openmode mode = std::ios_base::out) + { + MPT_FSTREAM_OPEN(filename.c_str(), mode); + } +#if MPT_OS_WINDOWS + MPT_DEPRECATED_PATH void open(const wchar_t * filename, std::ios_base::openmode mode = std::ios_base::out) + { + MPT_FSTREAM_OPEN(filename, mode); + } + MPT_DEPRECATED_PATH void open(const std::wstring & filename, std::ios_base::openmode mode = std::ios_base::out) + { + MPT_FSTREAM_OPEN(filename.c_str(), mode); + } +#endif +}; + +#undef MPT_FSTREAM_OPEN + + + +// class FILE_ostream, FILE_output_streambuf and FILE_output_buffered_streambuf +// provide a portable way of wrapping a std::ostream around an FILE* opened for output. +// They offer similar functionality to the badly documented +// MSVC std::fstream(FILE*) constructor or GCC libstdc++ __gnu_cxx::stdio_sync_filebuf class, +// and, for other compilers, provide a race-free alternative to +// closing the FILE* and opening it again as a std::ofstream. +// +// Only output functionality is implemented because we have no need for an input wrapper. +// +// During the whole lifetime of the iostream wrappers, the FILE* object is assumend to be +// either +// - NULL +// or +// - valid +// - opened for writing in non-append mode +// - opened in binary mode +// - seekable +// Some of these preconditions cannot be verified, +// and even the others do not get verified. +// Behaviour in case of any unmet preconditions is undefined. +// +// The buffered streambuf and the ostream use a buffer of 64KiB by default. +// +// For FILE_output_streambuf, coherency with the underlying FILE* is always guaranteed. +// For FILE_ostream and FILE_output_buffered_streambuf, coherence is only +// guaranteed when flush() or pubsync() get called. +// The constructors and destructors take care to not violate coherency. +// When mixing FILE* and iostream I/O during the lifetime of the iostream objects, +// the user is responsible for providing coherency via the appropriate +// flush and sync functions. +// Behaviour in case of incoherent access is undefined. + + +class FILE_output_streambuf : public std::streambuf +{ +public: + typedef std::streambuf::char_type char_type; + typedef std::streambuf::traits_type traits_type; + typedef traits_type::int_type int_type; + typedef traits_type::pos_type pos_type; + typedef traits_type::off_type off_type; +protected: + FILE *f; +public: + FILE_output_streambuf(FILE *f) + : f(f) + { + return; + } + ~FILE_output_streambuf() + { + return; + } +protected: + virtual int_type overflow(int_type ch) + { + if(!mpt::IO::IsValid(f)) + { + return traits_type::eof(); + } + if(traits_type::eq_int_type(ch, traits_type::eof())) + { + return traits_type::eof(); + } + char_type c = traits_type::to_char_type(ch); + if(!mpt::IO::WriteRaw(f, &c, 1)) + { + return traits_type::eof(); + } + return ch; + } + virtual int sync() + { + if(!mpt::IO::IsValid(f)) + { + return -1; + } + if(!mpt::IO::Flush(f)) + { + return -1; + } + return 0; + } + virtual pos_type seekpos(pos_type pos, std::ios_base::openmode which) + { + if(!mpt::IO::IsValid(f)) + { + return pos_type(off_type(-1)); + } + return seekoff(pos, std::ios_base::beg, which); + } + virtual pos_type seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which) + { + if(!mpt::IO::IsValid(f)) + { + return pos_type(off_type(-1)); + } + if(which & std::ios_base::in) + { + return pos_type(off_type(-1)); + } + if(!(which & std::ios_base::out)) + { + return pos_type(off_type(-1)); + } + mpt::IO::Offset oldpos = mpt::IO::TellWrite(f); + if(dir == std::ios_base::beg) + { + if(!mpt::IO::SeekAbsolute(f, off)) + { + mpt::IO::SeekAbsolute(f, oldpos); + return pos_type(off_type(-1)); + } + } else if(dir == std::ios_base::cur) + { + if(!mpt::IO::SeekRelative(f, off)) + { + mpt::IO::SeekAbsolute(f, oldpos); + return pos_type(off_type(-1)); + } + } else if(dir == std::ios_base::end) + { + if(!(mpt::IO::SeekEnd(f) && mpt::IO::SeekRelative(f, off))) + { + mpt::IO::SeekAbsolute(f, oldpos); + return pos_type(off_type(-1)); + } + } else + { + return pos_type(off_type(-1)); + } + mpt::IO::Offset newpos = mpt::IO::TellWrite(f); + if(!mpt::IO::OffsetFits<off_type>(newpos)) + { + mpt::IO::SeekAbsolute(f, oldpos); + return pos_type(off_type(-1)); + } + return pos_type(static_cast<off_type>(newpos)); + } +}; // class FILE_output_streambuf + + +class FILE_output_buffered_streambuf : public FILE_output_streambuf +{ +public: + typedef std::streambuf::char_type char_type; + typedef std::streambuf::traits_type traits_type; + typedef traits_type::int_type int_type; + typedef traits_type::pos_type pos_type; + typedef traits_type::off_type off_type; +private: + typedef FILE_output_streambuf Tparent; + std::vector<char_type> buf; +public: + FILE_output_buffered_streambuf(FILE *f, std::size_t bufSize = 64*1024) + : FILE_output_streambuf(f) + , buf((bufSize > 0) ? bufSize : 1) + { + setp(&buf[0], &buf[0] + buf.size()); + } + ~FILE_output_buffered_streambuf() + { + if(!mpt::IO::IsValid(f)) + { + return; + } + WriteOut(); + } +private: + bool IsDirty() const + { + return ((pptr() - pbase()) > 0); + } + bool WriteOut() + { + std::ptrdiff_t n = pptr() - pbase(); + std::ptrdiff_t left = n; + while(left > 0) + { + int backchunk = mpt::saturate_cast<int>(-left); + pbump(backchunk); + left += backchunk; + } + return mpt::IO::WriteRaw(f, pbase(), n); + } +protected: + virtual int_type overflow(int_type ch) + { + if(!mpt::IO::IsValid(f)) + { + return traits_type::eof(); + } + if(traits_type::eq_int_type(ch, traits_type::eof())) + { + return traits_type::eof(); + } + if(!WriteOut()) + { + return traits_type::eof(); + } + char_type c = traits_type::to_char_type(ch); + *pptr() = c; + pbump(1); + return ch; + } + virtual int sync() + { + if(!mpt::IO::IsValid(f)) + { + return -1; + } + if(!WriteOut()) + { + return -1; + } + return Tparent::sync(); + } + virtual pos_type seekpos(pos_type pos, std::ios_base::openmode which) + { + if(!mpt::IO::IsValid(f)) + { + return pos_type(off_type(-1)); + } + if(!WriteOut()) + { + return pos_type(off_type(-1)); + } + return Tparent::seekpos(pos, which); + } + virtual pos_type seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which) + { + if(!mpt::IO::IsValid(f)) + { + return pos_type(off_type(-1)); + } + if(!WriteOut()) + { + return pos_type(off_type(-1)); + } + return Tparent::seekoff(off, dir, which); + } +}; // class FILE_output_buffered_streambuf + + +class FILE_ostream : public std::ostream { +private: + FILE *f; + FILE_output_buffered_streambuf buf; +public: + FILE_ostream(FILE *f, std::size_t bufSize = 64*1024) + : std::ostream(&buf) + , f(f) + , buf(f, bufSize) + { + if(mpt::IO::IsValid(f)) mpt::IO::Flush(f); + } + ~FILE_ostream() + { + flush(); + buf.pubsync(); + if(mpt::IO::IsValid(f)) mpt::IO::Flush(f); + } +}; // class FILE_ostream + + +} // namespace mpt + + + +#ifdef MODPLUG_TRACKER +//=============== +class CMappedFile +//=============== +{ +protected: + HANDLE m_hFile; + HANDLE m_hFMap; + void *m_pData; + mpt::PathString m_FileName; + +public: + CMappedFile() : m_hFile(nullptr), m_hFMap(nullptr), m_pData(nullptr) { } + ~CMappedFile(); + +public: + bool Open(const mpt::PathString &filename); + bool IsOpen() const { return m_hFile != NULL && m_hFile != INVALID_HANDLE_VALUE; } + const mpt::PathString * GetpFilename() const { return &m_FileName; } + void Close(); + size_t GetLength(); + const void *Lock(); +}; +#endif // MODPLUG_TRACKER + + +//============= +class InputFile +//============= +{ +private: + mpt::PathString m_Filename; + #ifdef MPT_FILEREADER_STD_ISTREAM + mpt::ifstream m_File; + #else + CMappedFile m_File; + #endif +public: + InputFile(); + InputFile(const mpt::PathString &filename); + ~InputFile(); + bool Open(const mpt::PathString &filename); + bool IsValid() const; +#if defined(MPT_FILEREADER_STD_ISTREAM) + typedef std::pair<std::istream*, const mpt::PathString*> ContentsRef; +#else + struct Data + { + const char *data; + std::size_t size; + }; + typedef std::pair<InputFile::Data, const mpt::PathString*> ContentsRef; +#endif + InputFile::ContentsRef Get(); +}; + + +#endif // MPT_WITH_PATHSTRING + + +OPENMPT_NAMESPACE_END + Deleted: trunk/OpenMPT/common/mptFstream.h =================================================================== --- trunk/OpenMPT/common/mptFstream.h 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/common/mptFstream.h 2014-10-25 15:27:10 UTC (rev 4489) @@ -1,555 +0,0 @@ -/* - * mptFstream.h - * ------------ - * Purpose: A wrapper around std::fstream, fixing VS2008 charset conversion braindamage, and enforcing usage of mpt::PathString. - * Notes : You should only ever use these wrappers instead of plain std::fstream classes. - * Authors: OpenMPT Devs - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - -#pragma once - -#include <fstream> -#include <ios> -#include <ostream> -#include <streambuf> - -#include "../common/mptString.h" -#include "../common/mptPathString.h" -#if defined(MPT_WITH_PATHSTRING) -#include "../common/mptIO.h" -#include <utility> -#endif - - -OPENMPT_NAMESPACE_BEGIN - - -#if defined(MPT_WITH_PATHSTRING) - - -static inline FILE * mpt_fopen(const mpt::PathString &filename, const char *mode) -//------------------------------------------------------------------------------- -{ - #if MPT_OS_WINDOWS - #if defined(MPT_WITH_CHARSET_LOCALE) - return _wfopen(filename.AsNative().c_str(), mode ? mpt::ToWide(mpt::CharsetLocale, mode).c_str() : nullptr); - #else - return _wfopen(filename.AsNative().c_str(), mode ? mpt::ToWide(mpt::CharsetUTF8, mode).c_str() : nullptr); - #endif - #else // !MPT_OS_WINDOWS - return fopen(filename.AsNative().c_str(), mode); - #endif // MPT_OS_WINDOWS -} - - -namespace mpt -{ - -#if MPT_COMPILER_MSVC && MPT_MSVC_BEFORE(2010,0) - -// VS2008 converts char filenames with CRT mbcs string conversion functions to wchar_t filenames. -// This is totally wrong for Win32 GUI applications because the C locale does not necessarily match the current windows ANSI codepage (CP_ACP). -// Work around this insanity by using our own string conversions for the std::fstream filenames. - -#define MPT_FSTREAM_DO_CONVERSIONS - -#elif MPT_COMPILER_GCC - -#if MPT_OS_WINDOWS -// GCC C++ library has no wchar_t overloads -#define MPT_FSTREAM_DO_CONVERSIONS -#define MPT_FSTREAM_DO_CONVERSIONS_ANSI -#endif - -#endif - -#ifdef MPT_FSTREAM_DO_CONVERSIONS -#define MPT_FSTREAM_OPEN(filename, mode) detail::fstream_open<Tbase>(*this, (filename), (mode)) -#else -#define MPT_FSTREAM_OPEN(filename, mode) Tbase::open((filename), (mode)) -#endif - -namespace detail -{ - -template<typename Tbase> -inline void fstream_open(Tbase & base, const mpt::PathString & filename, std::ios_base::openmode mode) -{ -#if defined( MPT_FSTREAM_DO_CONVERSIONS_ANSI) - base.open(mpt::ToLocale(filename.AsNative()).c_str(), mode); -#else - base.open(filename.AsNative().c_str(), mode); -#endif -} - -#ifdef MPT_FSTREAM_DO_CONVERSIONS - -template<typename Tbase> -inline void fstream_open(Tbase & base, const std::wstring & filename, std::ios_base::openmode mode) -{ - detail::fstream_open<Tbase>(base, mpt::PathString::FromWide(filename), mode); -} - -template<typename Tbase> -inline void fstream_open(Tbase & base, const wchar_t * filename, std::ios_base::openmode mode) -{ - detail::fstream_open<Tbase>(base, mpt::PathString::FromWide(filename ? std::wstring(filename) : std::wstring()), mode); -} - -template<typename Tbase> -inline void fstream_open(Tbase & base, const std::string & filename, std::ios_base::openmode mode) -{ - detail::fstream_open<Tbase>(base, mpt::PathString::FromWide(mpt::ToWide(mpt::CharsetLocale, filename)), mode); -} - -template<typename Tbase> -inline void fstream_open(Tbase & base, const char * filename, std::ios_base::openmode mode) -{ - detail::fstream_open<Tbase>(base, mpt::PathString::FromWide(mpt::ToWide(mpt::CharsetLocale, filename ? std::string(filename) : std::string())), mode); -} - -#endif - -} // namespace detail - -class fstream - : public std::fstream -{ -private: - typedef std::fstream Tbase; -public: - fstream() {} - fstream(const mpt::PathString & filename, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) - { - detail::fstream_open<Tbase>(*this, filename, mode); - } - void open(const mpt::PathString & filename, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) - { - detail::fstream_open<Tbase>(*this, filename, mode); - } - MPT_DEPRECATED_PATH void open(const char * filename, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) - { - MPT_FSTREAM_OPEN(filename, mode); - } - MPT_DEPRECATED_PATH void open(const std::string & filename, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) - { - MPT_FSTREAM_OPEN(filename.c_str(), mode); - } -#if MPT_OS_WINDOWS - MPT_DEPRECATED_PATH void open(const wchar_t * filename, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) - { - MPT_FSTREAM_OPEN(filename, mode); - } - MPT_DEPRECATED_PATH void open(const std::wstring & filename, std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) - { - MPT_FSTREAM_OPEN(filename.c_str(), mode); - } -#endif -}; - -class ifstream - : public std::ifstream -{ -private: - typedef std::ifstream Tbase; -public: - ifstream() {} - ifstream(const mpt::PathString & filename, std::ios_base::openmode mode = std::ios_base::in) - { - detail::fstream_open<Tbase>(*this, filename, mode); - } - void open(const mpt::PathString & filename, std::ios_base::openmode mode = std::ios_base::in) - { - detail::fstream_open<Tbase>(*this, filename, mode); - } - MPT_DEPRECATED_PATH void open(const char * filename, std::ios_base::openmode mode = std::ios_base::in) - { - MPT_FSTREAM_OPEN(filename, mode); - } - MPT_DEPRECATED_PATH void open(const std::string & filename, std::ios_base::openmode mode = std::ios_base::in) - { - MPT_FSTREAM_OPEN(filename.c_str(), mode); - } -#if MPT_OS_WINDOWS - MPT_DEPRECATED_PATH void open(const wchar_t * filename, std::ios_base::openmode mode = std::ios_base::in) - { - MPT_FSTREAM_OPEN(filename, mode); - } - MPT_DEPRECATED_PATH void open(const std::wstring & filename, std::ios_base::openmode mode = std::ios_base::in) - { - MPT_FSTREAM_OPEN(filename.c_str(), mode); - } -#endif -}; - -class ofstream - : public std::ofstream -{ -private: - typedef std::ofstream Tbase; -public: - ofstream() {} - ofstream(const mpt::PathString & filename, std::ios_base::openmode mode = std::ios_base::out) - { - detail::fstream_open<Tbase>(*this, filename, mode); - } - void open(const mpt::PathString & filename, std::ios_base::openmode mode = std::ios_base::out) - { - detail::fstream_open<Tbase>(*this, filename, mode); - } - MPT_DEPRECATED_PATH void open(const char * filename, std::ios_base::openmode mode = std::ios_base::out) - { - MPT_FSTREAM_OPEN(filename, mode); - } - MPT_DEPRECATED_PATH void open(const std::string & filename, std::ios_base::openmode mode = std::ios_base::out) - { - MPT_FSTREAM_OPEN(filename.c_str(), mode); - } -#if MPT_OS_WINDOWS - MPT_DEPRECATED_PATH void open(const wchar_t * filename, std::ios_base::openmode mode = std::ios_base::out) - { - MPT_FSTREAM_OPEN(filename, mode); - } - MPT_DEPRECATED_PATH void open(const std::wstring & filename, std::ios_base::openmode mode = std::ios_base::out) - { - MPT_FSTREAM_OPEN(filename.c_str(), mode); - } -#endif -}; - -#undef MPT_FSTREAM_OPEN - - - -// class FILE_ostream, FILE_output_streambuf and FILE_output_buffered_streambuf -// provide a portable way of wrapping a std::ostream around an FILE* opened for output. -// They offer similar functionality to the badly documented -// MSVC std::fstream(FILE*) constructor or GCC libstdc++ __gnu_cxx::stdio_sync_filebuf class, -// and, for other compilers, provide a race-free alternative to -// closing the FILE* and opening it again as a std::ofstream. -// -// Only output functionality is implemented because we have no need for an input wrapper. -// -// During the whole lifetime of the iostream wrappers, the FILE* object is assumend to be -// either -// - NULL -// or -// - valid -// - opened for writing in non-append mode -// - opened in binary mode -// - seekable -// Some of these preconditions cannot be verified, -// and even the others do not get verified. -// Behaviour in case of any unmet preconditions is undefined. -// -// The buffered streambuf and the ostream use a buffer of 64KiB by default. -// -// For FILE_output_streambuf, coherency with the underlying FILE* is always guaranteed. -// For FILE_ostream and FILE_output_buffered_streambuf, coherence is only -// guaranteed when flush() or pubsync() get called. -// The constructors and destructors take care to not violate coherency. -// When mixing FILE* and iostream I/O during the lifetime of the iostream objects, -// the user is responsible for providing coherency via the appropriate -// flush and sync functions. -// Behaviour in case of incoherent access is undefined. - - -class FILE_output_streambuf : public std::streambuf -{ -public: - typedef std::streambuf::char_type char_type; - typedef std::streambuf::traits_type traits_type; - typedef traits_type::int_type int_type; - typedef traits_type::pos_type pos_type; - typedef traits_type::off_type off_type; -protected: - FILE *f; -public: - FILE_output_streambuf(FILE *f) - : f(f) - { - return; - } - ~FILE_output_streambuf() - { - return; - } -protected: - virtual int_type overflow(int_type ch) - { - if(!mpt::IO::IsValid(f)) - { - return traits_type::eof(); - } - if(traits_type::eq_int_type(ch, traits_type::eof())) - { - return traits_type::eof(); - } - char_type c = traits_type::to_char_type(ch); - if(!mpt::IO::WriteRaw(f, &c, 1)) - { - return traits_type::eof(); - } - return ch; - } - virtual int sync() - { - if(!mpt::IO::IsValid(f)) - { - return -1; - } - if(!mpt::IO::Flush(f)) - { - return -1; - } - return 0; - } - virtual pos_type seekpos(pos_type pos, std::ios_base::openmode which) - { - if(!mpt::IO::IsValid(f)) - { - return pos_type(off_type(-1)); - } - return seekoff(pos, std::ios_base::beg, which); - } - virtual pos_type seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which) - { - if(!mpt::IO::IsValid(f)) - { - return pos_type(off_type(-1)); - } - if(which & std::ios_base::in) - { - return pos_type(off_type(-1)); - } - if(!(which & std::ios_base::out)) - { - return pos_type(off_type(-1)); - } - mpt::IO::Offset oldpos = mpt::IO::TellWrite(f); - if(dir == std::ios_base::beg) - { - if(!mpt::IO::SeekAbsolute(f, off)) - { - mpt::IO::SeekAbsolute(f, oldpos); - return pos_type(off_type(-1)); - } - } else if(dir == std::ios_base::cur) - { - if(!mpt::IO::SeekRelative(f, off)) - { - mpt::IO::SeekAbsolute(f, oldpos); - return pos_type(off_type(-1)); - } - } else if(dir == std::ios_base::end) - { - if(!(mpt::IO::SeekEnd(f) && mpt::IO::SeekRelative(f, off))) - { - mpt::IO::SeekAbsolute(f, oldpos); - return pos_type(off_type(-1)); - } - } else - { - return pos_type(off_type(-1)); - } - mpt::IO::Offset newpos = mpt::IO::TellWrite(f); - if(!mpt::IO::OffsetFits<off_type>(newpos)) - { - mpt::IO::SeekAbsolute(f, oldpos); - return pos_type(off_type(-1)); - } - return pos_type(static_cast<off_type>(newpos)); - } -}; // class FILE_output_streambuf - - -class FILE_output_buffered_streambuf : public FILE_output_streambuf -{ -public: - typedef std::streambuf::char_type char_type; - typedef std::streambuf::traits_type traits_type; - typedef traits_type::int_type int_type; - typedef traits_type::pos_type pos_type; - typedef traits_type::off_type off_type; -private: - typedef FILE_output_streambuf Tparent; - std::vector<char_type> buf; -public: - FILE_output_buffered_streambuf(FILE *f, std::size_t bufSize = 64*1024) - : FILE_output_streambuf(f) - , buf((bufSize > 0) ? bufSize : 1) - { - setp(&buf[0], &buf[0] + buf.size()); - } - ~FILE_output_buffered_streambuf() - { - if(!mpt::IO::IsValid(f)) - { - return; - } - WriteOut(); - } -private: - bool IsDirty() const - { - return ((pptr() - pbase()) > 0); - } - bool WriteOut() - { - std::ptrdiff_t n = pptr() - pbase(); - std::ptrdiff_t left = n; - while(left > 0) - { - int backchunk = mpt::saturate_cast<int>(-left); - pbump(backchunk); - left += backchunk; - } - return mpt::IO::WriteRaw(f, pbase(), n); - } -protected: - virtual int_type overflow(int_type ch) - { - if(!mpt::IO::IsValid(f)) - { - return traits_type::eof(); - } - if(traits_type::eq_int_type(ch, traits_type::eof())) - { - return traits_type::eof(); - } - if(!WriteOut()) - { - return traits_type::eof(); - } - char_type c = traits_type::to_char_type(ch); - *pptr() = c; - pbump(1); - return ch; - } - virtual int sync() - { - if(!mpt::IO::IsValid(f)) - { - return -1; - } - if(!WriteOut()) - { - return -1; - } - return Tparent::sync(); - } - virtual pos_type seekpos(pos_type pos, std::ios_base::openmode which) - { - if(!mpt::IO::IsValid(f)) - { - return pos_type(off_type(-1)); - } - if(!WriteOut()) - { - return pos_type(off_type(-1)); - } - return Tparent::seekpos(pos, which); - } - virtual pos_type seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which) - { - if(!mpt::IO::IsValid(f)) - { - return pos_type(off_type(-1)); - } - if(!WriteOut()) - { - return pos_type(off_type(-1)); - } - return Tparent::seekoff(off, dir, which); - } -}; // class FILE_output_buffered_streambuf - - -class FILE_ostream : public std::ostream { -private: - FILE *f; - FILE_output_buffered_streambuf buf; -public: - FILE_ostream(FILE *f, std::size_t bufSize = 64*1024) - : std::ostream(&buf) - , f(f) - , buf(f, bufSize) - { - if(mpt::IO::IsValid(f)) mpt::IO::Flush(f); - } - ~FILE_ostream() - { - flush(); - buf.pubsync(); - if(mpt::IO::IsValid(f)) mpt::IO::Flush(f); - } -}; // class FILE_ostream - - -} // namespace mpt - - - -#ifdef MODPLUG_TRACKER -//=============== -class CMappedFile -//=============== -{ -protected: - HANDLE m_hFile; - HANDLE m_hFMap; - void *m_pData; - mpt::PathString m_FileName; - -public: - CMappedFile() : m_hFile(nullptr), m_hFMap(nullptr), m_pData(nullptr) { } - ~CMappedFile(); - -public: - bool Open(const mpt::PathString &filename); - bool IsOpen() const { return m_hFile != NULL && m_hFile != INVALID_HANDLE_VALUE; } - const mpt::PathString * GetpFilename() const { return &m_FileName; } - void Close(); - size_t GetLength(); - const void *Lock(); -}; -#endif // MODPLUG_TRACKER - - -//============= -class InputFile -//============= -{ -private: - mpt::PathString m_Filename; - #ifdef MPT_FILEREADER_STD_ISTREAM - mpt::ifstream m_File; - #else - CMappedFile m_File; - #endif -public: - InputFile(); - InputFile(const mpt::PathString &filename); - ~InputFile(); - bool Open(const mpt::PathString &filename); - bool IsValid() const; -#if defined(MPT_FILEREADER_STD_ISTREAM) - typedef std::pair<std::istream*, const mpt::PathString*> ContentsRef; -#else - struct Data - { - const char *data; - std::size_t size; - }; - typedef std::pair<InputFile::Data, const mpt::PathString*> ContentsRef; -#endif - InputFile::ContentsRef Get(); -}; - - -#endif // MPT_WITH_PATHSTRING - - -OPENMPT_NAMESPACE_END - Modified: trunk/OpenMPT/common/mptIO.cpp =================================================================== --- trunk/OpenMPT/common/mptIO.cpp 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/common/mptIO.cpp 2014-10-25 15:27:10 UTC (rev 4489) @@ -254,224 +254,3 @@ OPENMPT_NAMESPACE_END - - - -// following ode should be moved to common/mptFileIO.cpp and common/mptFstream.h should be renamed to common/mptFileIO.h. - -#include "mptFstream.h" - - -OPENMPT_NAMESPACE_BEGIN - - -#ifdef MODPLUG_TRACKER - -CMappedFile::~CMappedFile() -//------------------------- -{ - Close(); -} - - -bool CMappedFile::Open(const mpt::PathString &filename) -//----------------------------------------------------- -{ - m_hFile = CreateFileW( - filename.AsNative().c_str(), - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - if(m_hFile == INVALID_HANDLE_VALUE) - { - m_hFile = nullptr; - return false; - } - m_FileName = filename; - return true; -} - - -void CMappedFile::Close() -//----------------------- -{ - m_FileName = mpt::PathString(); - // Unlock file - if(m_hFMap) - { - if(m_pData) - { - UnmapViewOfFile(m_pData); - m_pData = nullptr; - } - CloseHandle(m_hFMap); - m_hFMap = nullptr; - } else if(m_pData) - { - free(m_pData); - m_pData = nullptr; - } - - // Close file handle - if(m_hFile) - { - CloseHandle(m_hFile); - m_hFile = nullptr; - } -} - - -size_t CMappedFile::GetLength() -//----------------------------- -{ - LARGE_INTEGER size; - if(GetFileSizeEx(m_hFile, &size) == FALSE) - { - return 0; - } - return mpt::saturate_cast<size_t>(size.QuadPart); -} - - -const void *CMappedFile::Lock() -//----------------------------- -{ - size_t length = GetLength(); - if(!length) return nullptr; - - void *lpStream; - - HANDLE hmf = CreateFileMapping( - m_hFile, - NULL, - PAGE_READONLY, - 0, 0, - NULL); - - // Try memory-mapping first - if(hmf) - { - lpStream = MapViewOfFile( - hmf, - FILE_MAP_READ, - 0, 0, - length); - if(lpStream) - { - m_hFMap = hmf; - m_pData = lpStream; - return lpStream; - } - CloseHandle(hmf); - hmf = nullptr; - } - - // Fallback if memory-mapping fails for some weird reason - if((lpStream = malloc(length)) == nullptr) return nullptr; - memset(lpStream, 0, length); - size_t bytesToRead = length; - size_t bytesRead = 0; - while(bytesToRead > 0) - { - DWORD chunkToRead = mpt::saturate_cast<DWORD>(length); - DWORD chunkRead = 0; - if(ReadFile(m_hFile, (char*)lpStream + bytesRead, chunkToRead, &chunkRead, NULL) == FALSE) - { - // error - free(lpStream); - return nullptr; - } - bytesRead += chunkRead; - bytesToRead -= chunkRead; - } - m_pData = lpStream; - return lpStream; -} - - -#endif // MODPLUG_TRACKER - - - -#if defined(MPT_WITH_PATHSTRING) - -InputFile::InputFile() -{ - return; -} - -InputFile::InputFile(const mpt::PathString &filename) - : m_Filename(filename) -{ - #if defined(MPT_FILEREADER_STD_ISTREAM) - m_File.open(m_Filename, std::ios::binary | std::ios::in); - #else - m_File.Open(m_Filename); - #endif -} - -InputFile::~InputFile() -{ - return; -} - - -bool InputFile::Open(const mpt::PathString &filename) -{ - m_Filename = filename; - #if defined(MPT_FILEREADER_STD_ISTREAM) - m_File.open(m_Filename, std::ios::binary | std::ios::in); - return m_File.good(); - #else - return m_File.Open(m_Filename); - #endif -} - - -bool InputFile::IsValid() const -{ - #if defined(MPT_FILEREADER_STD_ISTREAM) - return m_File.good(); - #else - return m_File.IsOpen(); - #endif -} - -#if defined(MPT_FILEREADER_STD_ISTREAM) - -InputFile::ContentsRef InputFile::Get() -{ - InputFile::ContentsRef result; - result.first = &m_File; - result.second = m_File.good() ? &m_Filename : nullptr; - return result; -} - -#else - -InputFile::ContentsRef InputFile::Get() -{ - InputFile::ContentsRef result; - result.first.data = nullptr; - result.first.size = 0; - result.second = nullptr; - if(!m_File.IsOpen()) - { - return result; - } - result.first.data = reinterpret_cast<const char*>(m_File.Lock()); - result.first.size = m_File.GetLength(); - result.second = &m_Filename; - return result; -} - -#endif - -#endif // MPT_WITH_PATHSTRING - - - -OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2014-10-25 15:27:10 UTC (rev 4489) @@ -185,7 +185,7 @@ <ClInclude Include="..\common\Logging.h" /> <ClInclude Include="..\common\misc_util.h" /> <ClInclude Include="..\common\mptAtomic.h" /> - <ClInclude Include="..\common\mptFstream.h" /> + <ClInclude Include="..\common\mptFileIO.h" /> <ClInclude Include="..\common\mptIO.h" /> <ClInclude Include="..\common\mptPathString.h" /> <ClInclude Include="..\common\mptString.h" /> @@ -261,6 +261,7 @@ <ClCompile Include="..\common\ComponentManager.cpp" /> <ClCompile Include="..\common\Logging.cpp" /> <ClCompile Include="..\common\misc_util.cpp" /> + <ClCompile Include="..\common\mptFileIO.cpp" /> <ClCompile Include="..\common\mptIO.cpp" /> <ClCompile Include="..\common\mptPathString.cpp" /> <ClCompile Include="..\common\mptString.cpp" /> @@ -333,6 +334,7 @@ <ClCompile Include="..\soundlib\tuning.cpp" /> <ClCompile Include="..\soundlib\tuningbase.cpp" /> <ClCompile Include="..\soundlib\tuningCollection.cpp" /> + <ClCompile Include="..\soundlib\UpgradeModule.cpp" /> <ClCompile Include="..\soundlib\WAVTools.cpp" /> <ClCompile Include="..\soundlib\WindowedFIR.cpp" /> <ClCompile Include="..\soundlib\XMTools.cpp" /> Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2014-10-25 15:27:10 UTC (rev 4489) @@ -224,9 +224,6 @@ <ClInclude Include="libopenmpt_stream_callbacks_file.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="..\common\mptFstream.h"> - <Filter>Header Files\common</Filter> - </ClInclude> <ClInclude Include="..\common\mptPathString.h"> <Filter>Header Files\common</Filter> </ClInclude> @@ -269,6 +266,9 @@ <ClInclude Include="..\common\ComponentManager.h"> <Filter>Header Files\common</Filter> </ClInclude> + <ClInclude Include="..\common\mptFileIO.h"> + <Filter>Header Files\common</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp"> @@ -526,5 +526,11 @@ <ClCompile Include="..\common\mptIO.cpp"> <Filter>Source Files\common</Filter> </ClCompile> + <ClCompile Include="..\common\mptFileIO.cpp"> + <Filter>Source Files\common</Filter> + </ClCompile> + <ClCompile Include="..\soundlib\UpgradeModule.cpp"> + <Filter>Source Files\soundlib</Filter> + </ClCompile> </ItemGroup> </Project> \ No newline at end of file Modified: trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2014-10-25 15:27:10 UTC (rev 4489) @@ -193,7 +193,7 @@ <ClInclude Include="..\common\Logging.h" /> <ClInclude Include="..\common\misc_util.h" /> <ClInclude Include="..\common\mptAtomic.h" /> - <ClInclude Include="..\common\mptFstream.h" /> + <ClInclude Include="..\common\mptFileIO.h" /> <ClInclude Include="..\common\mptIO.h" /> <ClInclude Include="..\common\mptPathString.h" /> <ClInclude Include="..\common\mptString.h" /> @@ -271,6 +271,7 @@ <ClCompile Include="..\common\ComponentManager.cpp" /> <ClCompile Include="..\common\Logging.cpp" /> <ClCompile Include="..\common\misc_util.cpp" /> + <ClCompile Include="..\common\mptFileIO.cpp" /> <ClCompile Include="..\common\mptIO.cpp" /> <ClCompile Include="..\common\mptPathString.cpp" /> <ClCompile Include="..\common\mptString.cpp" /> @@ -343,6 +344,7 @@ <ClCompile Include="..\soundlib\tuning.cpp" /> <ClCompile Include="..\soundlib\tuningbase.cpp" /> <ClCompile Include="..\soundlib\tuningCollection.cpp" /> + <ClCompile Include="..\soundlib\UpgradeModule.cpp" /> <ClCompile Include="..\soundlib\WAVTools.cpp" /> <ClCompile Include="..\soundlib\WindowedFIR.cpp" /> <ClCompile Include="..\soundlib\XMTools.cpp" /> Modified: trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters 2014-10-25 15:27:10 UTC (rev 4489) @@ -230,9 +230,6 @@ <ClInclude Include="libopenmpt_stream_callbacks_file.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="..\common\mptFstream.h"> - <Filter>Header Files\common</Filter> - </ClInclude> <ClInclude Include="..\common\mptPathString.h"> <Filter>Header Files\common</Filter> </ClInclude> @@ -275,6 +272,9 @@ <ClInclude Include="..\common\ComponentManager.h"> <Filter>Header Files\common</Filter> </ClInclude> + <ClInclude Include="..\common\mptFileIO.h"> + <Filter>Header Files\common</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp"> @@ -532,5 +532,11 @@ <ClCompile Include="..\common\mptIO.cpp"> <Filter>Source Files\common</Filter> </ClCompile> + <ClCompile Include="..\common\mptFileIO.cpp"> + <Filter>Source Files\common</Filter> + </ClCompile> + <ClCompile Include="..\soundlib\UpgradeModule.cpp"> + <Filter>Source Files\soundlib</Filter> + </ClCompile> </ItemGroup> </Project> \ No newline at end of file Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj 2014-10-25 15:27:10 UTC (rev 4489) @@ -189,7 +189,7 @@ <ClInclude Include="..\common\Logging.h" /> <ClInclude Include="..\common\misc_util.h" /> <ClInclude Include="..\common\mptAtomic.h" /> - <ClInclude Include="..\common\mptFstream.h" /> + <ClInclude Include="..\common\mptFileIO.h" /> <ClInclude Include="..\common\mptIO.h" /> <ClInclude Include="..\common\mptPathString.h" /> <ClInclude Include="..\common\mptString.h" /> @@ -265,6 +265,7 @@ <ClCompile Include="..\common\ComponentManager.cpp" /> <ClCompile Include="..\common\Logging.cpp" /> <ClCompile Include="..\common\misc_util.cpp" /> + <ClCompile Include="..\common\mptFileIO.cpp" /> <ClCompile Include="..\common\mptIO.cpp" /> <ClCompile Include="..\common\mptPathString.cpp" /> <ClCompile Include="..\common\mptString.cpp" /> @@ -337,6 +338,7 @@ <ClCompile Include="..\soundlib\tuning.cpp" /> <ClCompile Include="..\soundlib\tuningbase.cpp" /> <ClCompile Include="..\soundlib\tuningCollection.cpp" /> + <ClCompile Include="..\soundlib\UpgradeModule.cpp" /> <ClCompile Include="..\soundlib\WAVTools.cpp" /> <ClCompile Include="..\soundlib\WindowedFIR.cpp" /> <ClCompile Include="..\soundlib\XMTools.cpp" /> Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters 2014-10-25 15:27:10 UTC (rev 4489) @@ -224,9 +224,6 @@ <ClInclude Include="libopenmpt_stream_callbacks_file.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="..\common\mptFstream.h"> - <Filter>Header Files\common</Filter> - </ClInclude> <ClInclude Include="..\common\mptPathString.h"> <Filter>Header Files\common</Filter> </ClInclude> @@ -269,6 +266,9 @@ <ClInclude Include="..\common\ComponentManager.h"> <Filter>Header Files\common</Filter> </ClInclude> + <ClInclude Include="..\common\mptFileIO.h"> + <Filter>Header Files\common</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="..\common\AudioCriticalSection.cpp"> @@ -529,5 +529,11 @@ <ClCompile Include="..\common\mptIO.cpp"> <Filter>Source Files\common</Filter> </ClCompile> + <ClCompile Include="..\common\mptFileIO.cpp"> + <Filter>Source Files\common</Filter> + </ClCompile> + <ClCompile Include="..\soundlib\UpgradeModule.cpp"> + <Filter>Source Files\soundlib</Filter> + </ClCompile> </ItemGroup> </Project> \ No newline at end of file Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-10-25 15:27:10 UTC (rev 4489) @@ -23,7 +23,8 @@ #include "../common/misc_util.h" #include "../common/StringFixer.h" #include "SelectPluginDialog.h" -#include "MemoryMappedFile.h" +#include "../common/mptFileIO.h" +#include "../soundlib/FileReader.h" #include "FileDialog.h" @@ -1422,11 +1423,11 @@ BOOL CCtrlInstruments::OpenInstrument(const mpt::PathString &fileName) //-------------------------------------------------------------------- { - CMappedFile f; BOOL bFirst, bOk; BeginWaitCursor(); - if(!f.Open(fileName)) + InputFile f(fileName); + if(!f.IsValid()) { EndWaitCursor(); return FALSE; Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-10-25 15:27:10 UTC (rev 4489) @@ -27,7 +27,7 @@ #include "modsmp_ctrl.h" #include "Autotune.h" #include "../common/StringFixer.h" -#include "MemoryMappedFile.h" +#include "../common/mptFileIO.h" #include "../soundlib/FileReader.h" #include "../soundlib/SampleFormatConverters.h" #include "FileDialog.h" @@ -778,9 +778,9 @@ bool CCtrlSamples::OpenSample(const mpt::PathString &fileName) //------------------------------------------------------------ { - CMappedFile f; BeginWaitCursor(); - if(!f.Open(fileName)) + InputFile f(fileName); + if(!f.IsValid()) { EndWaitCursor(); return false; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-10-25 15:27:10 UTC (rev 4489) @@ -34,7 +34,7 @@ #include "SelectPluginDialog.h" #include "ExceptionHandler.h" #include "PatternClipboard.h" -#include "MemoryMappedFile.h" +#include "../common/mptFileIO.h" #include "../soundlib/FileReader.h" #include "../common/Profiler.h" #include "FileDialog.h" @@ -1524,9 +1524,8 @@ if(!ok && !filename.empty()) { - CMappedFile f; - - if(f.Open(filename)) + InputFile f(filename); + if(f.IsValid()) { FileReader file = GetFileReader(f); if(file.IsValid()) Deleted: trunk/OpenMPT/mptrack/MemoryMappedFile.cpp =================================================================== --- trunk/OpenMPT/mptrack/MemoryMappedFile.cpp 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/mptrack/MemoryMappedFile.cpp 2014-10-25 15:27:10 UTC (rev 4489) @@ -1,20 +0,0 @@ -/* - * MemoryMappedFile.cpp - * -------------------- - * Purpose: Wrapper class for memory-mapped files - * Notes : (currently none) - * Authors: OpenMPT Devs - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - - -#include "stdafx.h" -#include "MemoryMappedFile.h" - - -OPENMPT_NAMESPACE_BEGIN - - - - -OPENMPT_NAMESPACE_END Deleted: trunk/OpenMPT/mptrack/MemoryMappedFile.h =================================================================== --- trunk/OpenMPT/mptrack/MemoryMappedFile.h 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/mptrack/MemoryMappedFile.h 2014-10-25 15:27:10 UTC (rev 4489) @@ -1,18 +0,0 @@ -/* - * MemoryMappedFile.h - * ------------------ - * Purpose: Header file for memory-mapped file wrapper - * Notes : (currently none) - * Authors: OpenMPT Devs - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - - -#pragma once - -#include "../soundlib/FileReader.h" -#include "../common/mptFstream.h" - -OPENMPT_NAMESPACE_BEGIN - -OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-10-25 15:27:10 UTC (rev 4489) @@ -29,11 +29,7 @@ #include "modsmp_ctrl.h" #include "CleanupSong.h" #include "../common/StringFixer.h" -#if defined(MPT_FILEREADER_STD_ISTREAM) -#include "../common/mptFstream.h" -#else -#include "MemoryMappedFile.h" -#endif +#include "../common/mptFileIO.h" #include "../soundlib/FileReader.h" #include <shlwapi.h> #include "FileDialog.h" Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2014-10-25 15:27:10 UTC (rev 4489) @@ -18,7 +18,7 @@ #include "Dlsbank.h" #include "dlg_misc.h" #include "vstplug.h" -#include "MemoryMappedFile.h" +#include "../common/mptFileIO.h" #include "../soundlib/FileReader.h" #include "FileDialog.h" #include "Globals.h" @@ -360,9 +360,8 @@ if(!songName.empty() && mpt::PathString::CompareNoCase(m_SongFileName, songName)) { // Load module for previewing its instruments - CMappedFile f; - - if(f.Open(libPath + songName)) + InputFile f(libPath + songName); + if(f.IsValid()) { FileReader file = GetFileReader(f); if(file.IsValid()) Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2014-10-25 15:27:10 UTC (rev 4489) @@ -23,9 +23,9 @@ #include "../soundlib/MIDIEvents.h" #include "MIDIMappingDialog.h" #include "../common/StringFixer.h" -#include "MemoryMappedFile.h" +#include "../common/mptFileIO.h" +#include "../soundlib/FileReader.h" #include "FileDialog.h" -#include "../common/mptFstream.h" OPENMPT_NAMESPACE_BEGIN @@ -1044,9 +1044,9 @@ fileName = dlg.GetFirstFile(); } - CMappedFile f; const char *errorStr = nullptr; - if(f.Open(fileName)) + InputFile f(fileName); + if(f.IsValid()) { FileReader file = GetFileReader(f); errorStr = VSTPresets::GetErrorMessage(VSTPresets::LoadFile(file, *this)); Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2014-10-25 15:27:10 UTC (rev 4489) @@ -572,10 +572,6 @@ > </File> <File - RelativePath=".\MemoryMappedFile.cpp" - > - </File> - <File RelativePath="..\soundlib\Message.cpp" > </File> @@ -660,6 +656,10 @@ > </File> <File + RelativePath="..\common\mptFileIO.cpp" + > + </File> + <File RelativePath=".\MPTHacks.cpp" > </File> @@ -868,6 +868,10 @@ > </File> <File + RelativePath="..\soundlib\UpgradeModule.cpp" + > + </File> + <File RelativePath="..\common\version.cpp" > </File> @@ -1270,10 +1274,6 @@ > </File> <File - RelativePath=".\MemoryMappedFile.h" - > - </File> - <File RelativePath="..\soundlib\MIDIEvents.h" > </File> @@ -1354,7 +1354,7 @@ > </File> <File - RelativePath="..\common\mptFstream.h" + RelativePath="..\common\mptFileIO.h" > </File> <File Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-10-25 12:52:24 UTC (rev 4488) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-10-25 15:27:10 UTC (rev 4489) @@ -728,6 +728,7 @@ <ClCompile Include="..\common\ComponentManager.cpp" /> <ClCompile Include="..\common\Logging.cpp" /> <ClCompile Include="..\common\misc_util.cpp" /> + <ClCompile Include="..\common\mptFileIO.cpp" /> <ClCompile Include="..\common\mptIO.cpp" /> <ClCompile Include="..\common\mptPathString.cpp" /> <ClCompile Include="..\common\mptString.cpp" /> @@ -791,6 +792,7 @@ <ClCompile Include="..\soundlib\SoundFilePlayConfig.cpp" /> <ClCompile Include="..\soundlib\Tables.cpp" /> <ClCompile Include="..\soundlib\Tagging.cpp" /> + <ClCompile Include="..\soundlib\UpgradeModule.cpp" /> <ClCompile Include="..\soundlib\WAVTools.cpp" /> <ClCompile Include="..\soundlib\WindowedFIR.cpp" /> <ClCompile Include="..\soundlib\XMTools.cpp" /> @@ -832,7 +834,6 @@ <ClCompile Include="KeyConfigDlg.cpp" /> <ClCompile Include="Mainbar.cpp" /> <ClCompile Include="MainFrm.cpp" /> - <ClCompile Include="MemoryMappedFile.cpp" /> <ClCompile Include="MIDIMacroDialog.cpp" /> <ClCompile Include="MIDIMapping.cpp" /> <ClCompile Include="MIDIMappingDialog.cpp" /> @@ -942,7 +943,7 @@ <ClInclude Include="..\common\Logging.h" /> <ClInclude Include="..\common\misc_util.h" /> <ClInclude Include="..\common\mptAtomic.h" /> - <ClInclude Include="..\common\mptFstream.h" /> + <ClInclude Include="..\common\mptFileIO.h" /> <ClInclude Include="..\common\mptIO.h" /> <ClInclude Include="..\common\mptPathString.h" /> <ClInclude Include="..\common\mptString.h" /> @@ -1045,7 +1046,6 @@ <ClInclude Include="InputHandler.h" /> <ClInclude Include="Mainbar.h" /> <ClInclude Include="Mainfrm.h" /> ... [truncated message content] |
From: <sag...@us...> - 2014-10-25 15:34:34
|
Revision: 4492 http://sourceforge.net/p/modplug/code/4492 Author: saga-games Date: 2014-10-25 15:34:20 +0000 (Sat, 25 Oct 2014) Log Message: ----------- [Fix] Various files were still pointing at the old mptFstream.h Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Settings.cpp trunk/OpenMPT/mptrack/TuningDialog.cpp trunk/OpenMPT/mptrack/mod2midi.cpp trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_mod.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp trunk/OpenMPT/soundlib/Load_s3m.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/SampleIO.cpp trunk/OpenMPT/soundlib/WAVTools.cpp Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -16,7 +16,7 @@ #include "../mptrack/Reporting.h" #include <stdio.h> #include <stdlib.h> -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" #include <sstream> Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -24,7 +24,7 @@ #include "../soundlib/Dither.h" #include "../soundlib/AudioReadTarget.h" -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" OPENMPT_NAMESPACE_BEGIN Modified: trunk/OpenMPT/mptrack/Settings.cpp =================================================================== --- trunk/OpenMPT/mptrack/Settings.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/mptrack/Settings.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -19,7 +19,7 @@ #include "Mainfrm.h" #include <algorithm> -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" #include <iterator> Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -13,7 +13,7 @@ #include "TuningDialog.h" #include "TrackerSettings.h" #include <algorithm> -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" #include "../common/misc_util.h" #include "tuningdialog.h" #include "FileDialog.h" Modified: trunk/OpenMPT/mptrack/mod2midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/mod2midi.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/mptrack/mod2midi.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -12,7 +12,7 @@ #include "Mptrack.h" #include "../soundlib/Sndfile.h" #include "../common/StringFixer.h" -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" #include "mod2midi.h" #include "Wav.h" Modified: trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp =================================================================== --- trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -16,7 +16,7 @@ #include "../mptrack/Mptrack.h" #include "../mptrack/Vstplug.h" #include "../mptrack/ExceptionHandler.h" -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" #include "../common/thread.h" #include "../common/StringFixer.h" Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -13,7 +13,7 @@ #include "Sndfile.h" #ifdef MODPLUG_TRACKER #include "../mptrack/mptrack.h" -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" #endif #include "Dlsbank.h" #include "Wav.h" Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -19,7 +19,7 @@ #include "../common/mptIO.h" #include "../common/serialization_utils.h" #ifndef MODPLUG_NO_FILESAVE -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" #endif #include <sstream> #include <list> Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -20,7 +20,7 @@ #include "ITTools.h" #ifdef MODPLUG_TRACKER #include "../mptrack/TrackerSettings.h" -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" #include "../mptrack/Moddoc.h" #endif Modified: trunk/OpenMPT/soundlib/Load_mod.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -13,7 +13,7 @@ #include "Loaders.h" #include "Tables.h" #ifndef MODPLUG_NO_FILESAVE -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" #endif OPENMPT_NAMESPACE_BEGIN Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -13,7 +13,7 @@ #include "Loaders.h" #ifdef MODPLUG_TRACKER // For loading external samples -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" #include "../mptrack/Moddoc.h" #endif Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -12,7 +12,7 @@ #include "Loaders.h" #include "S3MTools.h" #ifndef MODPLUG_NO_FILESAVE -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" #endif #include "../common/version.h" Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -16,7 +16,7 @@ #include "../common/misc_util.h" #include "XMTools.h" #ifndef MODPLUG_NO_FILESAVE -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" #endif #include <algorithm> #ifdef MODPLUG_TRACKER Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -17,7 +17,7 @@ #endif //MODPLUG_TRACKER #include "../common/AudioCriticalSection.h" #ifndef MODPLUG_NO_FILESAVE -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" #endif #include "Wav.h" #include "Tagging.h" Modified: trunk/OpenMPT/soundlib/SampleIO.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleIO.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/soundlib/SampleIO.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -17,7 +17,7 @@ #include "ITCompression.h" #include "../common/mptIO.h" #ifndef MODPLUG_NO_FILESAVE -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" #endif Modified: trunk/OpenMPT/soundlib/WAVTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/WAVTools.cpp 2014-10-25 15:32:44 UTC (rev 4491) +++ trunk/OpenMPT/soundlib/WAVTools.cpp 2014-10-25 15:34:20 UTC (rev 4492) @@ -12,7 +12,7 @@ #include "Loaders.h" #include "WAVTools.h" #ifndef MODPLUG_NO_FILESAVE -#include "../common/mptFstream.h" +#include "../common/mptFileIO.h" #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-25 17:28:26
|
Revision: 4497 http://sourceforge.net/p/modplug/code/4497 Author: manxorist Date: 2014-10-25 17:28:11 +0000 (Sat, 25 Oct 2014) Log Message: ----------- [Ref] Replace to additional occurences of CMappedFile with InputFile. [Ref] As GetFileReader is now only used with InputFile, it can be trivially templated and moved from Sndfile.cpp into FileReader.h without causing additional header dependencies. Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/soundlib/FileReader.h trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-10-25 16:54:07 UTC (rev 4496) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-10-25 17:28:11 UTC (rev 4497) @@ -328,7 +328,7 @@ } else { // Load from Instrument or Sample file - CMappedFile f; + InputFile f; if(f.Open(pszMidiMapName)) { @@ -673,8 +673,8 @@ for(size_t counter = 0; counter < files.size(); counter++) { - CMappedFile mappedFile; - if(mappedFile.Open(files[counter]) && source.Create(GetFileReader(mappedFile), CSoundFile::loadCompleteModule)) + InputFile f; + if(f.Open(files[counter]) && source.Create(GetFileReader(f), CSoundFile::loadCompleteModule)) { AppendModule(source); source.Destroy(); Modified: trunk/OpenMPT/soundlib/FileReader.h =================================================================== --- trunk/OpenMPT/soundlib/FileReader.h 2014-10-25 16:54:07 UTC (rev 4496) +++ trunk/OpenMPT/soundlib/FileReader.h 2014-10-25 17:28:11 UTC (rev 4497) @@ -776,12 +776,34 @@ #if defined(MPT_WITH_PATHSTRING) -class InputFile; -FileReader GetFileReader(InputFile &file); -#ifdef MODPLUG_TRACKER -class CMappedFile; -FileReader GetFileReader(CMappedFile &file); -#endif +// templated in order to reduce header inter-depoendencies +template <typename TInputFile> +FileReader GetFileReader(TInputFile &file) +{ + #if defined(MPT_FILEREADER_STD_ISTREAM) + typename InputFile::ContentsRef tmp = file.Get(); + if(!tmp.first) + { + return FileReader(); + } + if(!tmp.first->good()) + { + return FileReader(); + } + #ifdef MDPLUG_TRACKER + return FileReader(tmp.first, tmp.second); + #else + return FileReader(tmp.first); + #endif + #else + typename InputFile::ContentsRef tmp = file.Get(); + #ifdef MDPLUG_TRACKER + return FileReader(tmp.first.data, tmp.first.size, tmp.second); + #else + return FileReader(tmp.first.data, tmp.first.size); + #endif + #endif +} #endif // MPT_WITH_PATHSTRING Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-25 16:54:07 UTC (rev 4496) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-25 17:28:11 UTC (rev 4497) @@ -24,7 +24,6 @@ #include "tuningcollection.h" #include "../common/StringFixer.h" #include "FileReader.h" -#include "../common/mptFileIO.h" #include <sstream> #include <time.h> @@ -36,56 +35,6 @@ OPENMPT_NAMESPACE_BEGIN - -// Note: Following code should be moved to FileReader.cpp - -#ifdef MPT_WITH_PATHSTRING - -FileReader GetFileReader(InputFile &file) -{ - #if defined(MPT_FILEREADER_STD_ISTREAM) - InputFile::ContentsRef tmp = file.Get(); - if(!tmp.first) - { - return FileReader(); - } - if(!tmp.first->good()) - { - return FileReader(); - } - #ifdef MDPLUG_TRACKER - return FileReader(tmp.first, tmp.second); - #else - return FileReader(tmp.first); - #endif - #else - InputFile::ContentsRef tmp = file.Get(); - #ifdef MDPLUG_TRACKER - return FileReader(tmp.first.data, tmp.first.size, tmp.second); - #else - return FileReader(tmp.first.data, tmp.first.size); - #endif - #endif -} - -#ifdef MODPLUG_TRACKER - -FileReader GetFileReader(CMappedFile &file) -{ - if(!file.IsOpen()) - { - return FileReader(); - } - return FileReader(file.Lock(), file.GetLength(), file.GetpFilename()); -} - -#endif - -#endif // MPT_WITH_PATHSTRING - - - - // -> CODE#0027 // -> DESC="per-instrument volume ramping setup (refered as attack)" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-26 10:39:22
|
Revision: 4500 http://sourceforge.net/p/modplug/code/4500 Author: manxorist Date: 2014-10-26 10:39:06 +0000 (Sun, 26 Oct 2014) Log Message: ----------- [Ref] SIZE_MAX is only guaranteed in C++11. Replace it with std::numeric_limits<std::size_t>::max(). Modified Paths: -------------- trunk/OpenMPT/common/StringFixer.h trunk/OpenMPT/common/mptString.h trunk/OpenMPT/soundlib/FileReader.h trunk/OpenMPT/soundlib/SampleFormats.cpp Modified: trunk/OpenMPT/common/StringFixer.h =================================================================== --- trunk/OpenMPT/common/StringFixer.h 2014-10-25 19:29:55 UTC (rev 4499) +++ trunk/OpenMPT/common/StringFixer.h 2014-10-26 10:39:06 UTC (rev 4500) @@ -368,8 +368,8 @@ // Copy from a char array to a fixed size char array. template <size_t destSize> - void CopyN(char (&destBuffer)[destSize], const char *srcBuffer, const size_t srcSize = SIZE_MAX) - //---------------------------------------------------------------------------------------------- + void CopyN(char (&destBuffer)[destSize], const char *srcBuffer, const size_t srcSize = std::numeric_limits<size_t>::max()) + //------------------------------------------------------------------------------------------------------------------------ { const size_t copySize = std::min(destSize - 1u, srcSize); std::strncpy(destBuffer, srcBuffer, copySize); @@ -377,8 +377,8 @@ } // Copy at most srcSize characters from srcBuffer to a std::string. - static inline void CopyN(std::string &dest, const char *srcBuffer, const size_t srcSize = SIZE_MAX) - //------------------------------------------------------------------------------------------------- + static inline void CopyN(std::string &dest, const char *srcBuffer, const size_t srcSize = std::numeric_limits<size_t>::max()) + //--------------------------------------------------------------------------------------------------------------------------- { dest.assign(srcBuffer, srcBuffer + mpt::strnlen(srcBuffer, srcSize)); } Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2014-10-25 19:29:55 UTC (rev 4499) +++ trunk/OpenMPT/common/mptString.h 2014-10-26 10:39:06 UTC (rev 4500) @@ -111,7 +111,7 @@ #if MPT_COMPILER_MSVC return ::strnlen(str, n); #else - if(n >= SIZE_MAX) + if(n >= std::numeric_limits<std::size_t>::max()) { return std::strlen(str); } Modified: trunk/OpenMPT/soundlib/FileReader.h =================================================================== --- trunk/OpenMPT/soundlib/FileReader.h 2014-10-25 19:29:55 UTC (rev 4499) +++ trunk/OpenMPT/soundlib/FileReader.h 2014-10-26 10:39:06 UTC (rev 4500) @@ -604,7 +604,7 @@ } // Read a null-terminated string into a std::string - bool ReadNullString(std::string &dest, const off_t maxLength = SIZE_MAX) + bool ReadNullString(std::string &dest, const off_t maxLength = std::numeric_limits<std::size_t>::max()) { dest.clear(); char c; Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-10-25 19:29:55 UTC (rev 4499) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-10-26 10:39:06 UTC (rev 4500) @@ -1760,7 +1760,7 @@ size_t GetLength() const { if(length == 0) // Broken files - return SIZE_MAX; + return std::numeric_limits<size_t>::max(); return SwapBytesReturnBE(length); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-26 11:19:02
|
Revision: 4503 http://sourceforge.net/p/modplug/code/4503 Author: manxorist Date: 2014-10-26 11:18:46 +0000 (Sun, 26 Oct 2014) Log Message: ----------- [Ref] Split MPT_WITH_PATHSTRING macro and add MPT_WITH_FILEIO. MPT_WITH_PATHSTRING is required by MPT_WITH_DYNBIND and MPT_WITH_DYNBIND and all combinations of these two are or will be meaningful for libopenmpt. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/common/mptFileIO.cpp trunk/OpenMPT/common/mptFileIO.h trunk/OpenMPT/common/mptIO.cpp trunk/OpenMPT/common/mptIO.h trunk/OpenMPT/soundlib/FileReader.h Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2014-10-26 10:47:56 UTC (rev 4502) +++ trunk/OpenMPT/common/BuildSettings.h 2014-10-26 11:18:46 UTC (rev 4503) @@ -317,13 +317,17 @@ #endif #if defined(ENABLE_TESTS) && !defined(MPT_WITH_PATHSTRING) -#define MPT_WITH_PATHSTRING // Test suite requires PathString for file loading. +#define MPT_WITH_FILEIO // Test suite requires PathString for file loading. #endif -#if defined(MODPLUG_TRACKER) && !defined(MPT_WITH_PATHSTRING) -#define MPT_WITH_PATHSTRING // Tracker requires PathString +#if defined(MODPLUG_TRACKER) && !defined(MPT_WITH_FILEIO) +#define MPT_WITH_FILEIO // Tracker requires disk file io #endif +#if defined(MPT_WITH_FILEIO) && !defined(MPT_WITH_PATHSTRING) +#define MPT_WITH_PATHSTRING // disk file io requires PathString +#endif + #if defined(MPT_WITH_DYNBIND) && !defined(MPT_WITH_PATHSTRING) #define MPT_WITH_PATHSTRING // dynamic library loading requires PathString #endif Modified: trunk/OpenMPT/common/mptFileIO.cpp =================================================================== --- trunk/OpenMPT/common/mptFileIO.cpp 2014-10-26 10:47:56 UTC (rev 4502) +++ trunk/OpenMPT/common/mptFileIO.cpp 2014-10-26 11:18:46 UTC (rev 4503) @@ -15,6 +15,8 @@ OPENMPT_NAMESPACE_BEGIN +#if defined(MPT_WITH_FILEIO) + #ifdef MODPLUG_TRACKER CMappedFile::~CMappedFile() @@ -146,8 +148,6 @@ -#if defined(MPT_WITH_PATHSTRING) - InputFile::InputFile() { return; @@ -220,7 +220,7 @@ #endif -#endif // MPT_WITH_PATHSTRING +#endif // MPT_WITH_FILEIO OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/common/mptFileIO.h =================================================================== --- trunk/OpenMPT/common/mptFileIO.h 2014-10-26 10:47:56 UTC (rev 4502) +++ trunk/OpenMPT/common/mptFileIO.h 2014-10-26 11:18:46 UTC (rev 4503) @@ -16,16 +16,16 @@ #include "../common/mptString.h" #include "../common/mptPathString.h" -#if defined(MPT_WITH_PATHSTRING) +#if defined(MPT_WITH_FILEIO) #include "../common/mptIO.h" #include <utility> -#endif +#endif // MPT_WITH_FILEIO OPENMPT_NAMESPACE_BEGIN -#if defined(MPT_WITH_PATHSTRING) +#if defined(MPT_WITH_FILEIO) static inline FILE * mpt_fopen(const mpt::PathString &filename, const char *mode) @@ -548,7 +548,7 @@ }; -#endif // MPT_WITH_PATHSTRING +#endif // MPT_WITH_FILEIO OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/common/mptIO.cpp =================================================================== --- trunk/OpenMPT/common/mptIO.cpp 2014-10-26 10:47:56 UTC (rev 4502) +++ trunk/OpenMPT/common/mptIO.cpp 2014-10-26 11:18:46 UTC (rev 4503) @@ -61,7 +61,7 @@ -#if defined(MPT_WITH_PATHSTRING) +#if defined(MPT_WITH_FILEIO) bool IsValid(FILE* & f) { return f != NULL; } @@ -105,7 +105,7 @@ bool IsEof(FILE * & f) { return feof(f) != 0; } bool Flush(FILE* & f) { return fflush(f) == 0; } -#endif // MPT_WITH_PATHSTRING +#endif // MPT_WITH_FILEIO Modified: trunk/OpenMPT/common/mptIO.h =================================================================== --- trunk/OpenMPT/common/mptIO.h 2014-10-26 10:47:56 UTC (rev 4502) +++ trunk/OpenMPT/common/mptIO.h 2014-10-26 11:18:46 UTC (rev 4503) @@ -23,10 +23,10 @@ #endif #include <cstring> -#if defined(MPT_WITH_PATHSTRING) +#if defined(MPT_WITH_FILEIO) #include <cstdio> #include <stdio.h> -#endif +#endif // MPT_WITH_FILEIO OPENMPT_NAMESPACE_BEGIN @@ -77,7 +77,7 @@ -#if defined(MPT_WITH_PATHSTRING) +#if defined(MPT_WITH_FILEIO) // FILE* only makes sense if we support filenames at all. @@ -97,7 +97,7 @@ bool IsEof(FILE * & f); bool Flush(FILE* & f); -#endif // MPT_WITH_PATHSTRING +#endif // MPT_WITH_FILEIO Modified: trunk/OpenMPT/soundlib/FileReader.h =================================================================== --- trunk/OpenMPT/soundlib/FileReader.h 2014-10-26 10:47:56 UTC (rev 4502) +++ trunk/OpenMPT/soundlib/FileReader.h 2014-10-26 11:18:46 UTC (rev 4503) @@ -57,12 +57,12 @@ off_t streamPos; // Cursor location in the file -#if defined(MODPLUG_TRACKER) +#if defined(MPT_WITH_FILEIO) const mpt::PathString *fileName; // Filename that corresponds to this FileReader. It is only set if this FileReader represents the whole contents of fileName. May be nullptr. #define MPT_FILEREADER_INIT_FILENAME ,fileName(nullptr) -#else +#else // !MPT_WITH_FILEIO #define MPT_FILEREADER_INIT_FILENAME -#endif +#endif // MPT_WITH_FILEIO public: @@ -75,29 +75,29 @@ FileReader(const void *voiddata, off_t length) : data(mpt::make_shared<FileDataContainerMemory>(static_cast<const char *>(voiddata), length)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } FileReader(const char *chardata, off_t length) : data(mpt::make_shared<FileDataContainerMemory>(chardata, length)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } FileReader(const uint8 *uint8data, off_t length) : data(mpt::make_shared<FileDataContainerMemory>(reinterpret_cast<const char *>(uint8data), length)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } -#if defined(MODPLUG_TRACKER) +#if defined(MPT_WITH_FILEIO) FileReader(const void *voiddata, off_t length, const mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerMemory>(static_cast<const char *>(voiddata), length)), streamPos(0), fileName(filename) { } FileReader(const char *chardata, off_t length, const mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerMemory>(chardata, length)), streamPos(0), fileName(filename) { } FileReader(const uint8 *uint8data, off_t length, const mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerMemory>(reinterpret_cast<const char *>(uint8data), length)), streamPos(0), fileName(filename) { } -#endif +#endif // MPT_WITH_FILEIO // Initialize file reader object with a std::istream. FileReader(std::istream *s) : data(mpt::make_shared<FileDataContainerStdStream>(s)), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } -#if defined(MODPLUG_TRACKER) +#if defined(MPT_WITH_FILEIO) FileReader(std::istream *s, const mpt::PathString *filename) : data(mpt::make_shared<FileDataContainerStdStream>(s)), streamPos(0), fileName(filename) { } -#endif +#endif // MPT_WITH_FILEIO // Initialize file reader object based on an existing file reader object window. FileReader(MPT_SHARED_PTR<IFileDataContainer> other) : data(other), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } // Initialize file reader object based on an existing file reader object. The other object's stream position is copied. FileReader(const FileReader &other) : data(other.data), streamPos(other.streamPos) -#if defined(MODPLUG_TRACKER) +#if defined(MPT_WITH_FILEIO) , fileName(other.fileName) -#endif +#endif // MPT_WITH_FILEIO { } -#else +#else // !MPT_FILEREADER_STD_ISTREAM // Initialize invalid file reader object. FileReader() : data(nullptr, 0), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } @@ -106,23 +106,23 @@ FileReader(const void *voiddata, off_t length) : data(static_cast<const char *>(voiddata), length), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } FileReader(const char *chardata, off_t length) : data(chardata, length), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } FileReader(const uint8 *uint8data, off_t length) : data(reinterpret_cast<const char *>(uint8data), length), streamPos(0) MPT_FILEREADER_INIT_FILENAME { } -#if defined(MODPLUG_TRACKER) +#if defined(MPT_WITH_FILEIO) FileReader(const void *voiddata, off_t length, const mpt::PathString *filename) : data(static_cast<const char *>(voiddata), length), streamPos(0), fileName(filename) { } FileReader(const char *chardata, off_t length, const mpt::PathString *filename) : data(chardata, length), streamPos(0), fileName(filename) { } FileReader(const uint8 *uint8data, off_t length, const mpt::PathString *filename) : data(reinterpret_cast<const char *>(uint8data), length), streamPos(0), fileName(filename) { } -#endif +#endif // MPT_WITH_FILEIO // Initialize file reader object based on an existing file reader object. The other object's stream position is copied. FileReader(const FileReader &other) : data(other.data), streamPos(other.streamPos) -#if defined(MODPLUG_TRACKER) +#if defined(MPT_WITH_FILEIO) , fileName(other.fileName) -#endif +#endif // MPT_WITH_FILEIO { } -#endif +#endif // MPT_FILEREADER_STD_ISTREAM -#if defined(MODPLUG_TRACKER) +#if defined(MPT_WITH_FILEIO) mpt::PathString GetFileName() const { if(!fileName) @@ -131,7 +131,7 @@ } return *fileName; } -#endif +#endif // MPT_WITH_FILEIO // Returns true if the object points to a valid stream. bool IsValid() const @@ -775,7 +775,7 @@ }; -#if defined(MPT_WITH_PATHSTRING) +#if defined(MPT_WITH_FILEIO) // templated in order to reduce header inter-depoendencies template <typename TInputFile> FileReader GetFileReader(TInputFile &file) @@ -790,21 +790,21 @@ { return FileReader(); } - #ifdef MODPLUG_TRACKER + #ifdef MPT_WITH_FILEIO return FileReader(tmp.first, tmp.second); #else return FileReader(tmp.first); #endif #else typename TInputFile::ContentsRef tmp = file.Get(); - #ifdef MODPLUG_TRACKER + #ifdef MPT_WITH_FILEIO return FileReader(tmp.first.data, tmp.first.size, tmp.second); #else return FileReader(tmp.first.data, tmp.first.size); #endif #endif } -#endif // MPT_WITH_PATHSTRING +#endif // MPT_WITH_FILEIO OPENMPT_NAMESPACE_END This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |