From: <man...@us...> - 2014-10-01 11:16:53
|
Revision: 4341 http://sourceforge.net/p/modplug/code/4341 Author: manxorist Date: 2014-10-01 11:16:38 +0000 (Wed, 01 Oct 2014) Log Message: ----------- [Ref] Add a MPT_WSTRING_FORMAT macro which controls the support for std::wstring based formatting functions in mptString.h. Supporting formatting of wide string results in usage of std::wistringstream and std::wostringstream which results in instatiation of the whole iostream formatting mchinery for wide character strings. Depending on the smartness of STL, compiler and linker, this may or may not result in considerable increase in binary size (or problems on platforms with bad oder incomplete wchar_t support). MPT_WSTRIMG_FORMAT is set for MPT_USTRING_MODE_WIDE and in tracker builds. As libopenmpt had not yet started using wide string formatting, it gets comletely disabled for non-MSVC libopenmpt builds immediately as of now. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/common/mptString.cpp trunk/OpenMPT/common/mptString.h trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2014-10-01 10:31:46 UTC (rev 4340) +++ trunk/OpenMPT/common/BuildSettings.h 2014-10-01 11:16:38 UTC (rev 4341) @@ -259,6 +259,11 @@ #define MPT_USTRING_MODE_WIDE 0 #define MPT_USTRING_MODE_UTF8 1 #endif // MPT_COMPILER_MSVC +#if defined(MODPLUG_TRACKER) || MPT_USTRING_MODE_WIDE +#define MPT_WSTRING_FORMAT 1 +#else +#define MPT_WSTRING_FORMAT 0 +#endif #if !defined(MPT_CHARSET_WIN32) && !defined(MPT_CHARSET_ICONV) && !defined(MPT_CHARSET_CODECVTUTF8) && !defined(MPT_CHARSET_INTERNAL) #define MPT_CHARSET_INTERNAL Modified: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp 2014-10-01 10:31:46 UTC (rev 4340) +++ trunk/OpenMPT/common/misc_util.cpp 2014-10-01 11:16:38 UTC (rev 4341) @@ -50,6 +50,7 @@ template<> inline signed char ConvertStrToHelper(const std::string &str) { return static_cast<signed char>(ConvertStrToHelper<signed int>(str)); } template<> inline unsigned char ConvertStrToHelper(const std::string &str) { return static_cast<unsigned char>(ConvertStrToHelper<unsigned int>(str)); } +#if MPT_WSTRING_FORMAT template<typename T> inline T ConvertStrToHelper(const std::wstring &str) { @@ -65,6 +66,7 @@ template<> inline bool ConvertStrToHelper(const std::wstring &str) { return ConvertStrToHelper<int>(str)?true:false; } template<> inline signed char ConvertStrToHelper(const std::wstring &str) { return static_cast<signed char>(ConvertStrToHelper<signed int>(str)); } template<> inline unsigned char ConvertStrToHelper(const std::wstring &str) { return static_cast<unsigned char>(ConvertStrToHelper<unsigned int>(str)); } +#endif bool ConvertStrToBool(const std::string &str) { return ConvertStrToHelper<bool>(str); } signed char ConvertStrToSignedChar(const std::string &str) { return ConvertStrToHelper<signed char>(str); } @@ -81,6 +83,7 @@ double ConvertStrToDouble(const std::string &str) { return ConvertStrToHelper<double>(str); } long double ConvertStrToLongDouble(const std::string &str) { return ConvertStrToHelper<long double>(str); } +#if MPT_WSTRING_FORMAT bool ConvertStrToBool(const std::wstring &str) { return ConvertStrToHelper<bool>(str); } signed char ConvertStrToSignedChar(const std::wstring &str) { return ConvertStrToHelper<signed char>(str); } unsigned char ConvertStrToUnsignedChar(const std::wstring &str) { return ConvertStrToHelper<unsigned char>(str); } @@ -95,6 +98,7 @@ float ConvertStrToFloat(const std::wstring &str) { return ConvertStrToHelper<float>(str); } double ConvertStrToDouble(const std::wstring &str) { return ConvertStrToHelper<double>(str); } long double ConvertStrToLongDouble(const std::wstring &str) { return ConvertStrToHelper<long double>(str); } +#endif namespace Util Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2014-10-01 10:31:46 UTC (rev 4340) +++ trunk/OpenMPT/common/misc_util.h 2014-10-01 11:16:38 UTC (rev 4341) @@ -40,7 +40,6 @@ float ConvertStrToFloat(const std::string &str); double ConvertStrToDouble(const std::string &str); long double ConvertStrToLongDouble(const std::string &str); - template<typename T> inline T ConvertStrTo(const std::string &str); // not defined, generates compiler error for non-specialized types template<> inline bool ConvertStrTo(const std::string &str) { return ConvertStrToBool(str); } template<> inline signed char ConvertStrTo(const std::string &str) { return ConvertStrToSignedChar(str); } @@ -57,6 +56,7 @@ template<> inline double ConvertStrTo(const std::string &str) { return ConvertStrToDouble(str); } template<> inline long double ConvertStrTo(const std::string &str) { return ConvertStrToLongDouble(str); } +#if MPT_WSTRING_FORMAT bool ConvertStrToBool(const std::wstring &str); signed char ConvertStrToSignedChar(const std::wstring &str); unsigned char ConvertStrToUnsignedChar(const std::wstring &str); @@ -71,7 +71,6 @@ float ConvertStrToFloat(const std::wstring &str); double ConvertStrToDouble(const std::wstring &str); long double ConvertStrToLongDouble(const std::wstring &str); - template<typename T> inline T ConvertStrTo(const std::wstring &str); // not defined, generates compiler error for non-specialized types template<> inline bool ConvertStrTo(const std::wstring &str) { return ConvertStrToBool(str); } template<> inline signed char ConvertStrTo(const std::wstring &str) { return ConvertStrToSignedChar(str); } @@ -87,6 +86,7 @@ template<> inline float ConvertStrTo(const std::wstring &str) { return ConvertStrToFloat(str); } template<> inline double ConvertStrTo(const std::wstring &str) { return ConvertStrToDouble(str); } template<> inline long double ConvertStrTo(const std::wstring &str) { return ConvertStrToLongDouble(str); } +#endif template<typename T> inline T ConvertStrTo(const char *str) @@ -98,6 +98,7 @@ return ConvertStrTo<T>(std::string(str)); } +#if MPT_WSTRING_FORMAT template<typename T> inline T ConvertStrTo(const wchar_t *str) { @@ -107,6 +108,7 @@ } return ConvertStrTo<T>(std::wstring(str)); } +#endif namespace mpt { namespace String { Modified: trunk/OpenMPT/common/mptString.cpp =================================================================== --- trunk/OpenMPT/common/mptString.cpp 2014-10-01 10:31:46 UTC (rev 4340) +++ trunk/OpenMPT/common/mptString.cpp 2014-10-01 11:16:38 UTC (rev 4341) @@ -1169,6 +1169,7 @@ return o.str(); } +#if MPT_WSTRING_FORMAT template<typename T> inline std::wstring ToWStringHelper(const T & x) { @@ -1177,6 +1178,7 @@ SaneInsert(o, x); return o.str(); } +#endif #if defined(MPT_WITH_CHARSET_LOCALE) std::string ToString(const std::wstring & x) { return mpt::ToLocale(x); } @@ -1204,6 +1206,7 @@ std::string ToString(const double & x) { return ToStringHelper(x); } std::string ToString(const long double & x) { return ToStringHelper(x); } +#if MPT_WSTRING_FORMAT #if defined(MPT_WITH_CHARSET_LOCALE) std::wstring ToWString(const std::string & x) { return mpt::ToWide(mpt::CharsetLocale, x); } std::wstring ToWString(const char * const & x) { return mpt::ToWide(mpt::CharsetLocale, x); } @@ -1229,6 +1232,7 @@ std::wstring ToWString(const float & x) { return ToWStringHelper(x); } std::wstring ToWString(const double & x) { return ToWStringHelper(x); } std::wstring ToWString(const long double & x) { return ToWStringHelper(x); } +#endif template<typename Tostream> @@ -1269,6 +1273,7 @@ return o.str(); } +#if MPT_WSTRING_FORMAT template<typename T> inline std::wstring FormatValWHelper(const T & x, const Format & f) { @@ -1278,6 +1283,7 @@ SaneInsert(o, x); return o.str(); } +#endif // Parses a useful subset of standard sprintf syntax for specifying floating point formatting. template<typename Tchar> @@ -1377,11 +1383,11 @@ std::string FormatVal(const unsigned long & x, const Format & f) { return FormatValHelper(x, f); } std::string FormatVal(const signed long long & x, const Format & f) { return FormatValHelper(x, f); } std::string FormatVal(const unsigned long long & x, const Format & f) { return FormatValHelper(x, f); } - std::string FormatVal(const float & x, const Format & f) { return FormatValHelper(x, f); } std::string FormatVal(const double & x, const Format & f) { return FormatValHelper(x, f); } std::string FormatVal(const long double & x, const Format & f) { return FormatValHelper(x, f); } +#if MPT_WSTRING_FORMAT std::wstring FormatValW(const char & x, const Format & f) { return FormatValWHelper(x, f); } std::wstring FormatValW(const wchar_t & x, const Format & f) { return FormatValWHelper(x, f); } std::wstring FormatValW(const bool & x, const Format & f) { return FormatValWHelper(x, f); } @@ -1395,10 +1401,10 @@ std::wstring FormatValW(const unsigned long & x, const Format & f) { return FormatValWHelper(x, f); } std::wstring FormatValW(const signed long long & x, const Format & f) { return FormatValWHelper(x, f); } std::wstring FormatValW(const unsigned long long & x, const Format & f) { return FormatValWHelper(x, f); } - std::wstring FormatValW(const float & x, const Format & f) { return FormatValWHelper(x, f); } std::wstring FormatValW(const double & x, const Format & f) { return FormatValWHelper(x, f); } std::wstring FormatValW(const long double & x, const Format & f) { return FormatValWHelper(x, f); } +#endif namespace String @@ -1468,6 +1474,7 @@ return PrintImplTemplate<std::string>(format, x1,x2,x3,x4,x5,x6,x7,x8); } +#if MPT_WSTRING_FORMAT std::wstring PrintImpl(const std::wstring & format , const std::wstring & x1 , const std::wstring & x2 @@ -1481,6 +1488,7 @@ { return PrintImplTemplate<std::wstring>(format, x1,x2,x3,x4,x5,x6,x7,x8); } +#endif #if MPT_USTRING_MODE_UTF8 mpt::ustring PrintImpl(const mpt::ustring & format Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2014-10-01 10:31:46 UTC (rev 4340) +++ trunk/OpenMPT/common/mptString.h 2014-10-01 11:16:38 UTC (rev 4341) @@ -491,11 +491,11 @@ std::string FormatVal(const unsigned long & x, const Format & f); std::string FormatVal(const signed long long & x, const Format & f); std::string FormatVal(const unsigned long long & x, const Format & f); - std::string FormatVal(const float & x, const Format & f); std::string FormatVal(const double & x, const Format & f); std::string FormatVal(const long double & x, const Format & f); +#if MPT_WSTRING_FORMAT MPT_DEPRECATED std::wstring FormatValW(const char & x, const Format & f); // deprecated to catch potential API mis-use, use std::string(1, x) instead MPT_DEPRECATED std::wstring FormatValW(const wchar_t & x, const Format & f); // deprecated to catch potential API mis-use, use std::wstring(1, x) instead std::wstring FormatValW(const bool & x, const Format & f); @@ -509,10 +509,10 @@ std::wstring FormatValW(const unsigned long & x, const Format & f); std::wstring FormatValW(const signed long long & x, const Format & f); std::wstring FormatValW(const unsigned long long & x, const Format & f); - std::wstring FormatValW(const float & x, const Format & f); std::wstring FormatValW(const double & x, const Format & f); std::wstring FormatValW(const long double & x, const Format & f); +#endif template <typename Tstring> struct FormatValTFunctor {}; template <> struct FormatValTFunctor<std::string> { template <typename T> inline std::string operator() (const T & x, const Format & f) { return FormatVal(x, f); } }; @@ -595,11 +595,13 @@ { return FormatVal(x, *this); } +#if MPT_WSTRING_FORMAT template<typename T> inline std::wstring ToWString(const T & x) const { return FormatValW(x, *this); } +#endif }; @@ -709,7 +711,9 @@ }; // struct fmtT typedef fmtT<std::string> fmt; +#if MPT_WSTRING_FORMAT typedef fmtT<std::wstring> wfmt; +#endif #if MPT_USTRING_MODE_WIDE typedef fmtT<std::wstring> ufmt; #else @@ -719,7 +723,9 @@ } // namespace mpt #define Stringify(x) mpt::ToString(x) +#if MPT_WSTRING_FORMAT #define StringifyW(x) mpt::ToWString(x) +#endif namespace mpt { namespace String { @@ -750,6 +756,7 @@ , const std::string & x8 = std::string() ); +#if MPT_WSTRING_FORMAT std::wstring PrintImpl(const std::wstring & format , const std::wstring & x1 = std::wstring() , const std::wstring & x2 = std::wstring() @@ -760,6 +767,7 @@ , const std::wstring & x7 = std::wstring() , const std::wstring & x8 = std::wstring() ); +#endif #if MPT_USTRING_MODE_UTF8 mpt::ustring PrintImpl(const mpt::ustring & format Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2014-10-01 10:31:46 UTC (rev 4340) +++ trunk/OpenMPT/test/test.cpp 2014-10-01 11:16:38 UTC (rev 4341) @@ -371,10 +371,12 @@ VERIFY_EQUAL(mpt::fmt::hex0<6>(0x123e), "00123e"); VERIFY_EQUAL(mpt::fmt::hex0<2>(0x123e), "123e"); +#if MPT_WSTRING_FORMAT VERIFY_EQUAL(mpt::wfmt::hex<3>((int32)-1), L"ffffffff"); VERIFY_EQUAL(mpt::wfmt::hex(0x123e), L"123e"); VERIFY_EQUAL(mpt::wfmt::hex0<6>(0x123e), L"00123e"); VERIFY_EQUAL(mpt::wfmt::hex0<2>(0x123e), L"123e"); +#endif VERIFY_EQUAL(Stringify(-87.0f), "-87"); if(Stringify(-0.5e-6) != "-5e-007" @@ -433,9 +435,11 @@ // As this test case is not fatal, ignore it for now in order to make the test cases pass. #endif +#if MPT_WSTRING_FORMAT VERIFY_EQUAL(mpt::wfmt::flt(6.12345, 7, 3), L" 6.123"); VERIFY_EQUAL(mpt::wfmt::fix(6.12345, 7, 3), L" 6.123"); VERIFY_EQUAL(mpt::wfmt::flt(6.12345, 0, 4), L"6.123"); +#endif // basic functionality VERIFY_EQUAL(mpt::String::Print("%1%2%3",1,2,3), "123"); @@ -444,9 +448,11 @@ // template argument deduction of string type VERIFY_EQUAL(mpt::String::Print(std::string("%1%2%3"),1,2,3), "123"); +#if MPT_WSTRING_FORMAT VERIFY_EQUAL(mpt::String::Print(std::wstring(L"%1%2%3"),1,2,3), L"123"); VERIFY_EQUAL(mpt::String::Print(L"%1%2%3",1,2,3), L"123"); VERIFY_EQUAL(mpt::String::PrintW(L"%1%2%3",1,2,3), L"123"); +#endif // escaping and error behviour of '%' VERIFY_EQUAL(mpt::String::Print("%"), "%"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-01 13:44:03
|
Revision: 4346 http://sourceforge.net/p/modplug/code/4346 Author: manxorist Date: 2014-10-01 13:43:56 +0000 (Wed, 01 Oct 2014) Log Message: ----------- [Ref] Convert all std::wstring in soundlib/ to mpt::ustring. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp trunk/OpenMPT/mptrack/mod2wave.h trunk/OpenMPT/soundlib/Dither.cpp trunk/OpenMPT/soundlib/Dither.h trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Tagging.cpp trunk/OpenMPT/soundlib/Tagging.h trunk/OpenMPT/soundlib/WAVTools.cpp trunk/OpenMPT/soundlib/WAVTools.h Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-10-01 13:28:43 UTC (rev 4345) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-10-01 13:43:56 UTC (rev 4346) @@ -78,32 +78,32 @@ } -static std::wstring GetDefaultArtist() +static mpt::ustring GetDefaultArtist() //------------------------------------ { if(std::getenv("USERNAME")) { - return mpt::ToWide(mpt::CharsetLocale, std::getenv("USERNAME")); + return mpt::ToUnicode(mpt::CharsetLocale, std::getenv("USERNAME")); } - return std::wstring(); + return mpt::ustring(); } -static std::wstring GetDefaultYear() +static mpt::ustring GetDefaultYear() //---------------------------------- { - return mpt::ToWide(CTime::GetCurrentTime().Format("%Y")); + return mpt::ToUnicode(CTime::GetCurrentTime().Format("%Y")); } StoredTags::StoredTags(SettingsContainer &conf) //--------------------------------------------- : artist(conf, "Export", "TagArtist", GetDefaultArtist()) - , album(conf, "Export", "TagAlbum", L"") - , trackno(conf, "Export", "TagTrackNo", L"") + , album(conf, "Export", "TagAlbum", MPT_USTRING("")) + , trackno(conf, "Export", "TagTrackNo", MPT_USTRING("")) , year(conf, "Export", "TagYear", GetDefaultYear()) - , url(conf, "Export", "TagURL", L"") - , genre(conf, "Export", "TagGenre", L"") + , url(conf, "Export", "TagURL", MPT_USTRING("")) + , genre(conf, "Export", "TagGenre", MPT_USTRING("")) { return; } @@ -239,8 +239,8 @@ void CWaveConvert::LoadTags() //--------------------------- { - m_Settings.Tags.title = mpt::ToWide(mpt::CharsetLocale, m_SndFile.GetTitle()); - m_Settings.Tags.comments = mpt::ToWide(mpt::CharsetLocale, m_SndFile.songMessage.GetFormatted(SongMessage::leLF)); + m_Settings.Tags.title = mpt::ToUnicode(mpt::CharsetLocale, m_SndFile.GetTitle()); + m_Settings.Tags.comments = mpt::ToUnicode(mpt::CharsetLocale, m_SndFile.songMessage.GetFormatted(SongMessage::leLF)); m_Settings.Tags.artist = m_Settings.storedTags.artist; m_Settings.Tags.album = m_Settings.storedTags.album; m_Settings.Tags.trackno = m_Settings.storedTags.trackno; @@ -539,7 +539,7 @@ m_CbnDither.EnableWindow(TRUE); for(int dither = 0; dither < NumDitherModes; ++dither) { - int ndx = m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName((DitherMode)dither) + L" dither")); + int ndx = m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName((DitherMode)dither) + MPT_USTRING(" dither"))); m_CbnDither.SetItemData(ndx, dither); } } else @@ -547,7 +547,7 @@ m_CbnDither.EnableWindow(FALSE); for(int dither = 0; dither < NumDitherModes; ++dither) { - int ndx = m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName(DitherNone) + L" dither")); + int ndx = m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName(DitherNone) + MPT_USTRING(" dither"))); m_CbnDither.SetItemData(ndx, dither); } } @@ -735,40 +735,40 @@ CString tmp; m_EditTitle.GetWindowText(tmp); - m_Settings.Tags.title = mpt::ToWide(tmp); + m_Settings.Tags.title = mpt::ToUnicode(tmp); m_EditAuthor.GetWindowText(tmp); - m_Settings.Tags.artist = mpt::ToWide(tmp); + m_Settings.Tags.artist = mpt::ToUnicode(tmp); m_EditAlbum.GetWindowText(tmp); - m_Settings.Tags.album = mpt::ToWide(tmp); + m_Settings.Tags.album = mpt::ToUnicode(tmp); m_EditURL.GetWindowText(tmp); - m_Settings.Tags.url = mpt::ToWide(tmp); + m_Settings.Tags.url = mpt::ToUnicode(tmp); if((encTraits->modesWithFixedGenres & encSettings.Mode) && !encTraits->genres.empty()) { m_CbnGenre.GetWindowText(tmp); - m_Settings.Tags.genre = mpt::ToWide(tmp); + m_Settings.Tags.genre = mpt::ToUnicode(tmp); } else { m_EditGenre.GetWindowText(tmp); - m_Settings.Tags.genre = mpt::ToWide(tmp); + m_Settings.Tags.genre = mpt::ToUnicode(tmp); } m_EditYear.GetWindowText(tmp); - m_Settings.Tags.year = mpt::ToWide(tmp); - if(m_Settings.Tags.year == L"0") + m_Settings.Tags.year = mpt::ToUnicode(tmp); + if(m_Settings.Tags.year == MPT_USTRING("0")) { - m_Settings.Tags.year = std::wstring(); + m_Settings.Tags.year = mpt::ustring(); } if(!m_SndFile.songMessage.empty()) { - m_Settings.Tags.comments = mpt::ToWide(mpt::CharsetLocale, m_SndFile.songMessage.GetFormatted(SongMessage::leLF)); + m_Settings.Tags.comments = mpt::ToUnicode(mpt::CharsetLocale, m_SndFile.songMessage.GetFormatted(SongMessage::leLF)); } - m_Settings.Tags.bpm = mpt::ToWString(m_SndFile.GetCurrentBPM()); + m_Settings.Tags.bpm = mpt::ToUString(m_SndFile.GetCurrentBPM()); SaveTags(); Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-10-01 13:28:43 UTC (rev 4345) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-10-01 13:43:56 UTC (rev 4346) @@ -524,19 +524,19 @@ m_CbnDither.EnableWindow(TRUE); for(int i=0; i<NumDitherModes; ++i) { - m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName((DitherMode)i) + L" dithering")); + m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName((DitherMode)i) + MPT_USTRING(" dithering"))); } } else if(m_CurrentDeviceCaps.HasInternalDither) { m_CbnDither.EnableWindow(TRUE); - m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName(DitherNone) + L" dithering")); - m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName(DitherDefault) + L" dithering")); + m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName(DitherNone) + MPT_USTRING(" dithering"))); + m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName(DitherDefault) + MPT_USTRING(" dithering"))); } else { m_CbnDither.EnableWindow(FALSE); for(int i=0; i<NumDitherModes; ++i) { - m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName(DitherNone) + L" dithering")); + m_CbnDither.AddString(mpt::ToCString(Dither::GetModeName(DitherNone) + MPT_USTRING(" dithering"))); } } if(m_Settings.DitherType < 0 || m_Settings.DitherType >= m_CbnDither.GetCount()) Modified: trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp 2014-10-01 13:28:43 UTC (rev 4345) +++ trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp 2014-10-01 13:43:56 UTC (rev 4346) @@ -113,7 +113,7 @@ } ASSERT(!inited && !started); } - void AddCommentField(const std::string &field, const std::wstring &data) + void AddCommentField(const std::string &field, const mpt::ustring &data) { if(!field.empty() && !data.empty()) { @@ -173,7 +173,7 @@ AddCommentField("ENCODER", tags.encoder); if(writeTags) { - AddCommentField("SOURCEMEDIA",L"tracked music file"); + AddCommentField("SOURCEMEDIA", MPT_USTRING("tracked music file")); AddCommentField("TITLE", tags.title ); AddCommentField("ARTIST", tags.artist ); AddCommentField("ALBUM", tags.album ); Modified: trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp 2014-10-01 13:28:43 UTC (rev 4345) +++ trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp 2014-10-01 13:43:56 UTC (rev 4346) @@ -322,7 +322,7 @@ std::memcpy(&buf[0], og.body, og.body_len); WriteBuffer(); } - void AddCommentField(const std::string &field, const std::wstring &data) + void AddCommentField(const std::string &field, const mpt::ustring &data) { if(!field.empty() && !data.empty()) { @@ -484,7 +484,7 @@ AddCommentField("ENCODER", tags.encoder); if(opus_tags) { - AddCommentField("SOURCEMEDIA",L"tracked music file"); + AddCommentField("SOURCEMEDIA", MPT_USTRING("tracked music file")); AddCommentField("TITLE", tags.title ); AddCommentField("ARTIST", tags.artist ); AddCommentField("ALBUM", tags.album ); Modified: trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp 2014-10-01 13:28:43 UTC (rev 4345) +++ trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp 2014-10-01 13:43:56 UTC (rev 4346) @@ -287,7 +287,7 @@ std::memcpy(&buf[0], og.body, og.body_len); WriteBuffer(); } - void AddCommentField(const std::string &field, const std::wstring &data) + void AddCommentField(const std::string &field, const mpt::ustring &data) { if(!field.empty() && !data.empty()) { @@ -346,7 +346,7 @@ AddCommentField("ENCODER", tags.encoder); if(vorbis_tags) { - AddCommentField("SOURCEMEDIA",L"tracked music file"); + AddCommentField("SOURCEMEDIA", MPT_USTRING("tracked music file")); AddCommentField("TITLE", tags.title ); AddCommentField("ARTIST", tags.artist ); AddCommentField("ALBUM", tags.album ); Modified: trunk/OpenMPT/mptrack/mod2wave.h =================================================================== --- trunk/OpenMPT/mptrack/mod2wave.h 2014-10-01 13:28:43 UTC (rev 4345) +++ trunk/OpenMPT/mptrack/mod2wave.h 2014-10-01 13:43:56 UTC (rev 4346) @@ -23,13 +23,13 @@ struct StoredTags { - Setting<std::wstring> artist; - Setting<std::wstring> album; - Setting<std::wstring> trackno; - Setting<std::wstring> year; - Setting<std::wstring> url; + Setting<mpt::ustring> artist; + Setting<mpt::ustring> album; + Setting<mpt::ustring> trackno; + Setting<mpt::ustring> year; + Setting<mpt::ustring> url; - Setting<std::wstring> genre; + Setting<mpt::ustring> genre; StoredTags(SettingsContainer &conf); Modified: trunk/OpenMPT/soundlib/Dither.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dither.cpp 2014-10-01 13:28:43 UTC (rev 4345) +++ trunk/OpenMPT/soundlib/Dither.cpp 2014-10-01 13:43:56 UTC (rev 4346) @@ -23,16 +23,16 @@ // Noise Shaping (Dithering) -std::wstring Dither::GetModeName(DitherMode mode) +mpt::ustring Dither::GetModeName(DitherMode mode) //----------------------------------------------- { switch(mode) { - case DitherNone : return L"no" ; break; - case DitherDefault: return L"default"; break; - case DitherModPlug: return L"0.5 bit"; break; - case DitherSimple : return L"1 bit" ; break; - default : return L"" ; break; + case DitherNone : return MPT_USTRING("no" ); break; + case DitherDefault: return MPT_USTRING("default"); break; + case DitherModPlug: return MPT_USTRING("0.5 bit"); break; + case DitherSimple : return MPT_USTRING("1 bit" ); break; + default : return MPT_USTRING("" ); break; } } Modified: trunk/OpenMPT/soundlib/Dither.h =================================================================== --- trunk/OpenMPT/soundlib/Dither.h 2014-10-01 13:28:43 UTC (rev 4345) +++ trunk/OpenMPT/soundlib/Dither.h 2014-10-01 13:43:56 UTC (rev 4346) @@ -65,7 +65,7 @@ DitherMode GetMode() const; void Reset(); void Process(int *mixbuffer, std::size_t count, std::size_t channels, int bits); - static std::wstring GetModeName(DitherMode mode); + static mpt::ustring GetModeName(DitherMode mode); }; Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-10-01 13:28:43 UTC (rev 4345) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-10-01 13:43:56 UTC (rev 4346) @@ -470,8 +470,8 @@ file.WriteExtraInformation(sample, GetType()); FileTags tags; - tags.title = mpt::ToWide(mpt::CharsetLocale, m_szNames[nSample]); - tags.encoder = mpt::ToWide(mpt::CharsetLocale, MptVersion::GetOpenMPTVersionStr()); + tags.title = mpt::ToUnicode(mpt::CharsetLocale, m_szNames[nSample]); + tags.encoder = mpt::ToUnicode(mpt::CharsetLocale, MptVersion::GetOpenMPTVersionStr()); file.WriteMetatags(tags); return true; Modified: trunk/OpenMPT/soundlib/Tagging.cpp =================================================================== --- trunk/OpenMPT/soundlib/Tagging.cpp 2014-10-01 13:28:43 UTC (rev 4345) +++ trunk/OpenMPT/soundlib/Tagging.cpp 2014-10-01 13:43:56 UTC (rev 4346) @@ -19,7 +19,7 @@ FileTags::FileTags() //------------------ { - encoder = mpt::ToWide(mpt::CharsetASCII, MptVersion::GetOpenMPTVersionStr()); + encoder = mpt::ToUnicode(mpt::CharsetASCII, MptVersion::GetOpenMPTVersionStr()); } #endif // MODPLUG_NO_FILESAVE Modified: trunk/OpenMPT/soundlib/Tagging.h =================================================================== --- trunk/OpenMPT/soundlib/Tagging.h 2014-10-01 13:28:43 UTC (rev 4345) +++ trunk/OpenMPT/soundlib/Tagging.h 2014-10-01 13:43:56 UTC (rev 4346) @@ -21,20 +21,20 @@ //============= { - std::wstring encoder; + mpt::ustring encoder; - std::wstring title; - std::wstring comments; + mpt::ustring title; + mpt::ustring comments; - std::wstring bpm; + mpt::ustring bpm; - std::wstring artist; - std::wstring album; - std::wstring trackno; - std::wstring year; - std::wstring url; + mpt::ustring artist; + mpt::ustring album; + mpt::ustring trackno; + mpt::ustring year; + mpt::ustring url; - std::wstring genre; + mpt::ustring genre; FileTags(); Modified: trunk/OpenMPT/soundlib/WAVTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/WAVTools.cpp 2014-10-01 13:28:43 UTC (rev 4345) +++ trunk/OpenMPT/soundlib/WAVTools.cpp 2014-10-01 13:43:56 UTC (rev 4346) @@ -504,10 +504,10 @@ // Write a single tag into a open idLIST chunk -void WAVWriter::WriteTag(RIFFChunk::id_type id, const std::wstring &wideText) -//--------------------------------------------------------------------------- +void WAVWriter::WriteTag(RIFFChunk::id_type id, const mpt::ustring &utext) +//------------------------------------------------------------------------ { - std::string text = mpt::ToCharset(mpt::CharsetWindows1252, wideText); + std::string text = mpt::ToCharset(mpt::CharsetWindows1252, utext); if(!text.empty()) { const size_t length = text.length() + 1; Modified: trunk/OpenMPT/soundlib/WAVTools.h =================================================================== --- trunk/OpenMPT/soundlib/WAVTools.h 2014-10-01 13:28:43 UTC (rev 4345) +++ trunk/OpenMPT/soundlib/WAVTools.h 2014-10-01 13:43:56 UTC (rev 4346) @@ -474,7 +474,7 @@ void Write(const void *data, size_t numBytes); // Write a single tag into a open idLIST chunk - void WriteTag(RIFFChunk::id_type id, const std::wstring &wideText); + void WriteTag(RIFFChunk::id_type id, const mpt::ustring &utext); }; #endif // MODPLUG_NO_FILESAVE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-02 07:21:43
|
Revision: 4351 http://sourceforge.net/p/modplug/code/4351 Author: manxorist Date: 2014-10-02 07:21:29 +0000 (Thu, 02 Oct 2014) Log Message: ----------- [Ref] Add MPT_UTF8 macro which allows defining mpt::ustring strings with non-ASCII characters by explicitely writing them in UTF-8 encoded form. [Ref] test: Add conversion test cases for mpt::ustring. Modified Paths: -------------- trunk/OpenMPT/common/mptString.h trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2014-10-02 06:49:00 UTC (rev 4350) +++ trunk/OpenMPT/common/mptString.h 2014-10-02 07:21:29 UTC (rev 4351) @@ -340,6 +340,13 @@ #endif // MFC #endif // MPT_USTRING_MODE_WIDE +// The MPT_UTF8 allows specifying UTF8 char arrays. +// The resulting type is mpt::ustring and the construction might require runtime translation, +// i.e. it is NOT generally available at compile time. +// Use explicit UTF8 encoding, +// i.e. U+00FC (LATIN SMALL LETTER U WITH DIAERESIS) would be written as "\xC3\xBC". +#define MPT_UTF8(x) mpt::ToUnicode(mpt::CharsetUTF8, x ) + } // namespace mpt Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2014-10-02 06:49:00 UTC (rev 4350) +++ trunk/OpenMPT/test/test.cpp 2014-10-02 07:21:29 UTC (rev 4351) @@ -64,6 +64,7 @@ static noinline void TestVersion(); static noinline void TestTypes(); static noinline void TestMisc(); +static noinline void TestCharsets(); static noinline void TestStringFormatting(); static noinline void TestSettings(); static noinline void TestStringIO(); @@ -103,6 +104,7 @@ DO_TEST(TestVersion); DO_TEST(TestTypes); DO_TEST(TestMisc); + DO_TEST(TestCharsets); DO_TEST(TestStringFormatting); DO_TEST(TestSettings); DO_TEST(TestStringIO); @@ -584,7 +586,125 @@ VERIFY_EQUAL(strlen(ModSpecs::Collection[i]->volcommands), (size_t)MAX_VOLCMDS); } + // UUID +#ifdef MODPLUG_TRACKER + VERIFY_EQUAL(Util::IsValid(Util::CreateGUID()), true); + VERIFY_EQUAL(Util::IsValid(Util::CreateUUID()), true); + VERIFY_EQUAL(Util::IsValid(Util::CreateLocalUUID()), true); + UUID uuid = Util::CreateUUID(); + VERIFY_EQUAL(IsEqualUUID(uuid, Util::StringToUUID(Util::UUIDToString(uuid))), true); + VERIFY_EQUAL(IsEqualUUID(uuid, Util::StringToGUID(Util::GUIDToString(uuid))), true); + VERIFY_EQUAL(IsEqualUUID(uuid, Util::StringToIID(Util::IIDToString(uuid))), true); + VERIFY_EQUAL(IsEqualUUID(uuid, Util::StringToCLSID(Util::CLSIDToString(uuid))), true); +#endif + +} + + +static noinline void TestCharsets() +//--------------------------------- +{ + + // MPT_UTF8 version + // Charset conversions (basic sanity checks) + VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetUTF8, MPT_USTRING("a")), "a"); + VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetISO8859_1, MPT_USTRING("a")), "a"); + VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetASCII, MPT_USTRING("a")), "a"); + VERIFY_EQUAL(mpt::ToWide(mpt::CharsetUTF8, "a"), MPT_USTRING("a")); + VERIFY_EQUAL(mpt::ToWide(mpt::CharsetISO8859_1, "a"), MPT_USTRING("a")); + VERIFY_EQUAL(mpt::ToWide(mpt::CharsetASCII, "a"), MPT_USTRING("a")); +#if defined(MPT_WITH_CHARSET_LOCALE) + VERIFY_EQUAL(mpt::ToLocale(MPT_USTRING("a")), "a"); + VERIFY_EQUAL(mpt::ToWide(mpt::CharsetLocale, "a"), MPT_USTRING("a")); +#endif + VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetUTF8, MPT_UTF8("a")), "a"); + VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetISO8859_1, MPT_UTF8("a")), "a"); + VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetASCII, MPT_UTF8("a")), "a"); + VERIFY_EQUAL(mpt::ToWide(mpt::CharsetUTF8, "a"), MPT_UTF8("a")); + VERIFY_EQUAL(mpt::ToWide(mpt::CharsetISO8859_1, "a"), MPT_UTF8("a")); + VERIFY_EQUAL(mpt::ToWide(mpt::CharsetASCII, "a"), MPT_UTF8("a")); +#if defined(MPT_WITH_CHARSET_LOCALE) + VERIFY_EQUAL(mpt::ToLocale(MPT_UTF8("a")), "a"); + VERIFY_EQUAL(mpt::ToWide(mpt::CharsetLocale, "a"), MPT_UTF8("a")); +#endif + + // Check that some character replacement is done (and not just empty strings or truncated strings are returned) + // We test german umlaut-a (U+00E4) (\xC3\xA4) and CJK U+5BB6 (\xE5\xAE\xB6) + + VERIFY_EQUAL(EndsWith(mpt::ToCharset(mpt::CharsetASCII,MPT_UTF8("abc\xC3\xA4xyz")),"xyz"),true); + VERIFY_EQUAL(EndsWith(mpt::ToCharset(mpt::CharsetISO8859_1,MPT_UTF8("abc\xC3\xA4xyz")),"xyz"),true); + VERIFY_EQUAL(EndsWith(mpt::ToCharset(mpt::CharsetCP437,MPT_UTF8("abc\xC3\xA4xyz")),"xyz"),true); + VERIFY_EQUAL(EndsWith(mpt::ToCharset(mpt::CharsetUTF8,MPT_UTF8("abc\xC3\xA4xyz")),"xyz"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToCharset(mpt::CharsetASCII,MPT_UTF8("abc\xC3\xA4xyz")),"abc"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToCharset(mpt::CharsetISO8859_1,MPT_UTF8("abc\xC3\xA4xyz")),"abc"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToCharset(mpt::CharsetCP437,MPT_UTF8("abc\xC3\xA4xyz")),"abc"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToCharset(mpt::CharsetUTF8,MPT_UTF8("abc\xC3\xA4xyz")),"abc"),true); +#if defined(MPT_WITH_CHARSET_LOCALE) + VERIFY_EQUAL(EndsWith(mpt::ToCharset(mpt::CharsetLocale,MPT_UTF8("abc\xC3\xA4xyz")),"xyz"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToCharset(mpt::CharsetLocale,MPT_UTF8("abc\xC3\xA4xyz")),"abc"),true); +#endif + + VERIFY_EQUAL(EndsWith(mpt::ToCharset(mpt::CharsetASCII,MPT_UTF8("abc\xE5\xAE\xB6xyz")),"xyz"),true); + VERIFY_EQUAL(EndsWith(mpt::ToCharset(mpt::CharsetISO8859_1,MPT_UTF8("abc\xE5\xAE\xB6xyz")),"xyz"),true); + VERIFY_EQUAL(EndsWith(mpt::ToCharset(mpt::CharsetCP437,MPT_UTF8("abc\xE5\xAE\xB6xyz")),"xyz"),true); + VERIFY_EQUAL(EndsWith(mpt::ToCharset(mpt::CharsetUTF8,MPT_UTF8("abc\xE5\xAE\xB6xyz")),"xyz"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToCharset(mpt::CharsetASCII,MPT_UTF8("abc\xE5\xAE\xB6xyz")),"abc"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToCharset(mpt::CharsetISO8859_1,MPT_UTF8("abc\xE5\xAE\xB6xyz")),"abc"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToCharset(mpt::CharsetCP437,MPT_UTF8("abc\xE5\xAE\xB6xyz")),"abc"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToCharset(mpt::CharsetUTF8,MPT_UTF8("abc\xE5\xAE\xB6xyz")),"abc"),true); +#if defined(MPT_WITH_CHARSET_LOCALE) + VERIFY_EQUAL(EndsWith(mpt::ToCharset(mpt::CharsetLocale,MPT_UTF8("abc\xE5\xAE\xB6xyz")),"xyz"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToCharset(mpt::CharsetLocale,MPT_UTF8("abc\xE5\xAE\xB6xyz")),"abc"),true); +#endif + + VERIFY_EQUAL(EndsWith(mpt::ToWide(mpt::CharsetASCII,"abc\xC3\xA4xyz"),L"xyz"),true); + VERIFY_EQUAL(EndsWith(mpt::ToWide(mpt::CharsetISO8859_1,"abc\xC3\xA4xyz"),L"xyz"),true); + VERIFY_EQUAL(EndsWith(mpt::ToWide(mpt::CharsetCP437,"abc\xC3\xA4xyz"),L"xyz"),true); + VERIFY_EQUAL(EndsWith(mpt::ToWide(mpt::CharsetUTF8,"abc\xC3\xA4xyz"),L"xyz"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToWide(mpt::CharsetASCII,"abc\xC3\xA4xyz"),L"abc"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToWide(mpt::CharsetISO8859_1,"abc\xC3\xA4xyz"),L"abc"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToWide(mpt::CharsetCP437,"abc\xC3\xA4xyz"),L"abc"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToWide(mpt::CharsetUTF8,"abc\xC3\xA4xyz"),L"abc"),true); +#if defined(MPT_WITH_CHARSET_LOCALE) + VERIFY_EQUAL(EndsWith(mpt::ToWide(mpt::CharsetLocale,"abc\xC3\xA4xyz"),L"xyz"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToWide(mpt::CharsetLocale,"abc\xC3\xA4xyz"),L"abc"),true); +#endif + + VERIFY_EQUAL(EndsWith(mpt::ToWide(mpt::CharsetASCII,"abc\xE5\xAE\xB6xyz"),L"xyz"),true); + VERIFY_EQUAL(EndsWith(mpt::ToWide(mpt::CharsetISO8859_1,"abc\xE5\xAE\xB6xyz"),L"xyz"),true); + VERIFY_EQUAL(EndsWith(mpt::ToWide(mpt::CharsetCP437,"abc\xE5\xAE\xB6xyz"),L"xyz"),true); + VERIFY_EQUAL(EndsWith(mpt::ToWide(mpt::CharsetUTF8,"abc\xE5\xAE\xB6xyz"),L"xyz"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToWide(mpt::CharsetASCII,"abc\xE5\xAE\xB6xyz"),L"abc"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToWide(mpt::CharsetISO8859_1,"abc\xE5\xAE\xB6xyz"),L"abc"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToWide(mpt::CharsetCP437,"abc\xE5\xAE\xB6xyz"),L"abc"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToWide(mpt::CharsetUTF8,"abc\xE5\xAE\xB6xyz"),L"abc"),true); +#if defined(MPT_WITH_CHARSET_LOCALE) + VERIFY_EQUAL(EndsWith(mpt::ToWide(mpt::CharsetLocale,"abc\xE5\xAE\xB6xyz"),L"xyz"),true); + VERIFY_EQUAL(BeginsWith(mpt::ToWide(mpt::CharsetLocale,"abc\xE5\xAE\xB6xyz"),L"abc"),true); +#endif + + // Check that characters are correctly converted + // We test german umlaut-a (U+00E4) and CJK U+5BB6 + + // cp437 + VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetCP437,MPT_UTF8("abc\xC3\xA4xyz")),"abc\x84xyz"); + VERIFY_EQUAL(MPT_UTF8("abc\xC3\xA4xyz"),mpt::ToWide(mpt::CharsetCP437,"abc\x84xyz")); + + // iso8859 + VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetISO8859_1,MPT_UTF8("abc\xC3\xA4xyz")),"abc\xE4xyz"); + VERIFY_EQUAL(MPT_UTF8("abc\xC3\xA4xyz"),mpt::ToWide(mpt::CharsetISO8859_1,"abc\xE4xyz")); + + // utf8 + VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetUTF8,MPT_UTF8("abc\xC3\xA4xyz")),"abc\xC3\xA4xyz"); + VERIFY_EQUAL(MPT_UTF8("abc\xC3\xA4xyz"),mpt::ToWide(mpt::CharsetUTF8,"abc\xC3\xA4xyz")); + VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetUTF8,MPT_UTF8("abc\xE5\xAE\xB6xyz")),"abc\xE5\xAE\xB6xyz"); + VERIFY_EQUAL(MPT_UTF8("abc\xE5\xAE\xB6xyz"),mpt::ToWide(mpt::CharsetUTF8,"abc\xE5\xAE\xB6xyz")); + + + // wide L"" version + + // Charset conversions (basic sanity checks) VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetUTF8, L"a"), "a"); VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetISO8859_1, L"a"), "a"); VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetASCII, L"a"), "a"); @@ -681,18 +801,6 @@ VERIFY_EQUAL(MPT_PATHSTRING("\\\\server\\path\\file").RelativePathToAbsolute(exePath), MPT_PATHSTRING("\\\\server\\path\\file")); #endif - // UUID -#ifdef MODPLUG_TRACKER - VERIFY_EQUAL(Util::IsValid(Util::CreateGUID()), true); - VERIFY_EQUAL(Util::IsValid(Util::CreateUUID()), true); - VERIFY_EQUAL(Util::IsValid(Util::CreateLocalUUID()), true); - UUID uuid = Util::CreateUUID(); - VERIFY_EQUAL(IsEqualUUID(uuid, Util::StringToUUID(Util::UUIDToString(uuid))), true); - VERIFY_EQUAL(IsEqualUUID(uuid, Util::StringToGUID(Util::GUIDToString(uuid))), true); - VERIFY_EQUAL(IsEqualUUID(uuid, Util::StringToIID(Util::IIDToString(uuid))), true); - VERIFY_EQUAL(IsEqualUUID(uuid, Util::StringToCLSID(Util::CLSIDToString(uuid))), true); -#endif - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-02 12:28:32
|
Revision: 4356 http://sourceforge.net/p/modplug/code/4356 Author: manxorist Date: 2014-10-02 12:28:17 +0000 (Thu, 02 Oct 2014) Log Message: ----------- [Ref] Completely disable mpt::ToWide in libopenmpt non-Windows builds via MPT_WSTRING_CONVERT macro. [Ref] Document the mpt::ustring and std::wstring related macros in BuildSettings.h . [Ref] Update documentation comments in mptString.h . [Ref] Small related cleanups. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/common/Logging.cpp trunk/OpenMPT/common/Logging.h trunk/OpenMPT/common/mptPathString.h trunk/OpenMPT/common/mptString.cpp trunk/OpenMPT/common/mptString.h trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2014-10-02 08:29:03 UTC (rev 4355) +++ trunk/OpenMPT/common/BuildSettings.h 2014-10-02 12:28:17 UTC (rev 4356) @@ -231,6 +231,60 @@ +#if MPT_COMPILER_MSVC + + // Use wide strings for MSVC because this is the native encoding on + // microsoft platforms. + #define MPT_USTRING_MODE_WIDE 1 + #define MPT_USTRING_MODE_UTF8 0 + +#else // !MPT_COMPILER_MSVC + + #define MPT_USTRING_MODE_WIDE 0 + #define MPT_USTRING_MODE_UTF8 1 + +#endif // MPT_COMPILER_MSVC + +#if MPT_USTRING_MODE_UTF8 + + // MPT_USTRING_MODE_UTF8 mpt::ustring is implemented via mpt::u8string + #define MPT_WITH_U8STRING 1 + +#else + + #define MPT_WITH_U8STRING 0 + +#endif + +#if defined(MODPLUG_TRACKER) || MPT_USTRING_MODE_WIDE + + // mpt::ToWString, mpt::wfmt, mpt::String::PrintW, ConvertStrTo<std::wstring> + // Required by the tracker to ease interfacing with WinAPI. + // Required by MPT_USTRING_MODE_WIDE to ease type tunneling in mpt::String::Print. + #define MPT_WSTRING_FORMAT 1 + +#else + + #define MPT_WSTRING_FORMAT 0 + +#endif + +#if MPT_OS_WINDOWS || MPT_USTRING_MODE_WIDE || MPT_WSTRING_FORMAT + + // mpt::ToWide + // Required on Windows by mpt::PathString. + // Required by MPT_USTRING_MODE_WIDE as they share the conversion functions. + // Required by MPT_WSTRING_FORMAT because of std::string<->std::wstring conversion in mpt::ToString and mpt::ToWString. + #define MPT_WSTRING_CONVERT 1 + +#else + + #define MPT_WSTRING_CONVERT 0 + +#endif + + + // fixing stuff up #if !defined(ENABLE_MMX) && !defined(NO_REVERB) @@ -250,21 +304,6 @@ #define NO_MINIZ #endif -#if MPT_COMPILER_MSVC -#define MPT_WITH_U8STRING 0 -#define MPT_USTRING_MODE_WIDE 1 -#define MPT_USTRING_MODE_UTF8 0 -#else // !MPT_COMPILER_MSVC -#define MPT_WITH_U8STRING 1 -#define MPT_USTRING_MODE_WIDE 0 -#define MPT_USTRING_MODE_UTF8 1 -#endif // MPT_COMPILER_MSVC -#if defined(MODPLUG_TRACKER) || MPT_USTRING_MODE_WIDE -#define MPT_WSTRING_FORMAT 1 -#else -#define MPT_WSTRING_FORMAT 0 -#endif - #if !defined(MPT_CHARSET_WIN32) && !defined(MPT_CHARSET_ICONV) && !defined(MPT_CHARSET_CODECVTUTF8) && !defined(MPT_CHARSET_INTERNAL) #define MPT_CHARSET_INTERNAL #endif Modified: trunk/OpenMPT/common/Logging.cpp =================================================================== --- trunk/OpenMPT/common/Logging.cpp 2014-10-02 08:29:03 UTC (rev 4355) +++ trunk/OpenMPT/common/Logging.cpp 2014-10-02 12:28:17 UTC (rev 4356) @@ -193,7 +193,7 @@ #endif } -#if !(MPT_USTRING_MODE_WIDE) +#if MPT_WSTRING_CONVERT && !(MPT_USTRING_MODE_WIDE) void Logger::operator () (const std::wstring &text) //------------------------------------------------- { Modified: trunk/OpenMPT/common/Logging.h =================================================================== --- trunk/OpenMPT/common/Logging.h 2014-10-02 08:29:03 UTC (rev 4355) +++ trunk/OpenMPT/common/Logging.h 2014-10-02 12:28:17 UTC (rev 4356) @@ -77,7 +77,7 @@ void MPT_PRINTF_FUNC(2,3) operator () (const char *format, ...); void operator () (const mpt::ustring &text); void operator () (const std::string &text); -#if !(MPT_USTRING_MODE_WIDE) +#if MPT_WSTRING_CONVERT && !(MPT_USTRING_MODE_WIDE) void operator () (const std::wstring &text); #endif }; @@ -94,7 +94,7 @@ inline void MPT_PRINTF_FUNC(2,3) operator () (const char * /*format*/, ...) {} inline void operator () (const mpt::ustring & /*text*/ ) {} inline void operator () (const std::string & /*text*/ ) {} -#if !(MPT_USTRING_MODE_WIDE) +#if MPT_WSTRING_CONVERT && !(MPT_USTRING_MODE_WIDE) inline void operator () (const std::wstring & /*text*/ ) {} #endif }; Modified: trunk/OpenMPT/common/mptPathString.h =================================================================== --- trunk/OpenMPT/common/mptPathString.h 2014-10-02 08:29:03 UTC (rev 4355) +++ trunk/OpenMPT/common/mptPathString.h 2014-10-02 12:28:17 UTC (rev 4356) @@ -134,6 +134,9 @@ #if MPT_OS_WINDOWS +#if !(MPT_WSTRING_CONVERT) +#error "mpt::PathString on Windows depends on MPT_WSTRING_CONVERT)" +#endif // conversions #if defined(MPT_WITH_CHARSET_LOCALE) MPT_DEPRECATED_PATH std::string ToLocale() const { return mpt::ToLocale(path); } @@ -175,20 +178,28 @@ #if defined(MPT_WITH_CHARSET_LOCALE) std::string ToLocale() const { return path; } std::string ToUTF8() const { return mpt::ToCharset(mpt::CharsetUTF8, mpt::CharsetLocale, path); } +#if MPT_WSTRING_CONVERT std::wstring ToWide() const { return mpt::ToWide(mpt::CharsetLocale, path); } +#endif mpt::ustring ToUnicode() const { return mpt::ToUnicode(mpt::CharsetLocale, path); } static PathString FromLocale(const std::string &path) { return PathString(path); } static PathString FromUTF8(const std::string &path) { return PathString(mpt::ToCharset(mpt::CharsetLocale, mpt::CharsetUTF8, path)); } +#if MPT_WSTRING_CONVERT static PathString FromWide(const std::wstring &path) { return PathString(mpt::ToCharset(mpt::CharsetLocale, path)); } +#endif static PathString FromUnicode(const mpt::ustring &path) { return PathString(mpt::ToCharset(mpt::CharsetLocale, path)); } RawPathString AsNative() const { return path; } static PathString FromNative(const RawPathString &path) { return PathString(path); } #else std::string ToUTF8() const { return path; } +#if MPT_WSTRING_CONVERT std::wstring ToWide() const { return mpt::ToWide(mpt::CharsetUTF8, path); } +#endif mpt::ustring ToUnicode() const { return mpt::ToUnicode(mpt::CharsetUTF8, path); } static PathString FromUTF8(const std::string &path) { return path; } +#if MPT_WSTRING_CONVERT static PathString FromWide(const std::wstring &path) { return PathString(mpt::ToCharset(mpt::CharsetUTF8, path)); } +#endif static PathString FromUnicode(const mpt::ustring &path) { return PathString(mpt::ToCharset(mpt::CharsetUTF8, path)); } RawPathString AsNative() const { return path; } static PathString FromNative(const RawPathString &path) { return PathString(path); } Modified: trunk/OpenMPT/common/mptString.cpp =================================================================== --- trunk/OpenMPT/common/mptString.cpp 2014-10-02 08:29:03 UTC (rev 4355) +++ trunk/OpenMPT/common/mptString.cpp 2014-10-02 12:28:17 UTC (rev 4356) @@ -1009,15 +1009,19 @@ } // namespace String +#if MPT_WSTRING_CONVERT std::wstring ToWide(Charset from, const std::string &str) { return String::DecodeImpl(from, str); } +#endif +#if MPT_WSTRING_CONVERT std::string ToCharset(Charset to, const std::wstring &str) { return String::EncodeImpl<std::string>(to, str); } +#endif std::string ToCharset(Charset to, Charset from, const std::string &str) { return String::ConvertImpl<std::string>(to, from, str); @@ -1127,10 +1131,12 @@ #if MPT_USTRING_MODE_WIDE // nothing, std::wstring overloads will catch all stuff #else // !MPT_USTRING_MODE_WIDE +#if MPT_WSTRING_CONVERT std::wstring ToWide(const mpt::ustring &str) { return String::DecodeImpl<mpt::ustring>(mpt::CharsetUTF8, str); } +#endif std::string ToCharset(Charset to, const mpt::ustring &str) { return String::ConvertImpl<std::string, mpt::ustring>(to, mpt::CharsetUTF8, str); @@ -1182,18 +1188,21 @@ } #endif +#if MPT_WSTRING_CONVERT #if defined(MPT_WITH_CHARSET_LOCALE) std::string ToString(const std::wstring & x) { return mpt::ToLocale(x); } std::string ToString(const wchar_t * const & x) { return mpt::ToLocale(x); } std::string ToString(const wchar_t & x) { return mpt::ToLocale(std::wstring(1, x)); } -#if MPT_USTRING_MODE_UTF8 -std::string ToString(const mpt::ustring & x) { return mpt::ToLocale(x); } -#endif #else std::string ToString(const std::wstring & x) { return mpt::ToCharset(mpt::CharsetUTF8, x); } std::string ToString(const wchar_t * const & x) { return mpt::ToCharset(mpt::CharsetUTF8, x); } std::string ToString(const wchar_t & x) { return mpt::ToCharset(mpt::CharsetUTF8, std::wstring(1, x)); } +#endif +#endif #if MPT_USTRING_MODE_UTF8 +#if defined(MPT_WITH_CHARSET_LOCALE) +std::string ToString(const mpt::ustring & x) { return mpt::ToLocale(x); } +#else std::string ToString(const mpt::ustring & x) { return mpt::ToCharset(mpt::CharsetUTF8, x); } #endif #endif Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2014-10-02 08:29:03 UTC (rev 4355) +++ trunk/OpenMPT/common/mptString.h 2014-10-02 12:28:17 UTC (rev 4356) @@ -190,12 +190,14 @@ #endif // MPT_WITH_U8STRING +#if MPT_WSTRING_CONVERT // Convert to a wide character string. // The wide encoding is UTF-16 or UTF-32, based on sizeof(wchar_t). // If str does not contain any invalid characters, this conversion is lossless. // Invalid source bytes will be replaced by some replacement character or string. static inline std::wstring ToWide(const std::wstring &str) { return str; } std::wstring ToWide(Charset from, const std::string &str); +#endif // Convert to a string encoded in the 'to'-specified character set. // If str does not contain any invalid characters, @@ -203,11 +205,16 @@ // 'to' is UTF8. // Invalid source bytes or characters that are not representable in the // destination charset will be replaced by some replacement character or string. +#if MPT_WSTRING_CONVERT std::string ToCharset(Charset to, const std::wstring &str); +#endif std::string ToCharset(Charset to, Charset from, const std::string &str); #if defined(_MFC_VER) +#if !(MPT_WSTRING_CONVERT) +#error "MFC depends on MPT_WSTRING_CONVERT)" +#endif // Convert to a MFC CString. The CString encoding depends on UNICODE. // This should also be used when converting to TCHAR strings. @@ -304,6 +311,9 @@ #endif // MPT_USTRING_MODE_UTF8 #if MPT_USTRING_MODE_WIDE +#if !(MPT_WSTRING_CONVERT) +#error "MPT_USTRING_MODE_WIDE depends on MPT_WSTRING_CONVERT)" +#endif static inline mpt::ustring ToUnicode(const std::wstring &str) { return str; } static inline mpt::ustring ToUnicode(Charset from, const std::string &str) { return ToWide(from, str); } #if defined(_MFC_VER) @@ -326,9 +336,14 @@ #endif // MPT_USTRING_MODE_WIDE #if MPT_USTRING_MODE_WIDE +#if !(MPT_WSTRING_CONVERT) +#error "MPT_USTRING_MODE_WIDE depends on MPT_WSTRING_CONVERT)" +#endif // nothing, std::wstring overloads will catch all stuff #else // !MPT_USTRING_MODE_WIDE +#if MPT_WSTRING_CONVERT std::wstring ToWide(const mpt::ustring &str); +#endif std::string ToCharset(Charset to, const mpt::ustring &str); #if defined(_MFC_VER) CString ToCString(const mpt::ustring &str); @@ -354,7 +369,7 @@ // The following section demands a rationale. -// 1. ToString() and ToWString() mimic the semantics of c++11 std::to_string() and std::to_wstring(). +// 1. ToString(), ToWString() an ToUString() mimic the semantics of c++11 std::to_string() and std::to_wstring(). // There is an important difference though. The c++11 versions are specified in terms of sprintf formatting which in turn // depend on the current C locale. This renders these functions unusable in a library context because the current // C locale is set by the library-using application and could be anything. There is no way a library can get reliable semantics @@ -363,7 +378,7 @@ // which results in "C" ASCII locale behavior. // 2. The full suite of printf-like or iostream like number formatting is generally not required. Instead, a sane subset functionality // is provided here. -// For convenience, mpt::Format().ParsePrintf(const char *).ToString(float) allows formatting a single floating point value with a +// For convenience, mpt::fmt::f(const char *, float) allows formatting a single floating point value with a // standard printf-like format string. This itself relies on iostream with classic() locale internally and is thus current locale // agnostic. // When formatting integers, it is recommended to use mpt::fmt::dec or mpt::fmt::hex. Appending a template argument '<n>' sets the width, @@ -375,13 +390,13 @@ // This mimics the behaviour of QString::arg() in QT4/5 or MFC AfxFormatString2(). C printf-like functions offer similar functionality // with a '%n$TYPE' syntax. In .NET, the syntax is '{n}'. This is useful to support localization strings that can change the parameter // ordering. -// 4. Every function is available for std::string and std::wstring. std::string makes no assumption about the encoding, which basically means, -// it should work for any 7-bit or 8-bit encoding, including for example ASCII, UTF8 or the current locale encoding. -// std::string std::wstring -// mpt::ToString mpt::ToWString -// mpt::FormatVal mpt::FormatValW -// mpt::fmt mpt::wfmt -// mpt::String::Print mpt::String::PrintW +// 4. Every function is available for std::string, std::wstring and mpt::ustring. std::string makes no assumption about the encoding, which +// basically means, it should work for any 7-bit or 8-bit encoding, including for example ASCII, UTF8 or the current locale encoding. +// std::string std::wstring mpt::ustring Tstring +// mpt::ToString mpt::ToWString mpt::ToUString mpt::ToStringT<Tstring> +// mpt::FormatVal mpt::FormatValW mpt::FormatValTFunctor<mpt::ustring>() mpt::FormatValTFunctor<Tstring>() +// mpt::fmt mpt::wfmt mpt::ufmt mpt::fmtT<Tstring> +// mpt::String::Print mpt::String::Print mpt::String::Print mpt::String::Print<Tstring> // 5. All functionality here delegates real work outside of the header file so that <sstream> and <locale> do not need to be included when // using this functionality. // Advantages: @@ -389,12 +404,12 @@ // - Faster compile times because <sstream> and <locale> (2 very complex headers) are not included everywhere. // Disadvantages: // - Slightly more c++ code is required for delegating work. -// - As the header does not use iostreams, custom types need to overload mpt::ToString and mpt::ToWstring instead of iostream -// operator << to allow for custom type formatting. -// - std::string and std::wstring are returned from somewhat deep cascades of helper functions. Where possible, code is written in such -// a way that return-value-optimization (RVO) or named-return-value-optimization (NRVO) should be able to eliminate almost all these -// copies. This should not be a problem for any decent modern compiler (and even less so for a c++11 compiler where move-semantics -// will kick in if RVO/NRVO fails). +// - As the header does not use iostreams, custom types need to overload mpt::ToString, mpt::ToWstring and mpt::ToUString instead of +// iostream operator << to allow for custom type formatting. +// - std::string, std::wstring and mpt::ustring are returned from somewhat deep cascades of helper functions. Where possible, code is +// written in such a way that return-value-optimization (RVO) or named-return-value-optimization (NRVO) should be able to eliminate +// almost all these copies. This should not be a problem for any decent modern compiler (and even less so for a c++11 compiler where +// move-semantics will kick in if RVO/NRVO fails). namespace mpt { @@ -406,9 +421,11 @@ static inline std::string ToString(const std::string & x) { return x; } static inline std::string ToString(const char * const & x) { return x; } MPT_DEPRECATED static inline std::string ToString(const char & x) { return std::string(1, x); } // deprecated to catch potential API mis-use, use std::string(1, x) instead +#if MPT_WSTRING_FORMAT MPT_DEPRECATED std::string ToString(const std::wstring & x); MPT_DEPRECATED std::string ToString(const wchar_t * const & x); MPT_DEPRECATED std::string ToString(const wchar_t & x); // deprecated to catch potential API mis-use, use std::wstring(1, x) instead +#endif #if MPT_USTRING_MODE_UTF8 MPT_DEPRECATED std::string ToString(const mpt::ustring & x); #endif @@ -459,7 +476,9 @@ { return mpt::ToUnicode(mpt::CharsetUTF8, ToString(x)); } +#if MPT_WSTRING_FORMAT static inline mpt::ustring ToUString(const std::wstring & x) { return mpt::ToUnicode(x); } +#endif #else template<typename T> mpt::ustring ToUString(const T & x) @@ -735,6 +754,15 @@ } } +template <typename T, typename Tformat> +static inline Tstring f(const Tformat & format, const T& x) +{ + #if defined(HAS_TYPE_TRAITS) + STATIC_ASSERT(std::is_floating_point<T>::value); + #endif + return FormatValTFunctor<Tstring>()(x, Format().ParsePrintf(format)); +} + }; // struct fmtT typedef fmtT<std::string> fmt; Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2014-10-02 08:29:03 UTC (rev 4355) +++ trunk/OpenMPT/test/test.cpp 2014-10-02 12:28:17 UTC (rev 4356) @@ -336,6 +336,7 @@ return (str.rfind(match) == (str.length() - match.length())); } +#if MPT_WSTRING_CONVERT static bool BeginsWith(const std::wstring &str, const std::wstring &match) { return (str.find(match) == 0); @@ -344,6 +345,7 @@ { return (str.rfind(match) == (str.length() - match.length())); } +#endif #if MPT_USTRING_MODE_UTF8 static bool BeginsWith(const mpt::ustring &str, const mpt::ustring &match) @@ -714,6 +716,8 @@ VERIFY_EQUAL(MPT_UTF8("abc\xE5\xAE\xB6xyz"),mpt::ToUnicode(mpt::CharsetUTF8,"abc\xE5\xAE\xB6xyz")); +#if MPT_WSTRING_CONVERT + // wide L"" version // Charset conversions (basic sanity checks) @@ -800,6 +804,9 @@ VERIFY_EQUAL(mpt::ToCharset(mpt::CharsetUTF8,L"abc\u5BB6xyz"),"abc\xE5\xAE\xB6xyz"); VERIFY_EQUAL(L"abc\u5BB6xyz",mpt::ToWide(mpt::CharsetUTF8,"abc\xE5\xAE\xB6xyz")); +#endif + + // Path conversions #ifdef MODPLUG_TRACKER const mpt::PathString exePath = MPT_PATHSTRING("C:\\OpenMPT\\"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-03 13:05:03
|
Revision: 4359 http://sourceforge.net/p/modplug/code/4359 Author: saga-games Date: 2014-10-03 13:04:56 +0000 (Fri, 03 Oct 2014) Log Message: ----------- [New] Can now also drag&drop folders full of song files or VSTs [Mod] OpenMPT: Version is now 1.24.00.06 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/Mptrack.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-10-03 12:42:05 UTC (rev 4358) +++ trunk/OpenMPT/common/versionNumber.h 2014-10-03 13:04:56 UTC (rev 4359) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 00 -#define VER_MINORMINOR 05 +#define VER_MINORMINOR 06 //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/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2014-10-03 12:42:05 UTC (rev 4358) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2014-10-03 13:04:56 UTC (rev 4359) @@ -64,6 +64,28 @@ CDocument *CModDocTemplate::OpenDocumentFile(const mpt::PathString &filename, BOOL addToMru, BOOL makeVisible) //------------------------------------------------------------------------------------------------------------ { + if(::PathIsDirectoryW(filename.AsNative().c_str())) + { + CDocument *pDoc = nullptr; + mpt::PathString path = filename; + if(!path.HasTrailingSlash()) path += MPT_PATHSTRING("\\"); + HANDLE hFind; + WIN32_FIND_DATAW wfd; + MemsetZero(wfd); + if((hFind = FindFirstFileW((path + MPT_PATHSTRING("*.*")).AsNative().c_str(), &wfd)) != INVALID_HANDLE_VALUE) + { + do + { + if(wcscmp(wfd.cFileName, L"..") && wcscmp(wfd.cFileName, L".")) + { + pDoc = OpenDocumentFile(path + mpt::PathString::FromNative(wfd.cFileName), addToMru, makeVisible); + } + } while (FindNextFileW(hFind, &wfd)); + FindClose(hFind); + } + return pDoc; + } + if(!mpt::PathString::CompareNoCase(filename.GetFileExt(), MPT_PATHSTRING(".dll"))) { CVstPluginManager *pPluginManager = theApp.GetPluginManager(); @@ -1371,11 +1393,9 @@ } // Call plugins idle routine for open editor - DWORD curTime = timeGetTime(); - // TODO: is it worth the overhead of checking that 10ms have passed, - // or should we just do it on every idle message? if (m_pPluginManager) { + DWORD curTime = timeGetTime(); //rewbs.vstCompliance: call @ 50Hz if (curTime - m_dwLastPluginIdleCall > 20) //20ms since last call? { @@ -1470,7 +1490,7 @@ ::SetTextColor(hdc, GetSysColor((bDisabled) ? COLOR_GRAYTEXT : COLOR_BTNTEXT)); ::SetBkMode(hdc, TRANSPARENT); HGDIOBJ oldfont = ::SelectObject(hdc, CMainFrame::GetGUIFont()); - ::DrawText(hdc, lpszText, -1, &rect, dwFlags | DT_SINGLELINE | DT_NOPREFIX); + ::DrawTextA(hdc, lpszText, -1, &rect, dwFlags | DT_SINGLELINE | DT_NOPREFIX); ::SelectObject(hdc, oldfont); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-04 12:48:46
|
Revision: 4367 http://sourceforge.net/p/modplug/code/4367 Author: saga-games Date: 2014-10-04 12:48:30 +0000 (Sat, 04 Oct 2014) Log Message: ----------- [Fix] Autosave path validation was not unicode-aware. [Ref] Add IsDirectory() to mpt::PathString. Modified Paths: -------------- trunk/OpenMPT/common/mptPathString.h trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/AutoSaver.h trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/View_tre.cpp Modified: trunk/OpenMPT/common/mptPathString.h =================================================================== --- trunk/OpenMPT/common/mptPathString.h 2014-10-04 09:40:54 UTC (rev 4366) +++ trunk/OpenMPT/common/mptPathString.h 2014-10-04 12:48:30 UTC (rev 4367) @@ -99,7 +99,10 @@ PathString GetPath() const; // Drive + Dir, e.g. "C:\OpenMPT\" PathString GetFileName() const; // File name without extension, e.g. "mptrack" PathString GetFileExt() const; // Extension including dot, e.g. ".exe" - PathString GetFullFileName() const; // File name + extension, e.g. "mptrack.exe" + PathString GetFullFileName() const; // File name + extension, e.g. "mptrack.exe"+ + + // Verify if this path represents a valid directory on the file system. + bool IsDirectory() const { return ::PathIsDirectoryW(path.c_str()) != FALSE; } // Return the same path string with a different (or appended) extension (including "."), e.g. "foo.bar",".txt" -> "foo.txt" or "C:\OpenMPT\foo",".txt" -> "C:\OpenMPT\foo.txt" PathString ReplaceExt(const mpt::PathString &newExt) const; Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2014-10-04 09:40:54 UTC (rev 4366) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2014-10-04 12:48:30 UTC (rev 4367) @@ -45,11 +45,7 @@ m_csFileNameTemplate = fileNameTemplate; } -CAutoSaver::~CAutoSaver() -{ -} - ////////////// // Entry Point ////////////// @@ -347,11 +343,9 @@ m_pAutoSaver = pAutoSaver; } -CAutoSaverGUI::~CAutoSaverGUI() -{ -} void CAutoSaverGUI::DoDataExchange(CDataExchange* pDX) +//---------------------------------------------------- { CPropertyPage::DoDataExchange(pDX); } @@ -370,6 +364,7 @@ // CAutoSaverGUI message handlers BOOL CAutoSaverGUI::OnInitDialog() +//-------------------------------- { CPropertyPage::OnInitDialog(); @@ -390,6 +385,7 @@ void CAutoSaverGUI::OnOK() +//------------------------ { WCHAR tempPath[MAX_PATH]; IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE) ? m_pAutoSaver->Enable() : m_pAutoSaver->Disable(); @@ -409,6 +405,7 @@ } void CAutoSaverGUI::OnBnClickedAutosaveBrowse() +//--------------------------------------------- { WCHAR szPath[MAX_PATH] = L""; ::GetDlgItemTextW(m_hWnd, IDC_AUTOSAVE_PATH, szPath, CountOf(szPath)); @@ -423,6 +420,7 @@ void CAutoSaverGUI::OnBnClickedAutosaveEnable() +//--------------------------------------------- { BOOL enabled = IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE); ::EnableWindow(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_INTERVAL), enabled); @@ -436,8 +434,10 @@ } void CAutoSaverGUI::OnBnClickedAutosaveUseorigdir() +//------------------------------------------------- { - if (IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE)) { + if (IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE)) + { BOOL enabled = IsDlgButtonChecked(IDC_AUTOSAVE_USEORIGDIR); ::EnableWindow(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_PATH), !enabled); ::EnableWindow(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_BROWSE), !enabled); @@ -446,7 +446,9 @@ return; } -void CAutoSaverGUI::OnSettingsChanged() { +void CAutoSaverGUI::OnSettingsChanged() +//------------------------------------- +{ SetModified(TRUE); } @@ -457,17 +459,13 @@ return CPropertyPage::OnSetActive(); } -BOOL CAutoSaverGUI::OnKillActive() -//--------------------------------- +BOOL CAutoSaverGUI::OnKillActive() +//-------------------------------- { - CString path; - GetDlgItemText(IDC_AUTOSAVE_PATH, path); - if (!path.IsEmpty() && (path.Right(1)!="\\")) { - path.Append("\\"); - } - bool pathIsOK = !_access(path, 0); + WCHAR szPath[MAX_PATH] = L""; + ::GetDlgItemTextW(m_hWnd, IDC_AUTOSAVE_PATH, szPath, CountOf(szPath)); - if (!pathIsOK && IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE) && !IsDlgButtonChecked(IDC_AUTOSAVE_USEORIGDIR)) + if (!::PathIsDirectoryW(szPath) && IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE) && !IsDlgButtonChecked(IDC_AUTOSAVE_USEORIGDIR)) { Reporting::Error("Error: backup path does not exist."); ::SetFocus(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_PATH)); Modified: trunk/OpenMPT/mptrack/AutoSaver.h =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.h 2014-10-04 09:40:54 UTC (rev 4366) +++ trunk/OpenMPT/mptrack/AutoSaver.h 2014-10-04 12:48:30 UTC (rev 4367) @@ -22,7 +22,6 @@ //Cons/Destr CAutoSaver(bool enabled=true, int saveInterval=10, int backupHistory=3, bool useOriginalPath=true, mpt::PathString path=mpt::PathString(), mpt::PathString fileNameTemplate=mpt::PathString()); - ~CAutoSaver(); //Work bool DoSave(DWORD curTime); @@ -75,7 +74,6 @@ public: CAutoSaverGUI(CAutoSaver* pAutoSaver); - virtual ~CAutoSaverGUI(); // Dialog Data enum { IDD = IDD_OPTIONS_AUTOSAVE }; Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2014-10-04 09:40:54 UTC (rev 4366) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2014-10-04 12:48:30 UTC (rev 4367) @@ -40,12 +40,12 @@ { // Create a crash directory baseRescuePath = Util::GetTempDirectory() + MPT_PATHSTRING("OpenMPT Crash Files\\"); - if(!PathIsDirectoryW(baseRescuePath.AsNative().c_str())) + if(!baseRescuePath.IsDirectory()) { CreateDirectoryW(baseRescuePath.AsNative().c_str(), nullptr); } baseRescuePath += timestampDir; - if(!PathIsDirectoryW(baseRescuePath.AsNative().c_str()) && !CreateDirectoryW(baseRescuePath.AsNative().c_str(), nullptr)) + if(!baseRescuePath.IsDirectory() && !CreateDirectoryW(baseRescuePath.AsNative().c_str(), nullptr)) { errorMessage += "\n\nCould not create the following directory for saving debug information and modified files to:\n" + mpt::ToCString(baseRescuePath.ToWide()); Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-10-04 09:40:54 UTC (rev 4366) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-10-04 12:48:30 UTC (rev 4367) @@ -2918,7 +2918,7 @@ { // Create template folder if doesn't exist already. const mpt::PathString templateFolder = TrackerDirectories::Instance().GetDefaultDirectory(DIR_TEMPLATE_FILES_USER); - if (!PathIsDirectoryW(templateFolder.AsNative().c_str())) + if (!templateFolder.IsDirectory()) { if (!CreateDirectoryW(templateFolder.AsNative().c_str(), nullptr)) { Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2014-10-04 09:40:54 UTC (rev 4366) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2014-10-04 12:48:30 UTC (rev 4367) @@ -64,7 +64,7 @@ CDocument *CModDocTemplate::OpenDocumentFile(const mpt::PathString &filename, BOOL addToMru, BOOL makeVisible) //------------------------------------------------------------------------------------------------------------ { - if(::PathIsDirectoryW(filename.AsNative().c_str())) + if(filename.IsDirectory()) { CDocument *pDoc = nullptr; mpt::PathString path = filename; @@ -778,7 +778,7 @@ m_szConfigDirectory += MPT_PATHSTRING("\\OpenMPT\\"); // Path doesn't exist yet, so it has to be created - if(PathIsDirectoryW(m_szConfigDirectory.AsNative().c_str()) == 0) + if(!m_szConfigDirectory.IsDirectory()) { CreateDirectoryW(m_szConfigDirectory.AsNative().c_str(), 0); } @@ -797,7 +797,7 @@ mpt::PathString sTuningPath = m_szConfigDirectory + MPT_PATHSTRING("tunings\\"); TrackerDirectories::Instance().SetDefaultDirectory(sTuningPath, DIR_TUNING); - if(PathIsDirectoryW(TrackerDirectories::Instance().GetDefaultDirectory(DIR_TUNING).AsNative().c_str()) == 0) + if(!TrackerDirectories::Instance().GetDefaultDirectory(DIR_TUNING).IsDirectory()) { CreateDirectoryW(TrackerDirectories::Instance().GetDefaultDirectory(DIR_TUNING).AsNative().c_str(), 0); } @@ -809,7 +809,7 @@ sOldTunings = GetAppDirPath(); sOldTunings += MPT_PATHSTRING("tunings\\"); - if(PathIsDirectoryW(sOldTunings.AsNative().c_str()) != 0) + if(sOldTunings.IsDirectory()) { mpt::PathString sSearchPattern; sSearchPattern = sOldTunings; Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2014-10-04 09:40:54 UTC (rev 4366) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2014-10-04 12:48:30 UTC (rev 4367) @@ -1957,7 +1957,7 @@ m_InstrLibHighlightPath = MPT_PATHSTRING(".."); // Highlight first entry } - if(::PathIsDirectoryW(dir.AsNative().c_str())) + if(dir.IsDirectory()) { m_SongFileName = MPT_PATHSTRING(""); delete m_SongFile; @@ -3657,7 +3657,7 @@ if(IsSampleBrowser()) { // Set sample browser location to this directory or file - const bool isSong = ::PathIsDirectoryW(fileName) == FALSE; + const bool isSong = !file.IsDirectory(); CModTree *dirBrowser = CMainFrame::GetMainFrame()->GetUpperTreeview(); dirBrowser->m_InstrLibPath = file.GetPath(); if(isSong) dirBrowser->RefreshInstrumentLibrary(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-04 13:37:19
|
Revision: 4368 http://sourceforge.net/p/modplug/code/4368 Author: saga-games Date: 2014-10-04 13:37:11 +0000 (Sat, 04 Oct 2014) Log Message: ----------- [Ref] Kill Autosaver's unused m_csFileNameTemplate and all related code. [Mod] Autosave: When "Use song's original directory" is enabled, but the song has not been saved so far, it is now saved in a sub folder called "Autosave" instead of the root of the settings directory. [Fix] Autosave: Autosaving modified templates or example tunes did not work as expected. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/installer/install.iss trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/AutoSaver.h trunk/OpenMPT/mptrack/TrackerSettings.cpp Modified: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp 2014-10-04 12:48:30 UTC (rev 4367) +++ trunk/OpenMPT/common/misc_util.cpp 2014-10-04 13:37:11 UTC (rev 4368) @@ -758,13 +758,12 @@ mpt::PathString GetAppPath() { #if defined(MODPLUG_TRACKER) - WCHAR exeFileName[MAX_PATH+1]; - MemsetZero(exeFileName); + WCHAR exeFileName[MAX_PATH + 1] = L""; if(!GetModuleFileNameW(NULL, exeFileName, MAX_PATH)) { return mpt::PathString(); } - return mpt::GetAbsolutePath(mpt::PathString::FromNative(exeFileName).GetDrive() + mpt::PathString::FromNative(exeFileName).GetDir()); + return mpt::GetAbsolutePath(mpt::PathString::FromNative(exeFileName).GetPath()); #else return mpt::PathString(); // dummy #endif @@ -773,8 +772,7 @@ mpt::PathString GetSystemPath() { - WCHAR path[MAX_PATH+1]; - MemsetZero(path); + WCHAR path[MAX_PATH + 1] = L""; if(!GetSystemDirectoryW(path, MAX_PATH)) { return mpt::PathString(); @@ -785,16 +783,15 @@ mpt::PathString GetAbsolutePath(const mpt::PathString &path) { - WCHAR fullPathName[MAX_PATH+1]; - MemsetZero(fullPathName); + WCHAR fullPathName[MAX_PATH + 1] = L""; if(!GetFullPathNameW(path.AsNative().c_str(), MAX_PATH, fullPathName, NULL)) { return path; } return mpt::PathString::FromNative(fullPathName); } - + class LibraryHandle { Modified: trunk/OpenMPT/installer/install.iss =================================================================== --- trunk/OpenMPT/installer/install.iss 2014-10-04 12:48:30 UTC (rev 4367) +++ trunk/OpenMPT/installer/install.iss 2014-10-04 13:37:11 UTC (rev 4368) @@ -12,6 +12,10 @@ #define GetAppVersion StringChange(GetFileProductVersion("..\bin\Win32\mptrack.exe"), ",", ".") #define GetAppVersionShort Copy(GetAppVersion, 1, 4) +#ifndef PlatformName +#error You must specify which installer to build by compiliing either win32.iss or win64.iss +#endif + #ifndef BaseNameAddition #define BaseNameAddition #endif @@ -129,10 +133,12 @@ ; internet shortcut has to be deleted manually Type: files; Name: {app}\ModPlug Central.url ; normal installation +Type: dirifempty; Name: {userappdata}\OpenMPT\Autosave; Tasks: not portable Type: dirifempty; Name: {userappdata}\OpenMPT\TemplateModules; Tasks: not portable Type: dirifempty; Name: {userappdata}\OpenMPT\tunings; Tasks: not portable Type: dirifempty; Name: {userappdata}\OpenMPT; Tasks: not portable ; portable installation +Type: dirifempty; Name: {app}\Autosave; Tasks: portable Type: dirifempty; Name: {app}\TemplateModules; Tasks: portable Type: dirifempty; Name: {app}\tunings; Tasks: portable #ifdef DOWNLOAD_MO3 @@ -281,6 +287,7 @@ DeleteFile(filepath + 'Keybindings.mkb'); DeleteFile(filepath + 'plugin.cache'); DeleteFile(filepath + 'tunings\local_tunings.tc'); + DelTree(filepath + 'Autosave\*.Autosave.*', False, True, False); filepath := GetTempDir(); if(filepath <> '') then Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2014-10-04 12:48:30 UTC (rev 4367) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2014-10-04 13:37:11 UTC (rev 4368) @@ -16,9 +16,6 @@ #include "moptions.h" #include "FileDialog.h" #include <algorithm> -#include <io.h> -#include <stdio.h> -#include <stdlib.h> OPENMPT_NAMESPACE_BEGIN @@ -32,17 +29,16 @@ // Construction/Destruction /////////////////////////// -CAutoSaver::CAutoSaver(bool enabled, int saveInterval, int backupHistory, bool useOriginalPath, mpt::PathString path, mpt::PathString fileNameTemplate) -//----------------------------------------------------------------------------------------------------------------------------------------------------- +CAutoSaver::CAutoSaver(bool enabled, int saveInterval, int backupHistory, bool useOriginalPath, mpt::PathString path) +//------------------------------------------------------------------------------------------------------------------- : m_bSaveInProgress(false) + , m_nLastSave(timeGetTime()) + , m_bEnabled(enabled) + , m_nSaveInterval(saveInterval * 60 * 1000) //minutes to milliseconds + , m_nBackupHistory(backupHistory) + , m_bUseOriginalPath(useOriginalPath) + , m_csPath(path) { - m_nLastSave = timeGetTime(); - m_bEnabled = enabled; - m_nSaveInterval = saveInterval*60*1000; //minutes to milliseconds - m_nBackupHistory = backupHistory; - m_bUseOriginalPath = useOriginalPath; - m_csPath = path; - m_csFileNameTemplate = fileNameTemplate; } @@ -90,105 +86,6 @@ } -//////////////// -// Member access -//////////////// - - -void CAutoSaver::Enable() -//----------------------- -{ - m_bEnabled = true; -} - - -void CAutoSaver::Disable() -//------------------------ -{ - m_bEnabled = false; -} - - -bool CAutoSaver::IsEnabled() -//-------------------------- -{ - return m_bEnabled; -} - - -void CAutoSaver::SetUseOriginalPath(bool useOrgPath) -//-------------------------------------------------- -{ - m_bUseOriginalPath=useOrgPath; -} - - -bool CAutoSaver::GetUseOriginalPath() -//----------------------------------- -{ - return m_bUseOriginalPath; -} - - -void CAutoSaver::SetPath(mpt::PathString path) -//-------------------------------------------- -{ - m_csPath = path; -} - - -mpt::PathString CAutoSaver::GetPath() -//----------------------------------- -{ - return m_csPath; -} - - -void CAutoSaver::SetFilenameTemplate(mpt::PathString fnTemplate) -//-------------------------------------------------------------- -{ - m_csFileNameTemplate = fnTemplate; -} - - -mpt::PathString CAutoSaver::GetFilenameTemplate() -//------------------------------------------------ -{ - return m_csFileNameTemplate; -} - - -void CAutoSaver::SetHistoryDepth(int history) -//------------------------------------------- -{ - Limit(history, 1, 100); - m_nBackupHistory = history; -} - - -int CAutoSaver::GetHistoryDepth() -//------------------------------- -{ - return m_nBackupHistory; -} - - -void CAutoSaver::SetSaveInterval(int minutes) -//------------------------------------------- -{ - Limit(minutes, 1, 10000); - - m_nSaveInterval=minutes * 60 * 1000; //minutes to milliseconds -} - - -int CAutoSaver::GetSaveInterval() -//------------------------------- -{ - return m_nSaveInterval/60/1000; -} - - /////////////////////////// // Implementation internals /////////////////////////// @@ -210,14 +107,18 @@ if(m_bUseOriginalPath) { - if(modDoc.m_bHasValidPath) + if(modDoc.m_bHasValidPath && !(name = modDoc.GetPathNameMpt()).empty()) { - // Check that the file has a user-chosen path - name = modDoc.GetPathNameMpt(); + // File has a user-chosen path - no change required } else { - // if it doesnt, put it in settings dir - name = theApp.GetConfigPath() + mpt::PathString::FromCStringSilent(modDoc.GetTitle()).SanitizeComponent(); + // if it doesn't, put it in settings dir + name = theApp.GetConfigPath() + MPT_PATHSTRING("Autosave\\"); + if(!CreateDirectoryW(name.AsNative().c_str(), nullptr)) + { + name = theApp.GetConfigPath(); + } + name += mpt::PathString::FromCStringSilent(modDoc.GetTitle()).SanitizeComponent(); } } else { @@ -225,7 +126,7 @@ } name += MPT_PATHSTRING(".AutoSave."); //append backup tag - name += mpt::PathString::FromWide(timeStamp); //append timestamp + name += mpt::PathString::FromWide(timeStamp); //append timestamp name += MPT_PATHSTRING("."); //append extension if(modDoc.GetrSoundFile().m_SongFlags[SONG_ITPROJECT]) { @@ -289,13 +190,14 @@ if (m_bUseOriginalPath) { - if (modDoc.m_bHasValidPath) // Check that the file has a user-chosen path + if (modDoc.m_bHasValidPath && !(path = modDoc.GetPathNameMpt()).empty()) { - mpt::PathString fullPath = modDoc.GetPathNameMpt(); - path = fullPath.GetDrive() + fullPath.GetDir(); // remove file name + // File has a user-chosen path - remove filename + path = path.GetPath(); } else { - path = theApp.GetConfigPath(); + // if it doesn't, put it in settings dir + path = theApp.GetConfigPath() + MPT_PATHSTRING("Autosave\\"); } } else { @@ -388,8 +290,7 @@ //------------------------ { WCHAR tempPath[MAX_PATH]; - IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE) ? m_pAutoSaver->Enable() : m_pAutoSaver->Disable(); - m_pAutoSaver->SetFilenameTemplate(MPT_PATHSTRING("")); //TODO + m_pAutoSaver->SetEnabled(IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE) != BST_UNCHECKED); m_pAutoSaver->SetHistoryDepth(GetDlgItemInt(IDC_AUTOSAVE_HISTORY)); m_pAutoSaver->SetSaveInterval(GetDlgItemInt(IDC_AUTOSAVE_INTERVAL)); m_pAutoSaver->SetUseOriginalPath(IsDlgButtonChecked(IDC_AUTOSAVE_USEORIGDIR) == BST_CHECKED); @@ -423,12 +324,12 @@ //--------------------------------------------- { BOOL enabled = IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE); - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_INTERVAL), enabled); - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_HISTORY), enabled); - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_USEORIGDIR), enabled); - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_USECUSTOMDIR), enabled); - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_PATH), enabled); - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_BROWSE), enabled); + GetDlgItem(IDC_AUTOSAVE_INTERVAL)->EnableWindow(enabled); + GetDlgItem(IDC_AUTOSAVE_HISTORY)->EnableWindow(enabled); + GetDlgItem(IDC_AUTOSAVE_USEORIGDIR)->EnableWindow(enabled); + GetDlgItem(IDC_AUTOSAVE_USECUSTOMDIR)->EnableWindow(enabled); + GetDlgItem(IDC_AUTOSAVE_PATH)->EnableWindow(enabled); + GetDlgItem(IDC_AUTOSAVE_BROWSE)->EnableWindow(enabled); OnSettingsChanged(); return; } @@ -439,8 +340,8 @@ if (IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE)) { BOOL enabled = IsDlgButtonChecked(IDC_AUTOSAVE_USEORIGDIR); - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_PATH), !enabled); - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_BROWSE), !enabled); + GetDlgItem(IDC_AUTOSAVE_PATH)->EnableWindow(!enabled); + GetDlgItem(IDC_AUTOSAVE_BROWSE)->EnableWindow(!enabled); OnSettingsChanged(); } return; @@ -467,8 +368,8 @@ if (!::PathIsDirectoryW(szPath) && IsDlgButtonChecked(IDC_AUTOSAVE_ENABLE) && !IsDlgButtonChecked(IDC_AUTOSAVE_USEORIGDIR)) { - Reporting::Error("Error: backup path does not exist."); - ::SetFocus(::GetDlgItem(m_hWnd, IDC_AUTOSAVE_PATH)); + Reporting::Error("Backup path does not exist."); + GetDlgItem(IDC_AUTOSAVE_PATH)->SetFocus(); return 0; } Modified: trunk/OpenMPT/mptrack/AutoSaver.h =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.h 2014-10-04 12:48:30 UTC (rev 4367) +++ trunk/OpenMPT/mptrack/AutoSaver.h 2014-10-04 13:37:11 UTC (rev 4368) @@ -21,26 +21,25 @@ public: //Cons/Destr CAutoSaver(bool enabled=true, int saveInterval=10, int backupHistory=3, - bool useOriginalPath=true, mpt::PathString path=mpt::PathString(), mpt::PathString fileNameTemplate=mpt::PathString()); + bool useOriginalPath=true, mpt::PathString path=mpt::PathString()); //Work bool DoSave(DWORD curTime); //Member access - void Enable(); - void Disable(); - void SetEnabled(bool enabled) { if(enabled) Enable(); else Disable(); } - bool IsEnabled(); - void SetUseOriginalPath(bool useOrgPath); - bool GetUseOriginalPath(); - void SetPath(mpt::PathString path); - mpt::PathString GetPath(); - void SetFilenameTemplate(mpt::PathString path); - mpt::PathString GetFilenameTemplate(); - void SetHistoryDepth(int); - int GetHistoryDepth(); - void SetSaveInterval(int minutes); - int GetSaveInterval(); + void SetEnabled(bool enabled) { m_bEnabled = enabled; } + bool IsEnabled() const { return m_bEnabled; } + void SetUseOriginalPath(bool useOrgPath) { m_bUseOriginalPath = useOrgPath; } + bool GetUseOriginalPath() const { return m_bUseOriginalPath; } + void SetPath(const mpt::PathString &path) { m_csPath = path; } + mpt::PathString GetPath() const { return m_csPath; } + void SetHistoryDepth(int history) { m_nBackupHistory = Clamp(history, 1, 1000); } + int GetHistoryDepth() const { return m_nBackupHistory; } + void SetSaveInterval(int minutes) + { + m_nSaveInterval = Clamp(minutes, 1, 10000) * 60 * 1000; //minutes to milliseconds + } + int GetSaveInterval() const { return m_nSaveInterval / 60 / 1000; } //internal implementation private: @@ -61,7 +60,6 @@ size_t m_nBackupHistory; bool m_bUseOriginalPath; mpt::PathString m_csPath; - mpt::PathString m_csFileNameTemplate; }; Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-10-04 12:48:30 UTC (rev 4367) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-10-04 13:37:11 UTC (rev 4368) @@ -267,7 +267,6 @@ CMainFrame::m_pAutoSaver->SetHistoryDepth(conf.Read<int32>("AutoSave", "BackupHistory", CMainFrame::m_pAutoSaver->GetHistoryDepth())); CMainFrame::m_pAutoSaver->SetUseOriginalPath(conf.Read<bool>("AutoSave", "UseOriginalPath", CMainFrame::m_pAutoSaver->GetUseOriginalPath())); CMainFrame::m_pAutoSaver->SetPath(theApp.RelativePathToAbsolute(conf.Read<mpt::PathString>("AutoSave", "Path", CMainFrame::m_pAutoSaver->GetPath()))); - CMainFrame::m_pAutoSaver->SetFilenameTemplate(conf.Read<mpt::PathString>("AutoSave", "FileNameTemplate", CMainFrame::m_pAutoSaver->GetFilenameTemplate())); // Paths for(size_t i = 0; i < NUM_DIRS; i++) { @@ -862,7 +861,6 @@ conf.Write<int32>("AutoSave", "BackupHistory", CMainFrame::m_pAutoSaver->GetHistoryDepth()); conf.Write<bool>("AutoSave", "UseOriginalPath", CMainFrame::m_pAutoSaver->GetUseOriginalPath()); conf.Write<mpt::PathString>("AutoSave", "Path", path); - conf.Write<mpt::PathString>("AutoSave", "FileNameTemplate", CMainFrame::m_pAutoSaver->GetFilenameTemplate()); // Paths for(size_t i = 0; i < NUM_DIRS; i++) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-05 22:27:04
|
Revision: 4379 http://sourceforge.net/p/modplug/code/4379 Author: saga-games Date: 2014-10-05 22:26:44 +0000 (Sun, 05 Oct 2014) Log Message: ----------- [Imp] Completely rewrote MT2 loader. This is by no means perfect yet, but it's a considerable improvement over the old loader: Some files that would previously not load properly do now load (e.g. Maxus - Andromeda), support for VST plugins and drum patterns has been added. [Mod] Allow CHN_SURROUND to be used as a channel flag (used in MT2 and GDM loaders) [Mod] OpenMPT: Version is now 1.24.00.07 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/soundlib/FileReader.h trunk/OpenMPT/soundlib/Load_gdm.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/patternContainer.cpp trunk/OpenMPT/soundlib/patternContainer.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-10-05 20:52:55 UTC (rev 4378) +++ trunk/OpenMPT/common/versionNumber.h 2014-10-05 22:26:44 UTC (rev 4379) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 00 -#define VER_MINORMINOR 06 +#define VER_MINORMINOR 07 //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/FileReader.h =================================================================== --- trunk/OpenMPT/soundlib/FileReader.h 2014-10-05 20:52:55 UTC (rev 4378) +++ trunk/OpenMPT/soundlib/FileReader.h 2014-10-05 22:26:44 UTC (rev 4379) @@ -870,6 +870,19 @@ } } + // Read a null-terminated string into a std::string or std::wstring + template<typename StrT> + bool ReadNullString(StrT &dest, const off_t maxLength = SIZE_MAX) + { + dest.clear(); + StrT::traits_type::char_type c; + while(Read(c) && c != 0 && dest.length() < maxLength) + { + dest += c; + } + return dest.length() != 0; + } + // Read an array of byte-sized values. // If successful, the file cursor is advanced by the size of the array. // Otherwise, the target is zeroed. @@ -993,12 +1006,12 @@ return false; } - off_t writtenBits = 0; + size_t writtenBits = 0; uint8 b = ReadUint8(); target = (b & 0x7F); // Count actual bits used in most significant byte (i.e. this one) - for(off_t bit = 0; bit < 7; bit++) + for(size_t bit = 0; bit < 7; bit++) { if((b & (1 << bit)) != 0) { Modified: trunk/OpenMPT/soundlib/Load_gdm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_gdm.cpp 2014-10-05 20:52:55 UTC (rev 4378) +++ trunk/OpenMPT/soundlib/Load_gdm.cpp 2014-10-05 22:26:44 UTC (rev 4379) @@ -260,6 +260,7 @@ sample.uFlags.set(CHN_PANNING); // 0...15, 16 = surround (not supported), 255 = no default panning sample.nPan = (gdmSample.panning > 15) ? 128 : MIN((gdmSample.panning * 16) + 8, 256); + sample.uFlags.set(CHN_SURROUND, gdmSample.panning == 16); } else { sample.nPan = 128; Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-05 20:52:55 UTC (rev 4378) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-05 22:26:44 UTC (rev 4379) @@ -2,7 +2,7 @@ * Load_mt2.cpp * ------------ * Purpose: MT2 (MadTracker 2) module loader - * Notes : Plugins are currently not imported. Better rewrite this crap. + * Notes : A couple of things are not handled properly or not at all, such as internal effects and automation envelopes * Authors: Olivier Lapicque * OpenMPT Devs * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. @@ -11,206 +11,341 @@ #include "stdafx.h" #include "Loaders.h" +#ifdef NO_FILEREADER_STD_ISTREAM +#include "../mptrack/MemoryMappedFile.h" +#else +#include "../common/mptFstream.h" +#endif +#ifdef MODPLUG_TRACKER +#include "../mptrack/Moddoc.h" +#endif OPENMPT_NAMESPACE_BEGIN -//#define MT2DEBUG - #ifdef NEEDS_PRAGMA_PACK #pragma pack(push, 1) #endif -typedef struct PACKED _MT2FILEHEADER +struct PACKED MT2FileHeader { - DWORD dwMT20; // 0x3032544D "MT20" - DWORD dwSpecial; - WORD wVersion; - char szTrackerName[32]; // "MadTracker 2.0" - char szSongName[64]; - WORD nOrders; - WORD wRestart; - WORD wPatterns; - WORD wChannels; - WORD wSamplesPerTick; - BYTE bTicksPerLine; - BYTE bLinesPerBeat; - DWORD fulFlags; // b0=packed patterns - WORD wInstruments; - WORD wSamples; - BYTE Orders[256]; -} MT2FILEHEADER; + enum MT2HeaderFlags + { + packedPatterns = 0x01, + automation = 0x02, + drumsAutomation = 0x08, + masterAutomation = 0x10, + }; -STATIC_ASSERT(sizeof(MT2FILEHEADER) == 382); + char signature[4]; // "MT20" + uint32 userID; + uint16 version; + char trackerName[32]; // "MadTracker 2.0" + char songName[64]; + uint16 numOrders; + uint16 restartPos; + uint16 numPatterns; + uint16 numChannels; + uint16 samplesPerTick; + uint8 ticksPerLine; + uint8 linesPerBeat; + uint32 flags; // See HeaderFlags + uint16 numInstruments; + uint16 numSamples; + uint8 Orders[256]; -typedef struct PACKED _MT2PATTERN + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(userID); + SwapBytesLE(version); + SwapBytesLE(numOrders); + SwapBytesLE(restartPos); + SwapBytesLE(numPatterns); + SwapBytesLE(numChannels); + SwapBytesLE(samplesPerTick); + SwapBytesLE(numInstruments); + SwapBytesLE(numSamples); + } +}; + +STATIC_ASSERT(sizeof(MT2FileHeader) == 382); + + +struct PACKED MT2DrumsData { - WORD wLines; - DWORD wDataLen; -} MT2PATTERN; + uint16 numDrumPatterns; + uint16 DrumSamples[8]; + uint8 DrumPatternOrder[256]; -STATIC_ASSERT(sizeof(MT2PATTERN) == 6); + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(numDrumPatterns); + for(size_t i = 0; i < CountOf(DrumSamples); i++) + { + SwapBytesLE(DrumSamples[i]); + } + } +}; -typedef struct PACKED _MT2COMMAND +STATIC_ASSERT(sizeof(MT2DrumsData) == 274); + + +struct PACKED MT2TrackSettings { - BYTE note; // 0=nothing, 97=note off - BYTE instr; - BYTE vol; - BYTE pan; - BYTE fxcmd; - BYTE fxparam1; - BYTE fxparam2; -} MT2COMMAND; + uint16 volume; + uint8 trackfx; // Built-in effect type is used + int8 output; + uint16 fxID; + uint16 trackEffectParam[64][8]; -STATIC_ASSERT(sizeof(MT2COMMAND) == 7); + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(volume); + SwapBytesLE(fxID); + for(size_t i = 0; i < CountOf(trackEffectParam); i++) + { + for(size_t j = 0; j < CountOf(trackEffectParam[0]); j++) + { + SwapBytesLE(trackEffectParam[i][j]); + } + } + } +}; -typedef struct PACKED _MT2DRUMSDATA +STATIC_ASSERT(sizeof(MT2TrackSettings) == 1030); + + +struct PACKED MT2Command { - WORD wDrumPatterns; - WORD wDrumSamples[8]; - BYTE DrumPatternOrder[256]; -} MT2DRUMSDATA; + uint8 note; // 0=nothing, 97=note off + uint8 instr; + uint8 vol; + uint8 pan; + uint8 fxcmd; + uint8 fxparam1; + uint8 fxparam2; +}; -STATIC_ASSERT(sizeof(MT2DRUMSDATA) == 274); +STATIC_ASSERT(sizeof(MT2Command) == 7); -typedef struct PACKED _MT2AUTOMATION + +struct PACKED MT2EnvPoint { - DWORD dwFlags; - DWORD dwEffectId; - DWORD nEnvPoints; -} MT2AUTOMATION; + uint16 x; + uint16 y; -STATIC_ASSERT(sizeof(MT2AUTOMATION) == 12); + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(x); + SwapBytesLE(y); + } +}; -typedef struct PACKED _MT2INSTRUMENT +STATIC_ASSERT(sizeof(MT2EnvPoint) == 4); + + +struct PACKED MT2Instrument { - char szName[32]; - DWORD dwDataLen; - WORD wSamples; - BYTE GroupsMapping[96]; - BYTE bVibType; - BYTE bVibSweep; - BYTE bVibDepth; - BYTE bVibRate; - WORD wFadeOut; - WORD wNNA; - WORD wInstrFlags; - WORD wEnvFlags1; - WORD wEnvFlags2; -} MT2INSTRUMENT; + enum EnvTypes + { + VolumeEnv = 1, + PanningEnv = 2, + PitchEnv = 4, + FilterEnv = 8, + }; -STATIC_ASSERT(sizeof(MT2INSTRUMENT) == 148); + uint16 numSamples; + uint8 groupMap[96]; + uint8 vibtype, vibsweep, vibdepth, vibrate; + uint16 fadeout; + uint16 nna; -typedef struct PACKED _MT2ENVELOPE + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(numSamples); + SwapBytesLE(fadeout); + SwapBytesLE(nna); + } +}; + +STATIC_ASSERT(sizeof(MT2Instrument) == 106); + + +struct PACKED MT2IEnvelope { - BYTE nFlags; - BYTE nPoints; - BYTE nSustainPos; - BYTE nLoopStart; - BYTE nLoopEnd; - BYTE bReserved[3]; - BYTE EnvData[64]; -} MT2ENVELOPE; + uint8 flags; + uint8 numPoints; + uint8 sustainPos; + uint8 loopStart; + uint8 loopEnd; + uint8 reserved[3]; + MT2EnvPoint points[16]; -STATIC_ASSERT(sizeof(MT2ENVELOPE) == 72); + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + for(size_t i = 0; i < CountOf(points); i++) + { + points[i].ConvertEndianness(); + } + } +}; -typedef struct PACKED _MT2SYNTH +STATIC_ASSERT(sizeof(MT2IEnvelope) == 72); + + +// Note: The order of these fields differs a bit in MTIOModule_MT2.cpp - maybe just typos, I'm not sure. +// This struct follows the safe format of MadTracker 2.6.1. +struct PACKED MT2InstrSynth { - BYTE nSynthId; - BYTE nFxId; - WORD wCutOff; - BYTE nResonance; - BYTE nAttack; - BYTE nDecay; - BYTE bReserved[25]; -} MT2SYNTH; + uint8 synthID; + uint8 effectID; // 0 = Lowpass filter, 1 = Highpass filter + uint16 cutoff; // 100...11000 Hz + uint8 resonance; // 0...128 + uint8 attack; // 0...128 + uint8 decay; // 0...128 + uint8 midiChannel; // 0...15 + uint8 device; // VST slot or MIDI device + int8 unknown1; // Missing in MTIOModule_MT2.cpp + uint8 volume; // 0...255 + int8 finetune; // -96...96 + int8 transpose; // -48...48 + uint8 unknown2; // Seems to be equal to instrument number. + uint8 unknown3; + uint8 midiProgram; + uint8 reserved[16]; -STATIC_ASSERT(sizeof(MT2SYNTH) == 32); + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(cutoff); + } +}; -typedef struct PACKED _MT2SAMPLE +STATIC_ASSERT(sizeof(MT2InstrSynth) == 32); + + +struct PACKED MT2Sample { - char szName[32]; - DWORD dwDataLen; - DWORD dwLength; - DWORD dwFrequency; - BYTE nQuality; - BYTE nChannels; - BYTE nFlags; // 8 = no interpolation - BYTE nLoop; - DWORD dwLoopStart; - DWORD dwLoopEnd; - WORD wVolume; - BYTE nPan; - BYTE nBaseNote; - WORD wSamplesPerBeat; -} MT2SAMPLE; + uint32 length; + uint32 frequency; + uint8 depth; + uint8 channels; + uint8 flags; + uint8 loopType; + uint32 loopStart; + uint32 loopEnd; + uint16 volume; + int8 panning; + int8 note; + int16 spb; -STATIC_ASSERT(sizeof(MT2SAMPLE) == 62); + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(length); + SwapBytesLE(frequency); + SwapBytesLE(loopStart); + SwapBytesLE(loopEnd); + SwapBytesLE(volume); + SwapBytesLE(spb); + } +}; -typedef struct PACKED _MT2GROUP +STATIC_ASSERT(sizeof(MT2Sample) == 26); + + +struct PACKED MT2Group { - uint8 nSmpNo; - uint8 nVolume; // 0-128 - int8 nFinePitch; - int8 Reserved[5]; -} MT2GROUP; + uint8 sample; + uint8 vol; // 0...128 + int8 pitch; // -128...127 + uint8 reserved[5]; -STATIC_ASSERT(sizeof(MT2GROUP) == 8); + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(pitch); + } +}; +STATIC_ASSERT(sizeof(MT2Group) == 8); + + +struct PACKED MT2VST +{ + char dll[64]; + char programName[28]; + uint32 fxID; + uint32 fxVersion; + uint32 programNr; + uint8 useChunks; + uint8 track; + int8 pan; // Not imported - could use pan mix mode for D/W ratio, but this is not implemented for instrument plugins! + char reserved[17]; + uint32 n; + + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(fxID); + SwapBytesLE(fxVersion); + SwapBytesLE(programNr); + } +}; + +STATIC_ASSERT(sizeof(MT2VST) == 128); + #ifdef NEEDS_PRAGMA_PACK #pragma pack(pop) #endif -static void ConvertMT2Command(CSoundFile *that, ModCommand *m, MT2COMMAND *p) +static void ConvertMT2Command(CSoundFile *that, ModCommand &m, MT2Command &p) //--------------------------------------------------------------------------- { // Note - m->note = NOTE_NONE; - if (p->note) m->note = (p->note > 96) ? 0xFF : p->note+12; + m.note = NOTE_NONE; + if(p.note) m.note = (p.note > 96) ? NOTE_KEYOFF : (p.note + NOTE_MIN + 11); // Instrument - m->instr = p->instr; + m.instr = p.instr; // Volume Column - if ((p->vol >= 0x10) && (p->vol <= 0x90)) + if(p.vol >= 0x10 && p.vol <= 0x90) { - m->volcmd = VOLCMD_VOLUME; - m->vol = (p->vol - 0x10) >> 1; - } else - if ((p->vol >= 0xA0) && (p->vol <= 0xAF)) + m.volcmd = VOLCMD_VOLUME; + m.vol = (p.vol - 0x10) / 2; + } else if(p.vol >= 0xA0 && p.vol <= 0xAF) { - m->volcmd = VOLCMD_VOLSLIDEDOWN; - m->vol = (p->vol & 0x0f); - } else - if ((p->vol >= 0xB0) && (p->vol <= 0xBF)) + m.volcmd = VOLCMD_VOLSLIDEDOWN; + m.vol = (p.vol & 0x0f); + } else if(p.vol >= 0xB0 && p.vol <= 0xBF) { - m->volcmd = VOLCMD_VOLSLIDEUP; - m->vol = (p->vol & 0x0f); - } else - if ((p->vol >= 0xC0) && (p->vol <= 0xCF)) + m.volcmd = VOLCMD_VOLSLIDEUP; + m.vol = (p.vol & 0x0F); + } else if(p.vol >= 0xC0 && p.vol <= 0xCF) + { + m.volcmd = VOLCMD_FINEVOLDOWN; + m.vol = (p.vol & 0x0F); + } else if(p.vol >= 0xD0 && p.vol <= 0xDF) { - m->volcmd = VOLCMD_FINEVOLDOWN; - m->vol = (p->vol & 0x0f); - } else - if ((p->vol >= 0xD0) && (p->vol <= 0xDF)) - { - m->volcmd = VOLCMD_FINEVOLUP; - m->vol = (p->vol & 0x0f); - } else - { - m->volcmd = 0; - m->vol = 0; + m.volcmd = VOLCMD_FINEVOLUP; + m.vol = (p.vol & 0x0F); } + // Effects - m->command = 0; - m->param = 0; - if ((p->fxcmd) || (p->fxparam1) || (p->fxparam2)) + if(p.fxcmd || p.fxparam1 || p.fxparam2) { - if (!p->fxcmd) + if(!p.fxcmd) { - m->command = p->fxparam2; - m->param = p->fxparam1; - that->ConvertModCommand(*m); + m.command = p.fxparam2; + m.param = p.fxparam1; + that->ConvertModCommand(m); #ifdef MODPLUG_TRACKER - m->Convert(MOD_TYPE_XM, MOD_TYPE_IT); + m.Convert(MOD_TYPE_XM, MOD_TYPE_IT); #endif // MODPLUG_TRACKER } else { @@ -220,465 +355,685 @@ } -bool CSoundFile::ReadMT2(const uint8 *lpStream, DWORD dwMemLength, ModLoadingFlags loadFlags) -//------------------------------------------------------------------------------------------ +// This doesn't really do anything but skipping the envelope chunk at the moment. +static void ReadMT2Automation(uint16 version, FileReader &file) +//------------------------------------------------------------- { - MT2FILEHEADER *pfh = (MT2FILEHEADER *)lpStream; - DWORD dwMemPos, dwDrumDataPos, dwExtraDataPos; - UINT nDrumDataLen, nExtraDataLen; - MT2DRUMSDATA *pdd; - MT2INSTRUMENT *InstrMap[255]; - MT2SAMPLE *SampleMap[256]; + uint32 flags; + uint32 trkfxid; + if(version >= 0x203) + { + flags = file.ReadUint32LE(); + trkfxid = file.ReadUint32LE(); + } else + { + flags = file.ReadUint16LE(); + trkfxid = file.ReadUint16LE(); + } + while(flags != 0) + { + if(flags & 1) + { + file.Skip(4 + sizeof(MT2EnvPoint) * 64); + } + flags >>= 1; + } +} - if ((!lpStream) || (dwMemLength < sizeof(MT2FILEHEADER)) - || (pfh->dwMT20 != 0x3032544D) - || (pfh->wVersion < 0x0200) || (pfh->wVersion >= 0x0300) - || (pfh->wChannels < 1) || (pfh->wChannels > MAX_BASECHANNELS)) + +bool CSoundFile::ReadMT2(FileReader &file, ModLoadingFlags loadFlags) +//------------------------------------------------------------------- +{ + file.Rewind(); + MT2FileHeader fileHeader; + if(!file.ReadConvertEndianness(fileHeader) + || memcmp(fileHeader.signature, "MT20", 4) + || fileHeader.version < 0x200 || fileHeader.version >= 0x300 + || fileHeader.numOrders > 256) { return false; } else if(loadFlags == onlyVerifyHeader) { return true; } - pdd = NULL; InitializeGlobals(); InitializeChannels(); - mpt::String::Read<mpt::String::maybeNullTerminated>(madeWithTracker, pfh->szTrackerName); m_nType = MOD_TYPE_MT2; - m_nChannels = pfh->wChannels; - m_nRestartPos = pfh->wRestart; - m_nDefaultSpeed = pfh->bTicksPerLine; + mpt::String::Read<mpt::String::maybeNullTerminated>(madeWithTracker, fileHeader.trackerName); + mpt::String::Read<mpt::String::maybeNullTerminated>(songName, fileHeader.songName); + m_nChannels = Clamp(fileHeader.numChannels, CHANNELINDEX(1), MAX_BASECHANNELS); + m_nRestartPos = fileHeader.restartPos; + m_nDefaultSpeed = fileHeader.ticksPerLine; + if(!m_nDefaultSpeed) m_nDefaultSpeed = 6; m_nDefaultTempo = 125; - m_SongFlags = (SONG_LINEARSLIDES | SONG_ITCOMPATGXX | SONG_EXFILTERRANGE); - m_nDefaultRowsPerBeat = pfh->bLinesPerBeat; + m_SongFlags = SONG_LINEARSLIDES | SONG_ITCOMPATGXX | SONG_EXFILTERRANGE; + m_nInstruments = fileHeader.numInstruments; + m_nSamples = fileHeader.numSamples; + m_nDefaultRowsPerBeat = fileHeader.linesPerBeat; + if(!m_nDefaultRowsPerBeat) m_nDefaultRowsPerBeat = 4; m_nDefaultRowsPerMeasure = m_nDefaultRowsPerBeat * 4; - if ((pfh->wSamplesPerTick > 100) && (pfh->wSamplesPerTick < 5000)) + SetModSpecsPointer(m_pModSpecs, GetBestSaveFormat()); + + if(fileHeader.samplesPerTick > 100 && fileHeader.samplesPerTick < 5000) { - m_nDefaultTempo = 110250 / pfh->wSamplesPerTick; + m_nDefaultTempo = 110250 / fileHeader.samplesPerTick; + //m_nDefaultTempo = 44100 * 60 / (m_nDefaultSpeed * m_nDefaultRowsPerBeat * fileHeader.samplesPerTick); } - Order.resize(pfh->nOrders, Order.GetInvalidPatIndex()); - for (UINT iOrd=0; iOrd < pfh->nOrders; iOrd++) + Order.ReadFromArray(fileHeader.Orders, fileHeader.numOrders); + + FileReader drumData = file.ReadChunk(file.ReadUint16LE()); + FileReader extraData = file.ReadChunk(file.ReadUint32LE()); + + const CHANNELINDEX channelsWithoutDrums = m_nChannels; + const bool hasDrumChannels = drumData.CanRead(sizeof(MT2DrumsData)); + if(hasDrumChannels) { - Order[iOrd] = (PATTERNINDEX)pfh->Orders[iOrd]; + m_nChannels += 8; } - mpt::String::Read<mpt::String::maybeNullTerminated>(songName, pfh->szSongName); + // Read patterns + for(PATTERNINDEX pat = 0; pat < fileHeader.numPatterns; pat++) + { + ROWINDEX numRows = file.ReadUint16LE(); + FileReader chunk = file.ReadChunk((file.ReadUint32LE() + 1) & ~1); - dwMemPos = sizeof(MT2FILEHEADER); - nDrumDataLen = *const_unaligned_ptr_le<WORD>(lpStream + dwMemPos); - dwDrumDataPos = dwMemPos + 2; - if (nDrumDataLen >= 2) pdd = (MT2DRUMSDATA *)(lpStream+dwDrumDataPos); - dwMemPos += 2 + nDrumDataLen; -#ifdef MT2DEBUG - Log("MT2 v%03X: \"%s\" (flags=%04X)\n", pfh->wVersion, songName.c_str(), pfh->fulFlags); - Log("%d Channels, %d Patterns, %d Instruments, %d Samples\n", pfh->wChannels, pfh->wPatterns, pfh->wInstruments, pfh->wSamples); - Log("Drum Data: %d bytes @%04X\n", nDrumDataLen, dwDrumDataPos); -#endif - if (dwMemPos >= dwMemLength-12) return true; - if (!*const_unaligned_ptr_le<DWORD>(lpStream+dwMemPos)) dwMemPos += 4; - if (!*const_unaligned_ptr_le<DWORD>(lpStream+dwMemPos)) dwMemPos += 4; - nExtraDataLen = *const_unaligned_ptr_le<DWORD>(lpStream+dwMemPos); - dwExtraDataPos = dwMemPos + 4; - dwMemPos += 4; -#ifdef MT2DEBUG - Log("Extra Data: %d bytes @%04X\n", nExtraDataLen, dwExtraDataPos); -#endif - if (dwMemPos + nExtraDataLen >= dwMemLength) return true; - while (dwMemPos+8 < dwExtraDataPos + nExtraDataLen) + LimitMax(numRows, MAX_PATTERN_ROWS); + if(!numRows + || !(loadFlags & loadPatternData) + || Patterns.Insert(pat, numRows)) + { + continue; + } + + if(fileHeader.flags & MT2FileHeader::packedPatterns) + { + ROWINDEX row = 0; + CHANNELINDEX chn = 0; + while(chunk.AreBytesLeft()) + { + MT2Command cmd; + + uint8 infobyte = chunk.ReadUint8(); + uint8 repeatCount = 0; + if(infobyte == 0xFF) + { + repeatCount = chunk.ReadUint8(); + infobyte = chunk.ReadUint8(); + } + if(infobyte & 0x7F) + { + ModCommand *m = Patterns[pat].GetpModCommand(row, chn); + MemsetZero(cmd); + if(infobyte & 0x01) cmd.note = chunk.ReadUint8(); + if(infobyte & 0x02) cmd.instr = chunk.ReadUint8(); + if(infobyte & 0x04) cmd.vol = chunk.ReadUint8(); + if(infobyte & 0x08) cmd.pan = chunk.ReadUint8(); + if(infobyte & 0x10) cmd.fxcmd = chunk.ReadUint8(); + if(infobyte & 0x20) cmd.fxparam1 = chunk.ReadUint8(); + if(infobyte & 0x40) cmd.fxparam2 = chunk.ReadUint8(); + ConvertMT2Command(this, *m, cmd); + const ModCommand &orig = *m; + const ROWINDEX fillRows = std::min((uint32)repeatCount, (uint32)numRows - (row + 1)); + for(ROWINDEX r = 0; r < fillRows; r++) + { + m += GetNumChannels(); + *m = orig; + } + } + row += repeatCount + 1; + while(row >= numRows) { row -= numRows; chn++; } + if(chn >= channelsWithoutDrums) break; + } + } else + { + for(ROWINDEX row = 0; row < numRows; row++) + { + ModCommand *m = Patterns[pat].GetRow(row); + for(CHANNELINDEX chn = 0; chn < channelsWithoutDrums; chn++, m++) + { + MT2Command cmd; + chunk.Read(cmd); + ConvertMT2Command(this, *m, cmd); + } + } + } + } + + // Read extra data + uint32 numVST = 0; + while(extraData.AreBytesLeft()) { - DWORD dwId = *const_unaligned_ptr_le<DWORD>(lpStream+dwMemPos); - DWORD dwLen = *const_unaligned_ptr_le<DWORD>(lpStream+dwMemPos+4); - dwMemPos += 8; - if (dwMemPos + dwLen > dwMemLength) return true; -#ifdef MT2DEBUG - char s[5]; - memcpy(s, &dwId, 4); - s[4] = 0; - Log("pos=0x%04X: %s: %d bytes\n", dwMemPos-8, s, dwLen); -#endif - switch(dwId) + uint32 id = extraData.ReadUint32LE(); + FileReader chunk = extraData.ReadChunk(extraData.ReadUint32LE()); + + switch(id) { - // MSG - case MAGIC4LE('M','S','G','\0'): - if (dwLen > 3) + case MAGIC4LE('B','P','M','+'): + if(0) { - DWORD nTxtLen = dwLen; - if (nTxtLen > 32000) nTxtLen = 32000; - songMessage.Read(lpStream + dwMemPos + 1, nTxtLen - 1, SongMessage::leCRLF); + double d; + if(chunk.Read(d) && fileHeader.samplesPerTick != 0 && d != 0.0) + { + m_nDefaultTempo = Util::Round<uint16>(44100.0 * 60.0 / (m_nDefaultSpeed * m_nDefaultRowsPerBeat * fileHeader.samplesPerTick * d)); + } } break; + + case MAGIC4LE('T','F','X','M'): + break; + case MAGIC4LE('T','R','K','S'): - if (dwLen >= 2) - { - m_nSamplePreAmp = LittleEndianW(*const_unaligned_ptr_le<uint16>(lpStream+dwMemPos)) >> 9; - dwMemPos += 2; - } + m_nSamplePreAmp = chunk.ReadUint16LE() >> 9; // 131072 is 0dB... I think (that's how MTIOModule_MT2.cpp reads) for(CHANNELINDEX c = 0; c < GetNumChannels(); c++) { - ChnSettings[c].Reset(); - if(dwMemPos + 1030 < dwMemLength) + MT2TrackSettings trackSettings; + if(chunk.ReadConvertEndianness(trackSettings)) { - ChnSettings[c].nVolume = LittleEndianW(*const_unaligned_ptr_le<uint16>(lpStream+dwMemPos)) >> 9; + ChnSettings[c].nVolume = trackSettings.volume >> 10; // 32768 is 0dB LimitMax(ChnSettings[c].nVolume, uint16(64)); - dwMemPos += 1030; } } break; - // SUM -> author name (or "Unregistered") - // TMAP - } - dwMemPos += dwLen; - } - // Load Patterns - dwMemPos = dwExtraDataPos + nExtraDataLen; - for (PATTERNINDEX iPat=0; iPat < pfh->wPatterns; iPat++) if (dwMemPos < dwMemLength - 6) - { - MT2PATTERN *pmp = (MT2PATTERN *)(lpStream+dwMemPos); - UINT wDataLen = (pmp->wDataLen + 1) & ~1; - dwMemPos += 6; - if (dwMemPos + wDataLen > dwMemLength) break; - UINT nLines = pmp->wLines; - if ((iPat < MAX_PATTERNS) && (nLines > 0) && (nLines <= MAX_PATTERN_ROWS) && (loadFlags & loadPatternData)) - { - #ifdef MT2DEBUG - Log("Pattern #%d @%04X: %d lines, %d bytes\n", iPat, dwMemPos-6, nLines, pmp->wDataLen); - #endif - Patterns.Insert(iPat, nLines); - if (!Patterns[iPat]) return true; - ModCommand *m = Patterns[iPat]; - UINT len = wDataLen; - if (pfh->fulFlags & 1) // Packed Patterns + + case MAGIC4LE('T','R','K','L'): + for(CHANNELINDEX i = 0; i < m_nChannels && chunk.AreBytesLeft(); i++) { - BYTE *p = (BYTE *)(lpStream+dwMemPos); - UINT pos = 0, row=0, ch=0; - while (pos < len) + std::string name; + chunk.ReadNullString(name); + mpt::String::Read<mpt::String::spacePadded>(ChnSettings[i].szName, name.c_str(), name.length()); + } + break; + + case MAGIC4LE('P','A','T','N'): + for(PATTERNINDEX i = 0; i < fileHeader.numPatterns && chunk.AreBytesLeft(); i++) + { + std::string name; + chunk.ReadNullString(name); + Patterns[i].SetName(name); + } + break; + + case MAGIC4LE('M','S','G','\0'): + chunk.Skip(1); // Show message on startup + songMessage.Read(chunk, chunk.BytesLeft(), SongMessage::leCRLF); + break; + + case MAGIC4LE('P','I','C','T'): + break; + + case MAGIC4LE('S','U','M','\0'): + { + uint8 summaryMask[6]; + chunk.ReadArray(summaryMask); + chunk.ReadNullString(songArtist); + if(songArtist == "Unregistered") songArtist.clear(); + } + break; + + case MAGIC4LE('T','M','A','P'): + break; + case MAGIC4LE('M','I','D','I'): + break; + case MAGIC4LE('T','R','E','Q'): + break; + + case MAGIC4LE('V','S','T','2'): + if(!(loadFlags & loadPluginData)) + { + break; + } + numVST = chunk.ReadUint32LE(); + LimitMax(numVST, MAX_MIXPLUGINS); + for(uint32 i = 0; i < numVST; i++) + { + MT2VST vstHeader; + if(chunk.ReadConvertEndianness(vstHeader)) { - MT2COMMAND cmd; - UINT infobyte = p[pos++]; - UINT rptcount = 0; - if (infobyte == 0xff) + chunk.Skip(64); // Seems to always contain values 0-15 as uint32? Maybe some MIDI routing info? + + SNDMIXPLUGIN &mixPlug = m_MixPlugins[i]; + mixPlug.Destroy(); + mpt::String::Read<mpt::String::maybeNullTerminated>(mixPlug.Info.szLibraryName, vstHeader.dll); + mpt::String::Read<mpt::String::maybeNullTerminated>(mixPlug.Info.szName, vstHeader.programName); + mixPlug.Info.dwPluginId1 = kEffectMagic; + mixPlug.Info.dwPluginId2 = vstHeader.fxID; + mixPlug.defaultProgram = vstHeader.programNr; + if(vstHeader.track >= m_nChannels) { - rptcount = p[pos++]; - infobyte = p[pos++]; - #if 0 - Log("(%d.%d) FF(%02X).%02X\n", row, ch, rptcount, infobyte); + mixPlug.SetMasterEffect(true); } else { - Log("(%d.%d) %02X\n", row, ch, infobyte); - #endif + if(!ChnSettings[vstHeader.track].nMixPlugin) + { + ChnSettings[vstHeader.track].nMixPlugin = static_cast<PLUGINDEX>(i + 1); + } else + { + // Channel already has plugin assignment - chain the plugins + PLUGINDEX outPlug = ChnSettings[vstHeader.track].nMixPlugin - 1; + while(true) + { + if(m_MixPlugins[outPlug].GetOutputPlugin() == PLUGINDEX_INVALID) + { + m_MixPlugins[outPlug].SetOutputPlugin(static_cast<PLUGINDEX>(i)); + break; + } + outPlug = m_MixPlugins[outPlug].GetOutputPlugin(); + } + } } - if (infobyte & 0x7f) + + // Read plugin settings + if(vstHeader.useChunks) { - UINT patpos = row*m_nChannels+ch; - cmd.note = cmd.instr = cmd.vol = cmd.pan = cmd.fxcmd = cmd.fxparam1 = cmd.fxparam2 = 0; - if (infobyte & 1) cmd.note = p[pos++]; - if (infobyte & 2) cmd.instr = p[pos++]; - if (infobyte & 4) cmd.vol = p[pos++]; - if (infobyte & 8) cmd.pan = p[pos++]; - if (infobyte & 16) cmd.fxcmd = p[pos++]; - if (infobyte & 32) cmd.fxparam1 = p[pos++]; - if (infobyte & 64) cmd.fxparam2 = p[pos++]; - #ifdef MT2DEBUG - if (cmd.fxcmd) + LimitMax(vstHeader.n, Util::MaxValueOfType(mixPlug.nPluginDataSize) - 4); + mixPlug.nPluginDataSize = vstHeader.n + 4; + } else + { + LimitMax(vstHeader.n, Util::MaxValueOfType(mixPlug.nPluginDataSize) / 4u); + mixPlug.nPluginDataSize = vstHeader.n * 4; + } + mixPlug.pPluginData = new (std::nothrow) char[mixPlug.nPluginDataSize]; + if(mixPlug.pPluginData != nullptr) + { + if(vstHeader.useChunks) { - Log("(%d.%d) MT2 FX=%02X.%02X.%02X\n", row, ch, cmd.fxcmd, cmd.fxparam1, cmd.fxparam2); - } - #endif - ConvertMT2Command(this, &m[patpos], &cmd); - const ModCommand &orig = m[patpos]; - const ROWINDEX fillRows = std::min(rptcount, nLines - (row + 1)); - for(ROWINDEX r = 0; r < fillRows; r++) + memcpy(mixPlug.pPluginData, "fEvN", 4); // 'NvEf' + chunk.ReadRaw(mixPlug.pPluginData + 4, vstHeader.n); + } else { - patpos += GetNumChannels(); - m[patpos] = orig; + float32 *f = reinterpret_cast<float32 *>(mixPlug.pPluginData); + for(uint32 param = 0; param < vstHeader.n; param++, f++) + { + *f = chunk.ReadFloatLE(); + } } } - row += rptcount+1; - while (row >= nLines) { row-=nLines; ch++; } - if (ch >= m_nChannels) break; } - } else + } + break; + } + } + + // Read drum channels + INSTRUMENTINDEX drumMap[8] = { 0 }; + if(hasDrumChannels) + { + MT2DrumsData drumHeader; + drumData.ReadConvertEndianness(drumHeader); + + // Allocate some instruments to handle the drum samples + for(INSTRUMENTINDEX i = 0; i < 8; i++) + { + drumMap[i] = GetNextFreeInstrument(m_nInstruments + 1); + if(drumMap[i] != INSTRUMENTINDEX_INVALID) { - MT2COMMAND *p = (MT2COMMAND *)(lpStream+dwMemPos); - UINT n = 0; - while ((len > sizeof(MT2COMMAND)) && (n < m_nChannels*nLines)) + m_nInstruments = drumMap[i]; + ModInstrument *mptIns = AllocateInstrument(drumMap[i], drumHeader.DrumSamples[i] + 1); + if(mptIns != nullptr) { - ConvertMT2Command(this, m, p); - len -= sizeof(MT2COMMAND); - n++; - p++; - m++; + strcpy(mptIns->name, "Drum #x"); + mptIns->name[6] = '1' + char(i); } + } else + { + drumMap[i] = 0; } } - dwMemPos += wDataLen; - } - // Skip Drum Patterns - if (pdd) - { - #ifdef MT2DEBUG - Log("%d Drum Patterns at offset 0x%08X\n", pdd->wDrumPatterns, dwMemPos); - #endif - for (UINT iDrm=0; iDrm<pdd->wDrumPatterns; iDrm++) + + // Get all the drum pattern chunks + std::vector<FileReader> patternChunks(drumHeader.numDrumPatterns); + for(uint32 pat = 0; pat < drumHeader.numDrumPatterns; pat++) { - if (dwMemPos > dwMemLength-2) return true; - UINT nLines = *const_unaligned_ptr_le<WORD>(lpStream+dwMemPos); - #ifdef MT2DEBUG - if (nLines != 64) Log("Drum Pattern %d: %d Lines @%04X\n", iDrm, nLines, dwMemPos); - #endif - dwMemPos += 2 + nLines * 32; + uint16 numRows = file.ReadUint16LE(); + patternChunks[pat] = file.ReadChunk(numRows * 32); } - } - // Automation - if (pfh->fulFlags & 2) - { - #ifdef MT2DEBUG - Log("Automation at offset 0x%08X\n", dwMemPos); - #endif - UINT nAutoCount = m_nChannels; - if (pfh->fulFlags & 0x10) nAutoCount++; // Master Automation - if ((pfh->fulFlags & 0x08) && (pdd)) nAutoCount += 8; // Drums Automation - nAutoCount *= pfh->wPatterns; - for (UINT iAuto=0; iAuto<nAutoCount; iAuto++) + + std::vector<PATTERNINDEX> patMapping(fileHeader.numPatterns, PATTERNINDEX_INVALID); + for(uint32 ord = 0; ord < fileHeader.numOrders; ord++) { - if (dwMemPos+12 >= dwMemLength) return true; - MT2AUTOMATION *pma = (MT2AUTOMATION *)(lpStream+dwMemPos); - dwMemPos += (pfh->wVersion <= 0x201) ? 4 : 8; - for (UINT iEnv=0; iEnv<14; iEnv++) + if(drumHeader.DrumPatternOrder[ord] >= drumHeader.numDrumPatterns) + continue; + + // Figure out where to write this drum pattern + PATTERNINDEX writePat = Order[ord]; + if(patMapping[writePat] == PATTERNINDEX_INVALID) { - if (pma->dwFlags & (1 << iEnv)) + patMapping[writePat] = drumHeader.DrumPatternOrder[ord]; + } else if(patMapping[writePat] != drumHeader.DrumPatternOrder[ord]) + { + // Damn, this pattern has previously used a different drum pattern. Duplicate it... + PATTERNINDEX newPat = Patterns.Duplicate(writePat); + if(newPat != PATTERNINDEX_INVALID) { - #ifdef MT2DEBUG - UINT nPoints = *(DWORD *)(lpStream+dwMemPos); - Log(" Env[%d/%d] %04X @%04X: %d points\n", iAuto, nAutoCount, 1 << iEnv, dwMemPos-8, nPoints); - #endif - dwMemPos += 260; + writePat = newPat; + Order[ord] = writePat; } } + + FileReader &chunk = patternChunks[drumHeader.DrumPatternOrder[ord]]; + chunk.Rewind(); + const ROWINDEX numRows = chunk.GetLength() / 32u; + for(ROWINDEX row = 0; row < Patterns[writePat].GetNumRows(); row++) + { + ModCommand *m = Patterns[writePat].GetpModCommand(row, m_nChannels - 8); + for(CHANNELINDEX chn = 0; chn < 8; chn++, m++) + { + *m = ModCommand::Empty(); + if(row >= numRows) + continue; + + uint8 drums[4]; + chunk.ReadArray(drums); + if(drums[0] & 0x80) + { + m->note = NOTE_MIDDLEC; + m->instr = static_cast<ModCommand::INSTR>(drumMap[chn]); + uint8 delay = drums[0] & 0x1F; + if(delay) + { + LimitMax(delay, uint8(0x0F)); + m->command = CMD_S3MCMDEX; + m->param = 0xD0 | delay; + } + m->volcmd = VOLCMD_VOLUME; + // Volume is actually 0...255, but 128 is equivalent to v64 :/ + m->vol = (std::min(drums[1], uint8(128)) + 1) / 2u; + } + } + } } } - // Load Instruments -#ifdef MT2DEBUG - Log("Loading instruments at offset 0x%08X\n", dwMemPos); -#endif - MemsetZero(InstrMap); - m_nInstruments = (pfh->wInstruments < MAX_INSTRUMENTS) ? pfh->wInstruments : MAX_INSTRUMENTS-1; - for(INSTRUMENTINDEX iIns = 1; iIns <= 255; iIns++) + + // Read automation envelopes + if(fileHeader.flags & MT2FileHeader::automation) { - if (dwMemPos+36 > dwMemLength) return true; - MT2INSTRUMENT *pmi = (MT2INSTRUMENT *)(lpStream+dwMemPos); - ModInstrument *pIns = NULL; - if (iIns <= m_nInstruments) + for(uint32 pat = 0; pat < fileHeader.numPatterns; pat++) { - pIns = AllocateInstrument(iIns); - if(pIns != nullptr) + const uint32 numEnvelopes = ((fileHeader.flags & MT2FileHeader::drumsAutomation) ? m_nChannels : channelsWithoutDrums) + + numVST + + ((fileHeader.flags & MT2FileHeader::masterAutomation) ? 1 : 0); + for(uint32 env = 0; env < numEnvelopes; env++) { - mpt::String::Read<mpt::String::maybeNullTerminated>(pIns->name, pmi->szName); + // TODO + ReadMT2Automation(fileHeader.version, file); } } - #ifdef MT2DEBUG - if (iIns <= pfh->wInstruments) Log(" Instrument #%d at offset %04X: %d bytes\n", iIns, dwMemPos, pmi->dwDataLen); - #endif - if (((int)pmi->dwDataLen > 0) && (dwMemPos <= dwMemLength - 40) && (pmi->dwDataLen <= dwMemLength - (dwMemPos + 40))) + } + + // Read instruments + std::vector<FileReader> instrChunks(255); + for(INSTRUMENTINDEX i = 0; i < 255; i++) + { + char instrName[32]; + file.ReadArray(instrName); + uint32 dataLength = file.ReadUint32LE(); + if(dataLength == 32) dataLength += 108 + sizeof(MT2IEnvelope) * 4; + if(fileHeader.version > 0x0201 && dataLength) dataLength += 4; + + FileReader instrChunk = instrChunks[i] = file.ReadChunk(dataLength); + + ModInstrument *mptIns = nullptr; + if(i < fileHeader.numInstruments) { - InstrMap[iIns-1] = pmi; - if (pIns) + mptIns = AllocateInstrument(i + 1); + } + if(mptIns == nullptr) + continue; + + mpt::String::Read<mpt::String::maybeNullTerminated>(mptIns->name, instrName); + + if(!dataLength) + continue; + + MT2Instrument insHeader; + instrChunk.ReadConvertEndianness(insHeader); + uint16 flags = 0; + if(fileHeader.version >= 0x0201) flags = instrChunk.ReadUint16LE(); + uint32 envMask = MT2Instrument::VolumeEnv | MT2Instrument::PanningEnv; + if(fileHeader.version >= 0x0202) envMask = instrChunk.ReadUint32LE(); + + mptIns->nFadeOut = insHeader.fadeout; + const uint8 NNA[4] = { NNA_NOTECUT, NNA_CONTINUE, NNA_NOTEOFF, NNA_NOTEFADE }; + const uint8 DCT[4] = { DCT_NONE, DCT_NOTE, DCT_SAMPLE, DCT_INSTRUMENT }; + const uint8 DNA[4] = { DNA_NOTECUT, DNA_NOTEFADE /* actually continue, but IT doesn't have that */, DNA_NOTEOFF, DNA_NOTEFADE }; + mptIns->nNNA = NNA[insHeader.nna & 3]; + mptIns->nDCT = DCT[(insHeader.nna >> 8) & 3]; + mptIns->nDNA = DNA[(insHeader.nna >> 12) & 3]; + + // Load envelopes + for(uint32 env = 0; env < 4; env++) + { + if(envMask & 1) { - pIns->nFadeOut = pmi->wFadeOut; - pIns->nNNA = pmi->wNNA & 3; - pIns->nDCT = (pmi->wNNA>>8) & 3; - pIns->nDNA = (pmi->wNNA>>12) & 3; - MT2ENVELOPE *pehdr[4]; - const_unaligned_ptr_le<WORD> pedata[4]; + MT2IEnvelope mt2Env; + instrChunk.ReadConvertEndianness(mt2Env); + + const enmEnvelopeTypes envType[4] = { ENV_VOLUME, ENV_PANNING, ENV_PITCH, ENV_PITCH }; + InstrumentEnvelope &mptEnv = mptIns->GetEnvelope(envType[env]); - if (pfh->wVersion <= 0x201) + mptEnv.dwFlags.set(ENV_FILTER, (env == 3) && (mt2Env.flags & 1) != 0); + mptEnv.dwFlags.set(ENV_ENABLED, (mt2Env.flags & 1) != 0); + mptEnv.dwFlags.set(ENV_SUSTAIN, (mt2Env.flags & 2) != 0); + mptEnv.dwFlags.set(ENV_LOOP, (mt2Env.flags & 4) != 0); + mptEnv.nNodes = mt2Env.numPoints; + LimitMax(mptEnv.nNodes, 16u); + mptEnv.nSustainStart = mptEnv.nSustainEnd = mt2Env.sustainPos; + mptEnv.nLoopStart = mt2Env.loopStart; + mptEnv.nLoopEnd = mt2Env.loopEnd; + + for(uint32 i = 0; i < mptEnv.nNodes; i++) { - DWORD dwEnvPos = dwMemPos + sizeof(MT2INSTRUMENT) - 4; - pehdr[0] = (MT2ENVELOPE *)(lpStream+dwEnvPos); - pehdr[1] = (MT2ENVELOPE *)(lpStream+dwEnvPos+8); - pehdr[2] = pehdr[3] = NULL; - pedata[0] = const_unaligned_ptr_le<WORD>(lpStream+dwEnvPos+16); - pedata[1] = const_unaligned_ptr_le<WORD>(lpStream+dwEnvPos+16+64); - pedata[2] = pedata[3] = const_unaligned_ptr_le<WORD>(); - } else + mptEnv.Ticks[i] = mt2Env.points[i].x; + mptEnv.Values[i] = static_cast<uint8>(Clamp(mt2Env.points[i].y, uint16(0), uint16(64))); + } + } + envMask >>= 1; + } + if(!mptIns->VolEnv.dwFlags[ENV_ENABLED]) + { + mptIns->nFadeOut = int16_max; + } + + if(flags) + { + MT2InstrSynth synthData; + instrChunk.ReadConvertEndianness(synthData); + + float cutoff = Clamp(synthData.cutoff, uint16(130), uint16(10670)); + cutoff = 28.8539f * std::log(0.00764451f * cutoff); // Translate frequency back to IT cutoff factor + mptIns->SetCutoff(static_cast<uint8>(cutoff), (flags & 2) != 0); + mptIns->SetResonance(synthData.resonance, (flags & 2) != 0); + mptIns->nFilterMode = synthData.effectID == 1 ? FLTMODE_HIGHPASS : FLTMODE_LOWPASS; + if(flags & 4) + { + // VST enabled + mptIns->nMidiChannel = synthData.midiChannel + 1; + mptIns->nMidiProgram = synthData.midiProgram + 1; + mptIns->nMixPlug = synthData.device + 1; + if(synthData.device == -1) { - DWORD dwEnvPos = dwMemPos + sizeof(MT2INSTRUMENT); - for (UINT i=0; i<4; i++) - { - if (pmi->wEnvFlags1 & (1<<i)) - { - pehdr[i] = (MT2ENVELOPE *)(lpStream+dwEnvPos); - pedata[i] = const_unaligned_ptr_le<WORD>(pehdr[i]->EnvData); - dwEnvPos += sizeof(MT2ENVELOPE); - } else - { - pehdr[i] = NULL; - pedata[i] = const_unaligned_ptr_le<WORD>(); - } - } + // TODO: This is a MIDI device - maybe use MIDI I/O plugin to emulate those? } - // Load envelopes - for (UINT iEnv=0; iEnv<4; iEnv++) if (pehdr[iEnv]) + if(synthData.transpose) { - MT2ENVELOPE *pme = pehdr[iEnv]; - InstrumentEnvelope *pEnv; - #ifdef MT2DEBUG - Log(" Env %d.%d @%04X: %d points\n", iIns, iEnv, (UINT)(((BYTE *)pme)-lpStream), pme->nPoints); - #endif - - switch(iEnv) + for(uint32 i = 0; i < CountOf(mptIns->NoteMap); i++) { - case 0: // Volume Envelope - pEnv = &pIns->VolEnv; - break; - case 1: // Panning Envelope - pEnv = &pIns->PanEnv; - break; - default: // Pitch/Filter envelope - pEnv = &pIns->PitchEnv; - pIns->PitchEnv.dwFlags.set(ENV_FILTER, (pme->nFlags & 1) && iEnv == 3); + int note = NOTE_MIN + i + synthData.transpose; + Limit(note, NOTE_MIN, NOTE_MAX); + mptIns->NoteMap[i] = static_cast<uint8>(note); } - - pEnv->dwFlags.set(ENV_ENABLED, (pme->nFlags & 1) != 0); - pEnv->dwFlags.set(ENV_SUSTAIN, (pme->nFlags & 2) != 0); - pEnv->dwFlags.set(ENV_LOOP, (pme->nFlags & 4) != 0); - pEnv->nNodes = (pme->nPoints > 16) ? 16 : pme->nPoints; - pEnv->nSustainStart = pEnv->nSustainEnd = pme->nSustainPos; - pEnv->nLoopStart = pme->nLoopStart; - pEnv->nLoopEnd = pme->nLoopEnd; - - // Envelope data - if (pedata[iEnv]) - { - const_unaligned_ptr_le<WORD> psrc = pedata[iEnv]; - for (UINT i=0; i<16; i++) - { - pEnv->Ticks[i] = psrc[i*2]; - pEnv->Values[i] = (BYTE)psrc[i*2+1]; - } - } } } - dwMemPos += pmi->dwDataLen + 36; - if (pfh->wVersion > 0x201) dwMemPos += 4; // ? - } else - { - dwMemPos += 36; } } -#ifdef MT2DEBUG - Log("Loading samples at offset 0x%08X\n", dwMemPos); -#endif - memset(SampleMap, 0, sizeof(SampleMap)); - m_nSamples = (pfh->wSamples < MAX_SAMPLES) ? pfh->wSamples : MAX_SAMPLES-1; - for (UINT iSmp=1; iSmp<=256; iSmp++) + + // Read sample headers + std::vector<bool> sampleInterpolation(256, true); + for(SAMPLEINDEX i = 0; i < 256; i++) { - if (dwMemPos+36 > dwMemLength) return true; - MT2SAMPLE *pms = (MT2SAMPLE *)(lpStream+dwMemPos); - #ifdef MT2DEBUG - if (iSmp <= m_nSamples) Log(" Sample #%d at offset %04X: %d bytes\n", iSmp, dwMemPos, pms->dwDataLen); - #endif - if (iSmp < MAX_SAMPLES) + char sampleName[32]; + file.ReadArray(sampleName); + uint32 dataLength = file.ReadUint32LE(); + + FileReader sampleChunk = file.ReadChunk(dataLength); + + if(i < fileHeader.numSamples) { - mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[iSmp], pms->szName); + mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[i + 1], sampleName); } - if (pms->dwDataLen > 0) + + if(dataLength && i < fileHeader.numSamples) { - SampleMap[iSmp-1] = pms; - if (iSmp < MAX_SAMPLES) + ModSample &mptSmp = Samples[i + 1]; + mptSmp.Initialize(MOD_TYPE_IT); + MT2Sample sampleHeader; + sampleChunk.ReadConvertEndianness(sampleHeader); + + mptSmp.nLength = sampleHeader.length; + mptSmp.nC5Speed = sampleHeader.frequency; + if(sampleHeader.depth > 1) { mptSmp.uFlags.set(CHN_16BIT); mptSmp.nLength /= 2u; } + if(sampleHeader.channels > 1) { mptSmp.uFlags.set(CHN_STEREO); mptSmp.nLength /= 2u; } + if(sampleHeader.loopType == 1) mptSmp.uFlags.set(CHN_LOOP); + else if(sampleHeader.loopType == 2) mptSmp.uFlags.set(CHN_LOOP | CHN_PINGPONGLOOP); + mptSmp.nLoopStart = sampleHeader.loopStart; + mptSmp.nLoopEnd = sampleHeader.loopEnd; + mptSmp.nVolume = sampleHeader.volume >> 7; + if(sampleHeader.panning == -128) + mptSmp.uFlags.set(CHN_SURROUND); + else + mptSmp.nPan = sampleHeader.panning + 128; + mptSmp.uFlags.set(CHN_PANNING); + mptSmp.RelativeTone = sampleHeader.note; + + //if(sampleHeader.flags & 2) // Sample is synchronized to beat - not supported in OpenMPT + if(sampleHeader.flags & 5) { - ModSample *psmp = &Samples[iSmp]; - psmp->Initialize(MOD_TYPE_XM); - psmp->nGlobalVol = 64; - psmp->nVolume = (pms->wVolume >> 7); - psmp->nPan = (pms->nPan == 0x80) ? 128 : (pms->nPan^0x80); - psmp->nLength = pms->dwLength; - psmp->nC5Speed = pms->dwFrequency; - psmp->nLoopStart = pms->dwLoopStart; - psmp->nLoopEnd = pms->dwLoopEnd; - if (pms->nQuality == 2) { psmp->uFlags |= CHN_16BIT; psmp->nLength >>= 1; } - if (pms->nChannels == 2) { psmp->nLength >>= 1; } - if (pms->nLoop == 1) psmp->uFlags |= CHN_LOOP; - if (pms->nLoop == 2) psmp->uFlags |= CHN_LOOP|CHN_PINGPONGLOOP; + // External sample + strcpy(mptSmp.filename, "Ext"); } - dwMemPos += pms->dwDataLen + 36; - } else - { - dwMemPos += 36; + if(sampleHeader.flags & 8) + { + sampleInterpolation[i] = false; + for(INSTRUMENTINDEX drum = 0; drum < 8; drum++) + { + if(drumMap[drum] != 0 && Instruments[drumMap[drum]] != nullptr) + { + Instruments[drumMap[drum]]->nResampling = SRCMODE_NEAREST; + } + } + } } } -#ifdef MT2DEBUG - Log("Loading groups at offset 0x%08X\n", dwMemPos); -#endif - for (UINT iMap=0; iMap<255; iMap++) if (InstrMap[iMap]) + + // Read sample groups + for(INSTRUMENTINDEX ins = 0; ins < 255; ins++) { - if (dwMemPos+8 > dwMemLength) return true; - MT2INSTRUMENT *pmi = InstrMap[iMap]; - ModInstrument *pIns = NULL; - if (iMap<m_nInstruments) pIns = Instruments[iMap+1]; - for (UINT iGrp=0; iGrp<pmi->wSamples; iGrp++) + ModInstrument *mptIns = Instruments[ins + 1]; + if(instrChunks[ins].GetLength()) { - if (pIns) + FileReader &chunk = instrChunks[ins]; + MT2Instrument insHeader; + chunk.Rewind(); + chunk.ReadConvertEndianness(insHeader); + + std::vector<MT2Group> groups(insHeader.numSamples); + for(uint32 grp = 0; grp < insHeader.numSamples; grp++) { - MT2GROUP *pmg = (MT2GROUP *)(lpStream+dwMemPos); - for (UINT i=0; i<96; i++) + file.ReadConvertEndianness(groups[grp]); + } + + if(mptIns != nullptr) + { + for(uint32 note = 0; note < 96; note++) { - if (pmi->GroupsMapping[i] == iGrp) + if(insHeader.groupMap[note] < insHeader.numSamples) { - UINT nSmp = pmg->nSmpNo+1; - pIns->Keyboard[i + 12] = (SAMPLEINDEX)nSmp; - if (nSmp <= m_nSamples && SampleMap[nSmp - 1] != nullptr) + const MT2Group &group = groups[insHeader.groupMap[note]]; + SAMPLEINDEX sample = group.sample + 1; + mptIns->Keyboard[note + 11 + NOTE_MIN] = sample; + if(sample > 0 && sample <= m_nSamples) { - Samples[nSmp].nVibType = pmi->bVibType; - Samples[nSmp].nVibSweep = pmi->bVibSweep; - Samples[nSmp].nVibDepth = pmi->bVibDepth; - Samples[nSmp].nVibRate = pmi->bVibRate; - Samples[nSmp].nC5Speed = Util::Round<uint32>(SampleMap[nSmp - 1]->dwFrequency * pow(2, -(SampleMap[nSmp - 1]->nBaseNote - 49 - (pmg->nFinePitch / 128.0f)) / 12.0f)); + ModSample &mptSmp = Samples[sample]; + mptSmp.nVibType = insHeader.vibtype; + mptSmp.nVibSweep = insHeader.vibsweep; + mptSmp.nVibDepth = insHeader.vibdepth; + mptSmp.nVibRate = insHeader.vibrate; + mptSmp.nGlobalVol = uint16(group.vol) * 2; + mptSmp.nFineTune = group.pitch; + if(!sampleInterpolation[sample - 1]) + { + mptIns->nResampling = SRCMODE_NEAREST; + } } + // TODO: volume, finetune for duplicated samples } } } - dwMemPos += 8; } } -#ifdef MT2DEBUG - Log("Loading sample data at offset 0x%08X\n", dwMemPos); -#endif + if(!(loadFlags & loadSampleData)) - { return true; - } - for (UINT iData=0; iData<256; iData++) if ((iData < m_nSamples) && (SampleMap[iData])) + + // Read sample data + for(SAMPLEINDEX i = 0; i < m_nSamples; i++) { - MT2SAMPLE *pms = SampleMap[iData]; - ModSample &sample = Samples[iData+1]; - if(!(pms->nFlags & 5)) + ModSample &mptSmp = Samples[i + 1]; + const uint32 freq = Util::Round<uint32>(mptSmp.nC5Speed * std::pow(2.0, -(mptSmp.RelativeTone - 49 - (mptSmp.nFineTune / 128.0)) / 12.0)); + + if(strcmp(mptSmp.filename, "Ext")) { - if(sample.nLength > 0) + SampleIO( + mptSmp.uFlags[CHN_16BIT] ? SampleIO::_16bit : SampleIO::_8bit, + mptSmp.uFlags[CHN_STEREO] ? SampleIO::stereoSplit : SampleIO::mono, + SampleIO::littleEndian, + SampleIO::MT2) + .ReadSample(mptSmp, file); + } else + { + // External sample + const uint32 filenameSize = file.ReadUint32LE(); + file.Skip(12); // Reserved + std::string filename; + file.ReadString<mpt::String::maybeNullTerminated>(filename, filenameSize); + mpt::String::Copy(mptSmp.filename, filename); + + mpt::PathString path(mpt::PathString::FromLocale(filename)); +#ifdef MODPLUG_TRACKER + if(GetpModDoc() != nullptr) { - #ifdef MT2DEBUG - Log(" Reading sample #%d at offset 0x%04X (len=%d)\n", iData+1, dwMemPos, psmp->nLength); - #endif + std::wstring pathStart = path.ToWide().substr(0, 2); + if(pathStart.length() >= 2 + && pathStart.at(0) != L'\\' + && pathStart.at(1) != L':') + { + // Relative path in sub directory + path = MPT_PATHSTRING(".\\") + path; + } + path = path.RelativePathToAbsolute(GetpModDoc()->GetPathNameMpt().GetPath()); + } +#endif - FileReader chunk(lpStream + dwMemPos, dwMemLength - dwMemPos); - dwMemPos += SampleIO( - (sample.uFlags & CHN_16BIT) ? SampleIO::_16bit : SampleIO::_8bit, - (pms->nChannels == 2) ? SampleIO::stereoSplit : SampleIO::mono, - SampleIO::littleEndian, - SampleIO::MT2) - .ReadSample(sample, chunk); - } - } else - if (dwMemPos+4 < dwMemLength) - { - UINT nNameLen = *const_unaligned_ptr_le<DWORD>(lpStream+dwMemPos); - dwMemPos += nNameLen + 16; +#ifdef NO_FILEREADER_STD_ISTREAM + CMappedFile f; + FileReader sampleFile; + if(f.Open(path)) + sampleFile = f.GetFile(); +#else + mpt::ifstream f(path, std::ios_base::binary); + if(f.good()) + sampleFile = FileReader(&f); +#endif + if(sampleFile.IsValid()) + ReadSampleFromFile(i + 1, sampleFile, false); } - if (dwMemPos+4 >= dwMemLength) break; + mptSmp.nC5Speed = freq; + mptSmp.nFineTune = 0; + mptSmp.RelativeTone = 0; } + return true; } - OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-10-05 20:52:55 UTC (rev 4378) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-10-05 22:26:44 UTC (rev 4379) @@ -1141,7 +1141,7 @@ pChn->nLength = pSmp->nLength; pChn->nLoopStart = pSmp->nLoopStart; pChn->nLoopEnd = pSmp->nLoopEnd; - pChn->dwFlags |= (pSmp->uFlags & CHN_SAMPLEFLAGS); + pChn->dwFlags |= (pSmp->uFlags & (CHN_SAMPLEFLAGS | CHN_SURROUND)); // IT Compatibility: Autovibrato reset if(IsCompatibleMode(TRK_IMPULSETRACKER)) @@ -1350,7 +1350,7 @@ { pChn->proTrackerOffset = 0; } - pChn->dwFlags = (pChn->dwFlags & CHN_CHANNELFLAGS) | (pSmp->uFlags & CHN_SAMPLEFLAGS); + pChn->dwFlags = (pChn->dwFlags & CHN_CHANNELFLAGS) | (pSmp->uFlags & (CHN_SAMPLEFLAGS | CHN_SURROUND)); if(pChn->dwFlags[CHN_SUSTAINLOOP]) { pChn->nLoopStart = pSmp->nSustainStart; @@ -4716,7 +4716,7 @@ { const bool bKeyOn = !pChn->dwFlags[CHN_KEYOFF]; pChn->dwFlags.set(CHN_KEYOFF); - if(pChn->pModInstrument != nullptr && !pChn->VolEnv.flags[ENV_ENABLED]) + if(pChn->pModInstrument != nullptr && !pChn->VolEnv.flags[ENV_ENABLED]) { pChn->dwFlags.set(CHN_NOTEFADE); } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-05 20:52:55 UTC (rev 4378) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-05 22:26:44 UTC (rev 4379) @@ -797,7 +797,7 @@ && !ReadAMF_DSMI(file, loadFlags) && !ReadPSM(file, loadFlags) && !ReadPSM16(file, loadFlags) - && !ReadMT2(lpStream, dwMemLength, loadFlags) + && !ReadMT2(file, loadFlags) #ifdef MODPLUG_TRACKER && !ReadMID(lpStream, dwMemLength, loadFlags) #endif // MODPLUG_TRACKER @@ -1768,7 +1768,7 @@ void CSoundFile::SetModSpecsPointer(const CModSpecifications*& pModSpecs, const MODTYPE type) -//------------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------------- { switch(type) { Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2014-10-05 20:52:55 UTC (rev 4378) +++ trunk/OpenMPT/soundlib/Sndfile.h 2014-10-05 22:26:44 UTC (rev 4379) @@ -640,7 +640,7 @@ bool ReadDBM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadAMF_Asylum(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadAMF_DSMI(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); - bool ReadMT2(const uint8 *lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule); + bool ReadMT2(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadPSM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadPSM16(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadUMX(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); Modified: trunk/OpenMPT/soundlib/patternContainer.cpp =================================================================== --- trunk/OpenMPT/soundlib/patternContainer.cpp 2014-10-05 20:52:55 UTC (rev 4378) +++ trunk/OpenMPT/soundlib/patternContainer.cpp 2014-10-05 22:26:44 UTC (rev 4379) @@ -36,6 +36,30 @@ } +PATTERNINDEX CPatternContainer::Duplicate(PATTERNINDEX from) +//---------------------------------------------------------- +{ + if(!IsValidPat(from)) + { + return PATTERNINDEX_INVALID; + } + + const CPattern &oldPat = m_Patterns[from]; + PATTERNINDEX newPatIndex = Insert(oldPat.GetNumRows()); + + if(newPatIndex != PATTERNINDEX_INVALID) + { + CPattern &newPat = m_Patterns[newPatIndex]; + memcpy(newPat.m_ModCommands, oldPat.m_ModCommands, newPat.GetNumChannels() * newPat.GetNumRows() * sizeof(ModCommand)); + newPat.m_Rows = oldPat.m_Rows; + newPat.m_RowsPerBeat = oldPat.m_RowsPerBeat; + newPat.m_RowsPerMeasure = oldPat.m_RowsPerMeasure; + newPat.m_PatternName = oldPat.m_PatternName; + } + return newPatIndex; +} + + PATTERNINDEX CPatternContainer::Insert(const ROWINDEX rows) //--------------------------------------------------------- { Modified: trunk/OpenMPT/soundlib/patternContainer.h =================================================================== --- trunk/OpenMPT/soundlib/patternContainer.h 2014-10-05 20:52:55 UTC (rev 4378) +++ trunk/OpenMPT/soundlib/patternContainer.h 2014-10-05 22:26:44 UTC (rev 4379) @@ -56,6 +56,9 @@ //on failure. PATTERNINDEX Insert(const ROWINDEX rows); + // Duplicate an existing pattern. Returns new pattern index on success, or PATTERNINDEX_INVALID on failure. + PATTERNINDEX Duplicate(PATTERNINDEX from); + //Remove pattern from given position. Currently it actually makes the pattern //'invisible' - the pattern data is cleared but the actual pattern object won't get removed. bool Remove(const PATTERNINDEX index); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-05 22:43:25
|
Revision: 4380 http://sourceforge.net/p/modplug/code/4380 Author: saga-games Date: 2014-10-05 22:43:11 +0000 (Sun, 05 Oct 2014) Log Message: ----------- [Ref] CCtrlPatterns::OnPatternDuplicate makes use of Patterns.Duplicate [Fix] FileReader compile fix for non-MSVC Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/soundlib/FileReader.h Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2014-10-05 22:26:44 UTC (rev 4379) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2014-10-05 22:43:11 UTC (rev 4380) @@ -847,27 +847,10 @@ PATTERNINDEX curPat = m_sndFile.Order[selection.firstOrd + i]; if(m_sndFile.Patterns.IsValidIndex(curPat) && patReplaceIndex[curPat] == PATTERNINDEX_INVALID) { - ROWINDEX rows = m_sndFile.Patterns[curPat].GetNumRows(); - Limit(rows, m_sndFile.GetModSpecifications().patternRowsMin, m_sndFile.GetModSpecifications().patternRowsMax); - - PATTERNINDEX newPat = m_modDoc.InsertPattern(insertWhere + i, rows); - if((newPat != PATTERNINDEX_INVALID) && (newPat < m_sndFile.Patterns.Size()) && (m_sndFile.Patterns[curPat] != nullptr)) + PATTERNINDEX newPat = m_sndFile.Patterns.Duplicate(curPat); + if(newPat != PATTERNINDEX_INVALID) { - // Update time signature and pattern name - if(m_sndFile.Patterns[curPat].GetOverrideSignature()) - { - m_sndFile.Patterns[newPat].SetSignature(m_sndFile.Patterns[curPat].GetRowsPerBeat(), m_sndFile.Patterns[curPat].GetRowsPerMeasure()); - } - m_sndFile.Patterns[newPat].SetName(m_sndFile.Patterns[curPat].GetName()); - - // Copy pattern data - size_t n = m_sndFile.Patterns[curPat].GetNumRows(); - if (m_sndFile.Patterns[newPat].GetNumRows() < n) n = m_sndFile.Patterns[newPat].GetNumRows(); - n *= m_sndFile.GetNumChannels(); - if(n) - { - memcpy(m_sndFile.Patterns[newPat], m_sndFile.Patterns[curPat], n * sizeof(ModCommand)); - } + m_sndFile.Order.Insert(insertWhere + i, 1, newPat); success = true; // Mark as duplicated, so if this pattern is to be duplicated again, the same new pattern number is inserted into the order list. patReplaceIndex[curPat] = newPat; Modified: trunk/OpenMPT/soundlib/FileReader.h =================================================================== --- trunk/OpenMPT/soundlib/FileReader.h 2014-10-05 22:26:44 UTC (rev 4379) +++ trunk/OpenMPT/soundlib/FileReader.h 2014-10-05 22:43:11 UTC (rev 4380) @@ -875,7 +875,7 @@ bool ReadNullString(StrT &dest, const off_t maxLength = SIZE_MAX) { dest.clear(); - StrT::traits_type::char_type c; + typename StrT::traits_type::char_type c; while(Read(c) && c != 0 && dest.length() < maxLength) { dest += c; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-06 09:48:31
|
Revision: 4384 http://sourceforge.net/p/modplug/code/4384 Author: manxorist Date: 2014-10-06 09:48:18 +0000 (Mon, 06 Oct 2014) Log Message: ----------- [Ref] Convert LogLevelToString() to mpt::ustring. Modified Paths: -------------- trunk/OpenMPT/common/Logging.h trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/common/Logging.h =================================================================== --- trunk/OpenMPT/common/Logging.h 2014-10-06 09:29:37 UTC (rev 4383) +++ trunk/OpenMPT/common/Logging.h 2014-10-06 09:48:18 UTC (rev 4384) @@ -23,16 +23,16 @@ }; -inline std::string LogLevelToString(LogLevel level) +inline mpt::ustring LogLevelToString(LogLevel level) { switch(level) { - case LogError: return "error"; break; - case LogWarning: return "warning"; break; - case LogInformation: return "info"; break; - case LogNotification: return "notify"; break; + case LogError: return MPT_USTRING("error"); break; + case LogWarning: return MPT_USTRING("warning"); break; + case LogInformation: return MPT_USTRING("info"); break; + case LogNotification: return MPT_USTRING("notify"); break; } - return "unknown"; + return MPT_USTRING("unknown"); } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-06 09:29:37 UTC (rev 4383) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-06 09:48:18 UTC (rev 4384) @@ -657,7 +657,11 @@ #ifdef MODPLUG_TRACKER if(GetpModDoc()) GetpModDoc()->AddToLog(level, text); #else - std::clog << "openmpt: " << LogLevelToString(level) << ": " << text << std::endl; + #ifdef MPT_WITH_CHARSET_LOCALE + std::clog << "openmpt: " << mpt::ToLocale(LogLevelToString(level)) << ": " << text << std::endl; + #else + std::clog << "openmpt: " << mpt::ToCharset(mpt::CharsetUTF8, LogLevelToString(level)) << ": " << text << std::endl; + #endif #endif } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-06 10:21:03
|
Revision: 4385 http://sourceforge.net/p/modplug/code/4385 Author: manxorist Date: 2014-10-06 10:20:57 +0000 (Mon, 06 Oct 2014) Log Message: ----------- [Ref] Add very portable implementation of IEEE754binary64 encoding/decoding. Modified Paths: -------------- trunk/OpenMPT/common/Endianness.h trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/common/Endianness.h =================================================================== --- trunk/OpenMPT/common/Endianness.h 2014-10-06 09:48:18 UTC (rev 4384) +++ trunk/OpenMPT/common/Endianness.h 2014-10-06 10:20:57 UTC (rev 4385) @@ -179,6 +179,26 @@ #error "IEEE754 single precision float support is required (for now)" #endif } +static forceinline uint64 EncodeIEEE754binary64(float64 f) +{ +#if MPT_PLATFORM_IEEE_FLOAT + STATIC_ASSERT(sizeof(uint64) == sizeof(float64)); + #if MPT_COMPILER_UNION_TYPE_ALIASES + union { + float64 f; + uint64 i; + } conv; + conv.f = f; + return conv.i; + #else + uint64 i = 0; + std::memcpy(&i, &f, sizeof(float32)); + return i; + #endif +#else + #error "IEEE754 double precision float support is required (for now)" +#endif +} // 0x3f800000u --> 1.0f static forceinline float32 DecodeIEEE754binary32(uint32 i) @@ -201,6 +221,26 @@ #error "IEEE754 single precision float support is required (for now)" #endif } +static forceinline float64 DecodeIEEE754binary64(uint64 i) +{ +#if MPT_PLATFORM_IEEE_FLOAT + STATIC_ASSERT(sizeof(uint64) == sizeof(float64)); + #if MPT_COMPILER_UNION_TYPE_ALIASES + union { + uint64 i; + float64 f; + } conv; + conv.i = i; + return conv.f; + #else + float64 f = 0.0f; + std::memcpy(&f, &i, sizeof(float64)); + return f; + #endif +#else + #error "IEEE754 double precision float support is required (for now)" +#endif +} // template parameters are byte indices corresponding to the individual bytes of iee754 in memory @@ -265,11 +305,87 @@ return !(*this == cmp); } }; +template<std::size_t hihihi, std::size_t hihilo, std::size_t hilohi, std::size_t hilolo, std::size_t lohihi, std::size_t lohilo, std::size_t lolohi, std::size_t lololo> +struct IEEE754binary64Emulated +{ +private: + typedef IEEE754binary64Emulated<hihihi,hihilo,hilohi,hilolo,lohihi,lohilo,lolohi,lololo> self_t; + uint8 bytes[8]; +public: + forceinline uint8 GetByte(std::size_t i) const + { + return bytes[i]; + } + forceinline IEEE754binary64Emulated() { } + forceinline explicit IEEE754binary64Emulated(float64 f) + { + SetInt64(EncodeIEEE754binary64(f)); + } + forceinline explicit IEEE754binary64Emulated(uint8 b0, uint8 b1, uint8 b2, uint8 b3, uint8 b4, uint8 b5, uint8 b6, uint8 b7) + { + bytes[0] = b0; + bytes[1] = b1; + bytes[2] = b2; + bytes[3] = b3; + bytes[4] = b4; + bytes[5] = b5; + bytes[6] = b6; + bytes[7] = b7; + } + forceinline operator float64 () const + { + return DecodeIEEE754binary64(GetInt64()); + } + forceinline self_t & SetInt64(uint64 i) + { + bytes[hihihi] = static_cast<uint8>(i >> 56); + bytes[hihilo] = static_cast<uint8>(i >> 48); + bytes[hilohi] = static_cast<uint8>(i >> 40); + bytes[hilolo] = static_cast<uint8>(i >> 32); + bytes[lohihi] = static_cast<uint8>(i >> 24); + bytes[lohilo] = static_cast<uint8>(i >> 16); + bytes[lolohi] = static_cast<uint8>(i >> 8); + bytes[lololo] = static_cast<uint8>(i >> 0); + return *this; + } + forceinline uint64 GetInt64() const + { + return 0u + | (static_cast<uint64>(bytes[hihihi]) << 56) + | (static_cast<uint64>(bytes[hihilo]) << 48) + | (static_cast<uint64>(bytes[hilohi]) << 40) + | (static_cast<uint64>(bytes[hilolo]) << 32) + | (static_cast<uint64>(bytes[lohihi]) << 24) + | (static_cast<uint64>(bytes[lohilo]) << 16) + | (static_cast<uint64>(bytes[lolohi]) << 8) + | (static_cast<uint64>(bytes[lololo]) << 0) + ; + } + forceinline bool operator == (const self_t &cmp) const + { + return true + && bytes[0] == cmp.bytes[0] + && bytes[1] == cmp.bytes[1] + && bytes[2] == cmp.bytes[2] + && bytes[3] == cmp.bytes[3] + && bytes[4] == cmp.bytes[4] + && bytes[5] == cmp.bytes[5] + && bytes[6] == cmp.bytes[6] + && bytes[7] == cmp.bytes[7] + ; + } + forceinline bool operator != (const self_t &cmp) const + { + return !(*this == cmp); + } +}; namespace mpt { template <> struct is_binary_safe<IEEE754binary32Emulated<0,1,2,3> > : public mpt::true_type { }; template <> struct is_binary_safe<IEEE754binary32Emulated<3,2,1,0> > : public mpt::true_type { }; +template <> struct is_binary_safe<IEEE754binary64Emulated<0,1,2,3,4,5,6,7> > : public mpt::true_type { }; +template <> struct is_binary_safe<IEEE754binary64Emulated<7,6,5,4,3,2,1,0> > : public mpt::true_type { }; } // namespace mpt @@ -341,29 +457,109 @@ } }; +struct IEEE754binary64Native +{ +private: + float64 value; +public: + forceinline uint8 GetByte(std::size_t i) const + { + #if defined(MPT_PLATFORM_LITTLE_ENDIAN) + return static_cast<uint8>(EncodeIEEE754binary64(value) >> (i*8)); + #elif defined(MPT_PLATFORM_BIG_ENDIAN) + return static_cast<uint8>(EncodeIEEE754binary64(value) >> ((8-1-i)*8)); + #else + STATIC_ASSERT(false); + #endif + } + forceinline IEEE754binary64Native() { } + forceinline explicit IEEE754binary64Native(float64 f) + { + value = f; + } + forceinline explicit IEEE754binary64Native(uint8 b0, uint8 b1, uint8 b2, uint8 b3, uint8 b4, uint8 b5, uint8 b6, uint8 b7) + { + #if defined(MPT_PLATFORM_LITTLE_ENDIAN) + value = DecodeIEEE754binary64(0ull + | (static_cast<uint64>(b0) << 0) + | (static_cast<uint64>(b1) << 8) + | (static_cast<uint64>(b2) << 16) + | (static_cast<uint64>(b3) << 24) + | (static_cast<uint64>(b4) << 32) + | (static_cast<uint64>(b5) << 40) + | (static_cast<uint64>(b6) << 48) + | (static_cast<uint64>(b7) << 56) + ); + #elif defined(MPT_PLATFORM_BIG_ENDIAN) + value = DecodeIEEE754binary64(0ull + | (static_cast<uint64>(b0) << 56) + | (static_cast<uint64>(b1) << 48) + | (static_cast<uint64>(b2) << 40) + | (static_cast<uint64>(b3) << 32) + | (static_cast<uint64>(b4) << 24) + | (static_cast<uint64>(b5) << 16) + | (static_cast<uint64>(b6) << 8) + | (static_cast<uint64>(b7) << 0) + ); + #else + STATIC_ASSERT(false); + #endif + } + forceinline operator float64 () const + { + return value; + } + forceinline IEEE754binary64Native & SetInt64(uint64 i) + { + value = DecodeIEEE754binary64(i); + return *this; + } + forceinline uint64 GetInt64() const + { + return EncodeIEEE754binary64(value); + } + forceinline bool operator == (const IEEE754binary64Native &cmp) const + { + return value == cmp.value; + } + forceinline bool operator != (const IEEE754binary64Native &cmp) const + { + return value != cmp.value; + } +}; + namespace mpt { template <> struct is_binary_safe<IEEE754binary32Native> : public mpt::true_type { }; +template <> struct is_binary_safe<IEEE754binary64Native> : public mpt::true_type { }; } // namespace mpt #if defined(MPT_PLATFORM_LITTLE_ENDIAN) -typedef IEEE754binary32Native IEEE754binary32LE; -typedef IEEE754binary32Emulated<0,1,2,3> IEEE754binary32BE; +typedef IEEE754binary32Native IEEE754binary32LE; +typedef IEEE754binary32Emulated<0,1,2,3> IEEE754binary32BE; +typedef IEEE754binary64Native IEEE754binary64LE; +typedef IEEE754binary64Emulated<0,1,2,3,4,5,6,7> IEEE754binary64BE; #elif defined(MPT_PLATFORM_BIG_ENDIAN) -typedef IEEE754binary32Emulated<3,2,1,0> IEEE754binary32LE; -typedef IEEE754binary32Native IEEE754binary32BE; +typedef IEEE754binary32Emulated<3,2,1,0> IEEE754binary32LE; +typedef IEEE754binary32Native IEEE754binary32BE; +typedef IEEE754binary64Emulated<7,6,5,4,3,2,1,0> IEEE754binary64LE; +typedef IEEE754binary64Native IEEE754binary64BE; #endif #else // !MPT_PLATFORM_IEEE_FLOAT typedef IEEE754binary32Emulated<3,2,1,0> IEEE754binary32LE; typedef IEEE754binary32Emulated<0,1,2,3> IEEE754binary32BE; +typedef IEEE754binary64Emulated<7,6,5,4,3,2,1,0> IEEE754binary64LE; +typedef IEEE754binary64Emulated<0,1,2,3,4,5,6,7> IEEE754binary64BE; #endif // MPT_PLATFORM_IEEE_FLOAT STATIC_ASSERT(sizeof(IEEE754binary32LE) == 4); STATIC_ASSERT(sizeof(IEEE754binary32BE) == 4); +STATIC_ASSERT(sizeof(IEEE754binary64LE) == 8); +STATIC_ASSERT(sizeof(IEEE754binary64BE) == 8); // Small helper class to support unaligned memory access on all platforms. Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2014-10-06 09:48:18 UTC (rev 4384) +++ trunk/OpenMPT/test/test.cpp 2014-10-06 10:20:57 UTC (rev 4385) @@ -506,6 +506,23 @@ VERIFY_EQUAL(IEEE754binary32LE(1.0f), IEEE754binary32LE(0x00,0x00,0x80,0x3f)); VERIFY_EQUAL(IEEE754binary32BE(1.0f), IEEE754binary32BE(0x3f,0x80,0x00,0x00)); + VERIFY_EQUAL(EncodeIEEE754binary64(1.0), 0x3ff0000000000000ull); + VERIFY_EQUAL(EncodeIEEE754binary64(-1.0), 0xbff0000000000000ull); + VERIFY_EQUAL(DecodeIEEE754binary64(0x0000000000000000ull), 0.0); + VERIFY_EQUAL(DecodeIEEE754binary64(0x4030800000000000ull), 16.5); + VERIFY_EQUAL(DecodeIEEE754binary64(0x3FF5400000000000ull), 1.328125); + VERIFY_EQUAL(DecodeIEEE754binary64(0xBFF5400000000000ull), -1.328125); + VERIFY_EQUAL(DecodeIEEE754binary64(0x3ff0000000000000ull), 1.0); + VERIFY_EQUAL(DecodeIEEE754binary64(0x0000000000000000ull), 0.0); + VERIFY_EQUAL(DecodeIEEE754binary64(0xbff0000000000000ull), -1.0); + VERIFY_EQUAL(DecodeIEEE754binary64(0x3ff0000000000000ull), 1.0); + VERIFY_EQUAL(IEEE754binary64LE(1.0).GetInt64(), 0x3ff0000000000000ull); + VERIFY_EQUAL(IEEE754binary64BE(1.0).GetInt64(), 0x3ff0000000000000ull); + VERIFY_EQUAL(IEEE754binary64LE(0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x3f), 1.0); + VERIFY_EQUAL(IEEE754binary64BE(0x3f,0xf0,0x00,0x00,0x00,0x00,0x00,0x00), 1.0); + VERIFY_EQUAL(IEEE754binary64LE(1.0), IEEE754binary64LE(0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x3f)); + VERIFY_EQUAL(IEEE754binary64BE(1.0), IEEE754binary64BE(0x3f,0xf0,0x00,0x00,0x00,0x00,0x00,0x00)); + VERIFY_EQUAL(ModCommand::IsPcNote(NOTE_MAX), false); VERIFY_EQUAL(ModCommand::IsPcNote(NOTE_PC), true); VERIFY_EQUAL(ModCommand::IsPcNote(NOTE_PCS), true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-06 10:45:21
|
Revision: 4388 http://sourceforge.net/p/modplug/code/4388 Author: manxorist Date: 2014-10-06 10:45:14 +0000 (Mon, 06 Oct 2014) Log Message: ----------- [Ref] FileReader: Make the dangerous Read(T) member protected, and convert the resulting broken users to ReadStruct (if it only contains 1 byte values) or ReadConvertEndianness (in most other cases). [Ref] FileReader: Add ReadDoubleLE and ReadDoubleBE. [Ref] MT2 loader: Use ReadDoubleLE for loading double values. [Fix] STM loader: STM loader was broken on big-endian. [Fix] GZIP unarchiver: Was slightly incorrent on big-endian (where it's currently not used however) [Fix[ J2B loader: Fix inconsistency between little and big endian (no negative consequences though at the moment). [Fix] DLS loader: Fix a place of brokenness on big-endian (there are still other broken places but it's not used on big-endian at the moment anyway). Modified Paths: -------------- trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/FileReader.h trunk/OpenMPT/soundlib/Load_amf.cpp trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/Load_dbm.cpp trunk/OpenMPT/soundlib/Load_dmf.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_psm.cpp trunk/OpenMPT/soundlib/Load_stm.cpp trunk/OpenMPT/soundlib/Load_ult.cpp trunk/OpenMPT/soundlib/load_j2b.cpp trunk/OpenMPT/unarchiver/ungzip.cpp trunk/OpenMPT/unarchiver/ungzip.h Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-10-06 10:45:14 UTC (rev 4388) @@ -19,6 +19,7 @@ #include "Wav.h" #include "../common/StringFixer.h" #include "../soundlib/FileReader.h" +#include "../common/Endianness.h" #include "SampleIO.h" #include <math.h> @@ -275,10 +276,17 @@ typedef struct PACKED WSMPSAMPLELOOP { - DWORD cbSize; - DWORD ulLoopType; - DWORD ulLoopStart; - DWORD ulLoopLength; + uint32 cbSize; + uint32 ulLoopType; + uint32 ulLoopStart; + uint32 ulLoopLength; + void ConvertEndianness() + { + SwapBytesLE(cbSize); + SwapBytesLE(ulLoopType); + SwapBytesLE(ulLoopStart); + SwapBytesLE(ulLoopLength); + } } WSMPSAMPLELOOP; STATIC_ASSERT(sizeof(WSMPSAMPLELOOP) == 16); @@ -1611,7 +1619,7 @@ { WSMPSAMPLELOOP loop; wsmpChunk.Skip(8 + wsmp.cbSize); - wsmpChunk.Read(loop); + wsmpChunk.ReadConvertEndianness(loop); if(loop.ulLoopLength > 3) { sample.uFlags.set(CHN_LOOP); Modified: trunk/OpenMPT/soundlib/FileReader.h =================================================================== --- trunk/OpenMPT/soundlib/FileReader.h 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/soundlib/FileReader.h 2014-10-06 10:45:14 UTC (rev 4388) @@ -566,6 +566,8 @@ streamPos += result; return result; } + +protected: // Read a "T" object from the stream. // If not enough bytes can be read, false is returned. @@ -791,6 +793,34 @@ } } + // Read 64-Bit float in little-endian format. + // If successful, the file cursor is advanced by the size of the float. + double ReadDoubleLE() + { + IEEE754binary64LE target; + if(Read(target)) + { + return target; + } else + { + return 0.0f; + } + } + + // Read 64-Bit float in big-endian format. + // If successful, the file cursor is advanced by the size of the float. + double ReadDoubleBE() + { + IEEE754binary64BE target; + if(Read(target)) + { + return target; + } else + { + return 0.0f; + } + } + // Read a struct. // If successful, the file cursor is advanced by the size of the struct. Otherwise, the target is zeroed. template <typename T> Modified: trunk/OpenMPT/soundlib/Load_amf.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_amf.cpp 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/soundlib/Load_amf.cpp 2014-10-06 10:45:14 UTC (rev 4388) @@ -109,7 +109,7 @@ file.Rewind(); AsylumFileHeader fileHeader; - if(!file.Read(fileHeader) + if(!file.ReadStruct(fileHeader) || strncmp(fileHeader.signature, "ASYLUM Music Format V1.0", 25) || fileHeader.numSamples > 64 || !file.CanRead(256 + 64 * sizeof(AsylumSampleHeader) + 64 * 4 * 8 * fileHeader.numPatterns)) Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2014-10-06 10:45:14 UTC (rev 4388) @@ -562,7 +562,7 @@ // Read envelope and do partial conversion. void ConvertToMPT(InstrumentEnvelope &mptEnv, FileReader &file) { - file.Read(*this); + file.ReadStruct(*this); // Read envelope points uint8 data[64][3]; Modified: trunk/OpenMPT/soundlib/Load_dbm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_dbm.cpp 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/soundlib/Load_dbm.cpp 2014-10-06 10:45:14 UTC (rev 4388) @@ -299,7 +299,7 @@ DBMFileHeader fileHeader; file.Rewind(); - if(!file.Read(fileHeader) + if(!file.ReadStruct(fileHeader) || memcmp(fileHeader.dbm0, "DBM0", 4) || fileHeader.trkVerHi > 3) { Modified: trunk/OpenMPT/soundlib/Load_dmf.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_dmf.cpp 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/soundlib/Load_dmf.cpp 2014-10-06 10:45:14 UTC (rev 4388) @@ -961,7 +961,7 @@ { DMFFileHeader fileHeader; file.Rewind(); - if(!file.Read(fileHeader) + if(!file.ReadStruct(fileHeader) || memcmp(fileHeader.signature, "DDMF", 4) || !fileHeader.version || fileHeader.version > 10) { Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-06 10:45:14 UTC (rev 4388) @@ -537,7 +537,7 @@ } // Reading MIDI Output & Macros - if(m_SongFlags[SONG_EMBEDMIDICFG] && file.Read(m_MidiCfg)) + if(m_SongFlags[SONG_EMBEDMIDICFG] && file.ReadStruct<MIDIMacroConfigData>(m_MidiCfg)) { m_MidiCfg.Sanitize(); } Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-06 10:45:14 UTC (rev 4388) @@ -216,8 +216,9 @@ ModCommand *target = Patterns[pat].GetpModCommand(0, 0); while(numCommands-- != 0) { + STATIC_ASSERT(sizeof(MODCOMMAND_ORIGINAL) == 6); MODCOMMAND_ORIGINAL data; - patternChunk.Read(data); + patternChunk.ReadStruct(data); *(target++) = data; } } Modified: trunk/OpenMPT/soundlib/Load_mod.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-06 10:45:14 UTC (rev 4388) @@ -573,7 +573,7 @@ // Read order information MODFileHeader fileHeader; - file.Read(fileHeader); + file.ReadStruct(fileHeader); file.Skip(4); // Magic bytes (we already parsed these) Order.ReadFromArray(fileHeader.orderList); @@ -862,7 +862,7 @@ } MODFileHeader fileHeader; - file.Read(fileHeader); + file.ReadStruct(fileHeader); // Sanity check: No more than 128 positions. ST's GUI limits tempo to [1, 220]. if(fileHeader.numOrders > 128 || fileHeader.restartPos == 0 || fileHeader.restartPos > 220) Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-06 10:45:14 UTC (rev 4388) @@ -495,7 +495,7 @@ for(CHANNELINDEX chn = 0; chn < channelsWithoutDrums; chn++, m++) { MT2Command cmd; - chunk.Read(cmd); + chunk.ReadStruct(cmd); ConvertMT2Command(this, *m, cmd); } } @@ -514,10 +514,13 @@ case MAGIC4LE('B','P','M','+'): if(0) { - double d; - if(chunk.Read(d) && fileHeader.samplesPerTick != 0 && d != 0.0) + if(chunk.CanRead(8)) { - m_nDefaultTempo = Util::Round<uint16>(44100.0 * 60.0 / (m_nDefaultSpeed * m_nDefaultRowsPerBeat * fileHeader.samplesPerTick * d)); + double d = chunk.ReadDoubleLE(); + if(fileHeader.samplesPerTick != 0 && d != 0.0) + { + m_nDefaultTempo = Util::Round<uint16>(44100.0 * 60.0 / (m_nDefaultSpeed * m_nDefaultRowsPerBeat * fileHeader.samplesPerTick * d)); + } } } break; Modified: trunk/OpenMPT/soundlib/Load_psm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_psm.cpp 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/soundlib/Load_psm.cpp 2014-10-06 10:45:14 UTC (rev 4388) @@ -347,7 +347,7 @@ { ChunkReader chunk(*subsongIter); PSMSongHeader songHeader; - if(!chunk.Read(songHeader)) + if(!chunk.ReadStruct(songHeader)) { return false; } Modified: trunk/OpenMPT/soundlib/Load_stm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_stm.cpp 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/soundlib/Load_stm.cpp 2014-10-06 10:45:14 UTC (rev 4388) @@ -94,6 +94,15 @@ uint8 reserved[13]; // More of PSi's internal crap STMSampleHeader samples[31]; // Sample headers uint8 order[128]; // Order list + + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + for(std::size_t i = 0; i < 32; ++i) + { + samples[i].ConvertEndianness(); + } + } }; STATIC_ASSERT(sizeof(STMFileHeader) == 1168); @@ -134,7 +143,7 @@ file.Rewind(); STMFileHeader fileHeader; - if(!file.Read(fileHeader) + if(!file.ReadConvertEndianness(fileHeader) || fileHeader.filetype != 2 || fileHeader.dosEof != 0x1A || (mpt::strnicmp(fileHeader.trackername, "!SCREAM!", 8) Modified: trunk/OpenMPT/soundlib/Load_ult.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ult.cpp 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/soundlib/Load_ult.cpp 2014-10-06 10:45:14 UTC (rev 4388) @@ -383,7 +383,7 @@ UltFileHeader fileHeader; // Tracker ID - if(!file.Read(fileHeader) + if(!file.ReadStruct(fileHeader) || fileHeader.version < '1' || fileHeader.version > '4' || memcmp(fileHeader.signature, "MAS_UTrack_V00", sizeof(fileHeader.signature)) != 0) Modified: trunk/OpenMPT/soundlib/load_j2b.cpp =================================================================== --- trunk/OpenMPT/soundlib/load_j2b.cpp 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/soundlib/load_j2b.cpp 2014-10-06 10:45:14 UTC (rev 4388) @@ -138,6 +138,12 @@ uint8 tempo; uint32 unknown; // 0x16078035 if original file was MOD, 0xC50100FF for everything else? it's 0xFF00FFFF in Carrotus.j2b (AMFF version) uint8 globalvolume; + + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(unknown); + } }; STATIC_ASSERT(sizeof(AMFFMainChunk) == 73); @@ -766,7 +772,7 @@ FileReader chunk(chunks.GetChunk(isAM ? AMFFRiffChunk::idINIT : AMFFRiffChunk::idMAIN)); AMFFMainChunk mainChunk; if(!chunk.IsValid() - || !chunk.Read(mainChunk) + || !chunk.ReadConvertEndianness(mainChunk) || mainChunk.channels < 1 || !chunk.CanRead(mainChunk.channels)) { Modified: trunk/OpenMPT/unarchiver/ungzip.cpp =================================================================== --- trunk/OpenMPT/unarchiver/ungzip.cpp 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/unarchiver/ungzip.cpp 2014-10-06 10:45:14 UTC (rev 4388) @@ -27,7 +27,7 @@ //-------------------------------------------------------------- { inFile.Rewind(); - inFile.Read(header); + inFile.ReadConvertEndianness(header); // Check header data + file size if(header.magic1 != GZ_HMAGIC1 || header.magic2 != GZ_HMAGIC2 || header.method != GZ_HMDEFLATE || (header.flags & GZ_FRESERVED) != 0 Modified: trunk/OpenMPT/unarchiver/ungzip.h =================================================================== --- trunk/OpenMPT/unarchiver/ungzip.h 2014-10-06 10:42:14 UTC (rev 4387) +++ trunk/OpenMPT/unarchiver/ungzip.h 2014-10-06 10:45:14 UTC (rev 4388) @@ -32,6 +32,11 @@ uint32 mtime; // UNIX time uint8 xflags; // Available for use by specific compression methods. We ignore this. uint8 os; // Which OS was used to compress the file? We also ignore this. + + void ConvertEndianness() + { + SwapBytesLE(mtime); + } }; STATIC_ASSERT(sizeof(GZheader) == 10); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-06 15:25:14
|
Revision: 4395 http://sourceforge.net/p/modplug/code/4395 Author: manxorist Date: 2014-10-06 15:25:07 +0000 (Mon, 06 Oct 2014) Log Message: ----------- [Ref] Reduce header bloat caused by iostreams in tuningbase.h and VstPresets.h . Modified Paths: -------------- trunk/OpenMPT/mptrack/VstPresets.cpp trunk/OpenMPT/mptrack/VstPresets.h trunk/OpenMPT/soundlib/tuningbase.cpp trunk/OpenMPT/soundlib/tuningbase.h Modified: trunk/OpenMPT/mptrack/VstPresets.cpp =================================================================== --- trunk/OpenMPT/mptrack/VstPresets.cpp 2014-10-06 15:18:40 UTC (rev 4394) +++ trunk/OpenMPT/mptrack/VstPresets.cpp 2014-10-06 15:25:07 UTC (rev 4395) @@ -16,6 +16,7 @@ #include <vstsdk2.4/pluginterfaces/vst2.x/vstfxstore.h> #include "VstPresets.h" #include "../soundlib/FileReader.h" +#include <ostream> OPENMPT_NAMESPACE_BEGIN Modified: trunk/OpenMPT/mptrack/VstPresets.h =================================================================== --- trunk/OpenMPT/mptrack/VstPresets.h 2014-10-06 15:18:40 UTC (rev 4394) +++ trunk/OpenMPT/mptrack/VstPresets.h 2014-10-06 15:25:07 UTC (rev 4395) @@ -10,7 +10,7 @@ #pragma once -#include <ostream> +#include <iosfwd> OPENMPT_NAMESPACE_BEGIN Modified: trunk/OpenMPT/soundlib/tuningbase.cpp =================================================================== --- trunk/OpenMPT/soundlib/tuningbase.cpp 2014-10-06 15:18:40 UTC (rev 4394) +++ trunk/OpenMPT/soundlib/tuningbase.cpp 2014-10-06 15:25:07 UTC (rev 4395) @@ -12,7 +12,10 @@ #include "tuningbase.h" #include "../common/serialization_utils.h" +#include <istream> +#include <ostream> + OPENMPT_NAMESPACE_BEGIN Modified: trunk/OpenMPT/soundlib/tuningbase.h =================================================================== --- trunk/OpenMPT/soundlib/tuningbase.h 2014-10-06 15:18:40 UTC (rev 4394) +++ trunk/OpenMPT/soundlib/tuningbase.h 2014-10-06 15:25:07 UTC (rev 4395) @@ -14,8 +14,7 @@ #include <string> #include <vector> #include <cmath> -#include <istream> -#include <ostream> +#include <iosfwd> #include <map> #include <limits> #include "../common/typedefs.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-06 16:27:39
|
Revision: 4396 http://sourceforge.net/p/modplug/code/4396 Author: manxorist Date: 2014-10-06 16:27:26 +0000 (Mon, 06 Oct 2014) Log Message: ----------- [Ref] libopenmpt: Base the fallback of AddToLog on Log() instead of std::clog. This should really only be relevant during the constructor of CSoundFile (which in turn should not log), because libopenmpt always sets a custom logger shortly after constructing CSoundFile. For clarity, just handle all potential to-console log output in one single place in Logging.cpp . Modified Paths: -------------- trunk/OpenMPT/common/Logging.cpp trunk/OpenMPT/common/Logging.h trunk/OpenMPT/soundlib/Sndfile.cpp Modified: trunk/OpenMPT/common/Logging.cpp =================================================================== --- trunk/OpenMPT/common/Logging.cpp 2014-10-06 15:25:07 UTC (rev 4395) +++ trunk/OpenMPT/common/Logging.cpp 2014-10-06 16:27:26 UTC (rev 4396) @@ -168,6 +168,12 @@ } +void Logger::operator () (LogLevel level, const mpt::ustring &text) +//----------------------------------------------------------------- +{ + DoLog(context, LogLevelToString(level) + MPT_USTRING(": ") + text); +} + void Logger::operator () (const mpt::ustring &text) //------------------------------------------------- { Modified: trunk/OpenMPT/common/Logging.h =================================================================== --- trunk/OpenMPT/common/Logging.h 2014-10-06 15:25:07 UTC (rev 4395) +++ trunk/OpenMPT/common/Logging.h 2014-10-06 16:27:26 UTC (rev 4396) @@ -75,6 +75,7 @@ public: Logger(const Context &context) : context(context) {} void MPT_PRINTF_FUNC(2,3) operator () (const char *format, ...); + void operator () (LogLevel level, const mpt::ustring &text); void operator () (const mpt::ustring &text); void operator () (const std::string &text); #if MPT_WSTRING_CONVERT && !(MPT_USTRING_MODE_WIDE) @@ -92,6 +93,7 @@ { public: inline void MPT_PRINTF_FUNC(2,3) operator () (const char * /*format*/, ...) {} + inline void operator () (LogLevel /*level*/ , const mpt::ustring & /*text*/ ) {} inline void operator () (const mpt::ustring & /*text*/ ) {} inline void operator () (const std::string & /*text*/ ) {} #if MPT_WSTRING_CONVERT && !(MPT_USTRING_MODE_WIDE) Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-06 15:25:07 UTC (rev 4395) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-06 16:27:26 UTC (rev 4396) @@ -24,7 +24,6 @@ #include "tuningcollection.h" #include "../common/StringFixer.h" #include "FileReader.h" -#include <iostream> #include <sstream> #include <time.h> @@ -653,16 +652,20 @@ //---------------------------------------------------------------------- { if(m_pCustomLog) - return m_pCustomLog->AddToLog(level, text); - #ifdef MODPLUG_TRACKER - if(GetpModDoc()) GetpModDoc()->AddToLog(level, text); - #else - #ifdef MPT_WITH_CHARSET_LOCALE - std::clog << "openmpt: " << mpt::ToLocale(LogLevelToString(level)) << ": " << text << std::endl; + { + m_pCustomLog->AddToLog(level, text); + } else + { + #ifdef MODPLUG_TRACKER + if(GetpModDoc()) GetpModDoc()->AddToLog(level, text); #else - std::clog << "openmpt: " << mpt::ToCharset(mpt::CharsetUTF8, LogLevelToString(level)) << ": " << text << std::endl; + #ifdef MPT_WITH_CHARSET_LOCALE + Log(level, mpt::ToUnicode(mpt::CharsetLocale, text)); + #else + Log(level, mpt::ToUnicode(mpt::CharsetUTF8, text)); + #endif #endif - #endif + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-06 16:40:24
|
Revision: 4397 http://sourceforge.net/p/modplug/code/4397 Author: manxorist Date: 2014-10-06 16:40:16 +0000 (Mon, 06 Oct 2014) Log Message: ----------- [Ref] Invert NO_FILEREADER_STD_ISTREAM to MPT_FILEREADER_STD_ISTREAM for better code readability. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/soundlib/FileReader.h trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2014-10-06 16:27:26 UTC (rev 4396) +++ trunk/OpenMPT/common/BuildSettings.h 2014-10-06 16:40:16 UTC (rev 4397) @@ -94,8 +94,8 @@ #define NO_ASSERTS #endif -// Disable std::istream support in class FileReader (this is generally not needed for the tracker, local files can easily be mmapped as they have been before introducing std::istream support) -#define NO_FILEREADER_STD_ISTREAM +// Enable std::istream support in class FileReader (this is generally not needed for the tracker, local files can easily be mmapped as they have been before introducing std::istream support) +//#define MPT_FILEREADER_STD_ISTREAM // Disable unarchiving support //#define NO_ARCHIVE_SUPPORT @@ -159,7 +159,7 @@ #endif //#define NO_ASSERTS //#define NO_LOGGING -//#define NO_FILEREADER_STD_ISTREAM +#define MPT_FILEREADER_STD_ISTREAM #define NO_ARCHIVE_SUPPORT #define NO_REVERB #define NO_DSP Modified: trunk/OpenMPT/soundlib/FileReader.h =================================================================== --- trunk/OpenMPT/soundlib/FileReader.h 2014-10-06 16:27:26 UTC (rev 4396) +++ trunk/OpenMPT/soundlib/FileReader.h 2014-10-06 16:40:16 UTC (rev 4397) @@ -16,7 +16,7 @@ #include "../common/misc_util.h" #include "../common/Endianness.h" #include <algorithm> -#ifndef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) #include <ios> #include <istream> #endif @@ -33,7 +33,7 @@ #define FILEREADER_DEPRECATED -#ifndef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) class IFileDataContainer { public: @@ -290,12 +290,12 @@ class FileDataContainerMemory -#ifndef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) : public IFileDataContainer #endif { -#ifdef NO_FILEREADER_STD_ISTREAM +#if !defined(MPT_FILEREADER_STD_ISTREAM) public: typedef std::size_t off_t; #endif @@ -308,7 +308,7 @@ public: FileDataContainerMemory() : streamData(nullptr), streamLength(0) { } FileDataContainerMemory(const char *data, off_t length) : streamData(data), streamLength(length) { } -#ifndef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) virtual #endif ~FileDataContainerMemory() { } @@ -374,7 +374,7 @@ public: -#ifndef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) typedef IFileDataContainer::off_t off_t; #else typedef FileDataContainerMemory::off_t off_t; @@ -382,7 +382,7 @@ private: -#ifndef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) const IFileDataContainer & DataContainer() const { return *data; } IFileDataContainer & DataContainer() { return *data; } MPT_SHARED_PTR<IFileDataContainer> data; @@ -396,7 +396,7 @@ public: -#ifndef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) // Initialize invalid file reader object. FileReader() : data(new FileDataContainerDummy()), streamPos(0) { } @@ -536,7 +536,7 @@ { return FileReader(); } - #ifndef NO_FILEREADER_STD_ISTREAM + #if defined(MPT_FILEREADER_STD_ISTREAM) return FileReader(MPT_SHARED_PTR<IFileDataContainer>(new FileDataContainerWindow(data, position, std::min(length, DataContainer().GetLength() - position)))); #else return FileReader(DataContainer().GetRawData() + position, std::min(length, DataContainer().GetLength() - position)); Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-06 16:27:26 UTC (rev 4396) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-06 16:40:16 UTC (rev 4397) @@ -20,7 +20,7 @@ #include "ITTools.h" #ifdef MODPLUG_TRACKER #include "../mptrack/TrackerSettings.h" -#ifdef NO_FILEREADER_STD_ISTREAM +#if !defined(MPT_FILEREADER_STD_ISTREAM) #include "../mptrack/MemoryMappedFile.h" #else #include "../common/mptFstream.h" @@ -259,16 +259,16 @@ { if(m_szInstrumentPath[ins].empty()) continue; -#ifdef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) + mpt::ifstream f(m_szInstrumentPath[ins], std::ios_base::binary); + if(!f.good()) + continue; + FileReader file(&f); +#else CMappedFile f; if(!f.Open(m_szInstrumentPath[ins])) continue; FileReader file = f.GetFile(); -#else - mpt::ifstream f(m_szInstrumentPath[ins], std::ios_base::binary); - if(!f.good()) - continue; - FileReader file(&f); #endif if(file.IsValid()) Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-06 16:27:26 UTC (rev 4396) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-06 16:40:16 UTC (rev 4397) @@ -13,10 +13,10 @@ #include "Loaders.h" #ifdef MODPLUG_TRACKER // For loading external samples -#ifdef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) +#include "../common/mptFstream.h" +#else #include "../mptrack/MemoryMappedFile.h" -#else -#include "../common/mptFstream.h" #endif #include "../mptrack/Moddoc.h" #endif @@ -1020,15 +1020,15 @@ path = path.RelativePathToAbsolute(GetpModDoc()->GetPathNameMpt().GetPath()); } -#ifdef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) + mpt::ifstream f(path, std::ios_base::binary); + if(f.good()) + sampleFile = FileReader(&f); +#else CMappedFile f; FileReader sampleFile; if(f.Open(path)) sampleFile = f.GetFile(); -#else - mpt::ifstream f(path, std::ios_base::binary); - if(f.good()) - sampleFile = FileReader(&f); #endif if(sampleFile.IsValid()) ReadSampleFromFile(i + 1, sampleFile, false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-06 19:03:38
|
Revision: 4400 http://sourceforge.net/p/modplug/code/4400 Author: manxorist Date: 2014-10-06 19:03:28 +0000 (Mon, 06 Oct 2014) Log Message: ----------- [Fix] The removal of iostream headers in other often-included headers made <cstdlib> not get included in a lot of files in at least emscripten builds. As abs() is required all over the place and the header is not that big, include it everywhere via stdafx.h. Modified Paths: -------------- trunk/OpenMPT/common/stdafx.h trunk/OpenMPT/soundlib/Fastmix.cpp Modified: trunk/OpenMPT/common/stdafx.h =================================================================== --- trunk/OpenMPT/common/stdafx.h 2014-10-06 17:08:53 UTC (rev 4399) +++ trunk/OpenMPT/common/stdafx.h 2014-10-06 19:03:28 UTC (rev 4400) @@ -73,6 +73,9 @@ // <cstring> // <time.h> +#include <cstdlib> +#include <stdlib.h> + //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2014-10-06 17:08:53 UTC (rev 4399) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2014-10-06 19:03:28 UTC (rev 4400) @@ -30,7 +30,6 @@ #include "FloatMixer.h" #endif // MPT_INTMIXER #include <algorithm> -#include <cstdlib> OPENMPT_NAMESPACE_BEGIN This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-07 15:17:52
|
Revision: 4403 http://sourceforge.net/p/modplug/code/4403 Author: saga-games Date: 2014-10-07 15:17:38 +0000 (Tue, 07 Oct 2014) Log Message: ----------- [Imp] Plugin selection dialog: When adding a new plugin that is missing from some open file, it is now automatically loaded and restored in that file. [Fix] MT2 Loader: MT2 only ever uses effGetChunk for programs, not banks. Since OpenMPT assumes that it should restore a plugin bank when the "default program" parameter is set, don't use it anymore when restoring plugin chunks. Modified Paths: -------------- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2014-10-07 08:51:36 UTC (rev 4402) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2014-10-07 15:17:38 UTC (rev 4403) @@ -564,6 +564,33 @@ } else { plugLib = lib; + + // If this plugin was missing anywhere, try loading it + std::vector<CModDoc *> docs(theApp.GetOpenDocuments()); + for(size_t i = 0; i < docs.size(); i++) + { + CModDoc &doc = *docs[i]; + CSoundFile &sndFile = doc.GetrSoundFile(); + bool updateDoc = false; + for(PLUGINDEX plug = 0; plug < MAX_MIXPLUGINS; plug++) + { + SNDMIXPLUGIN &plugin = sndFile.m_MixPlugins[plug]; + if(plugin.pMixPlugin == nullptr + && plugin.Info.dwPluginId1 == lib->pluginId1 + && plugin.Info.dwPluginId2 == lib->pluginId2) + { + CSoundFile::gpMixPluginCreateProc(plugin, sndFile); + if(plugin.pMixPlugin) + { + plugin.pMixPlugin->RestoreAllParameters(plugin.defaultProgram); + } + } + } + if(updateDoc) + { + doc.UpdateAllViews(nullptr, HINT_MIXPLUGINS); + } + } } } } Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-07 08:51:36 UTC (rev 4402) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-07 15:17:38 UTC (rev 4403) @@ -639,7 +639,6 @@ } mixPlug.Info.dwPluginId1 = kEffectMagic; mixPlug.Info.dwPluginId2 = vstHeader.fxID; - mixPlug.defaultProgram = vstHeader.programNr; if(vstHeader.track >= m_nChannels) { mixPlug.SetMasterEffect(true); @@ -667,10 +666,14 @@ // Read plugin settings if(vstHeader.useChunks) { + // MT2 only ever calls effGetChunk for programs, and OpenMPT uses the defaultProgram value to determine + // whether it should use effSetChunk for programs or banks... + mixPlug.defaultProgram = -1; LimitMax(vstHeader.n, Util::MaxValueOfType(mixPlug.nPluginDataSize) - 4); mixPlug.nPluginDataSize = vstHeader.n + 4; } else { + mixPlug.defaultProgram = vstHeader.programNr; LimitMax(vstHeader.n, Util::MaxValueOfType(mixPlug.nPluginDataSize) / 4u); mixPlug.nPluginDataSize = vstHeader.n * 4; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-08 12:41:01
|
Revision: 4404 http://sourceforge.net/p/modplug/code/4404 Author: manxorist Date: 2014-10-08 12:40:51 +0000 (Wed, 08 Oct 2014) Log Message: ----------- [Ref] Move mpt_fopen from mptPathString.h into mptFstream.h where all disk based file io functionality is now located. [Ref] Do not include full iostream headers in mptIO.h. Instead, just use <iosfwd> and move the implementation for std::istream and std::ostream (and FILE* as well) into mptIO.cpp. [Ref] Move FILE* streambuf classes and FILE_ostream from mptIO.h into mptFstream.h. [Ref] Move the DataContainer implementations from FileReader.h into mptIO.h . Make the std::istream based implementation non-inline in order to make the inclusion of <iosfwd> sufficient in the headers. [Ref] All in all, this speeds up compilation of libopenmpt non-test builds by up to 10% (depending on the compiler and platform) and improves separation between file io from the rest of the code. 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/Logging.cpp trunk/OpenMPT/common/mptFstream.h trunk/OpenMPT/common/mptIO.h trunk/OpenMPT/common/mptPathString.cpp trunk/OpenMPT/common/mptPathString.h trunk/OpenMPT/common/stdafx.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/mod2midi.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/FileReader.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_mod.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/build/android_ndk/Android.mk =================================================================== --- trunk/OpenMPT/build/android_ndk/Android.mk 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/build/android_ndk/Android.mk 2014-10-08 12:40:51 UTC (rev 4404) @@ -19,6 +19,7 @@ common/stdafx.cpp \ common/Logging.cpp \ common/misc_util.cpp \ + common/mptIO.cpp \ common/mptPathString.cpp \ common/mptString.cpp \ common/Profiler.cpp \ Modified: trunk/OpenMPT/build/autotools/Makefile.am =================================================================== --- trunk/OpenMPT/build/autotools/Makefile.am 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/build/autotools/Makefile.am 2014-10-08 12:40:51 UTC (rev 4404) @@ -86,6 +86,7 @@ libopenmpt_la_SOURCES += common/misc_util.h libopenmpt_la_SOURCES += common/mptAtomic.h libopenmpt_la_SOURCES += common/mptFstream.h +libopenmpt_la_SOURCES += common/mptIO.cpp libopenmpt_la_SOURCES += common/mptIO.h libopenmpt_la_SOURCES += common/mptPathString.cpp libopenmpt_la_SOURCES += common/mptPathString.h @@ -283,6 +284,7 @@ libopenmpttest_SOURCES += common/misc_util.h libopenmpttest_SOURCES += common/mptAtomic.h libopenmpttest_SOURCES += common/mptFstream.h +libopenmpttest_SOURCES += common/mptIO.cpp libopenmpttest_SOURCES += common/mptIO.h libopenmpttest_SOURCES += common/mptPathString.cpp libopenmpttest_SOURCES += common/mptPathString.h Modified: trunk/OpenMPT/build/vs2008/libopenmpt/libopenmpt.vcproj =================================================================== --- trunk/OpenMPT/build/vs2008/libopenmpt/libopenmpt.vcproj 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/build/vs2008/libopenmpt/libopenmpt.vcproj 2014-10-08 12:40:51 UTC (rev 4404) @@ -194,6 +194,10 @@ > </File> <File + RelativePath="..\..\..\common\mptIO.cpp" + > + </File> + <File RelativePath="..\..\..\common\mptPathString.cpp" > </File> Modified: trunk/OpenMPT/common/Logging.cpp =================================================================== --- trunk/OpenMPT/common/Logging.cpp 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/common/Logging.cpp 2014-10-08 12:40:51 UTC (rev 4404) @@ -11,6 +11,7 @@ #include "stdafx.h" #include "Logging.h" +#include "mptFstream.h" #include <iostream> #include <cstring> Modified: trunk/OpenMPT/common/mptFstream.h =================================================================== --- trunk/OpenMPT/common/mptFstream.h 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/common/mptFstream.h 2014-10-08 12:40:51 UTC (rev 4404) @@ -10,14 +10,38 @@ #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" +#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 { @@ -195,8 +219,278 @@ #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 static_cast<pos_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 + #endif // MPT_WITH_PATHSTRING + OPENMPT_NAMESPACE_END + Modified: trunk/OpenMPT/common/mptIO.h =================================================================== --- trunk/OpenMPT/common/mptIO.h 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/common/mptIO.h 2014-10-08 12:40:51 UTC (rev 4404) @@ -5,6 +5,7 @@ * Notes : This is work-in-progress. * Some useful functions for reading and writing are still missing. * Authors: Joern Heusipp + * OpenMPT Devs * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. */ @@ -15,16 +16,17 @@ #include "../common/typedefs.h" #include "../common/Endianness.h" #include <algorithm> -#include <ios> -#include <istream> +#include <iosfwd> #include <limits> -#include <ostream> #if defined(HAS_TYPE_TRAITS) #include <type_traits> #endif +#include <cstring> + +#if defined(MPT_WITH_PATHSTRING) #include <cstdio> -#include <cstring> #include <stdio.h> +#endif OPENMPT_NAMESPACE_BEGIN @@ -47,79 +49,58 @@ -//STATIC_ASSERT(sizeof(std::streamoff) == 8); // Assert 64bit file support. -inline bool IsValid(std::ostream & f) { return !f.fail(); } -inline bool IsValid(std::istream & f) { return !f.fail(); } -inline bool IsValid(std::iostream & f) { return !f.fail(); } -inline IO::Offset TellRead(std::istream & f) { return f.tellg(); } -inline IO::Offset TellWrite(std::ostream & f) { return f.tellp(); } -inline bool SeekBegin(std::ostream & f) { f.seekp(0); return !f.fail(); } -inline bool SeekBegin(std::istream & f) { f.seekg(0); return !f.fail(); } -inline bool SeekBegin(std::iostream & f) { f.seekg(0); f.seekp(0); return !f.fail(); } -inline bool SeekEnd(std::ostream & f) { f.seekp(0, std::ios::end); return !f.fail(); } -inline bool SeekEnd(std::istream & f) { f.seekg(0, std::ios::end); return !f.fail(); } -inline bool SeekEnd(std::iostream & f) { f.seekg(0, std::ios::end); f.seekp(0, std::ios::end); return !f.fail(); } -inline bool SeekAbsolute(std::ostream & f, IO::Offset pos) { if(!OffsetFits<std::streamoff>(pos)) { return false; } f.seekp(static_cast<std::streamoff>(pos), std::ios::beg); return !f.fail(); } -inline bool SeekAbsolute(std::istream & f, IO::Offset pos) { if(!OffsetFits<std::streamoff>(pos)) { return false; } f.seekg(static_cast<std::streamoff>(pos), std::ios::beg); return !f.fail(); } -inline bool SeekAbsolute(std::iostream & f, IO::Offset pos) { if(!OffsetFits<std::streamoff>(pos)) { return false; } f.seekg(static_cast<std::streamoff>(pos), std::ios::beg); f.seekp(static_cast<std::streamoff>(pos), std::ios::beg); return !f.fail(); } -inline bool SeekRelative(std::ostream & f, IO::Offset off) { if(!OffsetFits<std::streamoff>(off)) { return false; } f.seekp(static_cast<std::streamoff>(off), std::ios::cur); return !f.fail(); } -inline bool SeekRelative(std::istream & f, IO::Offset off) { if(!OffsetFits<std::streamoff>(off)) { return false; } f.seekg(static_cast<std::streamoff>(off), std::ios::cur); return !f.fail(); } -inline bool SeekRelative(std::iostream & f, IO::Offset off) { if(!OffsetFits<std::streamoff>(off)) { return false; } f.seekg(static_cast<std::streamoff>(off), std::ios::cur); f.seekp(static_cast<std::streamoff>(off), std::ios::cur); return !f.fail(); } -inline IO::Offset ReadRaw(std::istream & f, uint8 * data, std::size_t size) { return f.read(reinterpret_cast<char *>(data), size) ? f.gcount() : std::streamsize(0); } -inline IO::Offset ReadRaw(std::istream & f, char * data, std::size_t size) { return f.read(data, size) ? f.gcount() : std::streamsize(0); } -inline IO::Offset ReadRaw(std::istream & f, void * data, std::size_t size) { return f.read(reinterpret_cast<char *>(data), size) ? f.gcount() : std::streamsize(0); } -inline bool WriteRaw(std::ostream & f, const uint8 * data, std::size_t size) { f.write(reinterpret_cast<const char *>(data), size); return !f.fail(); } -inline bool WriteRaw(std::ostream & f, const char * data, std::size_t size) { f.write(data, size); return !f.fail(); } -inline bool WriteRaw(std::ostream & f, const void * data, std::size_t size) { f.write(reinterpret_cast<const char *>(data), size); return !f.fail(); } -inline bool IsEof(std::istream & f) { return f.eof(); } -inline bool Flush(std::ostream & f) { f.flush(); return !f.fail(); } +bool IsValid(std::ostream & f); +bool IsValid(std::istream & f); +bool IsValid(std::iostream & f); +IO::Offset TellRead(std::istream & f); +IO::Offset TellWrite(std::ostream & f); +bool SeekBegin(std::ostream & f); +bool SeekBegin(std::istream & f); +bool SeekBegin(std::iostream & f); +bool SeekEnd(std::ostream & f); +bool SeekEnd(std::istream & f); +bool SeekEnd(std::iostream & f); +bool SeekAbsolute(std::ostream & f, IO::Offset pos); +bool SeekAbsolute(std::istream & f, IO::Offset pos); +bool SeekAbsolute(std::iostream & f, IO::Offset pos); +bool SeekRelative(std::ostream & f, IO::Offset off); +bool SeekRelative(std::istream & f, IO::Offset off); +bool SeekRelative(std::iostream & f, IO::Offset off); +IO::Offset ReadRaw(std::istream & f, uint8 * data, std::size_t size); +IO::Offset ReadRaw(std::istream & f, char * data, std::size_t size); +IO::Offset ReadRaw(std::istream & f, void * data, std::size_t size); +bool WriteRaw(std::ostream & f, const uint8 * data, std::size_t size); +bool WriteRaw(std::ostream & f, const char * data, std::size_t size); +bool WriteRaw(std::ostream & f, const void * data, std::size_t size); +bool IsEof(std::istream & f); +bool Flush(std::ostream & f); -inline bool IsValid(FILE* & f) { return f != NULL; } +#if defined(MPT_WITH_PATHSTRING) -#if MPT_COMPILER_MSVC +// FILE* only makes sense if we support filenames at all. -inline IO::Offset TellRead(FILE* & f) { return _ftelli64(f); } -inline IO::Offset TellWrite(FILE* & f) { return _ftelli64(f); } -inline bool SeekBegin(FILE* & f) { return _fseeki64(f, 0, SEEK_SET) == 0; } -inline bool SeekEnd(FILE* & f) { return _fseeki64(f, 0, SEEK_END) == 0; } -inline bool SeekAbsolute(FILE* & f, IO::Offset pos) { return _fseeki64(f, pos, SEEK_SET) == 0; } -inline bool SeekRelative(FILE* & f, IO::Offset off) { return _fseeki64(f, off, SEEK_CUR) == 0; } +bool IsValid(FILE* & f); +IO::Offset TellRead(FILE* & f); +IO::Offset TellWrite(FILE* & f); +bool SeekBegin(FILE* & f); +bool SeekEnd(FILE* & f); +bool SeekAbsolute(FILE* & f, IO::Offset pos); +bool SeekRelative(FILE* & f, IO::Offset off); +IO::Offset ReadRaw(FILE * & f, uint8 * data, std::size_t size); +IO::Offset ReadRaw(FILE * & f, char * data, std::size_t size); +IO::Offset ReadRaw(FILE * & f, void * data, std::size_t size); +bool WriteRaw(FILE* & f, const uint8 * data, std::size_t size); +bool WriteRaw(FILE* & f, const char * data, std::size_t size); +bool WriteRaw(FILE* & f, const void * data, std::size_t size); +bool IsEof(FILE * & f); +bool Flush(FILE* & f); -#elif defined(_POSIX_SOURCE) && (_POSIX_SOURCE > 0) +#endif // MPT_WITH_PATHSTRING -//STATIC_ASSERT(sizeof(off_t) == 8); -inline IO::Offset TellRead(FILE* & f) { return ftello(f); } -inline IO::Offset TellWrite(FILE* & f) { return ftello(f); } -inline bool SeekBegin(FILE* & f) { return fseeko(f, 0, SEEK_SET) == 0; } -inline bool SeekEnd(FILE* & f) { return fseeko(f, 0, SEEK_END) == 0; } -inline bool SeekAbsolute(FILE* & f, IO::Offset pos) { return OffsetFits<off_t>(pos) && (fseek(f, mpt::saturate_cast<off_t>(pos), SEEK_SET) == 0); } -inline bool SeekRelative(FILE* & f, IO::Offset off) { return OffsetFits<off_t>(off) && (fseek(f, mpt::saturate_cast<off_t>(off), SEEK_CUR) == 0); } -#else -//STATIC_ASSERT(sizeof(long) == 8); // Fails on 32bit non-POSIX systems for now. -inline IO::Offset TellRead(FILE* & f) { return ftell(f); } -inline IO::Offset TellWrite(FILE* & f) { return ftell(f); } -inline bool SeekBegin(FILE* & f) { return fseek(f, 0, SEEK_SET) == 0; } -inline bool SeekEnd(FILE* & f) { return fseek(f, 0, SEEK_END) == 0; } -inline bool SeekAbsolute(FILE* & f, IO::Offset pos) { return OffsetFits<long>(pos) && (fseek(f, mpt::saturate_cast<long>(pos), SEEK_SET) == 0); } -inline bool SeekRelative(FILE* & f, IO::Offset off) { return OffsetFits<long>(off) && (fseek(f, mpt::saturate_cast<long>(off), SEEK_CUR) == 0); } - -#endif - -inline IO::Offset ReadRaw(FILE * & f, uint8 * data, std::size_t size) { return fread(data, 1, size, f); } -inline IO::Offset ReadRaw(FILE * & f, char * data, std::size_t size) { return fread(data, 1, size, f); } -inline IO::Offset ReadRaw(FILE * & f, void * data, std::size_t size) { return fread(data, 1, size, f); } -inline bool WriteRaw(FILE* & f, const uint8 * data, std::size_t size) { return fwrite(data, 1, size, f) == size; } -inline bool WriteRaw(FILE* & f, const char * data, std::size_t size) { return fwrite(data, 1, size, f) == size; } -inline bool WriteRaw(FILE* & f, const void * data, std::size_t size) { return fwrite(data, 1, size, f) == size; } -inline bool IsEof(FILE * & f) { return feof(f) != 0; } -inline bool Flush(FILE* & f) { return fflush(f) == 0; } - - - template <typename Tbinary, typename Tfile> inline bool Read(Tfile & f, Tbinary & v) { @@ -364,272 +345,243 @@ } // namespace IO -// 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. +} // namespace mpt -class FILE_output_streambuf : public std::streambuf -{ + +#if defined(MPT_FILEREADER_STD_ISTREAM) + +class IFileDataContainer { 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; + typedef std::size_t off_t; protected: - FILE *f; + IFileDataContainer() { } public: - FILE_output_streambuf(FILE *f) - : f(f) + virtual ~IFileDataContainer() { } +public: + virtual bool IsValid() const = 0; + virtual const char *GetRawData() const = 0; + virtual off_t GetLength() const = 0; + virtual off_t Read(char *dst, off_t pos, off_t count) const = 0; + + virtual const char *GetPartialRawData(off_t pos, off_t length) const // DO NOT USE!!! this is just for ReadMagic ... the pointer returned may be invalid after the next Read() { - return; + if(pos + length > GetLength()) + { + return nullptr; + } + return GetRawData() + pos; } - ~FILE_output_streambuf() + + virtual bool CanRead(off_t pos, off_t length) const { - return; + return pos + length <= GetLength(); } -protected: - virtual int_type overflow(int_type ch) + + virtual off_t GetReadableLength(off_t pos, off_t length) const { - if(!mpt::IO::IsValid(f)) + if(pos >= GetLength()) { - return traits_type::eof(); + return 0; } - 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; + return std::min<off_t>(length, GetLength() - pos); } - virtual int sync() +}; + + +class FileDataContainerDummy : public IFileDataContainer { +public: + FileDataContainerDummy() { } + virtual ~FileDataContainerDummy() { } +public: + bool IsValid() const { - if(!mpt::IO::IsValid(f)) - { - return -1; - } - if(!mpt::IO::Flush(f)) - { - return -1; - } - return 0; + return false; } - virtual pos_type seekpos(pos_type pos, std::ios_base::openmode which) + + const char *GetRawData() const { - if(!mpt::IO::IsValid(f)) - { - return pos_type(off_type(-1)); - } - return seekoff(pos, std::ios_base::beg, which); + return nullptr; } - virtual pos_type seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which) + + off_t GetLength() const { - 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 static_cast<pos_type>(newpos); + return 0; } -}; // class FILE_output_streambuf + off_t Read(char * /*dst*/, off_t /*pos*/, off_t /*count*/) const + { + return 0; + } +}; -class FILE_output_buffered_streambuf : public FILE_output_streambuf +class FileDataContainerWindow : public IFileDataContainer { -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; + MPT_SHARED_PTR<IFileDataContainer> data; + const off_t dataOffset; + const off_t dataLength; public: - FILE_output_buffered_streambuf(FILE *f, std::size_t bufSize = 64*1024) - : FILE_output_streambuf(f) - , buf((bufSize > 0) ? bufSize : 1) + FileDataContainerWindow(MPT_SHARED_PTR<IFileDataContainer> src, off_t off, off_t len) : data(src), dataOffset(off), dataLength(len) { } + virtual ~FileDataContainerWindow() { } + + bool IsValid() const { - setp(&buf[0], &buf[0] + buf.size()); + return data->IsValid(); } - ~FILE_output_buffered_streambuf() - { - if(!mpt::IO::IsValid(f)) - { - return; - } - WriteOut(); + const char *GetRawData() const { + return data->GetRawData() + dataOffset; } -private: - bool IsDirty() const - { - return ((pptr() - pbase()) > 0); + off_t GetLength() const { + return dataLength; } - bool WriteOut() + off_t Read(char *dst, off_t pos, off_t count) const { - std::ptrdiff_t n = pptr() - pbase(); - std::ptrdiff_t left = n; - while(left > 0) + if(pos >= dataLength) { - int backchunk = mpt::saturate_cast<int>(-left); - pbump(backchunk); - left += backchunk; + return 0; } - return mpt::IO::WriteRaw(f, pbase(), n); + return data->Read(dst, dataOffset + pos, std::min(count, dataLength - pos)); } -protected: - virtual int_type overflow(int_type ch) + const char *GetPartialRawData(off_t pos, off_t length) const { - if(!mpt::IO::IsValid(f)) + if(pos + length > dataLength) { - return traits_type::eof(); + return nullptr; } - 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; + return data->GetPartialRawData(dataOffset + pos, length); } - virtual int sync() + bool CanRead(off_t pos, off_t length) const { + return (pos + length <= dataLength); + } + off_t GetReadableLength(off_t pos, off_t length) const { - if(!mpt::IO::IsValid(f)) + if(pos >= dataLength) { - return -1; + return 0; } - if(!WriteOut()) - { - return -1; - } - return Tparent::sync(); + return std::min(length, dataLength - pos); } - virtual pos_type seekpos(pos_type pos, std::ios_base::openmode which) +}; + + +class FileDataContainerStdStream : public IFileDataContainer { + +private: + + mutable std::vector<char> cache; + mutable bool streamFullyCached; + + std::istream *stream; + +public: + + FileDataContainerStdStream(std::istream *s); + virtual ~FileDataContainerStdStream(); + +private: + + static const std::size_t buffer_size = 65536; + + void CacheStream() const; + void CacheStreamUpTo(std::streampos pos) const; + +private: + + void ReadCached(char *dst, off_t pos, off_t count) const; + +public: + + bool IsValid() const; + const char *GetRawData() const; + off_t GetLength() const; + off_t Read(char *dst, off_t pos, off_t count) const; + const char *GetPartialRawData(off_t pos, off_t length) const; + bool CanRead(off_t pos, off_t length) const; + off_t GetReadableLength(off_t pos, off_t length) const; + +}; + +#endif + + +class FileDataContainerMemory +#if defined(MPT_FILEREADER_STD_ISTREAM) + : public IFileDataContainer +#endif +{ + +#if !defined(MPT_FILEREADER_STD_ISTREAM) +public: + typedef std::size_t off_t; +#endif + +private: + + const char *streamData; // Pointer to memory-mapped file + off_t streamLength; // Size of memory-mapped file in bytes + +public: + FileDataContainerMemory() : streamData(nullptr), streamLength(0) { } + FileDataContainerMemory(const char *data, off_t length) : streamData(data), streamLength(length) { } +#if defined(MPT_FILEREADER_STD_ISTREAM) + virtual +#endif + ~FileDataContainerMemory() { } + +public: + + bool IsValid() const { - if(!mpt::IO::IsValid(f)) + return streamData != nullptr; + } + + const char *GetRawData() const + { + return streamData; + } + + off_t GetLength() const + { + return streamLength; + } + + off_t Read(char *dst, off_t pos, off_t count) const + { + if(pos >= streamLength) { - return pos_type(off_type(-1)); + return 0; } - if(!WriteOut()) - { - return pos_type(off_type(-1)); - } - return Tparent::seekpos(pos, which); + off_t avail = std::min<off_t>(streamLength - pos, count); + std::copy(streamData + pos, streamData + pos + avail, dst); + return avail; } - virtual pos_type seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which) + + const char *GetPartialRawData(off_t pos, off_t length) const { - if(!mpt::IO::IsValid(f)) + if(pos + length > streamLength) { - return pos_type(off_type(-1)); + return nullptr; } - if(!WriteOut()) - { - return pos_type(off_type(-1)); - } - return Tparent::seekoff(off, dir, which); + return streamData + pos; } -}; // 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) + bool CanRead(off_t pos, off_t length) const { - if(mpt::IO::IsValid(f)) mpt::IO::Flush(f); + return pos + length <= streamLength; } - ~FILE_ostream() + + off_t GetReadableLength(off_t pos, off_t length) const { - flush(); - buf.pubsync(); - if(mpt::IO::IsValid(f)) mpt::IO::Flush(f); + if(pos >= streamLength) + { + return 0; + } + return std::min<off_t>(length, streamLength - pos); } -}; // class FILE_ostream +}; -} // namespace mpt OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/common/mptPathString.cpp =================================================================== --- trunk/OpenMPT/common/mptPathString.cpp 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/common/mptPathString.cpp 2014-10-08 12:40:51 UTC (rev 4404) @@ -205,21 +205,6 @@ #endif -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 -} - - #if defined(MODPLUG_TRACKER) static inline char SanitizeFilenameChar(char c) Modified: trunk/OpenMPT/common/mptPathString.h =================================================================== --- trunk/OpenMPT/common/mptPathString.h 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/common/mptPathString.h 2014-10-08 12:40:51 UTC (rev 4404) @@ -10,9 +10,6 @@ #pragma once -#include <cstdio> -#include <stdio.h> - OPENMPT_NAMESPACE_BEGIN #if defined(MPT_WITH_PATHSTRING) @@ -231,8 +228,6 @@ #endif // MPT_OS_WINDOWS -FILE * mpt_fopen(const mpt::PathString &filename, const char *mode); - #if defined(MODPLUG_TRACKER) // Sanitize a filename (remove special chars) Modified: trunk/OpenMPT/common/stdafx.h =================================================================== --- trunk/OpenMPT/common/stdafx.h 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/common/stdafx.h 2014-10-08 12:40:51 UTC (rev 4404) @@ -59,8 +59,6 @@ // <cstring> #include "../common/mptPathString.h" -// <cstdio> -// <stdio.h> #include "../common/Logging.h" @@ -73,9 +71,15 @@ // <cstring> // <time.h> +// for std::abs #include <cstdlib> #include <stdlib.h> +#ifndef MODPLUG_NO_FILESAVE +// for FILE* definition (which cannot be forward-declared in a portable way) +#include <stdio.h> +#endif + //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2014-10-08 12:40:51 UTC (rev 4404) @@ -259,6 +259,7 @@ <ClCompile Include="..\common\AudioCriticalSection.cpp" /> <ClCompile Include="..\common\Logging.cpp" /> <ClCompile Include="..\common\misc_util.cpp" /> + <ClCompile Include="..\common\mptIO.cpp" /> <ClCompile Include="..\common\mptPathString.cpp" /> <ClCompile Include="..\common\mptString.cpp" /> <ClCompile Include="..\common\Profiler.cpp" /> Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj.filters 2014-10-08 12:40:51 UTC (rev 4404) @@ -517,5 +517,8 @@ <ClCompile Include="..\test\TestToolsLib.cpp"> <Filter>Source Files\test</Filter> </ClCompile> + <ClCompile Include="..\common\mptIO.cpp"> + <Filter>Source Files\common</Filter> + </ClCompile> </ItemGroup> </Project> \ No newline at end of file Modified: trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2014-10-08 12:40:51 UTC (rev 4404) @@ -269,6 +269,7 @@ <ClCompile Include="..\common\AudioCriticalSection.cpp" /> <ClCompile Include="..\common\Logging.cpp" /> <ClCompile Include="..\common\misc_util.cpp" /> + <ClCompile Include="..\common\mptIO.cpp" /> <ClCompile Include="..\common\mptPathString.cpp" /> <ClCompile Include="..\common\mptString.cpp" /> <ClCompile Include="..\common\Profiler.cpp" /> Modified: trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj.filters 2014-10-08 12:40:51 UTC (rev 4404) @@ -523,5 +523,8 @@ <ClCompile Include="..\test\TestToolsLib.cpp"> <Filter>Source Files\test</Filter> </ClCompile> + <ClCompile Include="..\common\mptIO.cpp"> + <Filter>Source Files\common</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-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj 2014-10-08 12:40:51 UTC (rev 4404) @@ -263,6 +263,7 @@ <ClCompile Include="..\common\AudioCriticalSection.cpp" /> <ClCompile Include="..\common\Logging.cpp" /> <ClCompile Include="..\common\misc_util.cpp" /> + <ClCompile Include="..\common\mptIO.cpp" /> <ClCompile Include="..\common\mptPathString.cpp" /> <ClCompile Include="..\common\mptString.cpp" /> <ClCompile Include="..\common\Profiler.cpp" /> Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj.filters 2014-10-08 12:40:51 UTC (rev 4404) @@ -520,5 +520,8 @@ <ClCompile Include="..\test\TestToolsLib.cpp"> <Filter>Source Files\test</Filter> </ClCompile> + <ClCompile Include="..\common\mptIO.cpp"> + <Filter>Source Files\common</Filter> + </ClCompile> </ItemGroup> </Project> \ No newline at end of file Modified: trunk/OpenMPT/mptrack/mod2midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/mod2midi.cpp 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/mptrack/mod2midi.cpp 2014-10-08 12:40:51 UTC (rev 4404) @@ -12,6 +12,7 @@ #include "Mptrack.h" #include "../soundlib/Sndfile.h" #include "../common/StringFixer.h" +#include "../common/mptFstream.h" #include "mod2midi.h" #include "Wav.h" Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2014-10-08 12:40:51 UTC (rev 4404) @@ -664,6 +664,10 @@ > </File> <File + RelativePath="..\common\mptIO.cpp" + > + </File> + <File RelativePath="..\common\mptPathString.cpp" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-10-08 12:40:51 UTC (rev 4404) @@ -447,6 +447,7 @@ <ClCompile Include="..\common\AudioCriticalSection.cpp" /> <ClCompile Include="..\common\Logging.cpp" /> <ClCompile Include="..\common\misc_util.cpp" /> + <ClCompile Include="..\common\mptIO.cpp" /> <ClCompile Include="..\common\mptPathString.cpp" /> <ClCompile Include="..\common\mptString.cpp" /> <ClCompile Include="..\common\Profiler.cpp" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2014-10-08 12:40:51 UTC (rev 4404) @@ -523,6 +523,9 @@ <ClCompile Include="MPTrackLink.cpp"> <Filter>Source Files\mptrack</Filter> </ClCompile> + <ClCompile Include="..\common\mptIO.cpp"> + <Filter>Source Files\common</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\soundlib\Loaders.h"> Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-10-08 12:40:51 UTC (rev 4404) @@ -14,6 +14,7 @@ #ifdef MODPLUG_TRACKER #include "../mptrack/mptrack.h" #include "../mptrack/MemoryMappedFile.h" +#include "../common/mptFstream.h" #endif #include "Dlsbank.h" #include "Wav.h" Modified: trunk/OpenMPT/soundlib/FileReader.h =================================================================== --- trunk/OpenMPT/soundlib/FileReader.h 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/soundlib/FileReader.h 2014-10-08 12:40:51 UTC (rev 4404) @@ -15,11 +15,8 @@ #include "../common/StringFixer.h" #include "../common/misc_util.h" #include "../common/Endianness.h" +#include "../common/mptIO.h" #include <algorithm> -#if defined(MPT_FILEREADER_STD_ISTREAM) -#include <ios> -#include <istream> -#endif #include <limits> #include <vector> #include <cstring> @@ -33,340 +30,6 @@ #define FILEREADER_DEPRECATED -#if defined(MPT_FILEREADER_STD_ISTREAM) - -class IFileDataContainer { -public: - typedef std::size_t off_t; -protected: - IFileDataContainer() { } -public: - virtual ~IFileDataContainer() { } -public: - virtual bool IsValid() const = 0; - virtual const char *GetRawData() const = 0; - virtual off_t GetLength() const = 0; - virtual off_t Read(char *dst, off_t pos, off_t count) const = 0; - - virtual const char *GetPartialRawData(off_t pos, off_t length) const // DO NOT USE!!! this is just for ReadMagic ... the pointer returned may be invalid after the next Read() - { - if(pos + length > GetLength()) - { - return nullptr; - } - return GetRawData() + pos; - } - - virtual bool CanRead(off_t pos, off_t length) const - { - return pos + length <= GetLength(); - } - - virtual off_t GetReadableLength(off_t pos, off_t length) const - { - if(pos >= GetLength()) - { - return 0; - } - return std::min<off_t>(length, GetLength() - pos); - } -}; - - -class FileDataContainerDummy : public IFileDataContainer { -public: - FileDataContainerDummy() { } - virtual ~FileDataContainerDummy() { } -public: - bool IsValid() const - { - return false; - } - - const char *GetRawData() const - { - return nullptr; - } - - off_t GetLength() const - { - return 0; - } - off_t Read(char * /*dst*/, off_t /*pos*/, off_t /*count*/) const - { - return 0; - } -}; - - -class FileDataContainerWindow : public IFileDataContainer -{ -private: - MPT_SHARED_PTR<IFileDataContainer> data; - const off_t dataOffset; - const off_t dataLength; -public: - FileDataContainerWindow(MPT_SHARED_PTR<IFileDataContainer> src, off_t off, off_t len) : data(src), dataOffset(off), dataLength(len) { } - virtual ~FileDataContainerWindow() { } - - bool IsValid() const - { - return data->IsValid(); - } - const char *GetRawData() const { - return data->GetRawData() + dataOffset; - } - off_t GetLength() const { - return dataLength; - } - off_t Read(char *dst, off_t pos, off_t count) const - { - if(pos >= dataLength) - { - return 0; - } - return data->Read(dst, dataOffset + pos, std::min(count, dataLength - pos)); - } - const char *GetPartialRawData(off_t pos, off_t length) const - { - if(pos + length > dataLength) - { - return nullptr; - } - return data->GetPartialRawData(dataOffset + pos, length); - } - bool CanRead(off_t pos, off_t length) const { - return (pos + length <= dataLength); - } - off_t GetReadableLength(off_t pos, off_t length) const - { - if(pos >= dataLength) - { - return 0; - } - return std::min(length, dataLength - pos); - } -}; - - -class FileDataContainerStdStream : public IFileDataContainer { -private: - mutable std::vector<char> cache; - mutable bool streamFullyCached; - - std::istream *stream; - -public: - FileDataContainerStdStream(std::istream *s) : streamFullyCached(false), stream(s) { } - virtual ~FileDataContainerStdStream() { } - -private: - static const std::size_t buffer_size = 65536; - void CacheStream() const - { - if(streamFullyCached) - { - return; - } - while(*stream) - { - cache.resize(cache.size() + buffer_size); - stream->read(&cache[cache.size() - buffer_size], buffer_size); - std::size_t readcount = static_cast<std::size_t>(stream->gcount()); - cache.resize(cache.size() - buffer_size + readcount); - } - streamFullyCached = true; - } - void CacheStreamUpTo(std::streampos pos) const - { - if(streamFullyCached) - { - return; - } - if(pos <= std::streampos(cache.size())) - { - return; - } - std::size_t needcount = static_cast<std::size_t>(pos - std::streampos(cache.size())); - cache.resize(static_cast<std::size_t>(pos)); - stream->read(&cache[cache.size() - needcount], needcount); - std::size_t readcount = static_cast<std::size_t>(stream->gcount()); - cache.resize(cache.size() - needcount + readcount); - if(*stream) - { - // can read further - return; - } - streamFullyCached = true; - } -private: - void ReadCached(char *dst, off_t pos, off_t count) const - { - std::copy(cache.begin() + pos, cache.begin() + pos + count, dst); - } - -public: - - bool IsValid() const - { - return true; - } - - const char *GetRawData() const - { - CacheStream(); - return &cache[0]; - } - - off_t GetLength() const - { - if(streamFullyCached) - { - return cache.size(); - } else - { - stream->clear(); - std::streampos oldpos = stream->tellg(); - if(!stream->fail() && oldpos != std::streampos(-1)) - { - stream->seekg(0, std::ios::end); - if(!stream->fail()) - { - std::streampos length = stream->tellg(); - if(!stream->fail() && length != std::streampos(-1)) - { - stream->seekg(oldpos); - stream->clear(); - return static_cast<off_t>(length); - } - } - stream->clear(); - stream->seekg(oldpos); - } - // not seekable - stream->clear(); - CacheStream(); - return cache.size(); - } - } - - off_t Read(char *dst, off_t pos, off_t count) const - { - CacheStreamUpTo(pos + count); - if(pos >= off_t(cache.size())) - { - return 0; - } - off_t cache_avail = std::min<off_t>(off_t(cache.size()) - pos, count); - ReadCached(dst, pos, cache_avail); - return cache_avail; - } - - const char *GetPartialRawData(off_t pos, off_t length) const - { - CacheStreamUpTo(pos + length); - if(pos + length > off_t(cache.size())) - { - return nullptr; - } - return &cache[pos]; - } - - bool CanRead(off_t pos, off_t length) const - { - CacheStreamUpTo(pos + length); - return pos + length <= off_t(cache.size()); - } - - off_t GetReadableLength(off_t pos, off_t length) const - { - CacheStreamUpTo(pos + length); - return std::min<off_t>(cache.size() - pos, length); - } - -}; - -#endif - - -class FileDataContainerMemory -#if defined(MPT_FILEREADER_STD_ISTREAM) - : public IFileDataContainer -#endif -{ - -#if !defined(MPT_FILEREADER_STD_ISTREAM) -public: - typedef std::size_t off_t; -#endif - -private: - - const char *streamData; // Pointer to memory-mapped file - off_t streamLength; // Size of memory-mapped file in bytes - -public: - FileDataContainerMemory() : streamData(nullptr), streamLength(0) { } - FileDataContainerMemory(const char *data, off_t length) : streamData(data), streamLength(length) { } -#if defined(MPT_FILEREADER_STD_ISTREAM) - virtual -#endif - ~FileDataContainerMemory() { } - -public: - - bool IsValid() const - { - return streamData != nullptr; - } - - const char *GetRawData() const - { - return streamData; - } - - off_t GetLength() const - { - return streamLength; - } - - off_t Read(char *dst, off_t pos, off_t count) const - { - if(pos >= streamLength) - { - return 0; - } - off_t avail = std::min<off_t>(streamLength - pos, count); - std::copy(streamData + pos, streamData + pos + avail, dst); - return avail; - } - - const char *GetPartialRawData(off_t pos, off_t length) const - { - if(pos + length > streamLength) - { - return nullptr; - } - return streamData + pos; - } - - bool CanRead(off_t pos, off_t length) const - { - return pos + length <= streamLength; - } - - off_t GetReadableLength(off_t pos, off_t length) const - { - if(pos >= streamLength) - { - return 0; - } - return std::min<off_t>(length, streamLength - pos); - } - -}; - - //============== class FileReader //============== Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-08 12:40:51 UTC (rev 4404) @@ -18,7 +18,9 @@ #endif #include "../common/mptIO.h" #include "../common/serialization_utils.h" +#ifndef MODPLUG_NO_FILESAVE #include "../common/mptFstream.h" +#endif #include <sstream> #include <list> #include "../common/version.h" Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-08 12:40:51 UTC (rev 4404) @@ -22,7 +22,8 @@ #include "../mptrack/TrackerSettings.h" #if !defined(MPT_FILEREADER_STD_ISTREAM) #include "../mptrack/MemoryMappedFile.h" -#else +#endif +#ifndef MODPLUG_NO_FILESAVE #include "../common/mptFstream.h" #endif #include "../mptrack/Moddoc.h" Modified: trunk/OpenMPT/soundlib/Load_mod.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-08 12:40:51 UTC (rev 4404) @@ -12,6 +12,9 @@ #include "stdafx.h" #include "Loaders.h" #include "Tables.h" +#ifndef MODPLUG_NO_FILESAVE +#include "../common/mptFstream.h" +#endif OPENMPT_NAMESPACE_BEGIN Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2014-10-08 12:40:51 UTC (rev 4404) @@ -11,6 +11,9 @@ #include "stdafx.h" #include "Loaders.h" #include "S3MTools.h" +#ifndef MODPLUG_NO_FILESAVE +#include "../common/mptFstream.h" +#endif #include "../common/version.h" Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2014-10-08 12:40:51 UTC (rev 4404) @@ -15,6 +15,9 @@ #include "../common/version.h" #include "../common/misc_util.h" #include "XMTools.h" +#ifndef MODPLUG_NO_FILESAVE +#include "../common/mptFstream.h" +#endif #include <algorithm> #ifdef MODPLUG_TRACKER #include "../mptrack/TrackerSettings.h" // For super smooth ramping option Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-10-08 12:40:51 UTC (rev 4404) @@ -16,6 +16,9 @@ #include "../mptrack/TrackerSettings.h" #endif //MODPLUG_TRACKER #include "../common/AudioCriticalSection.h" +#ifndef MODPLUG_NO_FILESAVE +#include "../common/mptFstream.h" +#endif #include "Wav.h" #include "Tagging.h" #include "ITTools.h" Modified: trunk/OpenMPT/soundlib/SampleIO.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleIO.cpp 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/soundlib/SampleIO.cpp 2014-10-08 12:40:51 UTC (rev 4404) @@ -16,6 +16,9 @@ #include "SampleFormatConverters.h" #include "ITCompression.h" #include "../common/mptIO.h" +#ifndef MODPLUG_NO_FILESAVE +#include "../common/mptFstream.h" +#endif OPENMPT_NAMESPACE_BEGIN Modified: trunk/OpenMPT/soundlib/WAVTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/WAVTools.cpp 2014-10-07 15:17:38 UTC (rev 4403) +++ trunk/OpenMPT/soundlib/WAVTools.cpp 2014-10-08 12:40:51 UTC (rev 4404) @@ -11,6 +11,9 @@ #include "stdafx.h" #include "Loaders.h" #include "WAVTools.h" +#ifndef MODPLUG_NO_FILESAVE +#include "../common/mptFstream.h" +#endif OPENMPT_NAMESPACE_BEGIN This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-09 08:13:27
|
Revision: 4407 http://sourceforge.net/p/modplug/code/4407 Author: manxorist Date: 2014-10-09 08:13:13 +0000 (Thu, 09 Oct 2014) Log Message: ----------- [Ref] Rename srlztn::StringFromBinaryStream to mpt::IO::ReadSizedStringLE and srlztn::StringToBinaryStream to mpt::IO::WriteSizedStringLE, and invert the logic to actually return true on success. Modified Paths: -------------- trunk/OpenMPT/common/mptIO.h trunk/OpenMPT/common/serialization_utils.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/tuning.cpp trunk/OpenMPT/soundlib/tuningCollection.cpp trunk/OpenMPT/soundlib/tuningbase.cpp Modified: trunk/OpenMPT/common/mptIO.h =================================================================== --- trunk/OpenMPT/common/mptIO.h 2014-10-08 22:27:31 UTC (rev 4406) +++ trunk/OpenMPT/common/mptIO.h 2014-10-09 08:13:13 UTC (rev 4407) @@ -239,6 +239,33 @@ return result; } +template <typename Tsize, typename Tfile> +inline bool ReadSizedStringLE(Tfile & f, std::string & str, Tsize maxSize = std::numeric_limits<Tsize>::max()) +{ + STATIC_ASSERT(std::numeric_limits<Tsize>::is_integer); + str.clear(); + Tsize size = 0; + if(!mpt::IO::ReadIntLE(f, size)) + { + return false; + } + if(size > maxSize) + { + return false; + } + for(Tsize i = 0; i != size; ++i) + { + char c = '\0'; + if(!mpt::IO::ReadIntLE(f, c)) + { + return false; + } + str.push_back(c); + } + return true; +} + + template <typename T, typename Tfile> inline bool WriteIntLE(Tfile & f, const T & v) { @@ -333,6 +360,26 @@ } } +template <typename Tsize, typename Tfile> +inline bool WriteSizedStringLE(Tfile & f, const std::string & str) +{ + STATIC_ASSERT(std::numeric_limits<Tsize>::is_integer); + if(str.size() > std::numeric_limits<Tsize>::max()) + { + return false; + } + Tsize size = str.size(); + if(!mpt::IO::WriteIntLE(f, size)) + { + return false; + } + if(!mpt::IO::WriteRaw(f, str.data(), str.size())) + { + return false; + } + return true; +} + template <typename T, typename Tfile> inline bool WriteConvertEndianness(Tfile & f, T & v) { Modified: trunk/OpenMPT/common/serialization_utils.h =================================================================== --- trunk/OpenMPT/common/serialization_utils.h 2014-10-08 22:27:31 UTC (rev 4406) +++ trunk/OpenMPT/common/serialization_utils.h 2014-10-09 08:13:13 UTC (rev 4407) @@ -16,12 +16,15 @@ #include <algorithm> #include <bitset> -#include <istream> +#include <ios> +#include <iosfwd> #include <limits> -#include <ostream> #include <string> #include <vector> +#include <istream> +#include <ostream> + #ifdef HAS_TYPE_TRAITS #include <type_traits> #endif @@ -506,37 +509,8 @@ size_t m_nCount; }; -template<class SIZETYPE> -bool StringToBinaryStream(std::ostream& oStrm, const std::string& str) -//-------------------------------------------------------------------- -{ - if(!oStrm.good()) return true; - if((std::numeric_limits<SIZETYPE>::max)() < str.size()) return true; - SIZETYPE size = static_cast<SIZETYPE>(str.size()); - Binarywrite(oStrm, size); - oStrm.write(str.c_str(), size); - if(oStrm.good()) return false; - else return true; -} -template<class SIZETYPE> -bool StringFromBinaryStream(std::istream& iStrm, std::string& str, const SIZETYPE maxSize = (std::numeric_limits<SIZETYPE>::max)()) -//--------------------------------------------------------------------------------------------------------------------------------- -{ - if(!iStrm.good()) return true; - SIZETYPE strSize; - Binaryread(iStrm, strSize); - if(strSize > maxSize) - return true; - str.resize(strSize); - for(SIZETYPE i = 0; i<strSize; i++) - iStrm.read(&str[i], 1); - if(iStrm.good()) return false; - else return true; -} - - } //namespace srlztn. Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-08 22:27:31 UTC (rev 4406) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-09 08:13:13 UTC (rev 4407) @@ -105,9 +105,9 @@ for(TNTS_MAP_ITER iter = tNameToShort_Map.begin(); iter != tNameToShort_Map.end(); iter++) { if(iter->first) - srlztn::StringToBinaryStream<uint8>(oStrm, iter->first->GetName()); + mpt::IO::WriteSizedStringLE<uint8>(oStrm, iter->first->GetName()); else //Case: Using original IT tuning. - srlztn::StringToBinaryStream<uint8>(oStrm, "->MPT_ORIGINAL_IT<-"); + mpt::IO::WriteSizedStringLE<uint8>(oStrm, "->MPT_ORIGINAL_IT<-"); mpt::IO::WriteIntLE<uint16>(oStrm, iter->second); } @@ -144,7 +144,7 @@ { std::string temp; uint16 ui; - if(srlztn::StringFromBinaryStream<STRSIZETYPE>(iStrm, temp, 255)) + if(!mpt::IO::ReadSizedStringLE<STRSIZETYPE>(iStrm, temp, 255)) return true; iStrm.read(reinterpret_cast<char*>(&ui), sizeof(ui)); Modified: trunk/OpenMPT/soundlib/tuning.cpp =================================================================== --- trunk/OpenMPT/soundlib/tuning.cpp 2014-10-08 22:27:31 UTC (rev 4406) +++ trunk/OpenMPT/soundlib/tuning.cpp 2014-10-09 08:13:13 UTC (rev 4407) @@ -11,6 +11,7 @@ #include "stdafx.h" #include "tuning.h" +#include "../common/mptIO.h" #include "../common/serialization_utils.h" #ifdef MODPLUG_TRACKER #include "../mptrack/Reporting.h" @@ -533,7 +534,7 @@ int16 key; mpt::IO::ReadIntLE<int16>(iStrm, key); std::string str; - srlztn::StringFromBinaryStream<uint8>(iStrm, str); + mpt::IO::ReadSizedStringLE<uint8>(iStrm, str); m[key] = str; } } @@ -575,7 +576,7 @@ for(; iter != end; iter++) { mpt::IO::WriteIntLE<int16>(oStrm, iter->first); - srlztn::StringToBinaryStream<uint8>(oStrm, iter->second); + mpt::IO::WriteSizedStringLE<uint8>(oStrm, iter->second); } } Modified: trunk/OpenMPT/soundlib/tuningCollection.cpp =================================================================== --- trunk/OpenMPT/soundlib/tuningCollection.cpp 2014-10-08 22:27:31 UTC (rev 4406) +++ trunk/OpenMPT/soundlib/tuningCollection.cpp 2014-10-09 08:13:13 UTC (rev 4407) @@ -10,6 +10,7 @@ #include "stdafx.h" #include "tuningcollection.h" +#include "../common/mptIO.h" #include "../common/serialization_utils.h" #include <algorithm> #include <bitset> @@ -221,12 +222,12 @@ //3. Name if(version < 2) { - if(srlztn::StringFromBinaryStream<uint32>(inStrm, m_Name, 256)) + if(!mpt::IO::ReadSizedStringLE<uint32>(inStrm, m_Name, 256)) return false; } else { - if(srlztn::StringFromBinaryStream<uint8>(inStrm, m_Name)) + if(!mpt::IO::ReadSizedStringLE<uint8>(inStrm, m_Name)) return false; } Modified: trunk/OpenMPT/soundlib/tuningbase.cpp =================================================================== --- trunk/OpenMPT/soundlib/tuningbase.cpp 2014-10-08 22:27:31 UTC (rev 4406) +++ trunk/OpenMPT/soundlib/tuningbase.cpp 2014-10-09 08:13:13 UTC (rev 4407) @@ -10,6 +10,7 @@ #include "stdafx.h" #include "tuningbase.h" +#include "../common/mptIO.h" #include "../common/serialization_utils.h" #include <istream> @@ -440,7 +441,7 @@ if(version != 4) return SERIALIZATION_FAILURE; //Tuning name - if(srlztn::StringFromBinaryStream<uint8>(inStrm, m_TuningName)) + if(!mpt::IO::ReadSizedStringLE<uint8>(inStrm, m_TuningName)) return SERIALIZATION_FAILURE; //Const mask @@ -461,7 +462,7 @@ NOTEINDEXTYPE n; std::string str; inStrm.read(reinterpret_cast<char*>(&n), sizeof(n)); - if(srlztn::StringFromBinaryStream<uint8>(inStrm, str)) + if(!mpt::IO::ReadSizedStringLE<uint8>(inStrm, str)) return SERIALIZATION_FAILURE; m_NoteNameMap[n] = str; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-10 13:23:26
|
Revision: 4408 http://sourceforge.net/p/modplug/code/4408 Author: manxorist Date: 2014-10-10 13:23:10 +0000 (Fri, 10 Oct 2014) Log Message: ----------- [Ref] Debug: Add a low overhead threadsafe trace logging system which gets always compiled in, even in release builds. The actual logging has to be enabled explicitely via [Debug]TraceEnable and is written out (when it had been enabled beforehand) at the same time when a crash minidump is written out, and, if a debugger is present, when an always-assert fires. When disabled, the runtime overhead is a single predicted branch per trace point. When enabled, the runtime overhead is a single predicted branch, a 32bit atomic increment, GetCurrentThreadId(), QueryPerformanceCounter() and a memcpy of less than a single cacheline. The executable size overhead is one string per file that contains trace points (the filename), one string for each function that contains trace points (the function name), and 4 bytes for each trace point (the line number). The current implementation is not suitable for very high thread counts and/or multi-socket SMP systems (because of cacheline bouncing of the atomic variable), and is not suitable to be used in innerloops in hot paths (where the overhead is no longer negligable). The runtime memory overhead, if enabled, is about 32MB by default (1000000 entries in trace buffer, can be changed via [Debug]TraceSize), and about zero otherwise. MPT_TRACE() adds a trace point. Modified Paths: -------------- trunk/OpenMPT/common/Logging.cpp trunk/OpenMPT/common/Logging.h trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/common/Logging.cpp =================================================================== --- trunk/OpenMPT/common/Logging.cpp 2014-10-09 08:13:13 UTC (rev 4407) +++ trunk/OpenMPT/common/Logging.cpp 2014-10-10 13:23:10 UTC (rev 4408) @@ -12,6 +12,10 @@ #include "Logging.h" #include "mptFstream.h" +#if defined(MODPLUG_TRACKER) +#include "mptAtomic.h" +#endif +#include "version.h" #include <iostream> #include <cstring> @@ -29,52 +33,28 @@ { -#ifndef NO_LOGGING - - static const std::size_t LOGBUF_SIZE = 1024; -Context::Context(const char *file, int line, const char *function) -//---------------------------------------------------------------- - : file(file) - , line(line) - , function(function) -{ - return; -} - - -Context::Context(const Context &c) -//-------------------------------- - : file(c.file) - , line(c.line) - , function(c.function) -{ - return; -} - - #if defined(MODPLUG_TRACKER) - -static uint64 GetTimeMS() -//----------------------- +static uint64 GetTime100ns() +//-------------------------- { FILETIME filetime; GetSystemTimeAsFileTime(&filetime); - return ((uint64)filetime.dwHighDateTime << 32 | filetime.dwLowDateTime) / 10000; + return ((uint64)filetime.dwHighDateTime << 32 | filetime.dwLowDateTime); } -static std::string TimeAsAsString(uint64 ms) -//------------------------------------------ +static std::string TimeAsString(uint64 time100ns) +//------------------------------------------------- { FILETIME filetime; SYSTEMTIME systime; - filetime.dwHighDateTime = (DWORD)(((uint64)ms * 10000) >> 32); - filetime.dwLowDateTime = (DWORD)((uint64)ms * 10000); + filetime.dwHighDateTime = (DWORD)(((uint64)time100ns) >> 32); + filetime.dwLowDateTime = (DWORD)((uint64)time100ns); FileTimeToSystemTime(&filetime, &systime); std::string result; @@ -92,7 +72,15 @@ return result; } +#endif // MODPLUG_TRACKER + +#ifndef NO_LOGGING + + +#if defined(MODPLUG_TRACKER) + + static std::string TimeDiffAsString(uint64 ms) //-------------------------------------------- { @@ -117,9 +105,9 @@ message = mpt::String::RTrim(message, MPT_USTRING("\r\n")); #if defined(MODPLUG_TRACKER) static uint64_t s_lastlogtime = 0; - uint64 cur = GetTimeMS(); - uint64 diff = cur - s_lastlogtime; - s_lastlogtime = cur; + uint64 cur = GetTime100ns(); + uint64 diff = cur/10000 - s_lastlogtime; + s_lastlogtime = cur/10000; #ifdef LOG_TO_FILE { static FILE * s_logfile = nullptr; @@ -129,7 +117,7 @@ } if(s_logfile) { - fprintf(s_logfile, "%s+%s %s(%i): %s [%s]\n", TimeAsAsString(cur).c_str(), TimeDiffAsString(diff).c_str(), context.file, context.line, mpt::ToCharset(mpt::CharsetUTF8, message).c_str(), context.function); + fprintf(s_logfile, "%s+%s %s(%i): %s [%s]\n", TimeAsString(cur).c_str(), TimeDiffAsString(diff).c_str(), context.file, context.line, mpt::ToCharset(mpt::CharsetUTF8, message).c_str(), context.function); fflush(s_logfile); } } @@ -212,6 +200,211 @@ #endif // !NO_LOGGING + +#if defined(MODPLUG_TRACKER) + +namespace Trace { + +// Debugging functionality will use simple globals. + +bool volatile g_Enabled = false; + +static bool g_Sealed = false; + +struct Entry { + uint32 Index; + uint32 ThreadId; + uint64 Timestamp; + const char * Function; + const char * File; + int Line; +}; + +inline bool operator < (const Entry &a, const Entry &b) +{ +/* + return false + || (a.Timestamp < b.Timestamp) + || (a.ThreadID < b.ThreadID) + || (a.File < b.File) + || (a.Line < b.Line) + || (a.Function < b.Function) + ; +*/ + return false + || (a.Index < b.Index) + ; +} + +static std::vector<mpt::log::Trace::Entry> Entries; + +static mpt::atomic_uint32_t NextIndex = 0; + +static uint32 ThreadIdGUI = 0; +static uint32 ThreadIdAudio = 0; +static uint32 ThreadIdNotify = 0; + +void Enable(std::size_t numEntries) +{ + if(g_Sealed) + { + return; + } + Entries.clear(); + Entries.resize(numEntries); + NextIndex.store(0); + g_Enabled = true; +} + +void Disable() +{ + if(g_Sealed) + { + return; + } + g_Enabled = false; +} + +noinline void Trace(const mpt::log::Context & context) +{ + // This will get called in realtime contexts and hot paths. + // No blocking allowed here. + const uint32 index = NextIndex.fetch_add(1); +#if 1 + LARGE_INTEGER time; + time.QuadPart = 0; + QueryPerformanceCounter(&time); + const uint64 timestamp = time.QuadPart; +#else + FILETIME time = FILETIME(); + GetSystemTimeAsFileTime(&time); + const uint64 timestamp = (static_cast<uint64>(time.dwHighDateTime) << 32) | (static_cast<uint64>(time.dwLowDateTime) << 0); +#endif + const uint32 threadid = static_cast<uint32>(GetCurrentThreadId()); + mpt::log::Trace::Entry & entry = Entries[index % Entries.size()]; + entry.Index = index; + entry.ThreadId = threadid; + entry.Timestamp = timestamp; + entry.Function = context.function; + entry.File = context.file; + entry.Line = context.line; +} + +void Seal() +{ + if(!g_Enabled) + { + return; + } + g_Enabled = false; + g_Sealed = true; + uint32 count = NextIndex.fetch_add(0); + if(count < Entries.size()) + { + Entries.resize(count); + } +} + +bool Dump(const mpt::PathString &filename) +{ + if(!g_Sealed) + { + return false; + } + + LARGE_INTEGER qpcNow; + qpcNow.QuadPart = 0; + QueryPerformanceCounter(&qpcNow); + uint64 ftNow = GetTime100ns(); + + // sort according to index in case of overflows + std::stable_sort(Entries.begin(), Entries.end()); + + WCHAR tmp[1024]; + GetCurrentDirectoryW(1023, tmp); + + mpt::ofstream f(filename, std::ios::out); + + f << "Build: OpenMPT " << MptVersion::GetVersionStringExtended() << std::endl; + + bool qpcValid = false; + + LARGE_INTEGER qpcFreq; + qpcFreq.QuadPart = 0; + QueryPerformanceFrequency(&qpcFreq); + if(qpcFreq.QuadPart > 0) + { + qpcValid = true; + } + + f << "Dump: " << TimeAsString(ftNow) << std::endl; + f << "Captured events: " << Entries.size() << std::endl; + if(qpcValid && (Entries.size() > 0)) + { + double period = static_cast<double>(Entries[Entries.size() - 1].Timestamp - Entries[0].Timestamp) / static_cast<double>(qpcFreq.QuadPart); + double eventsPerSecond = Entries.size() / period; + f << "Period [s]: " << mpt::fmt::fix(period) << std::endl; + f << "Events/second: " << mpt::fmt::fix(eventsPerSecond) << std::endl; + } + + for(std::size_t i = 0; i < Entries.size(); ++i) + { + mpt::log::Trace::Entry & entry = Entries[i]; + if(!entry.Function) entry.Function = ""; + if(!entry.File) entry.File = ""; + std::string time; + if(qpcValid) + { + time = TimeAsString( ftNow - static_cast<int64>( static_cast<double>(qpcNow.QuadPart - entry.Timestamp) * (10000000.0 / static_cast<double>(qpcFreq.QuadPart) ) ) ); + } else + { + time = mpt::String::Print<std::string>("0x%1", mpt::fmt::hex0<16>(entry.Timestamp)); + } + f << time; + if(entry.ThreadId == ThreadIdGUI) + { + f << " -----GUI "; + } else if(entry.ThreadId == ThreadIdAudio) + { + f << " ---Audio "; + } else if(entry.ThreadId == ThreadIdNotify) + { + f << " --Notify "; + } else + { + f << " " << mpt::fmt::hex0<8>(entry.ThreadId) << " "; + } + f << entry.File << "(" << entry.Line << "): " << entry.Function; + f << std::endl; + } + return true; +} + +void SetThreadId(mpt::log::Trace::ThreadKind kind, uint32 id) +{ + if(id == 0) + { + return; + } + switch(kind) + { + case ThreadKindGUI: + ThreadIdGUI = id; + break; + case ThreadKindAudio: + ThreadIdAudio = id; + break; + case ThreadKindNotify: + ThreadIdNotify = id; + break; + } +} + +} // namespace Trace + +#endif // MODPLUG_TRACKER + + } // namespace log } // namespace mpt Modified: trunk/OpenMPT/common/Logging.h =================================================================== --- trunk/OpenMPT/common/Logging.h 2014-10-09 08:13:13 UTC (rev 4407) +++ trunk/OpenMPT/common/Logging.h 2014-10-10 13:23:10 UTC (rev 4408) @@ -51,23 +51,32 @@ { -#ifndef NO_LOGGING - - -class Context +struct Context { -public: const char * const file; const int line; const char * const function; -public: - Context(const char *file, int line, const char *function); - Context(const Context &c); + forceinline Context(const char *file, int line, const char *function) + : file(file) + , line(line) + , function(function) + { + return; + } + forceinline Context(const Context &c) + : file(c.file) + , line(c.line) + , function(c.function) + { + return; + } }; // class Context #define MPT_LOG_CURRENTCONTEXT() mpt::log::Context( __FILE__ , __LINE__ , __FUNCTION__ ) +#ifndef NO_LOGGING + class Logger { private: @@ -85,10 +94,8 @@ #define Log mpt::log::Logger(MPT_LOG_CURRENTCONTEXT()) - #else // !NO_LOGGING - class Logger { public: @@ -103,10 +110,51 @@ #define Log if(true) {} else mpt::log::Logger() // completely compile out arguments to Log() so that they do not even get evaluated - #endif // NO_LOGGING + +#if defined(MODPLUG_TRACKER) + +namespace Trace { + +// This is not strictly thread safe in all corner cases because of missing barriers. +// We do not care in order to not harm the fast path with additional barriers. +// Enabled tracing incurs a runtime overhead with multiple threads as a global atomic variable +// gets modified. +// This cacheline bouncing does not matter at all +// if there are not multiple thread adding trace points at high frequency (way greater than 1000Hz), +// which, in OpenMPT, is only ever the case for just a single thread (the audio thread), if at all. +extern bool volatile g_Enabled; + +noinline void Trace(const mpt::log::Context & contexxt); + +enum ThreadKind { + ThreadKindGUI, + ThreadKindAudio, + ThreadKindNotify, +}; + +void Enable(std::size_t numEntries); +void Disable(); + +void SetThreadId(mpt::log::Trace::ThreadKind kind, uint32 id); + +void Seal(); +bool Dump(const mpt::PathString &filename); + +#define MPT_TRACE() do { if(mpt::log::Trace::g_Enabled) { mpt::log::Trace::Trace(MPT_LOG_CURRENTCONTEXT()); } } while(0) + +} // namespace Trace + +#else // !MODPLUG_TRACKER + +#define MPT_TRACE() do { } while(0) + +#endif // MODPLUG_TRACKER + + + } // namespace log } // namespace mpt Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2014-10-09 08:13:13 UTC (rev 4407) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2014-10-10 13:23:10 UTC (rev 4408) @@ -33,6 +33,10 @@ static void GenerateDump(CString &errorMessage, _EXCEPTION_POINTERS *pExceptionInfo=NULL, DumpMode mode=DumpModeCrash) //-------------------------------------------------------------------------------------------------------------------- { + + // seal the trace log as early as possible + mpt::log::Trace::Seal(); + CMainFrame* pMainFrame = CMainFrame::GetMainFrame(); const mpt::PathString timestampDir = mpt::PathString::FromCStringSilent((CTime::GetCurrentTime()).Format("%Y-%m-%d %H.%M.%S\\")); @@ -52,10 +56,28 @@ } } + bool hasWrittenDebug = false; + // Create minidump... - const mpt::PathString filename = baseRescuePath + MPT_PATHSTRING("crash.dmp"); - if(WriteMemoryDump(pExceptionInfo, filename.AsNative().c_str(), ExceptionHandler::fullMemDump)) { + const mpt::PathString filename = baseRescuePath + MPT_PATHSTRING("crash.dmp"); + if(WriteMemoryDump(pExceptionInfo, filename.AsNative().c_str(), ExceptionHandler::fullMemDump)) + { + hasWrittenDebug = true; + } + } + + // Create trace log... + { + const mpt::PathString filename = baseRescuePath + MPT_PATHSTRING("trace.log"); + if(mpt::log::Trace::Dump(filename)) + { + hasWrittenDebug = true; + } + } + + if(hasWrittenDebug) + { errorMessage += "\n\nDebug information has been saved to\n" + mpt::ToCString(baseRescuePath.ToWide()); } @@ -116,6 +138,10 @@ LONG ExceptionHandler::UnhandledExceptionFilter(_EXCEPTION_POINTERS *pExceptionInfo) //---------------------------------------------------------------------------------- { + + // seal the trace log as early as possible + mpt::log::Trace::Seal(); + // Shut down audio device... CMainFrame* pMainFrame = CMainFrame::GetMainFrame(); if(pMainFrame) @@ -151,8 +177,12 @@ noinline void AssertHandler(const char *file, int line, const char *function, const char *expr, const char *msg) //-------------------------------------------------------------------------------------------------------------- { + // seal the trace log as early as possible + mpt::log::Trace::Seal(); + if(IsDebuggerPresent()) { + mpt::log::Trace::Dump(MPT_PATHSTRING("mptrack.trace.log")); OutputDebugString("ASSERT("); OutputDebugString(expr); OutputDebugString(") failed\n"); Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-10-09 08:13:13 UTC (rev 4407) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-10-10 13:23:10 UTC (rev 4408) @@ -674,6 +674,7 @@ CriticalSection cs; ALWAYS_ASSERT(m_pSndFile != nullptr); m_AudioThreadId = GetCurrentThreadId(); + mpt::log::Trace::SetThreadId(mpt::log::Trace::ThreadKindAudio, m_AudioThreadId); callback.FillAudioBuffer(); m_AudioThreadId = 0; } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2014-10-09 08:13:13 UTC (rev 4407) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2014-10-10 13:23:10 UTC (rev 4408) @@ -651,7 +651,8 @@ #endif m_GuiThreadId = GetCurrentThreadId(); - + mpt::log::Trace::SetThreadId(mpt::log::Trace::ThreadKindGUI, m_GuiThreadId); + ExceptionHandler::Register(); m_bPortableMode = false; @@ -901,6 +902,13 @@ m_pTrackerSettings = new TrackerSettings(*m_pSettings); + // enable debug features (as early as possible after reading the settings) + if(TrackerSettings::Instance().DebugTraceEnable) + { + mpt::log::Trace::Enable(TrackerSettings::Instance().DebugTraceSize); + } + MPT_TRACE(); + m_pPluginCache = new IniFileSettingsContainer(m_szPluginCacheFileName); LoadStdProfileSettings(0); // Load standard INI file options (without MRU) Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-10-09 08:13:13 UTC (rev 4407) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-10-10 13:23:10 UTC (rev 4408) @@ -225,6 +225,8 @@ , mruListLength(conf, "Misc", "MRUListLength", 10) // Plugins , bridgeAllPlugins(conf, "VST Plugins", "BridgeAllPlugins", false) + , DebugTraceEnable(conf, "Debug", "TraceEnable", false) + , DebugTraceSize(conf, "Debug", "TraceSize", 1000000) { // Effects #ifndef NO_DSP Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2014-10-09 08:13:13 UTC (rev 4407) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2014-10-10 13:23:10 UTC (rev 4408) @@ -468,18 +468,27 @@ // Paths mpt::PathString m_szKbdFile; + // Default template + Setting<mpt::PathString> defaultTemplateFile; Setting<uint32> mruListLength; std::vector<mpt::PathString> mruFiles; // Chords + MPTChords Chords; // Plugins + Setting<bool> bridgeAllPlugins; + // Debug + + Setting<bool> DebugTraceEnable; + Setting<uint32> DebugTraceSize; + public: TrackerSettings(SettingsContainer &conf); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-10 13:26:16
|
Revision: 4409 http://sourceforge.net/p/modplug/code/4409 Author: manxorist Date: 2014-10-10 13:26:08 +0000 (Fri, 10 Oct 2014) Log Message: ----------- [Ref] Debug: Add MPT_TRACE() to all sound device related functions in CMainFrame and to all functions in CASIODevice in order to better understand ASIO-related threading bugs. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-10-10 13:23:10 UTC (rev 4408) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-10-10 13:26:08 UTC (rev 4409) @@ -458,6 +458,7 @@ void CMainFrame::OnClose() //------------------------ { + MPT_TRACE(); if(!(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_NOCLOSEDIALOG)) { // Show modified documents window @@ -618,6 +619,7 @@ void CMainFrame::OnTimerNotify() //------------------------------ { + MPT_TRACE(); ASSERT(InGuiThread()); ASSERT(!InNotifyHandler()); m_InNotifyHandler = true; @@ -664,6 +666,7 @@ void CMainFrame::AudioMessage(const std::string &str) //--------------------------------------------------- { + MPT_TRACE(); Reporting::Notification(str.c_str()); } @@ -671,6 +674,7 @@ void CMainFrame::FillAudioBufferLocked(SoundDevice::IFillAudioBuffer &callback) //----------------------------------------------------------------------------- { + MPT_TRACE(); CriticalSection cs; ALWAYS_ASSERT(m_pSndFile != nullptr); m_AudioThreadId = GetCurrentThreadId(); @@ -755,6 +759,7 @@ void CMainFrame::AudioRead(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, void *buffer) //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- { + MPT_TRACE(); ASSERT(InAudioThread()); OPENMPT_PROFILE_FUNCTION(Profiler::Audio); TimingInfo timingInfo; @@ -787,6 +792,7 @@ void CMainFrame::AudioDone(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, int64 streamPosition) //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ { + MPT_TRACE(); MPT_UNREFERENCED_PARAMETER(settings); MPT_UNREFERENCED_PARAMETER(flags); MPT_UNREFERENCED_PARAMETER(bufferAttributes); @@ -801,6 +807,7 @@ bool CMainFrame::IsAudioDeviceOpen() const //---------------------------------------- { + MPT_TRACE(); return gpSoundDevice && gpSoundDevice->IsOpen(); } @@ -808,6 +815,7 @@ bool CMainFrame::audioOpenDevice() //-------------------------------- { + MPT_TRACE(); if(!TrackerSettings::Instance().GetMixerSettings().IsValid()) { Reporting::Error("Unable to open sound device: Invalid mixer settings."); @@ -864,6 +872,7 @@ void CMainFrame::audioCloseDevice() //--------------------------------- { + MPT_TRACE(); if(gpSoundDevice) { gpSoundDevice->Close(); @@ -913,6 +922,7 @@ bool CMainFrame::DoNotification(DWORD dwSamplesRead, int64 streamPosition) //------------------------------------------------------------------------ { + MPT_TRACE(); ASSERT(InAudioThread()); if(!m_pSndFile) return false; @@ -1195,6 +1205,7 @@ void CMainFrame::ResetNotificationBuffer() //---------------------------------------- { + MPT_TRACE(); Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); m_NotifyBuffer.clear(); } @@ -1203,6 +1214,7 @@ bool CMainFrame::PreparePlayback() //-------------------------------- { + MPT_TRACE(); // open the audio device to update needed TrackerSettings mixer parameters if(!audioOpenDevice()) return false; return true; @@ -1212,6 +1224,7 @@ bool CMainFrame::StartPlayback() //------------------------------ { + MPT_TRACE(); if(!m_pSndFile) return false; // nothing to play if(!IsAudioDeviceOpen()) return false; if(!gpSoundDevice->Start()) return false; @@ -1232,6 +1245,7 @@ void CMainFrame::StopPlayback() //----------------------------- { + MPT_TRACE(); if(!IsAudioDeviceOpen()) return; gpSoundDevice->Stop(); if(m_NotifyTimer) @@ -1250,6 +1264,7 @@ bool CMainFrame::RestartPlayback() //-------------------------------- { + MPT_TRACE(); if(!m_pSndFile) return false; // nothing to play if(!IsAudioDeviceOpen()) return false; if(!gpSoundDevice->IsPlaying()) return false; @@ -1267,6 +1282,7 @@ bool CMainFrame::PausePlayback() //------------------------------ { + MPT_TRACE(); if(!IsAudioDeviceOpen()) return false; gpSoundDevice->Stop(); if(m_NotifyTimer) @@ -1658,6 +1674,7 @@ void CMainFrame::IdleHandlerSounddevice() //--------------------------------------- { + MPT_TRACE(); if(gpSoundDevice) { const LONG requestFlags = gpSoundDevice->GetRequestFlags(); @@ -1682,6 +1699,7 @@ BOOL CMainFrame::ResetSoundCard() //------------------------------- { + MPT_TRACE(); return CMainFrame::SetupSoundCard(TrackerSettings::Instance().GetSoundDeviceSettings(TrackerSettings::Instance().GetSoundDeviceIdentifier()), TrackerSettings::Instance().GetSoundDeviceIdentifier(), TrackerSettings::Instance().m_SoundSettingsStopMode, true); } @@ -1689,6 +1707,7 @@ BOOL CMainFrame::SetupSoundCard(SoundDevice::Settings deviceSettings, SoundDevice::Identifier deviceIdentifier, SoundDevice::StopMode stoppedMode, bool forceReset) //----------------------------------------------------------------------------------------------------------------------------------------------------------------- { + MPT_TRACE(); if(forceReset || (TrackerSettings::Instance().GetSoundDeviceIdentifier() != deviceIdentifier) || (TrackerSettings::Instance().GetSoundDeviceSettings(deviceIdentifier) != deviceSettings) Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2014-10-10 13:23:10 UTC (rev 4408) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2014-10-10 13:26:08 UTC (rev 4409) @@ -111,6 +111,7 @@ std::vector<SoundDevice::Info> CASIODevice::EnumerateDevices() //---------------------------------------------------------- { + MPT_TRACE(); std::vector<SoundDevice::Info> devices; LONG cr; @@ -184,6 +185,7 @@ //---------------------------------------------- : SoundDevice::Base(info) { + MPT_TRACE(); InitMembers(); m_QueriedFeatures.reset(); m_UsedFeatures.reset(); @@ -193,6 +195,7 @@ void CASIODevice::InitMembers() //----------------------------- { + MPT_TRACE(); m_pAsioDrv = nullptr; m_nAsioBufferLen = 0; @@ -219,6 +222,7 @@ bool CASIODevice::HandleRequests() //-------------------------------- { + MPT_TRACE(); bool result = false; LONG flags = InterlockedExchange(&m_AsioRequestFlags, 0); if(flags & AsioRequestFlagLatenciesChanged) @@ -233,6 +237,7 @@ CASIODevice::~CASIODevice() //------------------------- { + MPT_TRACE(); Close(); } @@ -240,6 +245,7 @@ bool CASIODevice::InternalOpen() //------------------------------ { + MPT_TRACE(); ASSERT(!IsDriverOpen()); @@ -468,6 +474,7 @@ void CASIODevice::UpdateLatency() //------------------------------- { + MPT_TRACE(); SoundDevice::BufferAttributes bufferAttributes; long inputLatency = 0; long outputLatency = 0; @@ -497,6 +504,7 @@ void CASIODevice::SetRenderSilence(bool silence, bool wait) //--------------------------------------------------------- { + MPT_TRACE(); InterlockedExchange(&m_RenderSilence, silence?1:0); if(!wait) { @@ -536,6 +544,7 @@ bool CASIODevice::InternalStart() //------------------------------- { + MPT_TRACE(); ALWAYS_ASSERT_WARN_MESSAGE(!CriticalSection::IsLocked(), "AudioCriticalSection locked while starting ASIO"); if(m_Settings.KeepDeviceRunning) @@ -565,18 +574,21 @@ void CASIODevice::InternalStopForce() //----------------------------------- { + MPT_TRACE(); InternalStopImpl(true); } void CASIODevice::InternalStop() //------------------------------ { + MPT_TRACE(); InternalStopImpl(false); } void CASIODevice::InternalStopImpl(bool force) //-------------------------------------------- { + MPT_TRACE(); ALWAYS_ASSERT_WARN_MESSAGE(!CriticalSection::IsLocked(), "AudioCriticalSection locked while stopping ASIO"); if(m_Settings.KeepDeviceRunning && !force) @@ -602,6 +614,7 @@ bool CASIODevice::InternalClose() //------------------------------- { + MPT_TRACE(); if(m_DeviceRunning) { m_DeviceRunning = false; @@ -651,6 +664,7 @@ void CASIODevice::OpenDriver() //---------------------------- { + MPT_TRACE(); if(IsDriverOpen()) { return; @@ -690,6 +704,7 @@ void CASIODevice::CloseDriver() //----------------------------- { + MPT_TRACE(); if(!IsDriverOpen()) { return; @@ -834,6 +849,7 @@ void CASIODevice::InternalFillAudioBuffer() //----------------------------------------- { + MPT_TRACE(); const bool rendersilence = (InterlockedExchangeAdd(&m_RenderSilence, 0) == 1); const int channels = m_Settings.Channels; const std::size_t countChunk = m_nAsioBufferLen; @@ -994,6 +1010,7 @@ bool CASIODevice::InternalHasTimeInfo() const //------------------------------------------- { + MPT_TRACE(); return m_Settings.UseHardwareTiming; } @@ -1001,6 +1018,7 @@ bool CASIODevice::InternalHasGetStreamPosition() const //---------------------------------------------------- { + MPT_TRACE(); return m_Settings.UseHardwareTiming; } @@ -1008,6 +1026,7 @@ int64 CASIODevice::InternalGetStreamPositionFrames() const //-------------------------------------------------------- { + MPT_TRACE(); if(m_Settings.UseHardwareTiming) { const uint64 asioNow = Clock().NowNanoseconds(); @@ -1028,6 +1047,7 @@ void CASIODevice::UpdateTimeInfo(AsioTimeInfo asioTimeInfo) //--------------------------------------------------------- { + MPT_TRACE(); if(m_Settings.UseHardwareTiming) { if((asioTimeInfo.flags & kSamplePositionValid) && (asioTimeInfo.flags & kSystemTimeValid)) @@ -1061,6 +1081,7 @@ void CASIODevice::BufferSwitch(long doubleBufferIndex, ASIOBool directProcess) //---------------------------------------------------------------------------- { + MPT_TRACE(); BufferSwitchTimeInfo(nullptr, doubleBufferIndex, directProcess); // delegate } @@ -1068,6 +1089,7 @@ ASIOTime* CASIODevice::BufferSwitchTimeInfo(ASIOTime* params, long doubleBufferIndex, ASIOBool directProcess) //----------------------------------------------------------------------------------------------------------- { + MPT_TRACE(); ASSERT(directProcess); // !directProcess is not handled correctly in OpenMPT, would require a separate thread and potentially additional buffering if(!directProcess) { @@ -1135,6 +1157,7 @@ void CASIODevice::SampleRateDidChange(ASIOSampleRate sRate) //--------------------------------------------------------- { + MPT_TRACE(); if(Util::Round<uint32>(sRate) == m_Settings.Samplerate) { // not different, ignore it @@ -1170,6 +1193,7 @@ std::string CASIODevice::GetStatistics() const //-------------------------------------------- { + MPT_TRACE(); const FlagSet<AsioFeatures> unsupported((AsioFeatures)(AsioFeatureNoDirectProcess | AsioFeatureOverload | AsioFeatureBufferSizeChange | AsioFeatureSampleRateChange)); FlagSet<AsioFeatures> unsupportedFeatues = m_UsedFeatures; unsupportedFeatues &= unsupported; @@ -1190,6 +1214,7 @@ long CASIODevice::AsioMessage(long selector, long value, void* message, double* opt) //---------------------------------------------------------------------------------- { + MPT_TRACE(); long result = 0; switch(selector) { @@ -1280,6 +1305,7 @@ long CASIODevice::CallbackAsioMessage(long selector, long value, void* message, double* opt) //------------------------------------------------------------------------------------------ { + MPT_TRACE(); ALWAYS_ASSERT(g_CallbacksInstance); if(!g_CallbacksInstance) return 0; return g_CallbacksInstance->AsioMessage(selector, value, message, opt); @@ -1289,6 +1315,7 @@ void CASIODevice::CallbackSampleRateDidChange(ASIOSampleRate sRate) //----------------------------------------------------------------- { + MPT_TRACE(); ALWAYS_ASSERT(g_CallbacksInstance); if(!g_CallbacksInstance) return; g_CallbacksInstance->SampleRateDidChange(sRate); @@ -1298,6 +1325,7 @@ void CASIODevice::CallbackBufferSwitch(long doubleBufferIndex, ASIOBool directProcess) //------------------------------------------------------------------------------------ { + MPT_TRACE(); ALWAYS_ASSERT(g_CallbacksInstance); if(!g_CallbacksInstance) return; g_CallbacksInstance->BufferSwitch(doubleBufferIndex, directProcess); @@ -1307,6 +1335,7 @@ ASIOTime* CASIODevice::CallbackBufferSwitchTimeInfo(ASIOTime* params, long doubleBufferIndex, ASIOBool directProcess) //------------------------------------------------------------------------------------------------------------------- { + MPT_TRACE(); ALWAYS_ASSERT(g_CallbacksInstance); if(!g_CallbacksInstance) return params; return g_CallbacksInstance->BufferSwitchTimeInfo(params, doubleBufferIndex, directProcess); @@ -1316,6 +1345,7 @@ void CASIODevice::ReportASIOException(const std::string &str) //----------------------------------------------------------- { + MPT_TRACE(); AudioSendMessage(str); Log("%s", str.c_str()); } @@ -1324,6 +1354,7 @@ SoundDevice::Caps CASIODevice::InternalGetDeviceCaps() //-------------------------------------------------- { + MPT_TRACE(); SoundDevice::Caps caps; caps.Available = true; @@ -1350,6 +1381,7 @@ SoundDevice::DynamicCaps CASIODevice::GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates) //-------------------------------------------------------------------------------------------------- { + MPT_TRACE(); SoundDevice::DynamicCaps caps; TemporaryASIODriverOpener opener(*this); @@ -1425,6 +1457,7 @@ bool CASIODevice::OpenDriverSettings() //------------------------------------ { + MPT_TRACE(); TemporaryASIODriverOpener opener(*this); if(!IsDriverOpen()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-10 19:41:09
|
Revision: 4411 http://sourceforge.net/p/modplug/code/4411 Author: saga-games Date: 2014-10-10 19:40:50 +0000 (Fri, 10 Oct 2014) Log Message: ----------- [New] Added support for a MOD variant introduced by SoundTracker 2.6 and Ice Tracker [Fix] XM: FT2 panning scheme was also applied to XMs made with trackers that most definitely don't use square root panning law. [Mod] OpenMPT: Version is now 1.24.00.08 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/soundlib/Load_mod.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-10-10 17:34:53 UTC (rev 4410) +++ trunk/OpenMPT/common/versionNumber.h 2014-10-10 19:40:50 UTC (rev 4411) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 00 -#define VER_MINORMINOR 07 +#define VER_MINORMINOR 08 //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/Load_mod.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-10 17:34:53 UTC (rev 4410) +++ trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-10 19:40:50 UTC (rev 4411) @@ -1,7 +1,7 @@ /* * Load_mod.cpp * ------------ - * Purpose: MOD / NST (ProTracker / NoiseTracker) and M15 / STK (Ultimate Soundtracker / Soundtracker) module loader / saver + * Purpose: MOD / NST (ProTracker / NoiseTracker), M15 / STK (Ultimate Soundtracker / Soundtracker) and ST26 (SoundTracker 2.6 / Ice Tracker) module loader / saver * Notes : (currently none) * Authors: Olivier Lapicque * OpenMPT Devs @@ -280,7 +280,7 @@ } } - // Convert OpenMPT's internal sample header to an MOD sample header. + // Convert OpenMPT's internal sample header to a MOD sample header. SmpLength ConvertToMOD(const ModSample &mptSmp) { SmpLength writeLength = mptSmp.pSample != nullptr ? mptSmp.nLength : 0; @@ -1134,6 +1134,122 @@ } +// SoundTracker 2.6 / Ice Tracker variation of the MOD format +// The only real difference to other SoundTracker formats is the way patterns are stored: +// Every pattern consists of four independent, re-usable tracks. +bool CSoundFile::ReadICE(FileReader &file, ModLoadingFlags loadFlags) +//------------------------------------------------------------------- +{ + char magic[4]; + if(!file.Seek(1464) || !file.ReadArray(magic)) + { + return false; + } + + InitializeGlobals(); + + if(IsMagic(magic, "MTN\0")) + madeWithTracker = "SoundTracker 2.6"; + else if(IsMagic(magic, "IT10")) + madeWithTracker = "Ice Tracker 1.0 / 1.1"; + else + return false; + + // Reading song title + file.Seek(0); + file.ReadString<mpt::String::spacePadded>(songName, 20); + + // Load Samples + m_nSamples = 31; + for(SAMPLEINDEX smp = 1; smp <= 31; smp++) + { + MODSampleHeader sampleHeader; + ReadSample(file, sampleHeader, Samples[smp], m_szNames[smp]); + } + + const uint8 numOrders = file.ReadUint8(); + const uint8 numTracks = file.ReadUint8(); + if(numOrders > 128) + return false; + + uint8 tracks[128 * 4]; + file.ReadArray(tracks); + for(size_t i = 0; i < CountOf(tracks); i++) + { + if(tracks[i] > numTracks) + return false; + } + + if(loadFlags == onlyVerifyHeader) + return true; + + // Now we can be pretty sure that this is a valid MOD file. Set up default song settings. + m_nType = MOD_TYPE_MOD; + m_nChannels = 4; + m_nInstruments = 0; + m_nDefaultSpeed = 6; + m_nDefaultTempo = 125; + m_nMinPeriod = 14 * 4; + m_nMaxPeriod = 3424 * 4; + m_nSamplePreAmp = 64; + m_SongFlags = SONG_PT1XMODE; + + // Setup channel pan positions and volume + SetupMODPanning(); + + // Reading patterns + Order.resize(numOrders); + for(PATTERNINDEX pat = 0; pat < numOrders; pat++) + { + Order[pat] = pat; + if(Patterns.Insert(pat, 64)) + continue; + + for(CHANNELINDEX chn = 0; chn < 4; chn++) + { + file.Seek(1468 + tracks[pat * 4 + chn] * 64u * 4u); + ModCommand *m = Patterns[pat].GetpModCommand(0, chn); + + for(ROWINDEX row = 0; row < 64; row++, m += 4) + { + ReadMODPatternEntry(file, *m); + + if((m->command || m->param) + && !(m->command == 0x0E && m->param >= 0x10) // Exx only sets filter + && !(m->command >= 0x05 && m->command <= 0x09)) // These don't exist in ST2.6 + { + ConvertModCommand(*m); + if(m->command == CMD_TEMPO) + { + m->command = CMD_SPEED; + } + } else + { + m->command = CMD_NONE; + } + } + } + } + + // Reading samples + if(loadFlags & loadSampleData) + { + file.Seek(1468 + numTracks * 64u * 4u); + for(SAMPLEINDEX smp = 1; smp <= 31; smp++) if(Samples[smp].nLength) + { + SampleIO( + SampleIO::_8bit, + SampleIO::mono, + SampleIO::littleEndian, + SampleIO::signedPCM) + .ReadSample(Samples[smp], file); + } + } + + return true; +} + + #ifndef MODPLUG_NO_FILESAVE bool CSoundFile::SaveMod(const mpt::PathString &filename) const Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2014-10-10 17:34:53 UTC (rev 4410) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2014-10-10 19:40:50 UTC (rev 4411) @@ -283,7 +283,7 @@ InitializeGlobals(); InitializeChannels(); ChangeModTypeTo(MOD_TYPE_XM); - m_nMixLevels = mixLevels_compatible_FT2; + m_nMixLevels = mixLevels_compatible; FlagSet<TrackerVersions> madeWith(verUnknown); @@ -583,6 +583,11 @@ mpt::String::SetNullTerminator(mptVersion); m_dwLastSavedWithVersion = MptVersion::ToNum(mptVersion); madeWith = verOpenMPT | verConfirmed; + + if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 22, 07, 19)) + m_nMixLevels = mixLevels_compatible; + else + m_nMixLevels = mixLevels_compatible_FT2; } if(m_dwLastSavedWithVersion != 0 && !madeWith[verOpenMPT]) @@ -591,23 +596,27 @@ SetModFlag(MSF_COMPATIBLE_PLAY, false); } - if(madeWith[verFT2Generic] && !m_SongFlags[SONG_EMBEDMIDICFG]) + if(madeWith[verFT2Generic]) { - // FT2 allows typing in arbitrary unsupported effect letters such as Zxx. - // Prevent these commands from being interpreted as filter commands by erasing the default MIDI Config. - MemsetZero(m_MidiCfg.szMidiSFXExt); - MemsetZero(m_MidiCfg.szMidiZXXExt); - } + m_nMixLevels = mixLevels_compatible_FT2; - if(madeWith[verFT2Generic] - && fileHeader.version >= 0x0104 // Old versions of FT2 didn't have (smooth) ramping. Disable it for those versions where we can be sure that there should be no ramping. + if(!m_SongFlags[SONG_EMBEDMIDICFG]) + { + // FT2 allows typing in arbitrary unsupported effect letters such as Zxx. + // Prevent these commands from being interpreted as filter commands by erasing the default MIDI Config. + MemsetZero(m_MidiCfg.szMidiSFXExt); + MemsetZero(m_MidiCfg.szMidiZXXExt); + } + + if(fileHeader.version >= 0x0104 // Old versions of FT2 didn't have (smooth) ramping. Disable it for those versions where we can be sure that there should be no ramping. #ifdef MODPLUG_TRACKER - && TrackerSettings::Instance().autoApplySmoothFT2Ramping + && TrackerSettings::Instance().autoApplySmoothFT2Ramping #endif // MODPLUG_TRACKER - ) - { - // apply FT2-style super-soft volume ramping - SetModFlag(MSF_VOLRAMP, true); + ) + { + // apply FT2-style super-soft volume ramping + SetModFlag(MSF_VOLRAMP, true); + } } if(madeWithTracker.empty()) @@ -688,7 +697,7 @@ memcpy(fileHeader.signature, "Extended Module: ", 17); mpt::String::Write<mpt::String::spacePadded>(fileHeader.songName, songName); fileHeader.eof = 0x1A; - std::string openMptTrackerName = MptVersion::GetOpenMPTVersionStr(); + const std::string openMptTrackerName = MptVersion::GetOpenMPTVersionStr(); mpt::String::Write<mpt::String::spacePadded>(fileHeader.trackerName, openMptTrackerName); // Writing song header Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-10 17:34:53 UTC (rev 4410) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-10 19:40:50 UTC (rev 4411) @@ -817,6 +817,7 @@ && !ReadJ2B(file, loadFlags) && !ReadMO3(file, loadFlags) && !ReadMod(file, loadFlags) + && !ReadICE(file, loadFlags) && !ReadM15(file, loadFlags)) { m_nType = MOD_TYPE_NONE; @@ -2394,11 +2395,7 @@ // Starting from OpenMPT 1.23.01.04, FT2-style panning has its own mix mode instead. if(GetType() == MOD_TYPE_XM) { - if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 22, 07, 19) - && GetMixLevels() == mixLevels_compatible_FT2) - { - SetMixLevels(mixLevels_compatible); - } else if(m_dwLastSavedWithVersion >= MAKE_VERSION_NUMERIC(1, 22, 07, 19) + if(m_dwLastSavedWithVersion >= MAKE_VERSION_NUMERIC(1, 22, 07, 19) && m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 23, 01, 04) && GetMixLevels() == mixLevels_compatible) { Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2014-10-10 17:34:53 UTC (rev 4410) +++ trunk/OpenMPT/soundlib/Sndfile.h 2014-10-10 19:40:50 UTC (rev 4411) @@ -623,6 +623,7 @@ bool ReadS3M(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadMod(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadM15(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); + bool ReadICE(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadMed(const uint8 *lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadMTM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadSTM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-10 19:50:03
|
Revision: 4412 http://sourceforge.net/p/modplug/code/4412 Author: saga-games Date: 2014-10-10 19:49:53 +0000 (Fri, 10 Oct 2014) Log Message: ----------- [Mod] Add IceTracker/SoundTracker 2.6 extensions (ICE = xmp extension, ST26 = ModLand extension) to various parts of the program. Modified Paths: -------------- trunk/OpenMPT/installer/filetypes.iss trunk/OpenMPT/libopenmpt/foo_openmpt.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/soundlib/Tables.cpp Modified: trunk/OpenMPT/installer/filetypes.iss =================================================================== --- trunk/OpenMPT/installer/filetypes.iss 2014-10-10 19:40:50 UTC (rev 4411) +++ trunk/OpenMPT/installer/filetypes.iss 2014-10-10 19:49:53 UTC (rev 4412) @@ -29,6 +29,7 @@ Name: "associate_exotic\far"; Description: "Farandole Composer (FAR)"; Name: "associate_exotic\gdm"; Description: "General Digital Music (GDM)"; Name: "associate_exotic\imf"; Description: "Imago Orpheus (IMF)"; +Name: "associate_exotic\ice"; Description: "Ice Tracker (ICE)"; Name: "associate_exotic\j2b"; Description: "Jazz Jackrabbit 2 Music (J2B)"; Name: "associate_exotic\m15"; Description: "Ultimate Soundtracker (M15)"; Name: "associate_exotic\mdl"; Description: "DigiTrakker (MDL)"; @@ -70,6 +71,7 @@ Root: HKCR; Subkey: ".far"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\far Root: HKCR; Subkey: ".gdm"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\gdm Root: HKCR; Subkey: ".imf"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\imf +Root: HKCR; Subkey: ".ice"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\ice Root: HKCR; Subkey: ".j2b"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\j2b Root: HKCR; Subkey: ".m15"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\m15 Root: HKCR; Subkey: ".mdl"; ValueType: string; ValueName: ""; ValueData: "OpenMPTFile"; Flags: uninsdeletevalue; Tasks: associate_exotic\mdl Modified: trunk/OpenMPT/libopenmpt/foo_openmpt.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/foo_openmpt.cpp 2014-10-10 19:40:50 UTC (rev 4411) +++ trunk/OpenMPT/libopenmpt/foo_openmpt.cpp 2014-10-10 19:49:53 UTC (rev 4412) @@ -289,6 +289,8 @@ "*.nst" ";" "*.m15" ";" "*.stk" ";" + "*.st26" ";" + "*.ice" ";" "*.wow" ";" "*.ult" ";" "*.669" ";" Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2014-10-10 19:40:50 UTC (rev 4411) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2014-10-10 19:49:53 UTC (rev 4412) @@ -1191,7 +1191,7 @@ static int nFilterIndex = 0; FileDialog dlg = OpenFileDialog() .AllowMultiSelect() - .ExtensionFilter("All Modules|" + exts + + .ExtensionFilter("All Modules|" + exts + ";mod.*" "|" "Compressed Modules (*.mdz;*.s3z;*.xmz;*.itz" #ifndef NO_MO3 @@ -1202,7 +1202,7 @@ ";*.mo3" #endif "|" - "ProTracker Modules (*.mod,*.nst)|*.mod;mod.*;*.mdz;*.nst;*.m15|" + "ProTracker Modules (*.mod,*.nst)|*.mod;mod.*;*.mdz;*.nst;*.m15;*.stk|" "ScreamTracker Modules (*.s3m,*.stm)|*.s3m;*.stm;*.s3z|" "FastTracker Modules (*.xm)|*.xm;*.xmz|" "Impulse Tracker Modules (*.it)|*.it;*.itz|" @@ -1211,7 +1211,7 @@ "Impulse Tracker Projects (*.itp)|*.itp;*.itpz|" // -! NEW_FEATURE#0023 "OpenMPT Modules (*.mptm)|*.mptm;*.mptmz|" - "Other Modules (mtm,okt,mdl,669,far,...)|*.mtm;*.669;*.ult;*.wow;*.far;*.mdl;*.okt;*.dmf;*.ptm;*.med;*.ams;*.dbm;*.digi;*.dsm;*.umx;*.amf;*.psm;*.mt2;*.gdm;*.imf;*.j2b|" + "Other Modules (mtm,okt,mdl,669,far,...)|*.mtm;*.669;*.ult;*.wow;*.far;*.mdl;*.okt;*.dmf;*.ptm;*.med;*.ams;*.dbm;*.digi;*.dsm;*.umx;*.amf;*.psm;*.mt2;*.gdm;*.imf;*.j2b;*.ice;*.st26|" "Wave Files (*.wav)|*.wav|" "MIDI Files (*.mid,*.rmi)|*.mid;*.rmi;*.smf|" "All Files (*.*)|*.*||") Modified: trunk/OpenMPT/soundlib/Tables.cpp =================================================================== --- trunk/OpenMPT/soundlib/Tables.cpp 2014-10-10 19:40:50 UTC (rev 4411) +++ trunk/OpenMPT/soundlib/Tables.cpp 2014-10-10 19:49:53 UTC (rev 4412) @@ -41,7 +41,7 @@ const char *extension; // "mod" }; -// remember to also update libopenmpt/libopenmpt_foobar2000.cpp (all other plugins read these dynamically) +// remember to also update libopenmpt/foo_openmpt.cpp (all other plugins read these dynamically) static const ModFormatInfo modFormatInfo[] = { { MOD_TYPE_MOD, "ProTracker", "mod" }, @@ -56,6 +56,8 @@ { MOD_TYPE_MOD, "NoiseTracker", "nst" }, { MOD_TYPE_MOD, "Soundtracker", "m15" }, { MOD_TYPE_MOD, "Soundtracker", "stk" }, + { MOD_TYPE_MOD, "SoundTracker 2.6", "st26" }, + { MOD_TYPE_MOD, "Ice Tracker", "ice" }, { MOD_TYPE_MOD, "Mod's Grave", "wow" }, { MOD_TYPE_ULT, "UltraTracker", "ult" }, { MOD_TYPE_669, "Composer 669 / UNIS 669", "669" }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-10-10 22:26:40
|
Revision: 4414 http://sourceforge.net/p/modplug/code/4414 Author: saga-games Date: 2014-10-10 22:26:29 +0000 (Fri, 10 Oct 2014) Log Message: ----------- [Imp] VST: Randomize params now randomizes parameters by a factor (this is much more useful than completely random parameters) [Fix] MOD: Sample names couldn't contain any ANSI characters (broke in r1526 / OpenMPT 1.22). Revision Links: -------------- http://sourceforge.net/p/modplug/code/1526 Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/soundlib/Load_mod.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-10-10 20:30:27 UTC (rev 4413) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-10-10 22:26:29 UTC (rev 4414) @@ -21,6 +21,7 @@ #include "VstPresets.h" #include "../soundlib/FileReader.h" #include "InputHandler.h" +#include "dlg_misc.h" #include <sstream> @@ -226,12 +227,15 @@ } -VOID CAbstractVstEditor::OnRandomizePreset() +void CAbstractVstEditor::OnRandomizePreset() //----------------------------------------- { - if(Reporting::Confirm("Are you sure you want to randomize parameters?\nYou will lose current parameter values.", false, false, this) == cnfYes) + static int randomFactor = 10; + CInputDlg dlg(this, _T("Input parameter randomization amount (0 = no change, 100 = completely random)"), 0, 100, randomFactor); + if(dlg.DoModal() == IDOK) { - m_VstPlugin.RandomizeParams(); + randomFactor = dlg.resultNumber; + m_VstPlugin.RandomizeParams(randomFactor); UpdateParamDisplays(); } } @@ -494,10 +498,8 @@ // Can't process notes return false; } - } else - { - return true; } + return true; } Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2014-10-10 20:30:27 UTC (rev 4413) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2014-10-10 22:26:29 UTC (rev 4414) @@ -959,21 +959,17 @@ } -bool CVstPlugin::RandomizeParams(PlugParamIndex minParam, PlugParamIndex maxParam) -//-------------------------------------------------------------------------------- +void CVstPlugin::RandomizeParams(int amount) +//------------------------------------------ { - if (minParam == 0 && maxParam == 0) + PlugParamValue factor = PlugParamValue(amount) / 100.0f; + for(PlugParamIndex p = 0; p < m_Effect.numParams; p++) { - maxParam = m_Effect.numParams; + PlugParamValue val = GetParameter(p); + val += (2.0f * PlugParamValue(rand()) / PlugParamValue(RAND_MAX) - 1.0f) * factor; + Limit(val, 0.0f, 1.0f); + SetParameter(p, val); } - LimitMax(maxParam, PlugParamIndex(m_Effect.numParams)); - - for(PlugParamIndex p = minParam; p < maxParam; p++) - { - SetParameter(p, (float(rand()) / float(RAND_MAX))); - } - - return true; } Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2014-10-10 20:30:27 UTC (rev 4413) +++ trunk/OpenMPT/mptrack/Vstplug.h 2014-10-10 22:26:29 UTC (rev 4414) @@ -213,7 +213,7 @@ // Check if programs should be stored as chunks or parameters bool ProgramsAreChunks() const { return (m_Effect.flags & effFlagsProgramChunks) != 0; } bool GetParams(float* param, VstInt32 min, VstInt32 max); - bool RandomizeParams(PlugParamIndex minParam = 0, PlugParamIndex maxParam = 0); + void RandomizeParams(int amount); // If true, the plugin produces an output even if silence is being fed into it. bool ShouldProcessSilence() { return m_Effect.numInputs == 0 || ((m_Effect.flags & effFlagsNoSoundInStop) == 0 && Dispatch(effGetTailSize, 0, 0, nullptr, 0.0f) != 1); } void ResetSilence() { m_MixState.ResetSilence(); } Modified: trunk/OpenMPT/soundlib/Load_mod.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-10 20:30:27 UTC (rev 4413) +++ trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-10 22:26:29 UTC (rev 4414) @@ -389,7 +389,7 @@ // Get rid of weird characters in sample names. for(size_t i = 0; i < CountOf(sampleName); i++) { - if(sampleName[i] && sampleName[i] < ' ') + if(sampleName[i] > 0 && sampleName[i] < ' ') { sampleName[i] = ' '; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-10-11 13:13:37
|
Revision: 4416 http://sourceforge.net/p/modplug/code/4416 Author: manxorist Date: 2014-10-11 13:13:25 +0000 (Sat, 11 Oct 2014) Log Message: ----------- [Ref] Debug: Change all MSVC debug project configurations to use static linking of runtime and MFC. This makes debug builds consistent with release builds (which always use static linking), allows foo_openmpt to build without changing project files in debug build (which has not been possible before because the fb2k SDK uses static linkage and libopenmpt dynamic linkage in debug builds because of interdependencies with external projects which inherited dynamic linkage from mptrack.exe), allows giving debug builds away without bundling the runtimes and prepares for an experimental VSTI version which can then use static MFC in both release and debug builds. The disadvantage is increased binary size of the debug build. Modified Paths: -------------- trunk/OpenMPT/build/gen/UnRAR.vcproj trunk/OpenMPT/build/gen/UnRAR.vcxproj trunk/OpenMPT/build/gen/flac.vcproj trunk/OpenMPT/build/gen/flac.vcxproj trunk/OpenMPT/build/gen/lhasa.vcproj trunk/OpenMPT/build/gen/lhasa.vcxproj trunk/OpenMPT/build/gen/miniz.vcproj trunk/OpenMPT/build/gen/miniz.vcxproj trunk/OpenMPT/build/gen/minizip.vcproj trunk/OpenMPT/build/gen/minizip.vcxproj trunk/OpenMPT/build/gen/portaudio.vcproj trunk/OpenMPT/build/gen/portaudio.vcxproj trunk/OpenMPT/build/gen/portmidi.vcproj trunk/OpenMPT/build/gen/portmidi.vcxproj trunk/OpenMPT/build/gen/smbPitchShift.vcproj trunk/OpenMPT/build/gen/smbPitchShift.vcxproj trunk/OpenMPT/build/gen/soundtouch.vcproj trunk/OpenMPT/build/gen/soundtouch.vcxproj trunk/OpenMPT/build/gen/zlib.vcproj trunk/OpenMPT/build/gen/zlib.vcxproj trunk/OpenMPT/build/premake4-defaults-static.lua trunk/OpenMPT/build/vs2008/libopenmpt/libopenmpt.vcproj trunk/OpenMPT/build/vs2008/libopenmpt_example_c/libopenmpt_example_c.vcproj trunk/OpenMPT/libopenmpt/foo_openmpt.vcxproj trunk/OpenMPT/libopenmpt/in_openmpt.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt_modplug.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj trunk/OpenMPT/libopenmpt/xmp-openmpt.vcxproj trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/openmpt123/openmpt123.vcxproj trunk/OpenMPT/pluginBridge/PluginBridge.vcxproj trunk/OpenMPT/plugins/MidiInOut/MidiInOut.vcxproj Modified: trunk/OpenMPT/build/gen/UnRAR.vcproj =================================================================== --- trunk/OpenMPT/build/gen/UnRAR.vcproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/UnRAR.vcproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -47,7 +47,7 @@ PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" @@ -124,7 +124,7 @@ PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" Modified: trunk/OpenMPT/build/gen/UnRAR.vcxproj =================================================================== --- trunk/OpenMPT/build/gen/UnRAR.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/UnRAR.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -116,7 +116,7 @@ <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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> @@ -142,7 +142,7 @@ <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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> Modified: trunk/OpenMPT/build/gen/flac.vcproj =================================================================== --- trunk/OpenMPT/build/gen/flac.vcproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/flac.vcproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -48,7 +48,7 @@ PreprocessorDefinitions="FLAC__NO_DLL;VERSION=\"1.3.0\";DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" @@ -127,7 +127,7 @@ PreprocessorDefinitions="FLAC__NO_DLL;VERSION=\"1.3.0\";DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" Modified: trunk/OpenMPT/build/gen/flac.vcxproj =================================================================== --- trunk/OpenMPT/build/gen/flac.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/flac.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -117,7 +117,7 @@ <PreprocessorDefinitions>FLAC__NO_DLL;VERSION="1.3.0";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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> @@ -145,7 +145,7 @@ <PreprocessorDefinitions>FLAC__NO_DLL;VERSION="1.3.0";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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> Modified: trunk/OpenMPT/build/gen/lhasa.vcproj =================================================================== --- trunk/OpenMPT/build/gen/lhasa.vcproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/lhasa.vcproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -47,7 +47,7 @@ PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" @@ -125,7 +125,7 @@ PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" Modified: trunk/OpenMPT/build/gen/lhasa.vcxproj =================================================================== --- trunk/OpenMPT/build/gen/lhasa.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/lhasa.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -116,7 +116,7 @@ <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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> @@ -143,7 +143,7 @@ <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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> Modified: trunk/OpenMPT/build/gen/miniz.vcproj =================================================================== --- trunk/OpenMPT/build/gen/miniz.vcproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/miniz.vcproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -46,7 +46,7 @@ PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" @@ -122,7 +122,7 @@ PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" Modified: trunk/OpenMPT/build/gen/miniz.vcxproj =================================================================== --- trunk/OpenMPT/build/gen/miniz.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/miniz.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -115,7 +115,7 @@ <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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> @@ -140,7 +140,7 @@ <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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> Modified: trunk/OpenMPT/build/gen/minizip.vcproj =================================================================== --- trunk/OpenMPT/build/gen/minizip.vcproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/minizip.vcproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -47,7 +47,7 @@ PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" @@ -125,7 +125,7 @@ PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" Modified: trunk/OpenMPT/build/gen/minizip.vcxproj =================================================================== --- trunk/OpenMPT/build/gen/minizip.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/minizip.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -116,7 +116,7 @@ <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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> @@ -143,7 +143,7 @@ <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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> Modified: trunk/OpenMPT/build/gen/portaudio.vcproj =================================================================== --- trunk/OpenMPT/build/gen/portaudio.vcproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/portaudio.vcproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -48,7 +48,7 @@ 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" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" @@ -127,7 +127,7 @@ 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" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" Modified: trunk/OpenMPT/build/gen/portaudio.vcxproj =================================================================== --- trunk/OpenMPT/build/gen/portaudio.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/portaudio.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -117,7 +117,7 @@ <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> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> @@ -145,7 +145,7 @@ <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> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> Modified: trunk/OpenMPT/build/gen/portmidi.vcproj =================================================================== --- trunk/OpenMPT/build/gen/portmidi.vcproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/portmidi.vcproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -47,7 +47,7 @@ PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" @@ -125,7 +125,7 @@ PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" Modified: trunk/OpenMPT/build/gen/portmidi.vcxproj =================================================================== --- trunk/OpenMPT/build/gen/portmidi.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/portmidi.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -116,7 +116,7 @@ <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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> @@ -143,7 +143,7 @@ <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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> Modified: trunk/OpenMPT/build/gen/smbPitchShift.vcproj =================================================================== --- trunk/OpenMPT/build/gen/smbPitchShift.vcproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/smbPitchShift.vcproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -46,7 +46,7 @@ PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" @@ -121,7 +121,7 @@ PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" Modified: trunk/OpenMPT/build/gen/smbPitchShift.vcxproj =================================================================== --- trunk/OpenMPT/build/gen/smbPitchShift.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/smbPitchShift.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -115,7 +115,7 @@ <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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> @@ -139,7 +139,7 @@ <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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> Modified: trunk/OpenMPT/build/gen/soundtouch.vcproj =================================================================== --- trunk/OpenMPT/build/gen/soundtouch.vcproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/soundtouch.vcproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -47,7 +47,7 @@ PreprocessorDefinitions="DLL_EXPORTS;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" @@ -131,7 +131,7 @@ PreprocessorDefinitions="DLL_EXPORTS;DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" Modified: trunk/OpenMPT/build/gen/soundtouch.vcxproj =================================================================== --- trunk/OpenMPT/build/gen/soundtouch.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/soundtouch.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -128,7 +128,7 @@ <PreprocessorDefinitions>DLL_EXPORTS;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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> @@ -155,7 +155,7 @@ <PreprocessorDefinitions>DLL_EXPORTS;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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> Modified: trunk/OpenMPT/build/gen/zlib.vcproj =================================================================== --- trunk/OpenMPT/build/gen/zlib.vcproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/zlib.vcproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -47,7 +47,7 @@ PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" @@ -125,7 +125,7 @@ PreprocessorDefinitions="DEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" Modified: trunk/OpenMPT/build/gen/zlib.vcxproj =================================================================== --- trunk/OpenMPT/build/gen/zlib.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/gen/zlib.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -116,7 +116,7 @@ <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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> @@ -143,7 +143,7 @@ <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>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking> <PrecompiledHeader></PrecompiledHeader> <WarningLevel>Level3</WarningLevel> Modified: trunk/OpenMPT/build/premake4-defaults-static.lua =================================================================== --- trunk/OpenMPT/build/premake4-defaults-static.lua 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/premake4-defaults-static.lua 2014-10-11 13:13:25 UTC (rev 4416) @@ -2,7 +2,7 @@ configuration "Debug" defines { "DEBUG" } defines { "WIN32", "_CRT_SECURE_NO_WARNINGS", "_CRT_NONSTDC_NO_DEPRECATE", "_CRT_SECURE_NO_DEPRECATE", "_CRT_NONSTDC_NO_WARNINGS" } - flags { "Symbols" } + flags { "Symbols", "StaticRuntime" } configuration "Release" defines { "NDEBUG" } Modified: trunk/OpenMPT/build/vs2008/libopenmpt/libopenmpt.vcproj =================================================================== --- trunk/OpenMPT/build/vs2008/libopenmpt/libopenmpt.vcproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/vs2008/libopenmpt/libopenmpt.vcproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -44,7 +44,7 @@ PreprocessorDefinitions="LIBOPENMPT_BUILD" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" WarningLevel="3" DebugInformationFormat="4" /> Modified: trunk/OpenMPT/build/vs2008/libopenmpt_example_c/libopenmpt_example_c.vcproj =================================================================== --- trunk/OpenMPT/build/vs2008/libopenmpt_example_c/libopenmpt_example_c.vcproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/build/vs2008/libopenmpt_example_c/libopenmpt_example_c.vcproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -43,7 +43,7 @@ AdditionalIncludeDirectories="../../../include/msinttypes/stdint;../../..;../../../include/portaudio/include" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" WarningLevel="3" DebugInformationFormat="4" /> Modified: trunk/OpenMPT/libopenmpt/foo_openmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/foo_openmpt.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/libopenmpt/foo_openmpt.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -51,6 +51,7 @@ <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>../include/foobar2000sdk</AdditionalIncludeDirectories> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> Modified: trunk/OpenMPT/libopenmpt/in_openmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/in_openmpt.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/libopenmpt/in_openmpt.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -49,6 +49,7 @@ <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>../include;$(IntDir)svn_version;../build/svn_version</AdditionalIncludeDirectories> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -91,7 +91,7 @@ <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..;../common;../include;$(IntDir)svn_version;../build/svn_version</AdditionalIncludeDirectories> <PreprocessorDefinitions>LIBOPENMPT_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> @@ -109,7 +109,7 @@ <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..;../common;../include;$(IntDir)svn_version;../build/svn_version</AdditionalIncludeDirectories> <PreprocessorDefinitions>LIBOPENMPT_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> Modified: trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/libopenmpt/libopenmptDLL.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -91,7 +91,7 @@ <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..;../common;../include;$(IntDir)svn_version;../build/svn_version</AdditionalIncludeDirectories> <PreprocessorDefinitions>_WINDLL;LIBOPENMPT_BUILD;LIBOPENMPT_BUILD_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> @@ -112,7 +112,7 @@ <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..;../common;../include;$(IntDir)svn_version;../build/svn_version</AdditionalIncludeDirectories> <PreprocessorDefinitions>_WINDLL;LIBOPENMPT_BUILD;LIBOPENMPT_BUILD_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> Modified: trunk/OpenMPT/libopenmpt/libopenmpt_modplug.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_modplug.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/libopenmpt/libopenmpt_modplug.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -91,7 +91,7 @@ <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..;../include/modplug/include;$(IntDir)svn_version;../build/svn_version</AdditionalIncludeDirectories> <PreprocessorDefinitions>_WINDLL;LIBOPENMPT_USE_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> @@ -112,7 +112,7 @@ <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..;../include/modplug/include;$(IntDir)svn_version;../build/svn_version</AdditionalIncludeDirectories> <PreprocessorDefinitions>_WINDLL;LIBOPENMPT_USE_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/libopenmpt/libopenmpt_test.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -87,7 +87,7 @@ <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..;../common;../include;$(IntDir)svn_version;../build/svn_version</AdditionalIncludeDirectories> <PreprocessorDefinitions>LIBOPENMPT_BUILD;LIBOPENMPT_BUILD_TEST;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> @@ -108,7 +108,7 @@ <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..;../common;../include;$(IntDir)svn_version;../build/svn_version</AdditionalIncludeDirectories> <PreprocessorDefinitions>LIBOPENMPT_BUILD;LIBOPENMPT_BUILD_TEST;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> Modified: trunk/OpenMPT/libopenmpt/xmp-openmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/xmp-openmpt.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/libopenmpt/xmp-openmpt.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -49,6 +49,7 @@ <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>../include;../include/pugixml/src;$(IntDir)svn_version;../build/svn_version</AdditionalIncludeDirectories> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -25,7 +25,7 @@ IntermediateDirectory="..\build\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)" ConfigurationType="1" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - UseOfMFC="2" + UseOfMFC="1" ATLMinimizesCRunTimeLibraryUsage="false" > <Tool @@ -57,7 +57,7 @@ StringPooling="true" ExceptionHandling="2" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" BufferSecurityCheck="true" EnableFunctionLevelLinking="true" UsePrecompiledHeader="2" @@ -124,7 +124,7 @@ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="1" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - UseOfMFC="2" + UseOfMFC="1" ATLMinimizesCRunTimeLibraryUsage="false" > <Tool @@ -156,7 +156,7 @@ StringPooling="true" ExceptionHandling="2" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" BufferSecurityCheck="true" EnableFunctionLevelLinking="true" UsePrecompiledHeader="2" @@ -1562,10 +1562,6 @@ > </File> <File - RelativePath="..\common\WriteMemoryDump.h" - > - </File> - <File RelativePath=".\view_com.h" > </File> @@ -1609,6 +1605,10 @@ RelativePath="..\soundlib\WindowedFIR.h" > </File> + <File + RelativePath="..\common\WriteMemoryDump.h" + > + </File> <Filter Name="tuning" > Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -59,11 +59,11 @@ </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> - <UseOfMfc>Dynamic</UseOfMfc> + <UseOfMfc>Static</UseOfMfc> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> - <UseOfMfc>Dynamic</UseOfMfc> + <UseOfMfc>Static</UseOfMfc> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> @@ -128,7 +128,7 @@ <PreprocessorDefinitions>_DEBUG;WIN32;_WINDOWS;MODPLUG_TRACKER;%(PreprocessorDefinitions)</PreprocessorDefinitions> <StringPooling>true</StringPooling> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <FunctionLevelLinking>true</FunctionLevelLinking> <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> @@ -179,7 +179,7 @@ <PreprocessorDefinitions>_DEBUG;WIN32;_WINDOWS;MODPLUG_TRACKER;%(PreprocessorDefinitions)</PreprocessorDefinitions> <StringPooling>true</StringPooling> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <FunctionLevelLinking>true</FunctionLevelLinking> <ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope> Modified: trunk/OpenMPT/openmpt123/openmpt123.vcxproj =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/openmpt123/openmpt123.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -86,7 +86,7 @@ <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..;../common;../include/flac/include;../include/portaudio/include;../common/svn_version;../common/svn_version_default</AdditionalIncludeDirectories> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> @@ -99,7 +99,7 @@ <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..;../common;../include/flac/include;../include/portaudio/include;../common/svn_version;../common/svn_version_default</AdditionalIncludeDirectories> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <GenerateDebugInformation>true</GenerateDebugInformation> Modified: trunk/OpenMPT/pluginBridge/PluginBridge.vcxproj =================================================================== --- trunk/OpenMPT/pluginBridge/PluginBridge.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/pluginBridge/PluginBridge.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -95,6 +95,7 @@ <Optimization>Disabled</Optimization> <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>../include/</AdditionalIncludeDirectories> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <SubSystem>Windows</SubSystem> @@ -120,6 +121,7 @@ <Optimization>Disabled</Optimization> <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>../include/</AdditionalIncludeDirectories> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <SubSystem>Windows</SubSystem> Modified: trunk/OpenMPT/plugins/MidiInOut/MidiInOut.vcxproj =================================================================== --- trunk/OpenMPT/plugins/MidiInOut/MidiInOut.vcxproj 2014-10-11 00:14:21 UTC (rev 4415) +++ trunk/OpenMPT/plugins/MidiInOut/MidiInOut.vcxproj 2014-10-11 13:13:25 UTC (rev 4416) @@ -83,7 +83,7 @@ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;AGAIN_EXPORTS;_CRT_SECURE_NO_DEPRECATE=1;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level3</WarningLevel> @@ -110,7 +110,7 @@ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;AGAIN_EXPORTS;VST_64BIT_PLATFORM=1;_CRT_SECURE_NO_DEPRECATE=1;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level3</WarningLevel> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |