From: <man...@us...> - 2015-01-29 10:53:33
|
Revision: 4735 http://sourceforge.net/p/modplug/code/4735 Author: manxorist Date: 2015-01-29 10:53:27 +0000 (Thu, 29 Jan 2015) Log Message: ----------- [Mod] libopenmpt: Enable asserts only in debug, checked or test suite builds. Modified Paths: -------------- trunk/OpenMPT/Makefile trunk/OpenMPT/common/BuildSettings.h Modified: trunk/OpenMPT/Makefile =================================================================== --- trunk/OpenMPT/Makefile 2015-01-29 10:35:45 UTC (rev 4734) +++ trunk/OpenMPT/Makefile 2015-01-29 10:53:27 UTC (rev 4735) @@ -236,6 +236,7 @@ ARFLAGS += ifeq ($(DEBUG),1) +CPPFLAGS += -DMPT_BUILD_DEBUG CXXFLAGS += -g CFLAGS += -g else @@ -263,6 +264,7 @@ ARFLAGS += ifeq ($(DEBUG),1) +CPPFLAGS += -DMPT_BUILD_DEBUG CXXFLAGS += -O0 -g CFLAGS += -O0 -g else Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2015-01-29 10:35:45 UTC (rev 4734) +++ trunk/OpenMPT/common/BuildSettings.h 2015-01-29 10:53:27 UTC (rev 4735) @@ -155,12 +155,20 @@ #include "config.h" #endif // HAVE_CONFIG_H +#if (defined(_DEBUG) || defined(DEBUG)) && !defined(MPT_BUILD_DEBUG) +#define MPT_BUILD_DEBUG +#endif + #if defined(LIBOPENMPT_BUILD_TEST) #define ENABLE_TESTS #else #define MODPLUG_NO_FILESAVE #endif -//#define NO_ASSERTS +#if defined(MPT_BUILD_CHECKED) || defined(ENABLE_TESTS) +// enable asserts +#else +#define NO_ASSERTS +#endif //#define NO_LOGGING #define MPT_FILEREADER_STD_ISTREAM //#define MPT_EXTERNAL_SAMPLES This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-01-31 13:03:54
|
Revision: 4741 http://sourceforge.net/p/modplug/code/4741 Author: manxorist Date: 2015-01-31 13:03:40 +0000 (Sat, 31 Jan 2015) Log Message: ----------- [Ref] sounddev: Convert more std::string to mpt::ustring. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp trunk/OpenMPT/sounddev/SoundDeviceASIO.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2015-01-31 11:02:10 UTC (rev 4740) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2015-01-31 13:03:40 UTC (rev 4741) @@ -629,11 +629,11 @@ } -void CMainFrame::AudioMessage(const std::string &str) -//--------------------------------------------------- +void CMainFrame::AudioMessage(const mpt::ustring &str) +//---------------------------------------------------- { MPT_TRACE(); - Reporting::Notification(str.c_str()); + Reporting::Notification(str); } Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2015-01-31 11:02:10 UTC (rev 4740) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2015-01-31 13:03:40 UTC (rev 4741) @@ -401,7 +401,7 @@ void AudioDone(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, int64 streamPosition); // from SoundDevice::IMessageReceiver - void AudioMessage(const std::string &str); + void AudioMessage(const mpt::ustring &str); bool InGuiThread() const { return theApp.InGuiThread(); } bool InAudioThread() const { return GetCurrentThreadId() == m_AudioThreadId; } Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2015-01-31 11:02:10 UTC (rev 4740) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2015-01-31 13:03:40 UTC (rev 4741) @@ -897,18 +897,18 @@ const double currentLatency = pMainFrm->gpSoundDevice->GetCurrentLatency(); const double currentUpdateInterval = pMainFrm->gpSoundDevice->GetCurrentUpdateInterval(); const uint32 samplerate = pMainFrm->gpSoundDevice->GetSettings().Samplerate; - std::string s; + mpt::ustring s; if(bufferAttributes.NumBuffers > 2) { - s += mpt::String::Print("Buffer: %1%% (%2/%3)\r\n", (bufferAttributes.Latency > 0.0) ? Util::Round<int64>(currentLatency / bufferAttributes.Latency * 100.0) : 0, (currentUpdateInterval > 0.0) ? Util::Round<int64>(bufferAttributes.Latency / currentUpdateInterval) : 0, bufferAttributes.NumBuffers); + s += mpt::String::Print(MPT_USTRING("Buffer: %1%% (%2/%3)\r\n"), (bufferAttributes.Latency > 0.0) ? Util::Round<int64>(currentLatency / bufferAttributes.Latency * 100.0) : 0, (currentUpdateInterval > 0.0) ? Util::Round<int64>(bufferAttributes.Latency / currentUpdateInterval) : 0, bufferAttributes.NumBuffers); } else { - s += mpt::String::Print("Buffer: %1%%\r\n", (bufferAttributes.Latency > 0.0) ? Util::Round<int64>(currentLatency / bufferAttributes.Latency * 100.0) : 0); + s += mpt::String::Print(MPT_USTRING("Buffer: %1%%\r\n"), (bufferAttributes.Latency > 0.0) ? Util::Round<int64>(currentLatency / bufferAttributes.Latency * 100.0) : 0); } - s += mpt::String::Print("Latency: %1 ms (current: %2 ms, %3 frames)\r\n", mpt::Format("%4.1f").ToString(bufferAttributes.Latency * 1000.0), mpt::Format("%4.1f").ToString(currentLatency * 1000.0), Util::Round<int64>(currentLatency * samplerate)); - s += mpt::String::Print("Period: %1 ms (current: %2 ms, %3 frames)\r\n", mpt::Format("%4.1f").ToString(bufferAttributes.UpdateInterval * 1000.0), mpt::Format("%4.1f").ToString(currentUpdateInterval * 1000.0), Util::Round<int64>(currentUpdateInterval * samplerate)); + s += mpt::String::Print(MPT_USTRING("Latency: %1 ms (current: %2 ms, %3 frames)\r\n"), mpt::ufmt::f("%4.1f", bufferAttributes.Latency * 1000.0), mpt::ufmt::f("%4.1f", currentLatency * 1000.0), Util::Round<int64>(currentLatency * samplerate)); + s += mpt::String::Print(MPT_USTRING("Period: %1 ms (current: %2 ms, %3 frames)\r\n"), mpt::ufmt::f("%4.1f", bufferAttributes.UpdateInterval * 1000.0), mpt::ufmt::f("%4.1f", currentUpdateInterval * 1000.0), Util::Round<int64>(currentUpdateInterval * samplerate)); s += pMainFrm->gpSoundDevice->GetStatistics(); - m_EditStatistics.SetWindowText(s.c_str()); + m_EditStatistics.SetWindowText(mpt::ToCString(s)); } else { if(theApp.GetSoundDevicesManager()->IsDeviceUnavailable(m_CurrentDeviceInfo.GetIdentifier())) Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2015-01-31 11:02:10 UTC (rev 4740) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2015-01-31 13:03:40 UTC (rev 4741) @@ -268,7 +268,7 @@ template<> inline SampleFormat FromSettingValue(const SettingValue &val) { return SampleFormatEnum(val.as<int32>()); } template<> inline SettingValue ToSettingValue(const SoundDevice::ChannelMapping &val) { return SettingValue(val.ToString(), "ChannelMapping"); } -template<> inline SoundDevice::ChannelMapping FromSettingValue(const SettingValue &val) { ASSERT(val.GetTypeTag() == "ChannelMapping"); return SoundDevice::ChannelMapping::FromString(val.as<std::string>()); } +template<> inline SoundDevice::ChannelMapping FromSettingValue(const SettingValue &val) { ASSERT(val.GetTypeTag() == "ChannelMapping"); return SoundDevice::ChannelMapping::FromString(val.as<mpt::ustring>()); } template<> inline SettingValue ToSettingValue(const ResamplingMode &val) { return SettingValue(int32(val)); } template<> inline ResamplingMode FromSettingValue(const SettingValue &val) { return ResamplingMode(val.as<int32>()); } Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-01-31 11:02:10 UTC (rev 4740) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-01-31 13:03:40 UTC (rev 4741) @@ -121,17 +121,17 @@ } -std::string ChannelMapping::ToString() const -//------------------------------------------ +mpt::ustring ChannelMapping::ToString() const +//------------------------------------------- { - return mpt::String::Combine<int32>(ChannelToDeviceChannel); + return mpt::ToUnicode(mpt::CharsetUTF8, mpt::String::Combine<int32>(ChannelToDeviceChannel)); } -ChannelMapping ChannelMapping::FromString(const std::string &str) -//--------------------------------------------------------------- +ChannelMapping ChannelMapping::FromString(const mpt::ustring &str) +//---------------------------------------------------------------- { - return SoundDevice::ChannelMapping(mpt::String::Split<int32>(str)); + return SoundDevice::ChannelMapping(mpt::String::Split<int32>(mpt::ToCharset(mpt::CharsetUTF8, str))); } @@ -371,8 +371,8 @@ } -void Base::AudioSendMessage(const std::string &str) -//------------------------------------------------- +void Base::AudioSendMessage(const mpt::ustring &str) +//-------------------------------------------------- { MPT_TRACE(); if(m_MessageReceiver) Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2015-01-31 11:02:10 UTC (rev 4740) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2015-01-31 13:03:40 UTC (rev 4741) @@ -43,7 +43,7 @@ //==================== { public: - virtual void AudioMessage(const std::string &str) = 0; + virtual void AudioMessage(const mpt::ustring &str) = 0; }; @@ -283,9 +283,9 @@ return ChannelToDeviceChannel[channel]; } - std::string ToString() const; + mpt::ustring ToString() const; - static SoundDevice::ChannelMapping FromString(const std::string &str); + static SoundDevice::ChannelMapping FromString(const mpt::ustring &str); }; @@ -507,7 +507,7 @@ virtual int64 GetStreamPositionFrames() const = 0; - virtual std::string GetStatistics() const = 0; + virtual mpt::ustring GetStatistics() const = 0; virtual bool OpenDriverSettings() = 0; @@ -574,7 +574,7 @@ void RequestReset() { m_RequestFlags.fetch_or(RequestFlagReset); } void RequestRestart() { m_RequestFlags.fetch_or(RequestFlagRestart); } - void AudioSendMessage(const std::string &str); + void AudioSendMessage(const mpt::ustring &str); protected: @@ -640,7 +640,7 @@ int64 GetStreamPositionFrames() const; - virtual std::string GetStatistics() const { return std::string(); } + virtual mpt::ustring GetStatistics() const { return mpt::ustring(); } virtual bool OpenDriverSettings() { return false; }; Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-01-31 11:02:10 UTC (rev 4740) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-01-31 13:03:40 UTC (rev 4741) @@ -1174,24 +1174,24 @@ } -static std::string AsioFeaturesToString(FlagSet<AsioFeatures> features) -//--------------------------------------------------------------------- +static mpt::ustring AsioFeaturesToString(FlagSet<AsioFeatures> features) +//---------------------------------------------------------------------- { - std::string result; + mpt::ustring result; bool first = true; - if(features[AsioFeatureResetRequest]) { if(!first) { result += ","; } first = false; result += "reset"; } - if(features[AsioFeatureResyncRequest]) { if(!first) { result += ","; } first = false; result += "resync"; } - if(features[AsioFeatureLatenciesChanged]) { if(!first) { result += ","; } first = false; result += "latency"; } - if(features[AsioFeatureBufferSizeChange]) { if(!first) { result += ","; } first = false; result += "buffer"; } - if(features[AsioFeatureOverload]) { if(!first) { result += ","; } first = false; result += "load"; } - if(features[AsioFeatureNoDirectProcess]) { if(!first) { result += ","; } first = false; result += "nodirect"; } - if(features[AsioFeatureSampleRateChange]) { if(!first) { result += ","; } first = false; result += "srate"; } + if(features[AsioFeatureResetRequest]) { if(!first) { result += MPT_USTRING(","); } first = false; result += MPT_USTRING("reset"); } + if(features[AsioFeatureResyncRequest]) { if(!first) { result += MPT_USTRING(","); } first = false; result += MPT_USTRING("resync"); } + if(features[AsioFeatureLatenciesChanged]) { if(!first) { result += MPT_USTRING(","); } first = false; result += MPT_USTRING("latency"); } + if(features[AsioFeatureBufferSizeChange]) { if(!first) { result += MPT_USTRING(","); } first = false; result += MPT_USTRING("buffer"); } + if(features[AsioFeatureOverload]) { if(!first) { result += MPT_USTRING(","); } first = false; result += MPT_USTRING("load"); } + if(features[AsioFeatureNoDirectProcess]) { if(!first) { result += MPT_USTRING(","); } first = false; result += MPT_USTRING("nodirect"); } + if(features[AsioFeatureSampleRateChange]) { if(!first) { result += MPT_USTRING(","); } first = false; result += MPT_USTRING("srate"); } return result; } -std::string CASIODevice::GetStatistics() const -//-------------------------------------------- +mpt::ustring CASIODevice::GetStatistics() const +//--------------------------------------------- { MPT_TRACE(); const FlagSet<AsioFeatures> unsupported(AsioFeatureNoDirectProcess | AsioFeatureOverload | AsioFeatureBufferSizeChange | AsioFeatureSampleRateChange); @@ -1199,15 +1199,15 @@ unsupportedFeatues &= unsupported; if(unsupportedFeatues.any()) { - return mpt::String::Print("WARNING: unsupported features: %1", AsioFeaturesToString(unsupportedFeatues)); + return mpt::String::Print(MPT_USTRING("WARNING: unsupported features: %1"), AsioFeaturesToString(unsupportedFeatues)); } else if(m_UsedFeatures.any()) { - return mpt::String::Print("OK, features used: %1", AsioFeaturesToString(m_UsedFeatures)); + return mpt::String::Print(MPT_USTRING("OK, features used: %1"), AsioFeaturesToString(m_UsedFeatures)); } else if(m_QueriedFeatures.any()) { - return mpt::String::Print("OK, features queried: %1", AsioFeaturesToString(m_QueriedFeatures)); + return mpt::String::Print(MPT_USTRING("OK, features queried: %1"), AsioFeaturesToString(m_QueriedFeatures)); } - return std::string("OK."); + return MPT_USTRING("OK."); } @@ -1346,7 +1346,7 @@ //----------------------------------------------------------- { MPT_TRACE(); - AudioSendMessage(str); + AudioSendMessage(mpt::ToUnicode(mpt::CharsetLocale, str)); Log("%s", str.c_str()); } Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2015-01-31 11:02:10 UTC (rev 4740) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2015-01-31 13:03:40 UTC (rev 4741) @@ -117,7 +117,7 @@ bool OpenDriverSettings(); - std::string GetStatistics() const; + mpt::ustring GetStatistics() const; public: static std::vector<SoundDevice::Info> EnumerateDevices(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-01-31 15:58:48
|
Revision: 4742 http://sourceforge.net/p/modplug/code/4742 Author: manxorist Date: 2015-01-31 15:58:28 +0000 (Sat, 31 Jan 2015) Log Message: ----------- [Ref] Convert mpt::String::Split and mpt::String::Combine to mpt::ustring. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/sounddev/SoundDevice.cpp Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2015-01-31 13:03:40 UTC (rev 4741) +++ trunk/OpenMPT/common/misc_util.h 2015-01-31 15:58:28 UTC (rev 4742) @@ -125,17 +125,17 @@ // Combine a vector of values into a string, separated with the given separator. // No escaping is performed. template<typename T> -std::string Combine(const std::vector<T> &vals, const std::string &sep=",") -//------------------------------------------------------------------------- +mpt::ustring Combine(const std::vector<T> &vals, const mpt::ustring &sep=MPT_USTRING(",")) +//---------------------------------------------------------------------------------------- { - std::string str; + mpt::ustring str; for(std::size_t i = 0; i < vals.size(); ++i) { if(i > 0) { str += sep; } - str += mpt::ToString(vals[i]); + str += mpt::ToUString(vals[i]); } return str; } @@ -144,8 +144,8 @@ // An empty string results in an empty vector. // Leading or trailing separators result in a default-constructed element being inserted before or after the other elements. template<typename T> -std::vector<T> Split(const std::string &str, const std::string &sep=",") -//---------------------------------------------------------------------- +std::vector<T> Split(const mpt::ustring &str, const mpt::ustring &sep=MPT_USTRING(",")) +//------------------------------------------------------------------------------------- { std::vector<T> vals; std::size_t pos = 0; Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-01-31 13:03:40 UTC (rev 4741) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-01-31 15:58:28 UTC (rev 4742) @@ -124,14 +124,14 @@ mpt::ustring ChannelMapping::ToString() const //------------------------------------------- { - return mpt::ToUnicode(mpt::CharsetUTF8, mpt::String::Combine<int32>(ChannelToDeviceChannel)); + return mpt::String::Combine<int32>(ChannelToDeviceChannel); } ChannelMapping ChannelMapping::FromString(const mpt::ustring &str) //---------------------------------------------------------------- { - return SoundDevice::ChannelMapping(mpt::String::Split<int32>(mpt::ToCharset(mpt::CharsetUTF8, str))); + return SoundDevice::ChannelMapping(mpt::String::Split<int32>(str)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-02 13:41:01
|
Revision: 4743 http://sourceforge.net/p/modplug/code/4743 Author: manxorist Date: 2015-02-02 13:40:54 +0000 (Mon, 02 Feb 2015) Log Message: ----------- [Ref] Move date and time handling code from all over the place into namespace mpt::Date in misc_util.h. [Ref] Convert related code to mpt::ustring. Modified Paths: -------------- trunk/OpenMPT/common/Logging.cpp trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/common/Logging.cpp =================================================================== --- trunk/OpenMPT/common/Logging.cpp 2015-01-31 15:58:28 UTC (rev 4742) +++ trunk/OpenMPT/common/Logging.cpp 2015-02-02 13:40:54 UTC (rev 4743) @@ -36,68 +36,9 @@ static const std::size_t LOGBUF_SIZE = 1024; -#if defined(MODPLUG_TRACKER) - -static uint64 GetTime100ns() -//-------------------------- -{ - FILETIME filetime; - GetSystemTimeAsFileTime(&filetime); - return ((uint64)filetime.dwHighDateTime << 32 | filetime.dwLowDateTime); -} - - -static std::string TimeAsString(uint64 time100ns) -//------------------------------------------------- -{ - - FILETIME filetime; - SYSTEMTIME systime; - filetime.dwHighDateTime = (DWORD)(((uint64)time100ns) >> 32); - filetime.dwLowDateTime = (DWORD)((uint64)time100ns); - FileTimeToSystemTime(&filetime, &systime); - - std::string result; - TCHAR buf[LOGBUF_SIZE]; - - GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, &systime, "yyyy-MM-dd ", buf, LOGBUF_SIZE); - result.append(buf); - - GetTimeFormat(LOCALE_SYSTEM_DEFAULT, TIME_FORCE24HOURFORMAT, &systime, "HH:mm:ss.", buf, LOGBUF_SIZE); - result.append(buf); - - sprintf(buf, "%03u", (unsigned)systime.wMilliseconds); - result.append(buf); - - return result; -} - -#endif // MODPLUG_TRACKER - - #ifndef NO_LOGGING -#if defined(MODPLUG_TRACKER) - - -static std::string TimeDiffAsString(uint64 ms) -//-------------------------------------------- -{ - return mpt::fmt::dec<6>(ms); -} - - -static std::wstring TimeDiffAsStringW(uint64 ms) -//---------------------------------------------- -{ - return mpt::wfmt::dec<6>(ms); -} - - -#endif // MODPLUG_TRACKER - - static noinline void DoLog(const mpt::log::Context &context, mpt::ustring message) //-------------------------------------------------------------------------------- { @@ -105,7 +46,7 @@ message = mpt::String::RTrim(message, MPT_USTRING("\r\n")); #if defined(MODPLUG_TRACKER) static uint64_t s_lastlogtime = 0; - uint64 cur = GetTime100ns(); + uint64 cur = mpt::Date::ANSI::Now(); uint64 diff = cur/10000 - s_lastlogtime; s_lastlogtime = cur/10000; #ifdef LOG_TO_FILE @@ -117,13 +58,26 @@ } if(s_logfile) { - 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); + fprintf(s_logfile, mpt::ToCharset(mpt::CharsetUTF8, mpt::String::Print(MPT_USTRING("%1+%2 %3(%4): %5 [%6]\n" + , mpt::Date::ANSI::ToString(cur) + , mpt::ufmt::dec<6>(diff) + , mpt::ToUnicode(mpt::CharsetASCII, context.file) + , context.line + , message + , mpt::ToUnicode(mpt::CharsetASCII, context.function) + ))).c_str()); fflush(s_logfile); } } #endif // LOG_TO_FILE { - OutputDebugStringW(mpt::String::PrintW(L"%1(%2): +%3 %4 [%5]\n", mpt::ToWide(mpt::CharsetASCII, context.file), context.line, TimeDiffAsStringW(diff), message, mpt::ToWide(mpt::CharsetASCII, context.function)).c_str()); + OutputDebugStringW(mpt::String::PrintW(L"%1(%2): +%3 %4 [%5]\n" + , mpt::ToWide(mpt::CharsetASCII, context.file) + , context.line + , mpt::wfmt::dec<6>(diff) + , message + , mpt::ToWide(mpt::CharsetASCII, context.function) + ).c_str()); } #else // !MODPLUG_TRACKER std::clog @@ -297,7 +251,7 @@ LARGE_INTEGER qpcNow; qpcNow.QuadPart = 0; QueryPerformanceCounter(&qpcNow); - uint64 ftNow = GetTime100ns(); + uint64 ftNow = mpt::Date::ANSI::Now(); // sort according to index in case of overflows std::stable_sort(Entries.begin(), Entries.end()); @@ -316,7 +270,7 @@ qpcValid = true; } - f << "Dump: " << TimeAsString(ftNow) << std::endl; + f << "Dump: " << mpt::ToCharset(mpt::CharsetUTF8, mpt::Date::ANSI::ToString(ftNow)) << std::endl; f << "Captured events: " << Entries.size() << std::endl; if(qpcValid && (Entries.size() > 0)) { @@ -334,7 +288,7 @@ 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) ) ) ); + time = mpt::ToCharset(mpt::CharsetUTF8, mpt::Date::ANSI::ToString( 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)); Modified: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp 2015-01-31 15:58:28 UTC (rev 4742) +++ trunk/OpenMPT/common/misc_util.cpp 2015-02-02 13:40:54 UTC (rev 4743) @@ -101,12 +101,65 @@ #endif -namespace Util +namespace mpt { +namespace Date +{ -time_t MakeGmTime(tm *timeUtc) -//---------------------------- +#if defined(MODPLUG_TRACKER) + +namespace ANSI { + +uint64 Now() +//---------- +{ + FILETIME filetime; + GetSystemTimeAsFileTime(&filetime); + return ((uint64)filetime.dwHighDateTime << 32 | filetime.dwLowDateTime); +} + +mpt::ustring ToString(uint64 time100ns) +//------------------------------------- +{ + static const std::size_t bufsize = 256; + + mpt::ustring result; + + FILETIME filetime; + SYSTEMTIME systime; + filetime.dwHighDateTime = (DWORD)(((uint64)time100ns) >> 32); + filetime.dwLowDateTime = (DWORD)((uint64)time100ns); + FileTimeToSystemTime(&filetime, &systime); + + WCHAR buf[bufsize]; + + GetDateFormatW(LOCALE_SYSTEM_DEFAULT, 0, &systime, L"yyyy-MM-dd", buf, bufsize); + result.append(mpt::ToUnicode(buf)); + + result.append(MPT_USTRING(" ")); + + GetTimeFormatW(LOCALE_SYSTEM_DEFAULT, TIME_FORCE24HOURFORMAT, &systime, L"HH:mm:ss", buf, bufsize); + result.append(mpt::ToUnicode(buf)); + + result.append(MPT_USTRING(".")); + + result.append(mpt::ufmt::dec0<3>((unsigned)systime.wMilliseconds)); + + return result; + +} + +} // namespace ANSI + +#endif // MODPLUG_TRACKER + +namespace Unix +{ + +time_t FromUTC(tm *timeUtc) +//------------------------- +{ #if MPT_COMPILER_MSVC return _mkgmtime(timeUtc); #else // !MPT_COMPILER_MSVC @@ -139,9 +192,64 @@ #endif // MPT_COMPILER_MSVC } -} // namespace Util +} // namespace Unix +mpt::ustring ToShortenedISO8601(tm date) +//-------------------------------------- +{ + // We assume date in UTC here. + // There are too many differences in supported format specifiers in strftime() + // and strftime does not support reduced precision ISO8601 at all. + // Just do the formatting ourselves. + mpt::ustring result; + mpt::ustring timezone = MPT_USTRING("Z"); + if(date.tm_year == 0) + { + return result; + } + result += mpt::ufmt::dec0<4>(date.tm_year + 1900); + if(date.tm_mon < 0 || date.tm_mon > 11) + { + return result; + } + result += MPT_USTRING("-") + mpt::ufmt::dec0<2>(date.tm_mon + 1); + if(date.tm_mday < 1 || date.tm_mday > 31) + { + return result; + } + result += MPT_USTRING("-") + mpt::ufmt::dec0<2>(date.tm_mday); + if(date.tm_hour == 0 && date.tm_min == 0 && date.tm_sec == 0) + { + return result; + } + if(date.tm_hour < 0 || date.tm_hour > 23) + { + return result; + } + if(date.tm_min < 0 || date.tm_min > 59) + { + return result; + } + result += MPT_USTRING("T"); + if(date.tm_isdst > 0) + { + timezone = MPT_USTRING("+01:00"); + } + result += mpt::ufmt::dec0<2>(date.tm_hour) + MPT_USTRING(":") + mpt::ufmt::dec0<2>(date.tm_min); + if(date.tm_sec < 0 || date.tm_sec > 61) + { + return result + timezone; + } + result += MPT_USTRING(":") + mpt::ufmt::dec0<2>(date.tm_sec); + result += timezone; + return result; +} +} // namespace Date +} // namespace mpt + + + #ifdef MODPLUG_TRACKER namespace Util Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2015-01-31 15:58:28 UTC (rev 4742) +++ trunk/OpenMPT/common/misc_util.h 2015-02-02 13:40:54 UTC (rev 4743) @@ -374,11 +374,44 @@ } + +namespace mpt +{ +namespace Date +{ + +#if defined(MODPLUG_TRACKER) + +namespace ANSI +{ +// uint64 counts 100ns since 1601-01-01T00:00Z + +uint64 Now(); + +mpt::ustring ToString(uint64 time100ns); // i.e. 2015-01-15 18:32:01.718 + +} // namespacee ANSI + +#endif // MODPLUG_TRACKER + +namespace Unix +{ +// time_t counts 1s since 1970-01-01T00:00Z + +time_t FromUTC(tm *timeUtc); + +} // namespace Unix + +mpt::ustring ToShortenedISO8601(tm date); // i.e. 2015-01-15T18:32:01Z + +} // namespace Date +} // namespace mpt + + + namespace Util { - time_t MakeGmTime(tm *timeUtc); - // Minimum of 3 values template <class T> inline const T& Min(const T& a, const T& b, const T& c) {return std::min(std::min(a, b), c);} Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2015-01-31 15:58:28 UTC (rev 4742) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2015-02-02 13:40:54 UTC (rev 4743) @@ -828,7 +828,7 @@ if ( m_sndFile->GetFileHistory().empty() ) { return std::string(); } - return mod_string_to_utf8( m_sndFile->GetFileHistory()[m_sndFile->GetFileHistory().size() - 1].AsISO8601() ); + return mpt::ToCharset(mpt::CharsetUTF8, m_sndFile->GetFileHistory()[m_sndFile->GetFileHistory().size() - 1].AsISO8601() ); } else if ( key == std::string("message") ) { std::string retval = m_sndFile->songMessage.GetFormatted( SongMessage::leLF ); if ( retval.empty() ) { Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-01-31 15:58:28 UTC (rev 4742) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-02-02 13:40:54 UTC (rev 4743) @@ -340,7 +340,7 @@ lastUpdate.tm_year -= 1900; lastUpdate.tm_mon--; } - time_t outTime = Util::MakeGmTime(&lastUpdate); + time_t outTime = mpt::Date::Unix::FromUTC(&lastUpdate); if(outTime < 0) outTime = 0; CUpdateCheck::SetUpdateSettings ( Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2015-01-31 15:58:28 UTC (rev 4742) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2015-02-02 13:40:54 UTC (rev 4743) @@ -492,8 +492,8 @@ // -! NEW_FEATURE#0027 -std::string FileHistory::AsISO8601() const -//---------------------------------------- +mpt::ustring FileHistory::AsISO8601() const +//----------------------------------------- { tm date = loadDate; if(openTime > 0) @@ -501,7 +501,7 @@ // Calculate the date when editing finished. double openSeconds = (double)openTime / (double)HISTORY_TIMER_PRECISION; tm tmpLoadDate = loadDate; - time_t loadDateSinceEpoch = Util::MakeGmTime(&tmpLoadDate); + time_t loadDateSinceEpoch = mpt::Date::Unix::FromUTC(&tmpLoadDate); double timeScaleFactor = difftime(2, 1); time_t saveDateSinceEpoch = loadDateSinceEpoch + Util::Round<time_t>(openSeconds / timeScaleFactor); const tm * tmpSaveDate = gmtime(&saveDateSinceEpoch); @@ -512,51 +512,7 @@ } // We assume date in UTC here. // This is not 100% correct because FileHistory does not contain complete timezone information. - // There are too many differences in supported format specifiers in strftime() - // and strftime does not support reduced precision ISO8601 at all. - // Just do the formatting ourselves. - std::string result; - std::string timezone = std::string("Z"); - if(date.tm_year == 0) - { - return result; - } - result += mpt::fmt::dec0<4>(date.tm_year + 1900); - if(date.tm_mon < 0 || date.tm_mon > 11) - { - return result; - } - result += std::string("-") + mpt::fmt::dec0<2>(date.tm_mon + 1); - if(date.tm_mday < 1 || date.tm_mday > 31) - { - return result; - } - result += std::string("-") + mpt::fmt::dec0<2>(date.tm_mday); - if(date.tm_hour == 0 && date.tm_min == 0 && date.tm_sec == 0) - { - return result; - } - if(date.tm_hour < 0 || date.tm_hour > 23) - { - return result; - } - if(date.tm_min < 0 || date.tm_min > 59) - { - return result; - } - result += std::string("T"); - if(date.tm_isdst > 0) - { - timezone = std::string("+01:00"); - } - result += mpt::fmt::dec0<2>(date.tm_hour) + std::string(":") + mpt::fmt::dec0<2>(date.tm_min); - if(date.tm_sec < 0 || date.tm_sec > 61) - { - return result + timezone; - } - result += std::string(":") + mpt::fmt::dec0<2>(date.tm_sec); - result += timezone; - return result; + return mpt::Date::ToShortenedISO8601(date); } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2015-01-31 15:58:28 UTC (rev 4742) +++ trunk/OpenMPT/soundlib/Sndfile.h 2015-02-02 13:40:54 UTC (rev 4743) @@ -243,7 +243,7 @@ // Time the file was open in the editor, in 1/18.2th seconds (frequency of a standard DOS timer, to keep compatibility with Impulse Tracker easy). uint32 openTime; // Return the date as a (possibly truncated if not enough precision is available) ISO 8601 formatted date. - std::string AsISO8601() const; + mpt::ustring AsISO8601() const; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-08 14:06:48
|
Revision: 4744 http://sourceforge.net/p/modplug/code/4744 Author: manxorist Date: 2015-02-08 14:06:34 +0000 (Sun, 08 Feb 2015) Log Message: ----------- [Ref] Replace all usage of <iterator> and std::back_inserter with simpler constructs. Modified Paths: -------------- trunk/OpenMPT/common/mptString.cpp trunk/OpenMPT/common/serialization_utils.cpp trunk/OpenMPT/mptrack/Settings.cpp trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDeviceThread.cpp trunk/OpenMPT/soundlib/Load_ams.cpp Modified: trunk/OpenMPT/common/mptString.cpp =================================================================== --- trunk/OpenMPT/common/mptString.cpp 2015-02-02 13:40:54 UTC (rev 4743) +++ trunk/OpenMPT/common/mptString.cpp 2015-02-08 14:06:34 UTC (rev 4744) @@ -17,7 +17,6 @@ #include <cstdlib> #endif #include <iomanip> -#include <iterator> #include <locale> #include <sstream> #include <string> @@ -770,9 +769,7 @@ std::string out; if(charset == CharsetCP437AMS ) out = String::To8bit(src, CharsetTableCP437AMS ); if(charset == CharsetCP437AMS2) out = String::To8bit(src, CharsetTableCP437AMS2); - Tdststring result; - std::copy(out.begin(), out.end(), std::back_inserter(result)); - return result; + return Tdststring(out.begin(), out.end()); } #if defined(MPT_WITH_CHARSET_LOCALE) #if defined(MPT_LOCALE_ASSUME_CHARSET) @@ -845,9 +842,7 @@ case CharsetCP437AMS2: out = String::To8bit(src, CharsetTableCP437AMS2); break; case CharsetWindows1252: out = String::To8bit(src, CharsetTableWindows1252); break; } - Tdststring result; - std::copy(out.begin(), out.end(), std::back_inserter(result)); - return result; + return Tdststring(out.begin(), out.end()); #endif } @@ -859,8 +854,7 @@ STATIC_ASSERT(sizeof(typename Tsrcstring::value_type) == sizeof(char)); if(charset == CharsetCP437AMS || charset == CharsetCP437AMS2) { - std::string in; - std::copy(src.begin(), src.end(), std::back_inserter(in)); + std::string in(src.begin(), src.end()); std::wstring out; if(charset == CharsetCP437AMS ) out = String::From8bit(in, CharsetTableCP437AMS ); if(charset == CharsetCP437AMS2) out = String::From8bit(in, CharsetTableCP437AMS2); @@ -926,8 +920,7 @@ conv = iconv_t(); return &wide_string[0]; #else - std::string in; - std::copy(src.begin(), src.end(), std::back_inserter(in)); + std::string in(src.begin(), src.end()); std::wstring out; switch(charset) { Modified: trunk/OpenMPT/common/serialization_utils.cpp =================================================================== --- trunk/OpenMPT/common/serialization_utils.cpp 2015-02-02 13:40:54 UTC (rev 4743) +++ trunk/OpenMPT/common/serialization_utils.cpp 2015-02-08 14:06:34 UTC (rev 4744) @@ -13,7 +13,6 @@ #include "serialization_utils.h" #include <istream> -#include <iterator> // for back_inserter #include <ostream> #include <sstream> Modified: trunk/OpenMPT/mptrack/Settings.cpp =================================================================== --- trunk/OpenMPT/mptrack/Settings.cpp 2015-02-02 13:40:54 UTC (rev 4743) +++ trunk/OpenMPT/mptrack/Settings.cpp 2015-02-08 14:06:34 UTC (rev 4744) @@ -20,7 +20,6 @@ #include <algorithm> #include "../common/mptFileIO.h" -#include <iterator> OPENMPT_NAMESPACE_BEGIN @@ -402,7 +401,7 @@ char buf[4096]; s.read(buf, 4096); std::streamsize count = s.gcount(); - std::copy(buf, buf + count, std::back_inserter(result)); + result.insert(result.end(), buf, buf + count); } return result; } Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-02 13:40:54 UTC (rev 4743) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-08 14:06:34 UTC (rev 4744) @@ -22,7 +22,6 @@ #include "SoundDeviceWaveout.h" #include <algorithm> -#include <iterator> #include <mmreg.h> @@ -484,25 +483,25 @@ if(enabledTypes[SoundDevice::TypeWAVEOUT]) { const std::vector<SoundDevice::Info> infos = CWaveDevice::EnumerateDevices(); - std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); } #ifndef NO_ASIO if(enabledTypes[SoundDevice::TypeASIO]) { const std::vector<SoundDevice::Info> infos = CASIODevice::EnumerateDevices(); - std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); } #endif // NO_ASIO #ifndef NO_PORTAUDIO if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_WASAPI]) { const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_WASAPI); - std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); } if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_WDMKS]) { const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_WDMKS); - std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); } #endif // NO_PORTAUDIO @@ -511,7 +510,7 @@ if(enabledTypes[SoundDevice::TypeDSOUND]) { const std::vector<SoundDevice::Info> infos = CDSoundDevice::EnumerateDevices(); - std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); } #endif // NO_DSOUND @@ -520,17 +519,17 @@ if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_WMME]) { const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_WMME); - std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); } if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_ASIO]) { const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_ASIO); - std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); } if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_DS]) { const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_DS); - std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); } #endif // NO_PORTAUDIO Modified: trunk/OpenMPT/sounddev/SoundDeviceThread.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceThread.cpp 2015-02-02 13:40:54 UTC (rev 4743) +++ trunk/OpenMPT/sounddev/SoundDeviceThread.cpp 2015-02-08 14:06:34 UTC (rev 4744) @@ -17,7 +17,6 @@ #include "../common/misc_util.h" #include <algorithm> -#include <iterator> #include <mmsystem.h> Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2015-02-02 13:40:54 UTC (rev 4743) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2015-02-08 14:06:34 UTC (rev 4744) @@ -18,9 +18,7 @@ #include "stdafx.h" #include "Loaders.h" -#include <iterator> - OPENMPT_NAMESPACE_BEGIN @@ -467,8 +465,7 @@ } } - std::string str; - std::copy(textOut.begin(), textOut.end(), std::back_inserter(str)); + std::string str(textOut.begin(), textOut.end()); str = mpt::ToCharset(mpt::CharsetCP437, mpt::CharsetCP437AMS, str); // Packed text doesn't include any line breaks! @@ -936,8 +933,7 @@ textOut[writeLen++] = c; } } - std::string str; - std::copy(textOut.begin(), textOut.begin() + descriptionHeader.unpackedLen, std::back_inserter(str)); + std::string str(textOut.begin(), textOut.begin() + descriptionHeader.unpackedLen); str = mpt::ToCharset(mpt::CharsetCP437, mpt::CharsetCP437AMS2, str); // Packed text doesn't include any line breaks! songMessage.ReadFixedLineLength(str.c_str(), str.length(), 74, 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-09 17:56:37
|
Revision: 4745 http://sourceforge.net/p/modplug/code/4745 Author: manxorist Date: 2015-02-09 17:56:30 +0000 (Mon, 09 Feb 2015) Log Message: ----------- [Ref] sounddev: Split class SoundDevice::Manager into separate SoundDeviceManager.* files. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h Added Paths: ----------- trunk/OpenMPT/sounddev/SoundDeviceManager.cpp trunk/OpenMPT/sounddev/SoundDeviceManager.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2015-02-08 14:06:34 UTC (rev 4744) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2015-02-09 17:56:30 UTC (rev 4745) @@ -12,6 +12,7 @@ #include "mptrack.h" #include "MainFrm.h" #include "../sounddev/SoundDevice.h" +#include "../sounddev/SoundDeviceManager.h" #include "../soundlib/AudioReadTarget.h" #include "moddoc.h" #include "childfrm.h" Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2015-02-08 14:06:34 UTC (rev 4744) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2015-02-09 17:56:30 UTC (rev 4745) @@ -16,9 +16,10 @@ #include "mpdlgs.h" #include "moptions.h" #include "moddoc.h" -#include "../sounddev/SoundDevice.h" #include "mpdlgs.h" #include "../common/StringFixer.h" +#include "../sounddev/SoundDevice.h" +#include "../sounddev/SoundDeviceManager.h" OPENMPT_NAMESPACE_BEGIN Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2015-02-08 14:06:34 UTC (rev 4744) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2015-02-09 17:56:30 UTC (rev 4745) @@ -32,6 +32,7 @@ #include "PNG.h" #include "../common/ComponentManager.h" #include "WelcomeDialog.h" +#include "../sounddev/SoundDeviceManager.h" // rewbs.memLeak #define _CRTDBG_MAP_ALLOC Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-02-08 14:06:34 UTC (rev 4744) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-02-09 17:56:30 UTC (rev 4745) @@ -14,6 +14,7 @@ #include "Moddoc.h" #include "Mainfrm.h" #include "../sounddev/SoundDevice.h" +#include "../sounddev/SoundDeviceManager.h" #include "../common/version.h" #include "UpdateCheck.h" #include "Mpdlgs.h" Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2015-02-08 14:06:34 UTC (rev 4744) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2015-02-09 17:56:30 UTC (rev 4745) @@ -768,6 +768,10 @@ > </File> <File + RelativePath="..\sounddev\SoundDeviceManager.cpp" + > + </File> + <File RelativePath="..\sounddev\SoundDeviceASIO.cpp" > </File> @@ -1510,6 +1514,10 @@ > </File> <File + RelativePath="..\sounddev\SoundDeviceManager.h" + > + </File> + <File RelativePath="..\sounddev\SoundDeviceASIO.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2015-02-08 14:06:34 UTC (rev 4744) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2015-02-09 17:56:30 UTC (rev 4745) @@ -740,6 +740,7 @@ <ClCompile Include="..\sounddev\SoundDevice.cpp" /> <ClCompile Include="..\sounddev\SoundDeviceASIO.cpp" /> <ClCompile Include="..\sounddev\SoundDeviceDirectSound.cpp" /> + <ClCompile Include="..\sounddev\SoundDeviceManager.cpp" /> <ClCompile Include="..\sounddev\SoundDevicePortAudio.cpp" /> <ClCompile Include="..\sounddev\SoundDeviceThread.cpp" /> <ClCompile Include="..\sounddev\SoundDeviceWaveout.cpp" /> @@ -967,6 +968,7 @@ <ClInclude Include="..\sounddev\SoundDevice.h" /> <ClInclude Include="..\sounddev\SoundDeviceASIO.h" /> <ClInclude Include="..\sounddev\SoundDeviceDirectSound.h" /> + <ClInclude Include="..\sounddev\SoundDeviceManager.h" /> <ClInclude Include="..\sounddev\SoundDevicePortAudio.h" /> <ClInclude Include="..\sounddev\SoundDeviceThread.h" /> <ClInclude Include="..\sounddev\SoundDeviceWaveout.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2015-02-08 14:06:34 UTC (rev 4744) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2015-02-09 17:56:30 UTC (rev 4745) @@ -544,6 +544,9 @@ <ClCompile Include="PatternFont.cpp"> <Filter>Source Files\mptrack</Filter> </ClCompile> + <ClCompile Include="..\sounddev\SoundDeviceManager.cpp"> + <Filter>Source Files\sounddev</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\soundlib\Loaders.h"> @@ -1065,6 +1068,9 @@ <ClInclude Include="PatternFont.h"> <Filter>Header Files\mptrack</Filter> </ClInclude> + <ClInclude Include="..\sounddev\SoundDeviceManager.h"> + <Filter>Header Files\sounddev</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-08 14:06:34 UTC (rev 4744) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-09 17:56:30 UTC (rev 4745) @@ -16,13 +16,6 @@ #include "../common/misc_util.h" #include "../common/StringFixer.h" -#include "SoundDeviceASIO.h" -#include "SoundDeviceDirectSound.h" -#include "SoundDevicePortAudio.h" -#include "SoundDeviceWaveout.h" - -#include <algorithm> - #include <mmreg.h> @@ -459,337 +452,6 @@ } -/////////////////////////////////////////////////////////////////////////////////////// -// -// Global Functions -// - - -void Manager::ReEnumerate(SoundDevice::TypesSet enabledTypes) -//----------------------------------------------------------- -{ - m_SoundDevices.clear(); - m_DeviceUnavailable.clear(); - m_DeviceCaps.clear(); - m_DeviceDynamicCaps.clear(); - -#ifndef NO_PORTAUDIO - if(IsComponentAvailable(m_PortAudio)) - { - m_PortAudio->ReInit(); - } -#endif // NO_PORTAUDIO - - if(enabledTypes[SoundDevice::TypeWAVEOUT]) - { - const std::vector<SoundDevice::Info> infos = CWaveDevice::EnumerateDevices(); - m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); - } -#ifndef NO_ASIO - if(enabledTypes[SoundDevice::TypeASIO]) - { - const std::vector<SoundDevice::Info> infos = CASIODevice::EnumerateDevices(); - m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); - } -#endif // NO_ASIO -#ifndef NO_PORTAUDIO - if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_WASAPI]) - { - const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_WASAPI); - m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); - } - if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_WDMKS]) - { - const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_WDMKS); - m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); - } -#endif // NO_PORTAUDIO - - // kind of deprecated by now -#ifndef NO_DSOUND - if(enabledTypes[SoundDevice::TypeDSOUND]) - { - const std::vector<SoundDevice::Info> infos = CDSoundDevice::EnumerateDevices(); - m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); - } -#endif // NO_DSOUND - - // duplicate devices, only used if [Sound Settings]MorePortaudio=1 -#ifndef NO_PORTAUDIO - if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_WMME]) - { - const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_WMME); - m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); - } - if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_ASIO]) - { - const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_ASIO); - m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); - } - if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_DS]) - { - const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_DS); - m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); - } -#endif // NO_PORTAUDIO - -} - - -SoundDevice::Info Manager::FindDeviceInfo(SoundDevice::ID id) const -//----------------------------------------------------------------- -{ - for(std::vector<SoundDevice::Info>::const_iterator it = begin(); it != end(); ++it) - { - if(it->id == id) - { - return *it; - } - } - return SoundDevice::Info(); -} - - -SoundDevice::Info Manager::FindDeviceInfo(SoundDevice::Identifier identifier) const -//--------------------------------------------------------------------------------- -{ - if(m_SoundDevices.empty()) - { - return SoundDevice::Info(); - } - if(identifier.empty()) - { - return m_SoundDevices[0]; - } - for(std::vector<SoundDevice::Info>::const_iterator it = begin(); it != end(); ++it) - { - if(it->GetIdentifier() == identifier) - { - return *it; - } - } - return SoundDevice::Info(); -} - - -SoundDevice::Type ParseType(const SoundDevice::Identifier &identifier) -//-------------------------------------------------------------------- -{ - for(int i = 0; i < TypeNUM_DEVTYPES; ++i) - { - const mpt::ustring api = SoundDevice::TypeToString(static_cast<SoundDevice::Type>(i)); - if(identifier.find(api) == 0) - { - return static_cast<SoundDevice::Type>(i); - } - } - return TypeINVALID; -} - - -SoundDevice::Info Manager::FindDeviceInfoBestMatch(SoundDevice::Identifier identifier, bool preferSameType) -//--------------------------------------------------------------------------------------------------------- -{ - if(m_SoundDevices.empty()) - { - return SoundDevice::Info(); - } - if(identifier.empty()) - { - return *begin(); - } - for(std::vector<SoundDevice::Info>::const_iterator it = begin(); it != end(); ++it) - { - if((it->GetIdentifier() == identifier) && !IsDeviceUnavailable(it->GetIdentifier())) - { // exact match - return *it; - } - } - const SoundDevice::Type type = ParseType(identifier); - switch(type) - { - case TypePORTAUDIO_WASAPI: - // WASAPI devices might change names if a different connector jack is used. - // In order to avoid defaulting to wave mapper in that case, - // just find the first WASAPI device. - for(std::vector<SoundDevice::Info>::const_iterator it = begin(); it != end(); ++it) - { - if((it->id.GetType() == TypePORTAUDIO_WASAPI) && !IsDeviceUnavailable(it->GetIdentifier())) - { - return *it; - } - } - // default to first device - return *begin(); - break; - case TypeWAVEOUT: - case TypeDSOUND: - case TypePORTAUDIO_WMME: - case TypePORTAUDIO_DS: - case TypeASIO: - case TypePORTAUDIO_WDMKS: - case TypePORTAUDIO_ASIO: - if(preferSameType) - { - for(std::vector<SoundDevice::Info>::const_iterator it = begin(); it != end(); ++it) - { - if((it->id.GetType() == type) && !IsDeviceUnavailable(it->GetIdentifier())) - { - return *it; - } - } - } else - { - // default to first device - return *begin(); - } - break; - } - // invalid - return SoundDevice::Info(); -} - - -bool Manager::OpenDriverSettings(SoundDevice::Identifier identifier, SoundDevice::IMessageReceiver *messageReceiver, SoundDevice::IBase *currentSoundDevice) -//---------------------------------------------------------------------------------------------------------------------------------------------------------- -{ - bool result = false; - if(currentSoundDevice && FindDeviceInfo(identifier).IsValid() && (currentSoundDevice->GetDeviceInfo().GetIdentifier() == identifier)) - { - result = currentSoundDevice->OpenDriverSettings(); - } else - { - SoundDevice::IBase *dummy = CreateSoundDevice(identifier); - if(dummy) - { - dummy->SetMessageReceiver(messageReceiver); - result = dummy->OpenDriverSettings(); - } - delete dummy; - } - return result; -} - - -SoundDevice::Caps Manager::GetDeviceCaps(SoundDevice::Identifier identifier, SoundDevice::IBase *currentSoundDevice) -//------------------------------------------------------------------------------------------------------------------ -{ - if(m_DeviceCaps.find(identifier) == m_DeviceCaps.end()) - { - if(currentSoundDevice && FindDeviceInfo(identifier).IsValid() && (currentSoundDevice->GetDeviceInfo().GetIdentifier() == identifier)) - { - m_DeviceCaps[identifier] = currentSoundDevice->GetDeviceCaps(); - } else - { - SoundDevice::IBase *dummy = CreateSoundDevice(identifier); - if(dummy) - { - m_DeviceCaps[identifier] = dummy->GetDeviceCaps(); - } else - { - SetDeviceUnavailable(identifier); - } - delete dummy; - } - } - return m_DeviceCaps[identifier]; -} - - -SoundDevice::DynamicCaps Manager::GetDeviceDynamicCaps(SoundDevice::Identifier identifier, const std::vector<uint32> &baseSampleRates, SoundDevice::IMessageReceiver *messageReceiver, SoundDevice::IBase *currentSoundDevice, bool update) -//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -{ - if((m_DeviceDynamicCaps.find(identifier) == m_DeviceDynamicCaps.end()) || update) - { - if(currentSoundDevice && FindDeviceInfo(identifier).IsValid() && (currentSoundDevice->GetDeviceInfo().GetIdentifier() == identifier)) - { - m_DeviceDynamicCaps[identifier] = currentSoundDevice->GetDeviceDynamicCaps(baseSampleRates); - if(!currentSoundDevice->IsAvailable()) - { - SetDeviceUnavailable(identifier); - } - } else - { - SoundDevice::IBase *dummy = CreateSoundDevice(identifier); - if(dummy) - { - dummy->SetMessageReceiver(messageReceiver); - m_DeviceDynamicCaps[identifier] = dummy->GetDeviceDynamicCaps(baseSampleRates); - if(!dummy->IsAvailable()) - { - SetDeviceUnavailable(identifier); - } - } else - { - SetDeviceUnavailable(identifier); - } - delete dummy; - } - } - return m_DeviceDynamicCaps[identifier]; -} - - -SoundDevice::IBase * Manager::CreateSoundDevice(SoundDevice::Identifier identifier) -//--------------------------------------------------------------------------------- -{ - const SoundDevice::Info info = FindDeviceInfo(identifier); - if(!info.IsValid()) - { - return nullptr; - } - SoundDevice::IBase *result = nullptr; - switch(info.id.GetType()) - { - case TypeWAVEOUT: result = new CWaveDevice(info); break; -#ifndef NO_DSOUND - case TypeDSOUND: result = new CDSoundDevice(info); break; -#endif // NO_DSOUND -#ifndef NO_ASIO - case TypeASIO: result = new CASIODevice(info); break; -#endif // NO_ASIO -#ifndef NO_PORTAUDIO - case TypePORTAUDIO_WASAPI: - case TypePORTAUDIO_WDMKS: - case TypePORTAUDIO_WMME: - case TypePORTAUDIO_DS: - case TypePORTAUDIO_ASIO: - if(IsComponentAvailable(m_PortAudio)) - { - result = new CPortaudioDevice(info); - } - break; -#endif // NO_PORTAUDIO - } - if(!result) - { - return nullptr; - } - if(!result->Init()) - { - delete result; - result = nullptr; - return nullptr; - } - m_DeviceCaps[identifier] = result->GetDeviceCaps(); // update cached caps - return result; -} - - -Manager::Manager(SoundDevice::TypesSet enabledTypes) -//-------------------------------------------------- -{ - ReEnumerate(enabledTypes); -} - - -Manager::~Manager() -//----------------- -{ - return; -} - - } // namespace SoundDevice Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2015-02-08 14:06:34 UTC (rev 4744) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2015-02-09 17:56:30 UTC (rev 4745) @@ -15,7 +15,6 @@ #include "../common/misc_util.h" #include "../common/FlagSet.h" #include "../common/mptAtomic.h" -#include "../common/ComponentManager.h" #include "../soundlib/SampleFormat.h" #include <bitset> @@ -647,53 +646,6 @@ }; -class ComponentPortAudio; - - -//=========== -class Manager -//=========== -{ -private: - -#ifndef NO_PORTAUDIO - ComponentHandle<ComponentPortAudio> m_PortAudio; -#endif // NO_PORTAUDIO - - std::vector<SoundDevice::Info> m_SoundDevices; - std::map<SoundDevice::Identifier, bool> m_DeviceUnavailable; - std::map<SoundDevice::Identifier, SoundDevice::Caps> m_DeviceCaps; - std::map<SoundDevice::Identifier, SoundDevice::DynamicCaps> m_DeviceDynamicCaps; - -public: - Manager(SoundDevice::TypesSet enabledTypes); - ~Manager(); - -public: - - void ReEnumerate(SoundDevice::TypesSet enabledTypes); - - std::vector<SoundDevice::Info>::const_iterator begin() const { return m_SoundDevices.begin(); } - std::vector<SoundDevice::Info>::const_iterator end() const { return m_SoundDevices.end(); } - const std::vector<SoundDevice::Info> & GetDeviceInfos() const { return m_SoundDevices; } - - SoundDevice::Info FindDeviceInfo(SoundDevice::ID id) const; - SoundDevice::Info FindDeviceInfo(SoundDevice::Identifier identifier) const; - SoundDevice::Info FindDeviceInfoBestMatch(SoundDevice::Identifier identifier, bool preferSameType); - - bool OpenDriverSettings(SoundDevice::Identifier identifier, SoundDevice::IMessageReceiver *messageReceiver = nullptr, SoundDevice::IBase *currentSoundDevice = nullptr); - - void SetDeviceUnavailable(SoundDevice::Identifier identifier) { m_DeviceUnavailable[identifier] = true; } - bool IsDeviceUnavailable(SoundDevice::Identifier identifier) { return m_DeviceUnavailable[identifier]; } - - SoundDevice::Caps GetDeviceCaps(SoundDevice::Identifier identifier, SoundDevice::IBase *currentSoundDevice = nullptr); - SoundDevice::DynamicCaps GetDeviceDynamicCaps(SoundDevice::Identifier identifier, const std::vector<uint32> &baseSampleRates, SoundDevice::IMessageReceiver *messageReceiver = nullptr, SoundDevice::IBase *currentSoundDevice = nullptr, bool update = false); - - SoundDevice::IBase * CreateSoundDevice(SoundDevice::Identifier identifier); - -}; - - } // namespace SoundDevice Copied: trunk/OpenMPT/sounddev/SoundDeviceManager.cpp (from rev 4744, trunk/OpenMPT/sounddev/SoundDevice.cpp) =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceManager.cpp (rev 0) +++ trunk/OpenMPT/sounddev/SoundDeviceManager.cpp 2015-02-09 17:56:30 UTC (rev 4745) @@ -0,0 +1,363 @@ +/* + * SoundDeviceManager.cpp + * ---------------------- + * Purpose: Sound device manager class. + * Notes : (currently none) + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "stdafx.h" + +#include "SoundDeviceManager.h" +#include "SoundDevice.h" + +#include "SoundDeviceASIO.h" +#include "SoundDeviceDirectSound.h" +#include "SoundDevicePortAudio.h" +#include "SoundDeviceWaveout.h" + + +OPENMPT_NAMESPACE_BEGIN + + +namespace SoundDevice { + + +/////////////////////////////////////////////////////////////////////////////////////// +// +// Global Functions +// + + +void Manager::ReEnumerate(SoundDevice::TypesSet enabledTypes) +//----------------------------------------------------------- +{ + m_SoundDevices.clear(); + m_DeviceUnavailable.clear(); + m_DeviceCaps.clear(); + m_DeviceDynamicCaps.clear(); + +#ifndef NO_PORTAUDIO + if(IsComponentAvailable(m_PortAudio)) + { + m_PortAudio->ReInit(); + } +#endif // NO_PORTAUDIO + + if(enabledTypes[SoundDevice::TypeWAVEOUT]) + { + const std::vector<SoundDevice::Info> infos = CWaveDevice::EnumerateDevices(); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); + } +#ifndef NO_ASIO + if(enabledTypes[SoundDevice::TypeASIO]) + { + const std::vector<SoundDevice::Info> infos = CASIODevice::EnumerateDevices(); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); + } +#endif // NO_ASIO +#ifndef NO_PORTAUDIO + if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_WASAPI]) + { + const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_WASAPI); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); + } + if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_WDMKS]) + { + const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_WDMKS); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); + } +#endif // NO_PORTAUDIO + + // kind of deprecated by now +#ifndef NO_DSOUND + if(enabledTypes[SoundDevice::TypeDSOUND]) + { + const std::vector<SoundDevice::Info> infos = CDSoundDevice::EnumerateDevices(); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); + } +#endif // NO_DSOUND + + // duplicate devices, only used if [Sound Settings]MorePortaudio=1 +#ifndef NO_PORTAUDIO + if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_WMME]) + { + const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_WMME); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); + } + if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_ASIO]) + { + const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_ASIO); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); + } + if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_DS]) + { + const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_DS); + m_SoundDevices.insert(m_SoundDevices.end(), infos.begin(), infos.end()); + } +#endif // NO_PORTAUDIO + +} + + +SoundDevice::Info Manager::FindDeviceInfo(SoundDevice::ID id) const +//----------------------------------------------------------------- +{ + for(std::vector<SoundDevice::Info>::const_iterator it = begin(); it != end(); ++it) + { + if(it->id == id) + { + return *it; + } + } + return SoundDevice::Info(); +} + + +SoundDevice::Info Manager::FindDeviceInfo(SoundDevice::Identifier identifier) const +//--------------------------------------------------------------------------------- +{ + if(m_SoundDevices.empty()) + { + return SoundDevice::Info(); + } + if(identifier.empty()) + { + return m_SoundDevices[0]; + } + for(std::vector<SoundDevice::Info>::const_iterator it = begin(); it != end(); ++it) + { + if(it->GetIdentifier() == identifier) + { + return *it; + } + } + return SoundDevice::Info(); +} + + +SoundDevice::Type ParseType(const SoundDevice::Identifier &identifier) +//-------------------------------------------------------------------- +{ + for(int i = 0; i < TypeNUM_DEVTYPES; ++i) + { + const mpt::ustring api = SoundDevice::TypeToString(static_cast<SoundDevice::Type>(i)); + if(identifier.find(api) == 0) + { + return static_cast<SoundDevice::Type>(i); + } + } + return TypeINVALID; +} + + +SoundDevice::Info Manager::FindDeviceInfoBestMatch(SoundDevice::Identifier identifier, bool preferSameType) +//--------------------------------------------------------------------------------------------------------- +{ + if(m_SoundDevices.empty()) + { + return SoundDevice::Info(); + } + if(identifier.empty()) + { + return *begin(); + } + for(std::vector<SoundDevice::Info>::const_iterator it = begin(); it != end(); ++it) + { + if((it->GetIdentifier() == identifier) && !IsDeviceUnavailable(it->GetIdentifier())) + { // exact match + return *it; + } + } + const SoundDevice::Type type = ParseType(identifier); + switch(type) + { + case TypePORTAUDIO_WASAPI: + // WASAPI devices might change names if a different connector jack is used. + // In order to avoid defaulting to wave mapper in that case, + // just find the first WASAPI device. + for(std::vector<SoundDevice::Info>::const_iterator it = begin(); it != end(); ++it) + { + if((it->id.GetType() == TypePORTAUDIO_WASAPI) && !IsDeviceUnavailable(it->GetIdentifier())) + { + return *it; + } + } + // default to first device + return *begin(); + break; + case TypeWAVEOUT: + case TypeDSOUND: + case TypePORTAUDIO_WMME: + case TypePORTAUDIO_DS: + case TypeASIO: + case TypePORTAUDIO_WDMKS: + case TypePORTAUDIO_ASIO: + if(preferSameType) + { + for(std::vector<SoundDevice::Info>::const_iterator it = begin(); it != end(); ++it) + { + if((it->id.GetType() == type) && !IsDeviceUnavailable(it->GetIdentifier())) + { + return *it; + } + } + } else + { + // default to first device + return *begin(); + } + break; + } + // invalid + return SoundDevice::Info(); +} + + +bool Manager::OpenDriverSettings(SoundDevice::Identifier identifier, SoundDevice::IMessageReceiver *messageReceiver, SoundDevice::IBase *currentSoundDevice) +//---------------------------------------------------------------------------------------------------------------------------------------------------------- +{ + bool result = false; + if(currentSoundDevice && FindDeviceInfo(identifier).IsValid() && (currentSoundDevice->GetDeviceInfo().GetIdentifier() == identifier)) + { + result = currentSoundDevice->OpenDriverSettings(); + } else + { + SoundDevice::IBase *dummy = CreateSoundDevice(identifier); + if(dummy) + { + dummy->SetMessageReceiver(messageReceiver); + result = dummy->OpenDriverSettings(); + } + delete dummy; + } + return result; +} + + +SoundDevice::Caps Manager::GetDeviceCaps(SoundDevice::Identifier identifier, SoundDevice::IBase *currentSoundDevice) +//------------------------------------------------------------------------------------------------------------------ +{ + if(m_DeviceCaps.find(identifier) == m_DeviceCaps.end()) + { + if(currentSoundDevice && FindDeviceInfo(identifier).IsValid() && (currentSoundDevice->GetDeviceInfo().GetIdentifier() == identifier)) + { + m_DeviceCaps[identifier] = currentSoundDevice->GetDeviceCaps(); + } else + { + SoundDevice::IBase *dummy = CreateSoundDevice(identifier); + if(dummy) + { + m_DeviceCaps[identifier] = dummy->GetDeviceCaps(); + } else + { + SetDeviceUnavailable(identifier); + } + delete dummy; + } + } + return m_DeviceCaps[identifier]; +} + + +SoundDevice::DynamicCaps Manager::GetDeviceDynamicCaps(SoundDevice::Identifier identifier, const std::vector<uint32> &baseSampleRates, SoundDevice::IMessageReceiver *messageReceiver, SoundDevice::IBase *currentSoundDevice, bool update) +//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +{ + if((m_DeviceDynamicCaps.find(identifier) == m_DeviceDynamicCaps.end()) || update) + { + if(currentSoundDevice && FindDeviceInfo(identifier).IsValid() && (currentSoundDevice->GetDeviceInfo().GetIdentifier() == identifier)) + { + m_DeviceDynamicCaps[identifier] = currentSoundDevice->GetDeviceDynamicCaps(baseSampleRates); + if(!currentSoundDevice->IsAvailable()) + { + SetDeviceUnavailable(identifier); + } + } else + { + SoundDevice::IBase *dummy = CreateSoundDevice(identifier); + if(dummy) + { + dummy->SetMessageReceiver(messageReceiver); + m_DeviceDynamicCaps[identifier] = dummy->GetDeviceDynamicCaps(baseSampleRates); + if(!dummy->IsAvailable()) + { + SetDeviceUnavailable(identifier); + } + } else + { + SetDeviceUnavailable(identifier); + } + delete dummy; + } + } + return m_DeviceDynamicCaps[identifier]; +} + + +SoundDevice::IBase * Manager::CreateSoundDevice(SoundDevice::Identifier identifier) +//--------------------------------------------------------------------------------- +{ + const SoundDevice::Info info = FindDeviceInfo(identifier); + if(!info.IsValid()) + { + return nullptr; + } + SoundDevice::IBase *result = nullptr; + switch(info.id.GetType()) + { + case TypeWAVEOUT: result = new CWaveDevice(info); break; +#ifndef NO_DSOUND + case TypeDSOUND: result = new CDSoundDevice(info); break; +#endif // NO_DSOUND +#ifndef NO_ASIO + case TypeASIO: result = new CASIODevice(info); break; +#endif // NO_ASIO +#ifndef NO_PORTAUDIO + case TypePORTAUDIO_WASAPI: + case TypePORTAUDIO_WDMKS: + case TypePORTAUDIO_WMME: + case TypePORTAUDIO_DS: + case TypePORTAUDIO_ASIO: + if(IsComponentAvailable(m_PortAudio)) + { + result = new CPortaudioDevice(info); + } + break; +#endif // NO_PORTAUDIO + } + if(!result) + { + return nullptr; + } + if(!result->Init()) + { + delete result; + result = nullptr; + return nullptr; + } + m_DeviceCaps[identifier] = result->GetDeviceCaps(); // update cached caps + return result; +} + + +Manager::Manager(SoundDevice::TypesSet enabledTypes) +//-------------------------------------------------- +{ + ReEnumerate(enabledTypes); +} + + +Manager::~Manager() +//----------------- +{ + return; +} + + +} // namespace SoundDevice + + +OPENMPT_NAMESPACE_END Copied: trunk/OpenMPT/sounddev/SoundDeviceManager.h (from rev 4744, trunk/OpenMPT/sounddev/SoundDevice.h) =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceManager.h (rev 0) +++ trunk/OpenMPT/sounddev/SoundDeviceManager.h 2015-02-09 17:56:30 UTC (rev 4745) @@ -0,0 +1,75 @@ +/* + * SoundDeviceManager.h + * -------------------- + * Purpose: Sound device manager class. + * Notes : (currently none) + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + +#include "SoundDevice.h" + +#include "../common/ComponentManager.h" + + +OPENMPT_NAMESPACE_BEGIN + + +namespace SoundDevice { + + +class ComponentPortAudio; + + +//=========== +class Manager +//=========== +{ +private: + +#ifndef NO_PORTAUDIO + ComponentHandle<ComponentPortAudio> m_PortAudio; +#endif // NO_PORTAUDIO + + std::vector<SoundDevice::Info> m_SoundDevices; + std::map<SoundDevice::Identifier, bool> m_DeviceUnavailable; + std::map<SoundDevice::Identifier, SoundDevice::Caps> m_DeviceCaps; + std::map<SoundDevice::Identifier, SoundDevice::DynamicCaps> m_DeviceDynamicCaps; + +public: + Manager(SoundDevice::TypesSet enabledTypes); + ~Manager(); + +public: + + void ReEnumerate(SoundDevice::TypesSet enabledTypes); + + std::vector<SoundDevice::Info>::const_iterator begin() const { return m_SoundDevices.begin(); } + std::vector<SoundDevice::Info>::const_iterator end() const { return m_SoundDevices.end(); } + const std::vector<SoundDevice::Info> & GetDeviceInfos() const { return m_SoundDevices; } + + SoundDevice::Info FindDeviceInfo(SoundDevice::ID id) const; + SoundDevice::Info FindDeviceInfo(SoundDevice::Identifier identifier) const; + SoundDevice::Info FindDeviceInfoBestMatch(SoundDevice::Identifier identifier, bool preferSameType); + + bool OpenDriverSettings(SoundDevice::Identifier identifier, SoundDevice::IMessageReceiver *messageReceiver = nullptr, SoundDevice::IBase *currentSoundDevice = nullptr); + + void SetDeviceUnavailable(SoundDevice::Identifier identifier) { m_DeviceUnavailable[identifier] = true; } + bool IsDeviceUnavailable(SoundDevice::Identifier identifier) { return m_DeviceUnavailable[identifier]; } + + SoundDevice::Caps GetDeviceCaps(SoundDevice::Identifier identifier, SoundDevice::IBase *currentSoundDevice = nullptr); + SoundDevice::DynamicCaps GetDeviceDynamicCaps(SoundDevice::Identifier identifier, const std::vector<uint32> &baseSampleRates, SoundDevice::IMessageReceiver *messageReceiver = nullptr, SoundDevice::IBase *currentSoundDevice = nullptr, bool update = false); + + SoundDevice::IBase * CreateSoundDevice(SoundDevice::Identifier identifier); + +}; + + +} // namespace SoundDevice + + +OPENMPT_NAMESPACE_END This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-11 14:36:17
|
Revision: 4750 http://sourceforge.net/p/modplug/code/4750 Author: manxorist Date: 2015-02-11 14:36:10 +0000 (Wed, 11 Feb 2015) Log Message: ----------- [Ref] sounddev: Remove redundant state in m_BufferAttributes. [Ref] sounddev: Merge GetCurrentLatency and GetCurrentUpdateInterval into GetStatistics. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp trunk/OpenMPT/sounddev/SoundDeviceASIO.h trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp trunk/OpenMPT/sounddev/SoundDevicePortAudio.h trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp trunk/OpenMPT/sounddev/SoundDeviceWaveout.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2015-02-11 14:36:10 UTC (rev 4750) @@ -1164,7 +1164,7 @@ m_NotifyTimer = SetTimer(TIMERID_NOTIFY, TrackerSettings::Instance().GUIUpdateInterval, NULL); } else { - m_NotifyTimer = SetTimer(TIMERID_NOTIFY, std::max<int>(1, Util::Round<int>(gpSoundDevice->GetBufferAttributes().UpdateInterval * 1000.0)), NULL); + m_NotifyTimer = SetTimer(TIMERID_NOTIFY, std::max<int>(1, Util::Round<int>(gpSoundDevice->GetEffectiveBufferAttributes().UpdateInterval * 1000.0)), NULL); } } return true; Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2015-02-11 14:36:10 UTC (rev 4750) @@ -894,21 +894,20 @@ CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); if(pMainFrm->gpSoundDevice && pMainFrm->IsPlaying()) { - const SoundDevice::BufferAttributes bufferAttributes = pMainFrm->gpSoundDevice->GetBufferAttributes(); - const double currentLatency = pMainFrm->gpSoundDevice->GetCurrentLatency(); - const double currentUpdateInterval = pMainFrm->gpSoundDevice->GetCurrentUpdateInterval(); + const SoundDevice::BufferAttributes bufferAttributes = pMainFrm->gpSoundDevice->GetEffectiveBufferAttributes(); + const SoundDevice::Statistics stats = pMainFrm->gpSoundDevice->GetStatistics(); const uint32 samplerate = pMainFrm->gpSoundDevice->GetSettings().Samplerate; mpt::ustring s; if(bufferAttributes.NumBuffers > 2) { - s += mpt::String::Print(MPT_USTRING("Buffer: %1%% (%2/%3)\r\n"), (bufferAttributes.Latency > 0.0) ? Util::Round<int64>(currentLatency / bufferAttributes.Latency * 100.0) : 0, (currentUpdateInterval > 0.0) ? Util::Round<int64>(bufferAttributes.Latency / currentUpdateInterval) : 0, bufferAttributes.NumBuffers); + s += mpt::String::Print(MPT_USTRING("Buffer: %1%% (%2/%3)\r\n"), (bufferAttributes.Latency > 0.0) ? Util::Round<int64>(stats.InstantaneousLatency / bufferAttributes.Latency * 100.0) : 0, (stats.LastUpdateInterval > 0.0) ? Util::Round<int64>(bufferAttributes.Latency / stats.LastUpdateInterval) : 0, bufferAttributes.NumBuffers); } else { - s += mpt::String::Print(MPT_USTRING("Buffer: %1%%\r\n"), (bufferAttributes.Latency > 0.0) ? Util::Round<int64>(currentLatency / bufferAttributes.Latency * 100.0) : 0); + s += mpt::String::Print(MPT_USTRING("Buffer: %1%%\r\n"), (bufferAttributes.Latency > 0.0) ? Util::Round<int64>(stats.InstantaneousLatency / bufferAttributes.Latency * 100.0) : 0); } - s += mpt::String::Print(MPT_USTRING("Latency: %1 ms (current: %2 ms, %3 frames)\r\n"), mpt::ufmt::f("%4.1f", bufferAttributes.Latency * 1000.0), mpt::ufmt::f("%4.1f", currentLatency * 1000.0), Util::Round<int64>(currentLatency * samplerate)); - s += mpt::String::Print(MPT_USTRING("Period: %1 ms (current: %2 ms, %3 frames)\r\n"), mpt::ufmt::f("%4.1f", bufferAttributes.UpdateInterval * 1000.0), mpt::ufmt::f("%4.1f", currentUpdateInterval * 1000.0), Util::Round<int64>(currentUpdateInterval * samplerate)); - s += pMainFrm->gpSoundDevice->GetStatistics(); + s += mpt::String::Print(MPT_USTRING("Latency: %1 ms (current: %2 ms, %3 frames)\r\n"), mpt::ufmt::f("%4.1f", bufferAttributes.Latency * 1000.0), mpt::ufmt::f("%4.1f", stats.InstantaneousLatency * 1000.0), Util::Round<int64>(stats.InstantaneousLatency * samplerate)); + s += mpt::String::Print(MPT_USTRING("Period: %1 ms (current: %2 ms, %3 frames)\r\n"), mpt::ufmt::f("%4.1f", bufferAttributes.UpdateInterval * 1000.0), mpt::ufmt::f("%4.1f", stats.LastUpdateInterval * 1000.0), Util::Round<int64>(stats.LastUpdateInterval * samplerate)); + s += stats.text; m_EditStatistics.SetWindowText(mpt::ToCString(s)); } else { Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-11 14:36:10 UTC (rev 4750) @@ -142,10 +142,6 @@ m_DeviceUnavailableOnOpen = false; - m_BufferAttributes.Latency = m_Settings.Latency; - m_BufferAttributes.UpdateInterval = m_Settings.UpdateInterval; - m_BufferAttributes.NumBuffers = 0; - m_IsPlaying = false; m_CurrentUpdateInterval = 0.0; m_StreamPositionRenderFrames = 0; @@ -206,14 +202,6 @@ } -void Base::UpdateBufferAttributes(SoundDevice::BufferAttributes attributes) -//------------------------------------------------------------------------- -{ - MPT_TRACE(); - m_BufferAttributes = attributes; -} - - void Base::UpdateTimeInfo(SoundDevice::TimeInfo timeInfo) //------------------------------------------------------- { @@ -265,9 +253,6 @@ } m_Flags = SoundDevice::Flags(); m_DeviceUnavailableOnOpen = false; - m_BufferAttributes.Latency = m_Settings.Latency; - m_BufferAttributes.UpdateInterval = m_Settings.UpdateInterval; - m_BufferAttributes.NumBuffers = 0; m_RequestFlags.store(0); return InternalOpen(); } @@ -324,7 +309,7 @@ Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex); timeInfo.StreamFrames = m_StreamPositionRenderFrames + numFrames; } - timeInfo.SystemTimestamp = Clock().NowNanoseconds() + Util::Round<int64>(m_BufferAttributes.Latency * 1000000000.0); + timeInfo.SystemTimestamp = Clock().NowNanoseconds() + Util::Round<int64>(GetEffectiveBufferAttributes().Latency * 1000000000.0); timeInfo.Speed = 1.0; UpdateTimeInfo(timeInfo); } @@ -339,7 +324,7 @@ { return; } - m_Source->AudioRead(m_Settings, m_Flags, m_BufferAttributes, m_TimeInfo, numFrames, buffer); + m_Source->AudioRead(m_Settings, m_Flags, GetEffectiveBufferAttributes(), m_TimeInfo, numFrames, buffer); } @@ -359,7 +344,7 @@ m_StreamPositionOutputFrames = m_StreamPositionRenderFrames - framesLatency; framesRendered = m_StreamPositionRenderFrames; } - m_Source->AudioDone(m_Settings, m_Flags, m_BufferAttributes, m_TimeInfo, numFrames, framesRendered); + m_Source->AudioDone(m_Settings, m_Flags, GetEffectiveBufferAttributes(), m_TimeInfo, numFrames, framesRendered); } @@ -427,8 +412,8 @@ } -double Base::GetCurrentUpdateInterval() const -//------------------------------------------- +double Base::GetLastUpdateInterval() const +//---------------------------------------- { MPT_TRACE(); Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex); @@ -452,6 +437,18 @@ } +SoundDevice::Statistics Base::GetStatistics() const +//------------------------------------------------- +{ + MPT_TRACE(); + SoundDevice::Statistics result; + result.InstantaneousLatency = m_Settings.Latency; + result.LastUpdateInterval = GetLastUpdateInterval(); + result.text = mpt::ustring(); + return result; +} + + } // namespace SoundDevice Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2015-02-11 14:36:10 UTC (rev 4750) @@ -450,6 +450,20 @@ MPT_DECLARE_ENUM(RequestFlags) +struct Statistics +{ + double InstantaneousLatency; + double LastUpdateInterval; + mpt::ustring text; + Statistics() + : InstantaneousLatency(0.0) + , LastUpdateInterval(0.0) + { + return; + } +}; + + //========= class IBase //========= @@ -495,19 +509,15 @@ virtual SoundDevice::Settings GetSettings() const = 0; virtual SampleFormat GetActualSampleFormat() const = 0; + virtual SoundDevice::BufferAttributes GetEffectiveBufferAttributes() const = 0; - virtual SoundDevice::BufferAttributes GetBufferAttributes() const = 0; virtual SoundDevice::TimeInfo GetTimeInfo() const = 0; + virtual int64 GetStreamPositionFrames() const = 0; // Informational only, do not use for timing. // Use GetStreamPositionFrames() for timing - virtual double GetCurrentLatency() const = 0; - virtual double GetCurrentUpdateInterval() const = 0; + virtual SoundDevice::Statistics GetStatistics() const = 0; - virtual int64 GetStreamPositionFrames() const = 0; - - virtual mpt::ustring GetStatistics() const = 0; - virtual bool OpenDriverSettings() = 0; }; @@ -538,8 +548,6 @@ private: - SoundDevice::BufferAttributes m_BufferAttributes; - bool m_IsPlaying; Util::MultimediaClock m_Clock; @@ -579,7 +587,6 @@ const Util::MultimediaClock & Clock() const { return m_Clock; } - void UpdateBufferAttributes(SoundDevice::BufferAttributes attributes); void UpdateTimeInfo(SoundDevice::TimeInfo timeInfo); virtual bool InternalHasTimeInfo() const { return false; } @@ -597,6 +604,10 @@ virtual SoundDevice::Caps InternalGetDeviceCaps() = 0; + virtual SoundDevice::BufferAttributes InternalGetEffectiveBufferAttributes() const = 0; + + double GetLastUpdateInterval() const; + protected: Base(SoundDevice::Info info); @@ -630,16 +641,12 @@ SoundDevice::Settings GetSettings() const { return m_Settings; } SampleFormat GetActualSampleFormat() const { return IsOpen() ? m_Settings.sampleFormat : SampleFormatInvalid; } + SoundDevice::BufferAttributes GetEffectiveBufferAttributes() const { return (IsOpen() && IsPlaying()) ? InternalGetEffectiveBufferAttributes() : SoundDevice::BufferAttributes(); } - SoundDevice::BufferAttributes GetBufferAttributes() const { return m_BufferAttributes; } SoundDevice::TimeInfo GetTimeInfo() const { return m_TimeInfo; } - - virtual double GetCurrentLatency() const { return m_BufferAttributes.Latency; } - double GetCurrentUpdateInterval() const; - int64 GetStreamPositionFrames() const; - virtual mpt::ustring GetStatistics() const { return mpt::ustring(); } + virtual SoundDevice::Statistics GetStatistics() const; virtual bool OpenDriverSettings() { return false; }; Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-02-11 14:36:10 UTC (rev 4750) @@ -198,6 +198,7 @@ MPT_TRACE(); m_pAsioDrv = nullptr; + m_BufferLatency = 0.0; m_nAsioBufferLen = 0; m_BufferInfo.clear(); MemsetZero(m_Callbacks); @@ -475,7 +476,6 @@ //------------------------------- { MPT_TRACE(); - SoundDevice::BufferAttributes bufferAttributes; long inputLatency = 0; long outputLatency = 0; try @@ -489,15 +489,12 @@ } if(outputLatency >= (long)m_nAsioBufferLen) { - bufferAttributes.Latency = (double)(outputLatency + m_nAsioBufferLen) / (double)m_Settings.Samplerate; // ASIO and OpenMPT semantics of 'latency' differ by one chunk/buffer + m_BufferLatency = (double)(outputLatency + m_nAsioBufferLen) / (double)m_Settings.Samplerate; // ASIO and OpenMPT semantics of 'latency' differ by one chunk/buffer } else { // pointless value returned from asio driver, use a sane estimate - bufferAttributes.Latency = 2.0 * (double)m_nAsioBufferLen / (double)m_Settings.Samplerate; + m_BufferLatency = 2.0 * (double)m_nAsioBufferLen / (double)m_Settings.Samplerate; } - bufferAttributes.UpdateInterval = (double)m_nAsioBufferLen / (double)m_Settings.Samplerate; - bufferAttributes.NumBuffers = 2; - UpdateBufferAttributes(bufferAttributes); } @@ -654,6 +651,7 @@ MemsetZero(m_Callbacks); m_BufferInfo.clear(); m_nAsioBufferLen = 0; + m_BufferLatency = 0.0; CloseDriver(); @@ -1044,6 +1042,17 @@ } +SoundDevice::BufferAttributes CASIODevice::InternalGetEffectiveBufferAttributes() const +//------------------------------------------------------------------------------------- +{ + SoundDevice::BufferAttributes bufferAttributes; + bufferAttributes.Latency = m_BufferLatency; + bufferAttributes.UpdateInterval = static_cast<double>(m_nAsioBufferLen) / static_cast<double>(m_Settings.Samplerate); + bufferAttributes.NumBuffers = 2; + return bufferAttributes; +} + + void CASIODevice::UpdateTimeInfo(AsioTimeInfo asioTimeInfo) //--------------------------------------------------------- { @@ -1070,7 +1079,7 @@ const uint64 asioNow = Clock().NowNanoseconds(); SoundDevice::TimeInfo timeInfo; timeInfo.StreamFrames = m_TotalFramesWritten + m_nAsioBufferLen - m_StreamPositionOffset; - timeInfo.SystemTimestamp = asioNow + Util::Round<int64>(GetBufferAttributes().Latency * 1000.0 * 1000.0 * 1000.0); + timeInfo.SystemTimestamp = asioNow + Util::Round<int64>(m_BufferLatency * 1000.0 * 1000.0 * 1000.0); timeInfo.Speed = 1.0; SoundDevice::Base::UpdateTimeInfo(timeInfo); } @@ -1190,24 +1199,31 @@ } -mpt::ustring CASIODevice::GetStatistics() const -//--------------------------------------------- +SoundDevice::Statistics CASIODevice::GetStatistics() const +//-------------------------------------------------------- { MPT_TRACE(); + SoundDevice::Statistics result; + result.InstantaneousLatency = m_BufferLatency; + result.LastUpdateInterval = static_cast<double>(m_nAsioBufferLen) / static_cast<double>(m_Settings.Samplerate); + result.text = mpt::ustring(); const FlagSet<AsioFeatures> unsupported(AsioFeatureNoDirectProcess | AsioFeatureOverload | AsioFeatureBufferSizeChange | AsioFeatureSampleRateChange); FlagSet<AsioFeatures> unsupportedFeatues = m_UsedFeatures; unsupportedFeatues &= unsupported; if(unsupportedFeatues.any()) { - return mpt::String::Print(MPT_USTRING("WARNING: unsupported features: %1"), AsioFeaturesToString(unsupportedFeatues)); + result.text = mpt::String::Print(MPT_USTRING("WARNING: unsupported features: %1"), AsioFeaturesToString(unsupportedFeatues)); } else if(m_UsedFeatures.any()) { - return mpt::String::Print(MPT_USTRING("OK, features used: %1"), AsioFeaturesToString(m_UsedFeatures)); + result.text = mpt::String::Print(MPT_USTRING("OK, features used: %1"), AsioFeaturesToString(m_UsedFeatures)); } else if(m_QueriedFeatures.any()) { - return mpt::String::Print(MPT_USTRING("OK, features queried: %1"), AsioFeaturesToString(m_QueriedFeatures)); + result.text = mpt::String::Print(MPT_USTRING("OK, features queried: %1"), AsioFeaturesToString(m_QueriedFeatures)); + } else + { + result.text = MPT_USTRING("OK."); } - return MPT_USTRING("OK."); + return result; } Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2015-02-11 14:36:10 UTC (rev 4750) @@ -53,6 +53,7 @@ IASIO *m_pAsioDrv; + double m_BufferLatency; long m_nAsioBufferLen; std::vector<ASIOBufferInfo> m_BufferInfo; ASIOCallbacks m_Callbacks; @@ -117,7 +118,7 @@ bool OpenDriverSettings(); - mpt::ustring GetStatistics() const; + SoundDevice::Statistics GetStatistics() const; public: static std::vector<SoundDevice::Info> EnumerateDevices(); @@ -131,6 +132,8 @@ bool InternalHasGetStreamPosition() const; int64 InternalGetStreamPositionFrames() const; + SoundDevice::BufferAttributes InternalGetEffectiveBufferAttributes() const; + protected: long AsioMessage(long selector, long value, void* message, double* opt); void SampleRateDidChange(ASIOSampleRate sRate); Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-02-11 14:36:10 UTC (rev 4750) @@ -301,11 +301,6 @@ m_dwWritePos = 0xFFFFFFFF; SetWakeupInterval(std::min(m_Settings.UpdateInterval, m_nDSoundBufferSize / (2.0 * m_Settings.GetBytesPerSecond()))); m_Flags.NeedsClippedFloat = mpt::Windows::Version::IsAtLeast(mpt::Windows::Version::WinVista); - SoundDevice::BufferAttributes bufferAttributes; - bufferAttributes.Latency = m_nDSoundBufferSize * 1.0 / m_Settings.GetBytesPerSecond(); - bufferAttributes.UpdateInterval = std::min(m_Settings.UpdateInterval, m_nDSoundBufferSize / (2.0 * m_Settings.GetBytesPerSecond())); - bufferAttributes.NumBuffers = 1; - UpdateBufferAttributes(bufferAttributes); return true; } @@ -486,6 +481,29 @@ } +SoundDevice::BufferAttributes CDSoundDevice::InternalGetEffectiveBufferAttributes() const +//--------------------------------------------------------------------------------------- +{ + SoundDevice::BufferAttributes bufferAttributes; + bufferAttributes.Latency = m_nDSoundBufferSize * 1.0 / m_Settings.GetBytesPerSecond(); + bufferAttributes.UpdateInterval = std::min(m_Settings.UpdateInterval, m_nDSoundBufferSize / (2.0 * m_Settings.GetBytesPerSecond())); + bufferAttributes.NumBuffers = 1; + return bufferAttributes; +} + + +SoundDevice::Statistics CDSoundDevice::GetStatistics() const +//---------------------------------------------------------- +{ + MPT_TRACE(); + SoundDevice::Statistics result; + result.InstantaneousLatency = 1.0 * m_dwLatency / m_Settings.GetBytesPerSecond(); + result.LastUpdateInterval = GetLastUpdateInterval(); + result.text = mpt::ustring(); + return result; +} + + #endif // NO_DIRECTSOUND Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2015-02-11 14:36:10 UTC (rev 4750) @@ -53,7 +53,8 @@ void StartFromSoundThread(); void StopFromSoundThread(); bool InternalIsOpen() const { return (m_pMixBuffer != NULL); } - double GetCurrentLatency() const { return 1.0 * m_dwLatency / m_Settings.GetBytesPerSecond(); } + SoundDevice::BufferAttributes InternalGetEffectiveBufferAttributes() const; + SoundDevice::Statistics GetStatistics() const; SoundDevice::Caps InternalGetDeviceCaps(); SoundDevice::DynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates); Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2015-02-11 14:36:10 UTC (rev 4750) @@ -131,11 +131,6 @@ m_Stream = 0; return false; } - SoundDevice::BufferAttributes bufferAttributes; - bufferAttributes.Latency = m_StreamInfo->outputLatency; - bufferAttributes.UpdateInterval = m_Settings.UpdateInterval; - bufferAttributes.NumBuffers = 1; - UpdateBufferAttributes(bufferAttributes); return true; } @@ -145,11 +140,12 @@ { if(m_Stream) { + const SoundDevice::BufferAttributes bufferAttributes = GetEffectiveBufferAttributes(); Pa_AbortStream(m_Stream); Pa_CloseStream(m_Stream); if(Pa_GetDeviceInfo(m_StreamParameters.device)->hostApi == Pa_HostApiTypeIdToHostApiIndex(paWDMKS)) { - Pa_Sleep(Util::Round<long>(GetBufferAttributes().Latency * 2.0 * 1000.0 + 0.5)); // wait for broken wdm drivers not closing the stream immediatly + Pa_Sleep(Util::Round<long>(bufferAttributes.Latency * 2.0 * 1000.0 + 0.5)); // wait for broken wdm drivers not closing the stream immediatly } MemsetZero(m_StreamParameters); m_StreamInfo = 0; @@ -193,13 +189,29 @@ } -double CPortaudioDevice::GetCurrentLatency() const -//------------------------------------------------ +SoundDevice::BufferAttributes CPortaudioDevice::InternalGetEffectiveBufferAttributes() const +//------------------------------------------------------------------------------------------ { - return m_CurrentRealLatency; + SoundDevice::BufferAttributes bufferAttributes; + bufferAttributes.Latency = m_StreamInfo->outputLatency; + bufferAttributes.UpdateInterval = m_Settings.UpdateInterval; + bufferAttributes.NumBuffers = 1; + return bufferAttributes; } +SoundDevice::Statistics CPortaudioDevice::GetStatistics() const +//------------------------------------------------------------- +{ + MPT_TRACE(); + SoundDevice::Statistics result; + result.InstantaneousLatency = m_CurrentRealLatency; + result.LastUpdateInterval = GetLastUpdateInterval(); + result.text = mpt::ustring(); + return result; +} + + SoundDevice::Caps CPortaudioDevice::InternalGetDeviceCaps() //------------------------------------------------------- { Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2015-02-11 14:36:10 UTC (rev 4750) @@ -56,9 +56,10 @@ bool InternalStart(); void InternalStop(); bool InternalIsOpen() const { return m_Stream ? true : false; } - double GetCurrentLatency() const; bool InternalHasGetStreamPosition() const { return false; } int64 InternalGetStreamPositionFrames() const; + SoundDevice::BufferAttributes InternalGetEffectiveBufferAttributes() const; + SoundDevice::Statistics GetStatistics() const; SoundDevice::Caps InternalGetDeviceCaps(); SoundDevice::DynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates); bool OpenDriverSettings(); Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2015-02-11 14:36:10 UTC (rev 4750) @@ -191,11 +191,6 @@ SetWakeupEvent(m_ThreadWakeupEvent); SetWakeupInterval(m_nWaveBufferSize * 1.0 / m_Settings.GetBytesPerSecond()); m_Flags.NeedsClippedFloat = mpt::Windows::Version::IsAtLeast(mpt::Windows::Version::WinVista); - SoundDevice::BufferAttributes bufferAttributes; - bufferAttributes.Latency = m_nWaveBufferSize * m_nPreparedHeaders * 1.0 / m_Settings.GetBytesPerSecond(); - bufferAttributes.UpdateInterval = m_nWaveBufferSize * 1.0 / m_Settings.GetBytesPerSecond(); - bufferAttributes.NumBuffers = m_nPreparedHeaders; - UpdateBufferAttributes(bufferAttributes); return true; } @@ -331,6 +326,29 @@ } +SoundDevice::BufferAttributes CWaveDevice::InternalGetEffectiveBufferAttributes() const +//------------------------------------------------------------------------------------- +{ + SoundDevice::BufferAttributes bufferAttributes; + bufferAttributes.Latency = m_nWaveBufferSize * m_nPreparedHeaders * 1.0 / m_Settings.GetBytesPerSecond(); + bufferAttributes.UpdateInterval = m_nWaveBufferSize * 1.0 / m_Settings.GetBytesPerSecond(); + bufferAttributes.NumBuffers = m_nPreparedHeaders; + return bufferAttributes; +} + + +SoundDevice::Statistics CWaveDevice::GetStatistics() const +//-------------------------------------------------------- +{ + MPT_TRACE(); + SoundDevice::Statistics result; + result.InstantaneousLatency = InterlockedExchangeAdd(&m_nBuffersPending, 0) * m_nWaveBufferSize * 1.0 / m_Settings.GetBytesPerSecond(); + result.LastUpdateInterval = GetLastUpdateInterval(); + result.text = mpt::ustring(); + return result; +} + + std::vector<SoundDevice::Info> CWaveDevice::EnumerateDevices() //---------------------------------------------------------- { Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2015-02-11 14:36:10 UTC (rev 4750) @@ -54,10 +54,12 @@ void StartFromSoundThread(); void StopFromSoundThread(); bool InternalIsOpen() const { return (m_hWaveOut != NULL); } - double GetCurrentLatency() const { return InterlockedExchangeAdd(&m_nBuffersPending, 0) * m_nWaveBufferSize * 1.0 / m_Settings.GetBytesPerSecond(); } bool InternalHasGetStreamPosition() const { return true; } int64 InternalGetStreamPositionFrames() const; + SoundDevice::BufferAttributes InternalGetEffectiveBufferAttributes() const; + SoundDevice::Statistics GetStatistics() const; + SoundDevice::Caps InternalGetDeviceCaps(); SoundDevice::DynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-11 17:16:25
|
Revision: 4751 http://sourceforge.net/p/modplug/code/4751 Author: manxorist Date: 2015-02-11 17:16:10 +0000 (Wed, 11 Feb 2015) Log Message: ----------- [Ref] sounddev: Rename SoundDeviceThread.* to SoundDeviceUtilities.* . Modified Paths: -------------- trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp trunk/OpenMPT/sounddev/SoundDeviceWaveout.h Added Paths: ----------- trunk/OpenMPT/sounddev/SoundDeviceUtilities.cpp trunk/OpenMPT/sounddev/SoundDeviceUtilities.h Removed Paths: ------------- trunk/OpenMPT/sounddev/SoundDeviceThread.cpp trunk/OpenMPT/sounddev/SoundDeviceThread.h Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2015-02-11 14:36:10 UTC (rev 4750) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2015-02-11 17:16:10 UTC (rev 4751) @@ -784,7 +784,7 @@ > </File> <File - RelativePath="..\sounddev\SoundDeviceThread.cpp" + RelativePath="..\sounddev\SoundDeviceUtilities.cpp" > </File> <File @@ -1530,7 +1530,7 @@ > </File> <File - RelativePath="..\sounddev\SoundDeviceThread.h" + RelativePath="..\sounddev\SoundDeviceUtilities.h" > </File> <File Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2015-02-11 14:36:10 UTC (rev 4750) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2015-02-11 17:16:10 UTC (rev 4751) @@ -742,7 +742,7 @@ <ClCompile Include="..\sounddev\SoundDeviceDirectSound.cpp" /> <ClCompile Include="..\sounddev\SoundDeviceManager.cpp" /> <ClCompile Include="..\sounddev\SoundDevicePortAudio.cpp" /> - <ClCompile Include="..\sounddev\SoundDeviceThread.cpp" /> + <ClCompile Include="..\sounddev\SoundDeviceUtilities.cpp" /> <ClCompile Include="..\sounddev\SoundDeviceWaveout.cpp" /> <ClCompile Include="..\sounddsp\AGC.cpp" /> <ClCompile Include="..\sounddsp\DSP.cpp" /> @@ -970,7 +970,7 @@ <ClInclude Include="..\sounddev\SoundDeviceDirectSound.h" /> <ClInclude Include="..\sounddev\SoundDeviceManager.h" /> <ClInclude Include="..\sounddev\SoundDevicePortAudio.h" /> - <ClInclude Include="..\sounddev\SoundDeviceThread.h" /> + <ClInclude Include="..\sounddev\SoundDeviceUtilities.h" /> <ClInclude Include="..\sounddev\SoundDeviceWaveout.h" /> <ClInclude Include="..\sounddsp\AGC.h" /> <ClInclude Include="..\sounddsp\DSP.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2015-02-11 14:36:10 UTC (rev 4750) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2015-02-11 17:16:10 UTC (rev 4751) @@ -493,9 +493,6 @@ <ClCompile Include="..\test\TestToolsLib.cpp"> <Filter>test</Filter> </ClCompile> - <ClCompile Include="..\sounddev\SoundDeviceThread.cpp"> - <Filter>Source Files\sounddev</Filter> - </ClCompile> <ClCompile Include="..\pluginBridge\BridgeWrapper.cpp"> <Filter>Source Files\pluginBridgeWrapper</Filter> </ClCompile> @@ -547,6 +544,9 @@ <ClCompile Include="..\sounddev\SoundDeviceManager.cpp"> <Filter>Source Files\sounddev</Filter> </ClCompile> + <ClCompile Include="..\sounddev\SoundDeviceUtilities.cpp"> + <Filter>Source Files\sounddev</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\soundlib\Loaders.h"> @@ -1005,9 +1005,6 @@ <ClInclude Include="..\test\TestTools.h"> <Filter>test</Filter> </ClInclude> - <ClInclude Include="..\sounddev\SoundDeviceThread.h"> - <Filter>Header Files\sounddev</Filter> - </ClInclude> <ClInclude Include="..\pluginBridge\AEffectWrapper.h"> <Filter>Header Files\pluginBridgeWrapper</Filter> </ClInclude> @@ -1071,6 +1068,9 @@ <ClInclude Include="..\sounddev\SoundDeviceManager.h"> <Filter>Header Files\sounddev</Filter> </ClInclude> + <ClInclude Include="..\sounddev\SoundDeviceUtilities.h"> + <Filter>Header Files\sounddev</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-02-11 14:36:10 UTC (rev 4750) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-02-11 17:16:10 UTC (rev 4751) @@ -12,7 +12,7 @@ #include "stdafx.h" #include "SoundDevice.h" -#include "SoundDeviceThread.h" +#include "SoundDeviceUtilities.h" #include "SoundDeviceDirectSound.h" Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2015-02-11 14:36:10 UTC (rev 4750) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2015-02-11 17:16:10 UTC (rev 4751) @@ -12,7 +12,7 @@ #pragma once #include "SoundDevice.h" -#include "SoundDeviceThread.h" +#include "SoundDeviceUtilities.h" #ifndef NO_DSOUND #include <dsound.h> Deleted: trunk/OpenMPT/sounddev/SoundDeviceThread.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceThread.cpp 2015-02-11 14:36:10 UTC (rev 4750) +++ trunk/OpenMPT/sounddev/SoundDeviceThread.cpp 2015-02-11 17:16:10 UTC (rev 4751) @@ -1,434 +0,0 @@ -/* - * SoundDeviceThread.cpp - * --------------------- - * Purpose: Sound device threading driver helpers. - * Notes : (currently none) - * Authors: Olivier Lapicque - * OpenMPT Devs - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - - -#include "stdafx.h" - -#include "SoundDevice.h" -#include "SoundDeviceThread.h" - -#include "../common/misc_util.h" - -#include <algorithm> - -#include <mmsystem.h> - - -OPENMPT_NAMESPACE_BEGIN - - -namespace SoundDevice { - - -CAudioThread::CAudioThread(CSoundDeviceWithThread &SoundDevice) : m_SoundDevice(SoundDevice) -//------------------------------------------------------------------------------------------ -{ - MPT_TRACE(); - m_WakeupInterval = 0.0; - m_hPlayThread = NULL; - m_dwPlayThreadId = 0; - m_hAudioWakeUp = NULL; - m_hAudioThreadTerminateRequest = NULL; - m_hAudioThreadGoneIdle = NULL; - m_hHardwareWakeupEvent = INVALID_HANDLE_VALUE; - m_AudioThreadActive = 0; - m_hAudioWakeUp = CreateEvent(NULL, FALSE, FALSE, NULL); - m_hAudioThreadTerminateRequest = CreateEvent(NULL, FALSE, FALSE, NULL); - m_hAudioThreadGoneIdle = CreateEvent(NULL, TRUE, FALSE, NULL); - m_hPlayThread = CreateThread(NULL, 0, AudioThreadWrapper, (LPVOID)this, 0, &m_dwPlayThreadId); -} - - -CAudioThread::~CAudioThread() -//--------------------------- -{ - MPT_TRACE(); - if(m_hPlayThread != NULL) - { - SetEvent(m_hAudioThreadTerminateRequest); - WaitForSingleObject(m_hPlayThread, INFINITE); - m_dwPlayThreadId = 0; - m_hPlayThread = NULL; - } - if(m_hAudioThreadTerminateRequest) - { - CloseHandle(m_hAudioThreadTerminateRequest); - m_hAudioThreadTerminateRequest = 0; - } - if(m_hAudioThreadGoneIdle != NULL) - { - CloseHandle(m_hAudioThreadGoneIdle); - m_hAudioThreadGoneIdle = 0; - } - if(m_hAudioWakeUp != NULL) - { - CloseHandle(m_hAudioWakeUp); - m_hAudioWakeUp = NULL; - } -} - - -CPriorityBooster::CPriorityBooster(bool boostPriority) -//---------------------------------------------------- - : m_HasVista(false) - , pAvSetMmThreadCharacteristics(nullptr) - , pAvRevertMmThreadCharacteristics(nullptr) - , m_BoostPriority(boostPriority) - , task_idx(0) - , hTask(NULL) -{ - - MPT_TRACE(); - - m_HasVista = mpt::Windows::Version::IsAtLeast(mpt::Windows::Version::WinVista); - - if(m_HasVista) - { - m_AvRtDLL = mpt::Library(mpt::LibraryPath::System(MPT_PATHSTRING("avrt"))); - if(m_AvRtDLL.IsValid()) - { - if(!m_AvRtDLL.Bind(pAvSetMmThreadCharacteristics, "AvSetMmThreadCharacteristicsA")) - { - m_HasVista = false; - } - if(!m_AvRtDLL.Bind(pAvRevertMmThreadCharacteristics, "AvRevertMmThreadCharacteristics")) - { - m_HasVista = false; - } - } else - { - m_HasVista = false; - } - } - - #ifdef _DEBUG - m_BoostPriority = false; - #endif - - if(m_BoostPriority) - { - if(m_HasVista) - { - hTask = pAvSetMmThreadCharacteristics(TEXT("Pro Audio"), &task_idx); - } else - { - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); - } - } - -} - - -CPriorityBooster::~CPriorityBooster() -//----------------------------------- -{ - - MPT_TRACE(); - - if(m_BoostPriority) - { - if(m_HasVista) - { - pAvRevertMmThreadCharacteristics(hTask); - hTask = NULL; - task_idx = 0; - } else - { - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); - } - } - - pAvRevertMmThreadCharacteristics = nullptr; - pAvSetMmThreadCharacteristics = nullptr; - -} - - -class CPeriodicWaker -{ -private: - CAudioThread &self; - - double sleepSeconds; - long sleepMilliseconds; - int64 sleep100Nanoseconds; - - Util::MultimediaClock clock_noxp; - - bool period_nont_set; - bool periodic_nt_timer; - - HANDLE sleepEvent; - -public: - - CPeriodicWaker(CAudioThread &self_, double sleepSeconds_) : self(self_), sleepSeconds(sleepSeconds_) - //-------------------------------------------------------------------------------------------------- - { - - MPT_TRACE(); - - sleepMilliseconds = static_cast<long>(sleepSeconds * 1000.0); - sleep100Nanoseconds = static_cast<int64>(sleepSeconds * 10000000.0); - if(sleepMilliseconds < 1) sleepMilliseconds = 1; - if(sleep100Nanoseconds < 1) sleep100Nanoseconds = 1; - - period_nont_set = false; - periodic_nt_timer = (sleep100Nanoseconds >= 10000); // can be represented as a millisecond period, otherwise use non-periodic timers which allow higher precision but might me slower because we have to set them again in each period - - sleepEvent = NULL; - - if(mpt::Windows::Version::IsNT()) - { - if(periodic_nt_timer) - { - sleepEvent = CreateWaitableTimer(NULL, FALSE, NULL); - LARGE_INTEGER dueTime; - dueTime.QuadPart = 0 - sleep100Nanoseconds; // negative time means relative - SetWaitableTimer(sleepEvent, &dueTime, sleepMilliseconds, NULL, NULL, FALSE); - } else - { - sleepEvent = CreateWaitableTimer(NULL, TRUE, NULL); - } - } else - { - sleepEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - clock_noxp.SetResolution(1); // increase resolution of multimedia timer - period_nont_set = true; - } - - } - - long GetSleepMilliseconds() const - //------------------------------- - { - return sleepMilliseconds; - } - - HANDLE GetWakeupEvent() const - //--------------------------- - { - return sleepEvent; - } - - void Retrigger() - //-------------- - { - MPT_TRACE(); - if(mpt::Windows::Version::IsNT()) - { - if(!periodic_nt_timer) - { - LARGE_INTEGER dueTime; - dueTime.QuadPart = 0 - sleep100Nanoseconds; // negative time means relative - SetWaitableTimer(sleepEvent, &dueTime, 0, NULL, NULL, FALSE); - } - } else - { - timeSetEvent(sleepMilliseconds, 1, (LPTIMECALLBACK)sleepEvent, NULL, TIME_ONESHOT | TIME_CALLBACK_EVENT_SET); - } - } - - CPeriodicWaker::~CPeriodicWaker() - //------------------------------- - { - MPT_TRACE(); - if(mpt::Windows::Version::IsNT()) - { - if(periodic_nt_timer) - { - CancelWaitableTimer(sleepEvent); - } - CloseHandle(sleepEvent); - sleepEvent = NULL; - } else - { - if(period_nont_set) - { - clock_noxp.SetResolution(0); - period_nont_set = false; - } - CloseHandle(sleepEvent); - sleepEvent = NULL; - } - } - -}; - - -DWORD WINAPI CAudioThread::AudioThreadWrapper(LPVOID user) -{ - return ((CAudioThread*)user)->AudioThread(); -} -DWORD CAudioThread::AudioThread() -//------------------------------- -{ - MPT_TRACE(); - - bool terminate = false; - while(!terminate) - { - - bool idle = true; - while(!terminate && idle) - { - HANDLE waithandles[2] = {m_hAudioThreadTerminateRequest, m_hAudioWakeUp}; - SetEvent(m_hAudioThreadGoneIdle); - switch(WaitForMultipleObjects(2, waithandles, FALSE, INFINITE)) - { - case WAIT_OBJECT_0: - terminate = true; - break; - case WAIT_OBJECT_0+1: - idle = false; - break; - } - } - - if(!terminate) - { - - CPriorityBooster priorityBooster(m_SoundDevice.m_Settings.BoostThreadPriority); - CPeriodicWaker periodicWaker(*this, m_WakeupInterval); - - m_SoundDevice.StartFromSoundThread(); - - while(!terminate && IsActive()) - { - - m_SoundDevice.FillAudioBufferLocked(); - - periodicWaker.Retrigger(); - - if(m_hHardwareWakeupEvent != INVALID_HANDLE_VALUE) - { - HANDLE waithandles[4] = {m_hAudioThreadTerminateRequest, m_hAudioWakeUp, m_hHardwareWakeupEvent, periodicWaker.GetWakeupEvent()}; - switch(WaitForMultipleObjects(4, waithandles, FALSE, periodicWaker.GetSleepMilliseconds())) - { - case WAIT_OBJECT_0: - terminate = true; - break; - } - } else - { - HANDLE waithandles[3] = {m_hAudioThreadTerminateRequest, m_hAudioWakeUp, periodicWaker.GetWakeupEvent()}; - switch(WaitForMultipleObjects(3, waithandles, FALSE, periodicWaker.GetSleepMilliseconds())) - { - case WAIT_OBJECT_0: - terminate = true; - break; - } - } - - } - - m_SoundDevice.StopFromSoundThread(); - - } - - } - - SetEvent(m_hAudioThreadGoneIdle); - - return 0; - -} - - -void CAudioThread::SetWakeupEvent(HANDLE ev) -//------------------------------------------ -{ - MPT_TRACE(); - m_hHardwareWakeupEvent = ev; -} - - -void CAudioThread::SetWakeupInterval(double seconds) -//-------------------------------------------------- -{ - MPT_TRACE(); - m_WakeupInterval = seconds; -} - - -void CAudioThread::Activate() -//--------------------------- -{ - MPT_TRACE(); - if(InterlockedExchangeAdd(&m_AudioThreadActive, 0)) - { - MPT_ASSERT_ALWAYS(false); - return; - } - ResetEvent(m_hAudioThreadGoneIdle); - InterlockedExchange(&m_AudioThreadActive, 1); - SetEvent(m_hAudioWakeUp); -} - - -void CAudioThread::Deactivate() -//----------------------------- -{ - MPT_TRACE(); - if(!InterlockedExchangeAdd(&m_AudioThreadActive, 0)) - { - MPT_ASSERT_ALWAYS(false); - return; - } - InterlockedExchange(&m_AudioThreadActive, 0); - WaitForSingleObject(m_hAudioThreadGoneIdle, INFINITE); -} - - -void CSoundDeviceWithThread::FillAudioBufferLocked() -//-------------------------------------------------- -{ - MPT_TRACE(); - SourceFillAudioBufferLocked(); -} - - -void CSoundDeviceWithThread::SetWakeupEvent(HANDLE ev) -//---------------------------------------------------- -{ - MPT_TRACE(); - m_AudioThread.SetWakeupEvent(ev); -} - - -void CSoundDeviceWithThread::SetWakeupInterval(double seconds) -//------------------------------------------------------------ -{ - MPT_TRACE(); - m_AudioThread.SetWakeupInterval(seconds); -} - - -bool CSoundDeviceWithThread::InternalStart() -//------------------------------------------ -{ - MPT_TRACE(); - m_AudioThread.Activate(); - return true; -} - - -void CSoundDeviceWithThread::InternalStop() -//----------------------------------------- -{ - MPT_TRACE(); - m_AudioThread.Deactivate(); -} - - -} // namespace SoundDevice - - -OPENMPT_NAMESPACE_END Deleted: trunk/OpenMPT/sounddev/SoundDeviceThread.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceThread.h 2015-02-11 14:36:10 UTC (rev 4750) +++ trunk/OpenMPT/sounddev/SoundDeviceThread.h 2015-02-11 17:16:10 UTC (rev 4751) @@ -1,97 +0,0 @@ -/* - * SoundDeviceThread.h - * ------------------- - * Purpose: Sound device threading driver helpers. - * Notes : (currently none) - * Authors: Olivier Lapicque - * OpenMPT Devs - * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. - */ - - -#pragma once - -#include "SoundDevice.h" - -#include "../common/misc_util.h" - - -OPENMPT_NAMESPACE_BEGIN - - -namespace SoundDevice { - - -class CSoundDeviceWithThread; - - -class CPriorityBooster -{ -private: - typedef HANDLE (WINAPI *FAvSetMmThreadCharacteristics)(LPCTSTR, LPDWORD); - typedef BOOL (WINAPI *FAvRevertMmThreadCharacteristics)(HANDLE); -private: - bool m_HasVista; - mpt::Library m_AvRtDLL; - FAvSetMmThreadCharacteristics pAvSetMmThreadCharacteristics; - FAvRevertMmThreadCharacteristics pAvRevertMmThreadCharacteristics; - bool m_BoostPriority; - DWORD task_idx; - HANDLE hTask; -public: - CPriorityBooster(bool boostPriority); - ~CPriorityBooster(); -}; - - -class CAudioThread -{ - friend class CPeriodicWaker; -private: - CSoundDeviceWithThread & m_SoundDevice; - - double m_WakeupInterval; - HANDLE m_hAudioWakeUp; - HANDLE m_hPlayThread; - HANDLE m_hAudioThreadTerminateRequest; - HANDLE m_hAudioThreadGoneIdle; - HANDLE m_hHardwareWakeupEvent; - DWORD m_dwPlayThreadId; - LONG m_AudioThreadActive; - static DWORD WINAPI AudioThreadWrapper(LPVOID user); - DWORD AudioThread(); - bool IsActive() { return InterlockedExchangeAdd(&m_AudioThreadActive, 0)?true:false; } -public: - CAudioThread(CSoundDeviceWithThread &SoundDevice); - ~CAudioThread(); - void Activate(); - void Deactivate(); - void SetWakeupEvent(HANDLE ev); - void SetWakeupInterval(double seconds); -}; - - -class CSoundDeviceWithThread : public SoundDevice::Base -{ - friend class CAudioThread; -protected: - CAudioThread m_AudioThread; -private: - void FillAudioBufferLocked(); -protected: - void SetWakeupEvent(HANDLE ev); - void SetWakeupInterval(double seconds); -public: - CSoundDeviceWithThread(SoundDevice::Info info) : SoundDevice::Base(info), m_AudioThread(*this) {} - virtual ~CSoundDeviceWithThread() {} - bool InternalStart(); - void InternalStop(); - virtual void StartFromSoundThread() = 0; - virtual void StopFromSoundThread() = 0; -}; - - -} // namespace SoundDevice - - -OPENMPT_NAMESPACE_END Copied: trunk/OpenMPT/sounddev/SoundDeviceUtilities.cpp (from rev 4750, trunk/OpenMPT/sounddev/SoundDeviceThread.cpp) =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceUtilities.cpp (rev 0) +++ trunk/OpenMPT/sounddev/SoundDeviceUtilities.cpp 2015-02-11 17:16:10 UTC (rev 4751) @@ -0,0 +1,434 @@ +/* + * SoundDeviceUtilities.cpp + * ------------------------ + * Purpose: Sound device utilities. + * Notes : (currently none) + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#include "stdafx.h" + +#include "SoundDevice.h" +#include "SoundDeviceUtilities.h" + +#include "../common/misc_util.h" + +#include <algorithm> + +#include <mmsystem.h> + + +OPENMPT_NAMESPACE_BEGIN + + +namespace SoundDevice { + + +CAudioThread::CAudioThread(CSoundDeviceWithThread &SoundDevice) : m_SoundDevice(SoundDevice) +//------------------------------------------------------------------------------------------ +{ + MPT_TRACE(); + m_WakeupInterval = 0.0; + m_hPlayThread = NULL; + m_dwPlayThreadId = 0; + m_hAudioWakeUp = NULL; + m_hAudioThreadTerminateRequest = NULL; + m_hAudioThreadGoneIdle = NULL; + m_hHardwareWakeupEvent = INVALID_HANDLE_VALUE; + m_AudioThreadActive = 0; + m_hAudioWakeUp = CreateEvent(NULL, FALSE, FALSE, NULL); + m_hAudioThreadTerminateRequest = CreateEvent(NULL, FALSE, FALSE, NULL); + m_hAudioThreadGoneIdle = CreateEvent(NULL, TRUE, FALSE, NULL); + m_hPlayThread = CreateThread(NULL, 0, AudioThreadWrapper, (LPVOID)this, 0, &m_dwPlayThreadId); +} + + +CAudioThread::~CAudioThread() +//--------------------------- +{ + MPT_TRACE(); + if(m_hPlayThread != NULL) + { + SetEvent(m_hAudioThreadTerminateRequest); + WaitForSingleObject(m_hPlayThread, INFINITE); + m_dwPlayThreadId = 0; + m_hPlayThread = NULL; + } + if(m_hAudioThreadTerminateRequest) + { + CloseHandle(m_hAudioThreadTerminateRequest); + m_hAudioThreadTerminateRequest = 0; + } + if(m_hAudioThreadGoneIdle != NULL) + { + CloseHandle(m_hAudioThreadGoneIdle); + m_hAudioThreadGoneIdle = 0; + } + if(m_hAudioWakeUp != NULL) + { + CloseHandle(m_hAudioWakeUp); + m_hAudioWakeUp = NULL; + } +} + + +CPriorityBooster::CPriorityBooster(bool boostPriority) +//---------------------------------------------------- + : m_HasVista(false) + , pAvSetMmThreadCharacteristics(nullptr) + , pAvRevertMmThreadCharacteristics(nullptr) + , m_BoostPriority(boostPriority) + , task_idx(0) + , hTask(NULL) +{ + + MPT_TRACE(); + + m_HasVista = mpt::Windows::Version::IsAtLeast(mpt::Windows::Version::WinVista); + + if(m_HasVista) + { + m_AvRtDLL = mpt::Library(mpt::LibraryPath::System(MPT_PATHSTRING("avrt"))); + if(m_AvRtDLL.IsValid()) + { + if(!m_AvRtDLL.Bind(pAvSetMmThreadCharacteristics, "AvSetMmThreadCharacteristicsA")) + { + m_HasVista = false; + } + if(!m_AvRtDLL.Bind(pAvRevertMmThreadCharacteristics, "AvRevertMmThreadCharacteristics")) + { + m_HasVista = false; + } + } else + { + m_HasVista = false; + } + } + + #ifdef _DEBUG + m_BoostPriority = false; + #endif + + if(m_BoostPriority) + { + if(m_HasVista) + { + hTask = pAvSetMmThreadCharacteristics(TEXT("Pro Audio"), &task_idx); + } else + { + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); + } + } + +} + + +CPriorityBooster::~CPriorityBooster() +//----------------------------------- +{ + + MPT_TRACE(); + + if(m_BoostPriority) + { + if(m_HasVista) + { + pAvRevertMmThreadCharacteristics(hTask); + hTask = NULL; + task_idx = 0; + } else + { + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); + } + } + + pAvRevertMmThreadCharacteristics = nullptr; + pAvSetMmThreadCharacteristics = nullptr; + +} + + +class CPeriodicWaker +{ +private: + CAudioThread &self; + + double sleepSeconds; + long sleepMilliseconds; + int64 sleep100Nanoseconds; + + Util::MultimediaClock clock_noxp; + + bool period_nont_set; + bool periodic_nt_timer; + + HANDLE sleepEvent; + +public: + + CPeriodicWaker(CAudioThread &self_, double sleepSeconds_) : self(self_), sleepSeconds(sleepSeconds_) + //-------------------------------------------------------------------------------------------------- + { + + MPT_TRACE(); + + sleepMilliseconds = static_cast<long>(sleepSeconds * 1000.0); + sleep100Nanoseconds = static_cast<int64>(sleepSeconds * 10000000.0); + if(sleepMilliseconds < 1) sleepMilliseconds = 1; + if(sleep100Nanoseconds < 1) sleep100Nanoseconds = 1; + + period_nont_set = false; + periodic_nt_timer = (sleep100Nanoseconds >= 10000); // can be represented as a millisecond period, otherwise use non-periodic timers which allow higher precision but might me slower because we have to set them again in each period + + sleepEvent = NULL; + + if(mpt::Windows::Version::IsNT()) + { + if(periodic_nt_timer) + { + sleepEvent = CreateWaitableTimer(NULL, FALSE, NULL); + LARGE_INTEGER dueTime; + dueTime.QuadPart = 0 - sleep100Nanoseconds; // negative time means relative + SetWaitableTimer(sleepEvent, &dueTime, sleepMilliseconds, NULL, NULL, FALSE); + } else + { + sleepEvent = CreateWaitableTimer(NULL, TRUE, NULL); + } + } else + { + sleepEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + clock_noxp.SetResolution(1); // increase resolution of multimedia timer + period_nont_set = true; + } + + } + + long GetSleepMilliseconds() const + //------------------------------- + { + return sleepMilliseconds; + } + + HANDLE GetWakeupEvent() const + //--------------------------- + { + return sleepEvent; + } + + void Retrigger() + //-------------- + { + MPT_TRACE(); + if(mpt::Windows::Version::IsNT()) + { + if(!periodic_nt_timer) + { + LARGE_INTEGER dueTime; + dueTime.QuadPart = 0 - sleep100Nanoseconds; // negative time means relative + SetWaitableTimer(sleepEvent, &dueTime, 0, NULL, NULL, FALSE); + } + } else + { + timeSetEvent(sleepMilliseconds, 1, (LPTIMECALLBACK)sleepEvent, NULL, TIME_ONESHOT | TIME_CALLBACK_EVENT_SET); + } + } + + CPeriodicWaker::~CPeriodicWaker() + //------------------------------- + { + MPT_TRACE(); + if(mpt::Windows::Version::IsNT()) + { + if(periodic_nt_timer) + { + CancelWaitableTimer(sleepEvent); + } + CloseHandle(sleepEvent); + sleepEvent = NULL; + } else + { + if(period_nont_set) + { + clock_noxp.SetResolution(0); + period_nont_set = false; + } + CloseHandle(sleepEvent); + sleepEvent = NULL; + } + } + +}; + + +DWORD WINAPI CAudioThread::AudioThreadWrapper(LPVOID user) +{ + return ((CAudioThread*)user)->AudioThread(); +} +DWORD CAudioThread::AudioThread() +//------------------------------- +{ + MPT_TRACE(); + + bool terminate = false; + while(!terminate) + { + + bool idle = true; + while(!terminate && idle) + { + HANDLE waithandles[2] = {m_hAudioThreadTerminateRequest, m_hAudioWakeUp}; + SetEvent(m_hAudioThreadGoneIdle); + switch(WaitForMultipleObjects(2, waithandles, FALSE, INFINITE)) + { + case WAIT_OBJECT_0: + terminate = true; + break; + case WAIT_OBJECT_0+1: + idle = false; + break; + } + } + + if(!terminate) + { + + CPriorityBooster priorityBooster(m_SoundDevice.m_Settings.BoostThreadPriority); + CPeriodicWaker periodicWaker(*this, m_WakeupInterval); + + m_SoundDevice.StartFromSoundThread(); + + while(!terminate && IsActive()) + { + + m_SoundDevice.FillAudioBufferLocked(); + + periodicWaker.Retrigger(); + + if(m_hHardwareWakeupEvent != INVALID_HANDLE_VALUE) + { + HANDLE waithandles[4] = {m_hAudioThreadTerminateRequest, m_hAudioWakeUp, m_hHardwareWakeupEvent, periodicWaker.GetWakeupEvent()}; + switch(WaitForMultipleObjects(4, waithandles, FALSE, periodicWaker.GetSleepMilliseconds())) + { + case WAIT_OBJECT_0: + terminate = true; + break; + } + } else + { + HANDLE waithandles[3] = {m_hAudioThreadTerminateRequest, m_hAudioWakeUp, periodicWaker.GetWakeupEvent()}; + switch(WaitForMultipleObjects(3, waithandles, FALSE, periodicWaker.GetSleepMilliseconds())) + { + case WAIT_OBJECT_0: + terminate = true; + break; + } + } + + } + + m_SoundDevice.StopFromSoundThread(); + + } + + } + + SetEvent(m_hAudioThreadGoneIdle); + + return 0; + +} + + +void CAudioThread::SetWakeupEvent(HANDLE ev) +//------------------------------------------ +{ + MPT_TRACE(); + m_hHardwareWakeupEvent = ev; +} + + +void CAudioThread::SetWakeupInterval(double seconds) +//-------------------------------------------------- +{ + MPT_TRACE(); + m_WakeupInterval = seconds; +} + + +void CAudioThread::Activate() +//--------------------------- +{ + MPT_TRACE(); + if(InterlockedExchangeAdd(&m_AudioThreadActive, 0)) + { + MPT_ASSERT_ALWAYS(false); + return; + } + ResetEvent(m_hAudioThreadGoneIdle); + InterlockedExchange(&m_AudioThreadActive, 1); + SetEvent(m_hAudioWakeUp); +} + + +void CAudioThread::Deactivate() +//----------------------------- +{ + MPT_TRACE(); + if(!InterlockedExchangeAdd(&m_AudioThreadActive, 0)) + { + MPT_ASSERT_ALWAYS(false); + return; + } + InterlockedExchange(&m_AudioThreadActive, 0); + WaitForSingleObject(m_hAudioThreadGoneIdle, INFINITE); +} + + +void CSoundDeviceWithThread::FillAudioBufferLocked() +//-------------------------------------------------- +{ + MPT_TRACE(); + SourceFillAudioBufferLocked(); +} + + +void CSoundDeviceWithThread::SetWakeupEvent(HANDLE ev) +//---------------------------------------------------- +{ + MPT_TRACE(); + m_AudioThread.SetWakeupEvent(ev); +} + + +void CSoundDeviceWithThread::SetWakeupInterval(double seconds) +//------------------------------------------------------------ +{ + MPT_TRACE(); + m_AudioThread.SetWakeupInterval(seconds); +} + + +bool CSoundDeviceWithThread::InternalStart() +//------------------------------------------ +{ + MPT_TRACE(); + m_AudioThread.Activate(); + return true; +} + + +void CSoundDeviceWithThread::InternalStop() +//----------------------------------------- +{ + MPT_TRACE(); + m_AudioThread.Deactivate(); +} + + +} // namespace SoundDevice + + +OPENMPT_NAMESPACE_END Copied: trunk/OpenMPT/sounddev/SoundDeviceUtilities.h (from rev 4750, trunk/OpenMPT/sounddev/SoundDeviceThread.h) =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceUtilities.h (rev 0) +++ trunk/OpenMPT/sounddev/SoundDeviceUtilities.h 2015-02-11 17:16:10 UTC (rev 4751) @@ -0,0 +1,97 @@ +/* + * SoundDeviceUtilities.h + * ---------------------- + * Purpose: Sound device utilities. + * Notes : (currently none) + * Authors: Olivier Lapicque + * OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + +#include "SoundDevice.h" + +#include "../common/misc_util.h" + + +OPENMPT_NAMESPACE_BEGIN + + +namespace SoundDevice { + + +class CSoundDeviceWithThread; + + +class CPriorityBooster +{ +private: + typedef HANDLE (WINAPI *FAvSetMmThreadCharacteristics)(LPCTSTR, LPDWORD); + typedef BOOL (WINAPI *FAvRevertMmThreadCharacteristics)(HANDLE); +private: + bool m_HasVista; + mpt::Library m_AvRtDLL; + FAvSetMmThreadCharacteristics pAvSetMmThreadCharacteristics; + FAvRevertMmThreadCharacteristics pAvRevertMmThreadCharacteristics; + bool m_BoostPriority; + DWORD task_idx; + HANDLE hTask; +public: + CPriorityBooster(bool boostPriority); + ~CPriorityBooster(); +}; + + +class CAudioThread +{ + friend class CPeriodicWaker; +private: + CSoundDeviceWithThread & m_SoundDevice; + + double m_WakeupInterval; + HANDLE m_hAudioWakeUp; + HANDLE m_hPlayThread; + HANDLE m_hAudioThreadTerminateRequest; + HANDLE m_hAudioThreadGoneIdle; + HANDLE m_hHardwareWakeupEvent; + DWORD m_dwPlayThreadId; + LONG m_AudioThreadActive; + static DWORD WINAPI AudioThreadWrapper(LPVOID user); + DWORD AudioThread(); + bool IsActive() { return InterlockedExchangeAdd(&m_AudioThreadActive, 0)?true:false; } +public: + CAudioThread(CSoundDeviceWithThread &SoundDevice); + ~CAudioThread(); + void Activate(); + void Deactivate(); + void SetWakeupEvent(HANDLE ev); + void SetWakeupInterval(double seconds); +}; + + +class CSoundDeviceWithThread : public SoundDevice::Base +{ + friend class CAudioThread; +protected: + CAudioThread m_AudioThread; +private: + void FillAudioBufferLocked(); +protected: + void SetWakeupEvent(HANDLE ev); + void SetWakeupInterval(double seconds); +public: + CSoundDeviceWithThread(SoundDevice::Info info) : SoundDevice::Base(info), m_AudioThread(*this) {} + virtual ~CSoundDeviceWithThread() {} + bool InternalStart(); + void InternalStop(); + virtual void StartFromSoundThread() = 0; + virtual void StopFromSoundThread() = 0; +}; + + +} // namespace SoundDevice + + +OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2015-02-11 14:36:10 UTC (rev 4750) +++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2015-02-11 17:16:10 UTC (rev 4751) @@ -12,7 +12,7 @@ #include "stdafx.h" #include "SoundDevice.h" -#include "SoundDeviceThread.h" +#include "SoundDeviceUtilities.h" #include "SoundDeviceWaveout.h" Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2015-02-11 14:36:10 UTC (rev 4750) +++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2015-02-11 17:16:10 UTC (rev 4751) @@ -12,7 +12,7 @@ #pragma once #include "SoundDevice.h" -#include "SoundDeviceThread.h" +#include "SoundDeviceUtilities.h" #include <MMSystem.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-12 21:35:20
|
Revision: 4753 http://sourceforge.net/p/modplug/code/4753 Author: manxorist Date: 2015-02-12 21:35:14 +0000 (Thu, 12 Feb 2015) Log Message: ----------- [New] libopenmpt: Fake mpt::Library implementation on Android that expects foreign shared object to be already loaded from the Java side and resolved required symbols globally. (completely untested code) [Mod] libopenmpt: Build Android version with MO3 support by default Modified Paths: -------------- trunk/OpenMPT/build/android_ndk/Android.mk trunk/OpenMPT/common/misc_util.cpp Modified: trunk/OpenMPT/build/android_ndk/Android.mk =================================================================== --- trunk/OpenMPT/build/android_ndk/Android.mk 2015-02-12 18:53:42 UTC (rev 4752) +++ trunk/OpenMPT/build/android_ndk/Android.mk 2015-02-12 21:35:14 UTC (rev 4753) @@ -10,8 +10,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/common $(LOCAL_PATH)/build/svn_version -LOCAL_CFLAGS := -fvisibility=hidden -DLIBOPENMPT_BUILD -DMPT_WITH_ZLIB -LOCAL_CPPFLAGS := -std=c++11 -fvisibility=hidden -DLIBOPENMPT_BUILD -DMPT_WITH_ZLIB +LOCAL_CFLAGS := -fvisibility=hidden -DLIBOPENMPT_BUILD -DMPT_WITH_ZLIB -DMPT_WITH_MO3 +LOCAL_CPPFLAGS := -std=c++11 -fvisibility=hidden -DLIBOPENMPT_BUILD -DMPT_WITH_ZLIB -DMPT_WITH_MO3 LOCAL_LDLIBS := -lz LOCAL_SRC_FILES := \ Modified: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp 2015-02-12 18:53:42 UTC (rev 4752) +++ trunk/OpenMPT/common/misc_util.cpp 2015-02-12 21:35:14 UTC (rev 4753) @@ -17,7 +17,11 @@ #include <time.h> #if defined(MPT_WITH_DYNBIND) -#if !MPT_OS_WINDOWS +#if MPT_OS_WINDOWS +#include <windows.h> +#elif MPT_OS_ANDROID +#include <dlfcn.h> +#else #include <ltdl.h> #endif #endif @@ -1016,12 +1020,52 @@ }; -#else +#elif MPT_OS_ANDROID +// Fake implementation. +// Load shared objects from the JAVA side of things. class LibraryHandle { +public: + + LibraryHandle(const mpt::LibraryPath &path) + { + return; + } + + ~LibraryHandle() + { + return; + } + +public: + + bool IsValid() const + { + return true; + } + + FuncPtr GetProcAddress(const std::string &symbol) const + { + if(!IsValid()) + { + return nullptr; + } + return reinterpret_cast<FuncPtr>(dlsym(0, symbol.c_str())); + } + +}; + + + +#else // MPT_OS + + +class LibraryHandle +{ + private: bool inited; @@ -1074,7 +1118,7 @@ }; -#endif +#endif // MPT_OS LibraryPath::LibraryPath(mpt::LibrarySearchPath searchPath, class mpt::PathString const &fileName) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-13 09:17:17
|
Revision: 4754 http://sourceforge.net/p/modplug/code/4754 Author: manxorist Date: 2015-02-13 09:17:11 +0000 (Fri, 13 Feb 2015) Log Message: ----------- [Doc] libopenmpt: Document unmo3 support for Android. Modified Paths: -------------- trunk/OpenMPT/build/android_ndk/README.AndroidNDK.txt trunk/OpenMPT/libopenmpt/dox/changelog.md Modified: trunk/OpenMPT/build/android_ndk/README.AndroidNDK.txt =================================================================== --- trunk/OpenMPT/build/android_ndk/README.AndroidNDK.txt 2015-02-12 21:35:14 UTC (rev 4753) +++ trunk/OpenMPT/build/android_ndk/README.AndroidNDK.txt 2015-02-13 09:17:11 UTC (rev 4754) @@ -7,4 +7,11 @@ 2. Copy build/android_ndk/* into the root of libopenmpt, i.e. also into the jni directory and adjust as needed. 3. Use ndk-build as usual. + 4. libopenmpt for Android gets built with un4seen unmo3 library support by + default. + If you want to disable it, remove the -DMPT_WITH_MO3 define in Android.mk. + If you want to use it, you have to load the unmo3 shared object + additionally to libopenmpt from your Java code because shared object + path handling is rather confused on Android. libopenmpt will then + automatically pick up the required symbols. Modified: trunk/OpenMPT/libopenmpt/dox/changelog.md =================================================================== --- trunk/OpenMPT/libopenmpt/dox/changelog.md 2015-02-12 21:35:14 UTC (rev 4753) +++ trunk/OpenMPT/libopenmpt/dox/changelog.md 2015-02-13 09:17:11 UTC (rev 4754) @@ -9,6 +9,8 @@ * Makefile configuration filenames changed from `build/make/Makefile.config.*` to `build/make/config-*.mk`. + * libopenmpt for Android now supports unmo3 from un4seen. See + `build/android_ndk/README.AndroidNDK.txt` for details. * [Bug] Fix out-of-bounds read in mixer code for ProTracker-compatible MOD files was introduced back in r4223 / beta6. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-14 14:20:25
|
Revision: 4755 http://sourceforge.net/p/modplug/code/4755 Author: manxorist Date: 2015-02-14 14:20:11 +0000 (Sat, 14 Feb 2015) Log Message: ----------- [Mod] libopenmpt: Add a MPT_LINKED_UNMO3 macro which results in resolving unmo3 symbols directly when linking libopenmpt instead of dynamically at runtime. This requires the build system to link against unmo3, obviously. [Mod] build: Split Android-unmo3.mk file from the regular one without unmo3 support and directly link the unmo3 library in the former. [Doc] libopenmpt: Update Android docs. Modified Paths: -------------- trunk/OpenMPT/build/android_ndk/Android.mk trunk/OpenMPT/build/android_ndk/README.AndroidNDK.txt trunk/OpenMPT/soundlib/Load_mo3.cpp Added Paths: ----------- trunk/OpenMPT/build/android_ndk/Android-unmo3.mk Copied: trunk/OpenMPT/build/android_ndk/Android-unmo3.mk (from rev 4754, trunk/OpenMPT/build/android_ndk/Android.mk) =================================================================== --- trunk/OpenMPT/build/android_ndk/Android-unmo3.mk (rev 0) +++ trunk/OpenMPT/build/android_ndk/Android-unmo3.mk 2015-02-14 14:20:11 UTC (rev 4755) @@ -0,0 +1,139 @@ + +LOCAL_PATH := $(call my-dir) + + +ifeq ($(TARGET_ARCH_ABI),armeabi) +include $(CLEAR_VARS) +LOCAL_MODULE := unmo3 +LOCAL_SRC_FILES := unmo3lib/android/armeabi/libunmo3.so +include $(PREBUILT_SHARED_LIBRARY) +endif + +ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) +include $(CLEAR_VARS) +LOCAL_MODULE := unmo3 +LOCAL_SRC_FILES := unmo3lib/android/armeabi-v7a/libunmo3.so +include $(PREBUILT_SHARED_LIBRARY) +endif + +ifeq ($(TARGET_ARCH_ABI),x86) +include $(CLEAR_VARS) +LOCAL_MODULE := unmo3 +LOCAL_SRC_FILES := unmo3lib/android/x86/libunmo3.so +include $(PREBUILT_SHARED_LIBRARY) +endif + + +include $(CLEAR_VARS) + +LOCAL_MODULE := openmpt + +LOCAL_CPP_FEATURES += exceptions +LOCAL_CPP_FEATURES += rtti + +LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/common $(LOCAL_PATH)/build/svn_version + +LOCAL_CFLAGS := -fvisibility=hidden -DLIBOPENMPT_BUILD -DMPT_WITH_ZLIB -DMPT_WITH_MO3 -DMPT_LINKED_UNMO3 +LOCAL_CPPFLAGS := -std=c++11 -fvisibility=hidden -DLIBOPENMPT_BUILD -DMPT_WITH_ZLIB -DMPT_WITH_MO3 -DMPT_LINKED_UNMO3 +LOCAL_LDLIBS := -lz + +ifeq ($(TARGET_ARCH_ABI),armeabi) +LOCAL_SHARED_LIBRARIES := unmo3 +endif +ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) +LOCAL_SHARED_LIBRARIES := unmo3 +endif +ifeq ($(TARGET_ARCH_ABI),x86) +LOCAL_SHARED_LIBRARIES := unmo3 +endif + +LOCAL_SRC_FILES := \ + common/stdafx.cpp \ + common/AudioCriticalSection.cpp \ + common/ComponentManager.cpp \ + common/Logging.cpp \ + common/misc_util.cpp \ + common/mptFileIO.cpp \ + common/mptIO.cpp \ + common/mptPathString.cpp \ + common/mptString.cpp \ + common/Profiler.cpp \ + common/serialization_utils.cpp \ + common/typedefs.cpp \ + common/version.cpp \ + libopenmpt/libopenmpt_c.cpp \ + libopenmpt/libopenmpt_cxx.cpp \ + libopenmpt/libopenmpt_impl.cpp \ + libopenmpt/libopenmpt_ext.cpp \ + soundlib/Dither.cpp \ + soundlib/Dlsbank.cpp \ + soundlib/Fastmix.cpp \ + soundlib/ITCompression.cpp \ + soundlib/ITTools.cpp \ + soundlib/Load_669.cpp \ + soundlib/Load_amf.cpp \ + soundlib/Load_ams.cpp \ + soundlib/Load_dbm.cpp \ + soundlib/Load_digi.cpp \ + soundlib/Load_dmf.cpp \ + soundlib/Load_dsm.cpp \ + soundlib/Load_far.cpp \ + soundlib/Load_gdm.cpp \ + soundlib/Load_imf.cpp \ + soundlib/Load_it.cpp \ + soundlib/Load_itp.cpp \ + soundlib/load_j2b.cpp \ + soundlib/Load_mdl.cpp \ + soundlib/Load_med.cpp \ + soundlib/Load_mid.cpp \ + soundlib/Load_mo3.cpp \ + soundlib/Load_mod.cpp \ + soundlib/Load_mt2.cpp \ + soundlib/Load_mtm.cpp \ + soundlib/Load_okt.cpp \ + soundlib/Load_psm.cpp \ + soundlib/Load_ptm.cpp \ + soundlib/Load_s3m.cpp \ + soundlib/Load_stm.cpp \ + soundlib/Load_ult.cpp \ + soundlib/Load_umx.cpp \ + soundlib/Load_wav.cpp \ + soundlib/Load_xm.cpp \ + soundlib/Message.cpp \ + soundlib/MIDIEvents.cpp \ + soundlib/MIDIMacros.cpp \ + soundlib/MixerLoops.cpp \ + soundlib/MixerSettings.cpp \ + soundlib/Mmcmp.cpp \ + soundlib/ModChannel.cpp \ + soundlib/modcommand.cpp \ + soundlib/ModInstrument.cpp \ + soundlib/ModSample.cpp \ + soundlib/ModSequence.cpp \ + soundlib/modsmp_ctrl.cpp \ + soundlib/mod_specifications.cpp \ + soundlib/patternContainer.cpp \ + soundlib/pattern.cpp \ + soundlib/RowVisitor.cpp \ + soundlib/S3MTools.cpp \ + soundlib/SampleFormats.cpp \ + soundlib/SampleIO.cpp \ + soundlib/Sndfile.cpp \ + soundlib/Snd_flt.cpp \ + soundlib/Snd_fx.cpp \ + soundlib/Sndmix.cpp \ + soundlib/SoundFilePlayConfig.cpp \ + soundlib/UpgradeModule.cpp \ + soundlib/Tables.cpp \ + soundlib/Tagging.cpp \ + soundlib/tuningbase.cpp \ + soundlib/tuningCollection.cpp \ + soundlib/tuning.cpp \ + soundlib/WAVTools.cpp \ + soundlib/WindowedFIR.cpp \ + soundlib/XMTools.cpp \ + test/TestToolsLib.cpp \ + test/test.cpp + +include $(BUILD_SHARED_LIBRARY) + Modified: trunk/OpenMPT/build/android_ndk/Android.mk =================================================================== --- trunk/OpenMPT/build/android_ndk/Android.mk 2015-02-13 09:17:11 UTC (rev 4754) +++ trunk/OpenMPT/build/android_ndk/Android.mk 2015-02-14 14:20:11 UTC (rev 4755) @@ -1,6 +1,7 @@ LOCAL_PATH := $(call my-dir) + include $(CLEAR_VARS) LOCAL_MODULE := openmpt @@ -10,8 +11,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/common $(LOCAL_PATH)/build/svn_version -LOCAL_CFLAGS := -fvisibility=hidden -DLIBOPENMPT_BUILD -DMPT_WITH_ZLIB -DMPT_WITH_MO3 -LOCAL_CPPFLAGS := -std=c++11 -fvisibility=hidden -DLIBOPENMPT_BUILD -DMPT_WITH_ZLIB -DMPT_WITH_MO3 +LOCAL_CFLAGS := -fvisibility=hidden -DLIBOPENMPT_BUILD -DMPT_WITH_ZLIB +LOCAL_CPPFLAGS := -std=c++11 -fvisibility=hidden -DLIBOPENMPT_BUILD -DMPT_WITH_ZLIB LOCAL_LDLIBS := -lz LOCAL_SRC_FILES := \ @@ -103,3 +104,4 @@ test/test.cpp include $(BUILD_SHARED_LIBRARY) + Modified: trunk/OpenMPT/build/android_ndk/README.AndroidNDK.txt =================================================================== --- trunk/OpenMPT/build/android_ndk/README.AndroidNDK.txt 2015-02-13 09:17:11 UTC (rev 4754) +++ trunk/OpenMPT/build/android_ndk/README.AndroidNDK.txt 2015-02-14 14:20:11 UTC (rev 4755) @@ -6,12 +6,8 @@ 1. Copy the whole libopenmpt source tree below your jni directory. 2. Copy build/android_ndk/* into the root of libopenmpt, i.e. also into the jni directory and adjust as needed. - 3. Use ndk-build as usual. - 4. libopenmpt for Android gets built with un4seen unmo3 library support by - default. - If you want to disable it, remove the -DMPT_WITH_MO3 define in Android.mk. - If you want to use it, you have to load the unmo3 shared object - additionally to libopenmpt from your Java code because shared object - path handling is rather confused on Android. libopenmpt will then - automatically pick up the required symbols. + 3. If you want to use unmo3, copy the contents of unmo3lib.zip from un4seen + into unmo3lib/ directory in your jni directory and rename Android-unmo3.mk + to Android.mk . + 4. Use ndk-build as usual. Modified: trunk/OpenMPT/soundlib/Load_mo3.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mo3.cpp 2015-02-13 09:17:11 UTC (rev 4754) +++ trunk/OpenMPT/soundlib/Load_mo3.cpp 2015-02-14 14:20:11 UTC (rev 4755) @@ -12,7 +12,25 @@ #include "Loaders.h" #include "../common/ComponentManager.h" +#ifndef NO_MO3 +#if MPT_OS_WINDOWS + #define UNMO3_API __stdcall +#else + #define UNMO3_API +#endif + +#ifdef MPT_LINKED_UNMO3 +extern "C" { +uint32 UNMO3_API UNMO3_GetVersion(void); +void UNMO3_API UNMO3_Free(const void *data); +int32 UNMO3_API UNMO3_Decode(const void **data, uint32 *len, uint32 flags); +}; +#endif // MPT_LINKED_UNMO3 + +#endif // !NO_MO3 + + OPENMPT_NAMESPACE_BEGIN @@ -22,12 +40,6 @@ { MPT_DECLARE_COMPONENT_MEMBERS public: - // Library loaded successfully. - #if MPT_OS_WINDOWS - #define UNMO3_API __stdcall - #else - #define UNMO3_API - #endif uint32 (UNMO3_API * UNMO3_GetVersion)(); // Decode a MO3 file (returns the same "exit codes" as UNMO3.EXE, eg. 0=success) // IN: data/len = MO3 data/len @@ -47,6 +59,13 @@ std::string GetSettingsKey() const { return "UnMO3"; } bool DoInitialize() { +#ifdef MPT_LINKED_UNMO3 + UNMO3_GetVersion = &(::UNMO3_GetVersion); + UNMO3_Free = &(::UNMO3_Free); + UNMO3_Decode_Old = nullptr; + UNMO3_Decode_New = &(::UNMO3_Decode); + return true; +#else AddLibrary("unmo3", mpt::LibraryPath::App(MPT_PATHSTRING("unmo3"))); MPT_COMPONENT_BIND("unmo3", UNMO3_Free); if(MPT_COMPONENT_BIND_OPTIONAL("unmo3", UNMO3_GetVersion)) @@ -60,6 +79,7 @@ MPT_COMPONENT_BIND_SYMBOL("unmo3", "UNMO3_Decode", UNMO3_Decode_Old); } return !HasBindFailed(); +#endif } }; MPT_REGISTERED_COMPONENT(ComponentUnMO3) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-02-15 00:19:22
|
Revision: 4757 http://sourceforge.net/p/modplug/code/4757 Author: saga-games Date: 2015-02-15 00:19:09 +0000 (Sun, 15 Feb 2015) Log Message: ----------- [Fix] Pattern tab: Note-offs from past notes are no longer written when recording notes into patterns (http://bugs.openmpt.org/view.php?id=645) [Mod] OpenMPT: Version is now 1.24.01.09 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-02-14 14:36:58 UTC (rev 4756) +++ trunk/OpenMPT/common/versionNumber.h 2015-02-15 00:19:09 UTC (rev 4757) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 01 -#define VER_MINORMINOR 08 +#define VER_MINORMINOR 09 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2015-02-14 14:36:58 UTC (rev 4756) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2015-02-15 00:19:09 UTC (rev 4757) @@ -173,6 +173,7 @@ MemsetZero(OldVUMeters); // -> CODE#0012 // -> DESC="midi keyboard split" + memset(previousNote, NOTE_NONE, sizeof(previousNote)); memset(splitActiveNoteChannel, 0xFF, sizeof(splitActiveNoteChannel)); memset(activeNoteChannel, 0xFF, sizeof(activeNoteChannel)); m_nPlayPat = PATTERNINDEX_INVALID; @@ -4854,6 +4855,7 @@ const CHANNELINDEX nChn = bChordMode ? chordPatternChannels[0] : (activeNoteMap[note] < sndFile.GetNumChannels() ? activeNoteMap[note] : nChnCursor); CHANNELINDEX noteChannels[MPTChord::notesPerChord] = { nChn }; + ModCommand::NOTE notes[MPTChord::notesPerChord] = { note }; int numNotes = 1; if(pModDoc) @@ -4875,7 +4877,6 @@ { m_Status.reset(psChordPlaying); - ModCommand::NOTE notes[4]; numNotes = ConstructChord(note, notes, prevChordBaseNote); if(!numNotes) { @@ -4944,6 +4945,11 @@ for(int i = 0; i < numNotes; i++) { + if(previousNote[noteChannels[i]] != notes[i]) + { + // This might be a note-off from a past note, but since we already hit a new note on this channel, we ignore it. + continue; + } ModCommand *pTarget = sndFile.Patterns[editPos.pattern].GetpModCommand(editPos.row, noteChannels[i]); // -- write sdx if playing live @@ -5300,6 +5306,11 @@ } } + if(newcmd.IsNote()) + { + previousNote[nChn] = note; + } + // -- if recording, handle post note entry behaviour (move cursor etc..) if(recordEnabled) { @@ -5485,7 +5496,7 @@ chordPatternChannels[i] = curChn; ModCommand &m = newRow[curChn]; - m.note = chordNotes[i]; + previousNote[curChn] = m.note = chordNotes[i]; if(newRow[chn].instr) { m.instr = newRow[chn].instr; Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2015-02-14 14:36:58 UTC (rev 4756) +++ trunk/OpenMPT/mptrack/View_pat.h 2015-02-15 00:19:09 UTC (rev 4757) @@ -201,6 +201,7 @@ WORD ChnVUMeters[MAX_BASECHANNELS]; WORD OldVUMeters[MAX_BASECHANNELS]; + ModCommand::NOTE previousNote[MAX_BASECHANNELS]; BYTE activeNoteChannel[NOTE_MAX + NOTE_MIN]; BYTE splitActiveNoteChannel[NOTE_MAX + NOTE_MIN]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-02-16 22:33:10
|
Revision: 4761 http://sourceforge.net/p/modplug/code/4761 Author: saga-games Date: 2015-02-16 22:32:57 +0000 (Mon, 16 Feb 2015) Log Message: ----------- [Mod] Updated release documents [Mod] Fully integrated manual generator into auto build process [Fix] Pattern tab: Note-offs from past notes are no longer written when recording notes into patterns (http://bugs.openmpt.org/view.php?id=645) [Mod] OpenMPT: Version is now 1.24.02.00 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/manual_generator/wiki.py trunk/OpenMPT/packageTemplate/History.txt trunk/OpenMPT/packageTemplate/OMPT_1.24_ReleaseNotes.html Removed Paths: ------------- trunk/OpenMPT/mptrack/manual_generator/run.cmd Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-02-16 10:16:25 UTC (rev 4760) +++ trunk/OpenMPT/common/versionNumber.h 2015-02-16 22:32:57 UTC (rev 4761) @@ -18,8 +18,8 @@ //Version definitions. The only thing that needs to be changed when changing version number. #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 -#define VER_MINOR 01 -#define VER_MINORMINOR 09 +#define VER_MINOR 02 +#define VER_MINORMINOR 00 //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) Deleted: trunk/OpenMPT/mptrack/manual_generator/run.cmd =================================================================== --- trunk/OpenMPT/mptrack/manual_generator/run.cmd 2015-02-16 10:16:25 UTC (rev 4760) +++ trunk/OpenMPT/mptrack/manual_generator/run.cmd 2015-02-16 22:32:57 UTC (rev 4761) @@ -1,7 +0,0 @@ -del /q /s html -mkdir html -python wiki.py -copy source\*.* html\ -htmlhelp\hhc.exe "html\OpenMPT Manual.hhp" -copy "html\OpenMPT Manual.chm" "..\..\packageTemplate\" -@pause \ No newline at end of file Modified: trunk/OpenMPT/mptrack/manual_generator/wiki.py =================================================================== --- trunk/OpenMPT/mptrack/manual_generator/wiki.py 2015-02-16 10:16:25 UTC (rev 4760) +++ trunk/OpenMPT/mptrack/manual_generator/wiki.py 2015-02-16 22:32:57 UTC (rev 4761) @@ -7,12 +7,15 @@ # HTML Help Workshop to generate a CHM file. from urllib.request import urlopen, urlretrieve -import re, os +import re, os, shutil, subprocess base_url = 'http://wiki.openmpt.org' os.chdir(os.path.dirname(os.path.abspath(__file__))) +shutil.rmtree('html', ignore_errors=True) +shutil.copytree('source', 'html') + style = urlopen(base_url + '/load.php?debug=false&lang=en&modules=mediawiki.legacy.common%2Cshared|mediawiki.ui.button|skins.vector.styles&only=styles&skin=vector&*').read().decode('UTF-8') # Remove a few unused CSS classes style = re.sub(r'\}(\w+)?[\.#]vector([\w >]+)\{.+?\}', '}', style) @@ -153,4 +156,11 @@ toc.write(""" </BODY></HTML> """) -toc.close() \ No newline at end of file +toc.close() + +subprocess.call(['htmlhelp/hhc.exe', '"html/OpenMPT Manual.hhp"']) +try: + os.remove('../../packageTemplate/html/OpenMPT Manual.chm') +except OSError: + pass +shutil.copy2('html/OpenMPT Manual.chm', '../../packageTemplate/') Modified: trunk/OpenMPT/packageTemplate/History.txt =================================================================== --- trunk/OpenMPT/packageTemplate/History.txt 2015-02-16 10:16:25 UTC (rev 4760) +++ trunk/OpenMPT/packageTemplate/History.txt 2015-02-16 22:32:57 UTC (rev 4761) @@ -25,6 +25,65 @@ <ks> coda / Ken Snyder +v1.24.02.00 (16 February 2014, revision 4761) +--------------------------------------------- +Pattern tab + [New] <js> Added suppport for custom pattern fonts as well as upscaled variants of the built-in fonts for High-DPI devices. + [Imp] <js> Data entry shortcuts / scroll wheel do now take the default volume into consideration, i.e. when making a data entry in an empty volume column field next to a note, a volume command is inserted (http://forum.openmpt.org/index.php?topic=5411.0). + [Imp] <js> Show verbose effect descriptions in the status bar instead of the short versions (http://bugs.openmpt.org/view.php?id=51). + [Imp] <js> Note-offs from past notes are no longer written when recording notes into patterns (http://bugs.openmpt.org/view.php?id=645). + [Mod] <js> In IT and XM, the o command (Offset) can no longer be entered into the volume column, as it's an OpenMPT-specific command. Old files using this command will still play as intended. + [Fix] <js> The Parameter Editor refused to work under random conditions. + +Sample tab + [New] <js> Added new shortcuts to center waveform around loop points. + [Fix] <js> Splitting a stereo sample into mono samples didn't update the sample list in other tabs. + +Instrument tab + [Fix] <js> Plugin list was updated on every instrument change, leading to a small but noticeable performance drop. + +Comments tab + [New] <js> It is now possible to use a custom font for displaying module comments. + +Tree view + [Fix] <js> When converting samples to instruments, the instrument folder in the tree view was not updated properly (tx eightbitbubsy). + [Fix] <js> OpenMPT 1.24 introduced a perceivable delay when loading samples for preview. + +Mod Conversion + [Imp] <js> Properly convert between IT / MPTM Hxx and XM 4xx vibrato depth. + +Playback + [Fix] <js> Vibrato was too weak in IT / MPTM with linear frequency slides since the previous version (http://bugs.openmpt.org/view.php?id=623). + [Fix] <js> Fine portamento was sometimes too weak in IT / MPTM with linear frequency slides since the previous version. + +IT + [Mod] <js> Allow loading IT files with tempo 31 normally. + +IT::Compatible Playback Mode + [Fix] <js> Default sample and instrument panning is only reset by notes, not instrument numbers. + [Fix] <js> Panbrello is not reset until the next note or panning command. + +MOD + [Mod] <js> To match ProTracker, the portamento target is no longer reset when a new note is encountered (like in FT2), but it is reset when the target is reached (like in IT). Fixes the intro in nuhanenatanssi.mod. + [Fix] <jh> Fixed random crash in ProTracker 1/2 mode when using on-the-fly sample swapping (http://bugs.openmpt.org/view.php?id=626). + +Other formats + [Fix] <js> STM: Samples were not loaded correctly in some files, e.g. fracture in space" by Purple Motion (tx deus-ex, http://www.un4seen.com/forum/?topic=15448.msg113496#msg113496) + [Fix] <js> STM: Volume slide nibbles are now prioritized correctly (fixes "fracture in space" by Purple Motion). + +Module Export + [Mod] <jh> Remove >48 KHz support for vorbis export. Even though vorbis supports these sampling rates, it's not tuned for them, and using >48 KHz for any lossy codec generally does not make any sense at all. + [Fix] <jh> Detection of available MP3 encoders was sometimes broken in the previous version. + +Audio I/O + [New] <jh> Added hidden options EnableWaveOut, EnableDirectSound, EnableASIO, EnablePortAudioWASAPI, EnablePortudioWDM-KS, EnablePortAudioDS, EnablePortAudioASIO in [Sound Settings] to disable certain types of audio drivers, if required for debugging. + +Misc + [New] <jh> Added hidden settings StopSoundDeviceOnCrash (default true) and TraceAlwaysDump (default false) in [Debug], which can be useful to debug sound device related problems that do not manifest in a crash. + [Imp] <js> Various parts of the program are now DPI-aware: Parameter editor, pattern editor, channel manager, plugin manager, splitter positions, MIDI Input/Output Plugin + [Fix] <js> When using the Song Properties dialog to change some properties of an IT file, re-saving the file always popped up the Save As dialog. + + v1.24.01.00 (21 December 2014, revision 4662) --------------------------------------------- General tab @@ -61,9 +120,9 @@ [New] <js> Custom background colour can now be specified. [Imp] <js> Since Impulse Tracker's fade-out value is 32 times less precise than what is displayed in the editor, automatically round it when the user makes fade-out adjustments in IT files. [Imp] <js> When previewing instruments with a fadeout value of 0, instantly stop them on key-up instead of letting them play forever. + [Mod] <js> Disallow OpenMPT-only "attack" setting to be used in IT and XM files. Old files using this setting still play as intended. [Fix] <js> When loading an instrument, force all sample views of the same module to be updated. [Fix] <js> Modifying envelopes using the keyboard didn't mark the module as modified. - [Reg] <js> Disallow OpenMPT-only "attack" setting to be used in IT and XM files. Tree view [New] <js> Dropping a module or folder on the sample browser opens this module or folder for browsing. @@ -124,14 +183,14 @@ [Fix] <js> Any non-ASCII characters were accidentally removed when loading a MOD file (broke in OpenMPT 1.22). MOD::ProTracker 1/2 Mode - [Fix] <js> Glissando is only applied on rows with a portamento effects, and never on the first tick of these rows. + [Fix] <js> Glissando is only applied on rows with a portamento effect, and never on the first tick of these rows. Other formats [New] <js> Added support for a MOD variant introduced by SoundTracker 2.6 and Ice Tracker (http://bugs.openmpt.org/view.php?id=597). [Imp] <js> SoundTracker auto-slides are now imported using the volume column. [Imp] <js> MT2: Completely rewrote loader. Some files that would previously not load properly do now load. Support for VST plugins, drum patterns and some extended MT2 pattern commands has been added. - [Fix] <js> ITP: Always load embedded MIDI macros for files made with OpenMPT 1.19 or older, since back then they were always read, no matter if the embed flag was checked or not. - [Fix] <js> ITP: Loading extended song properties was broken for a very long time, probably since OpenMPT 1.20. + [Fix] <js> ITP: Always load embedded MIDI macros for files made with OpenMPT 1.19 or older, since back then they were always read, no matter if the embed flag was set or not. + [Fix] <js> ITP: Loading extended song properties was broken since OpenMPT 1.21. [Reg] <js> ITP: Saving and editing ITP files is no longer supported. ITP files are now imported as normal IT files. ITP's functionality is superseded by MPTM's new external sample functionality. Module Export @@ -1202,7 +1261,7 @@ [Fix] <js> Removed portamento speed A01 "fix". At speed 1, use fine pitch slides instead of normal ones (they behave identically to what OpenMPT did previously at speed 1). IT - [Reg] <js> Random filter variation settings are not supported anymore when editing IT files. Please use the MPTM format instead. Importing old files with random filter settings does still work. + [Mod] <js> Random filter variation settings are not supported anymore when editing IT files. Please use the MPTM format instead. Importing old files with random filter settings does still work. IT::Compatible Playback Mode [Fix] <js> Combinations of Qxy (retrigger) with a pattern delay at Speed y should now work as intended. @@ -1392,6 +1451,7 @@ IT [Mod] <js> Newly created IT files have compatible playback mode enabled by default. [Mod] <js> Saving: Files with filter envelopes use a different file version (IT 2.16 instead of IT 2.17) now. + [Mod] <js> Removed restart position and Pitch/Tempo Lock from IT extensions. They can still be edited when loading an old IT file with restart position set or Pitch/Tempo Lock enabled, but for all other files, they are not available. [Fix] <js> Fixed volume and pan drifting when using Volume Swing / Pan Swing in compatible mode (tx Teasy). [Fix] <js> Volume Swing range was 0 to 64 while it should be a percentage from 0 to 100 (old files are fixed automatically). [Fix] <js> Multiple fine pattern delays on the same row weren't added up. @@ -1399,7 +1459,6 @@ [Fix] <js> Tone Portamento is now ignored if no note was previously playing. [Fix] <js> If there are multiple row delay commands on the same row, only the leftmost command is considered. [Fix] <js> Delayed notes that are on the same row as a row delay effect are be retriggered. - [Reg] <js> Removed restart position and Pitch/Tempo Lock from IT extensions. They can still be edited when loading an old IT file with restart position set or Pitch/Tempo Lock enabled, but for all other files, they are not available. IT::Compatible Playback Mode [Fix] <js> New filter mode which pretty much sounds like Impulse Tracker's resonant filter (http://bugs.openmpt.org/view.php?id=8). The new filter mode is used iff "More IT compatible playback" is turned on and extended filter range is turned off. @@ -1453,12 +1512,12 @@ [Fix] <js> Saving: When saving an XM with no instruments, garbage instrument settings were written. S3M + [Mod] <js> \xx command has been removed from S3M format (existing tracks are updated automatically to use the Zxx command instead). [Fix] <js> Some commands (Dxy, Exx, Fxx, Ixy, Jxy, Kxy, Lxy, Qxy, Rxy, Sxy) use the last non-zero effect parameter as memory. This fixes for example Satellite One by Purple Motion. [Fix] <js> Pattern loops have no per-channel memory in ST3 (tx GreaseMonkey). [Fix] <js> Amiga limits are now enfored correctly if the "preserve Amiga limits" flag is set. [Fix] <js> If there are multiple row delay commands on the same row, only the leftmost command is considered. [Fix] <js> Delayed notes that are on the same row as a row delay effect are be retriggered. - [Reg] <js> \xx command has been removed from S3M format (existing tracks are updated automatically to use the Zxx command instead). S3M::Loading [Imp] <js> Default channel panning is now scalled better when loading and saving, for a full 0...256 range. @@ -1667,6 +1726,7 @@ [New] <js> Experimental feature: Play the whole pattern row when entering notes and chords into the pattern editor. This can be enabled from the setup screen. [Mod] <js> Using the Goto Dialog updates channel parameters and sets the elapsed time now (http://bugs.openmpt.org/view.php?id=28). [Mod] <js> Undo steps have been increased from 100 to 1000. + [Mod] <js> The "Position aware timer" option is gone. The position aware timer is now automatically used. It was optional in the first place because of some buggy code, which is now fixed. [Fix] <js> Shrink selection is more consistent with Shrink pattern now: Entries on odd rows are not ignored anymore if there is no entry in the even rows. Also, cleaning of the pattern after shrinking the selection has been fixed - it cleaned whole commands instead of just the selected parts of a command (http://bugs.openmpt.org/view.php?id=89). [Fix] <js> Cursor paste was possible even when editing was disabled. [Fix] <js> Using Right-Click -> Change Plugin on Parameter Control Events did not work for plugin numbers that were higher than the highest instrument number. @@ -1679,7 +1739,6 @@ [Fix] <js> Entering a note-off event in the MOD format created an unnecessary undo event. [Fix] <js> Automation data is not written to the pattern if the current module format does not support smooth MIDI macros. [Fix] <js> Selections were not clamped properly to the end of the pattern sometimes. - [Reg] <js> The "Position aware timer" option is gone. The position aware timer is now automatically used. It was optional in the first place because of some buggy code, which is now fixed. Pattern tab::Note properties [Fix] <js> Explanation of Q0x was wrong for IT / S3M. @@ -1868,7 +1927,7 @@ [Imp] <js> Panning ranges from 0 to 256 again for MPTM, and from 0 to 64 for IT files (previously, it ranged from 0 to 255). [Imp] <js> Sample Map accepts various new shortcuts now. [Imp] <js> When pasting an envelope with a release node, it's now ignored in formats that don't support it. - [Reg] <js> Envelope release nodes cannot be enabled for IT files anymore, but they are still played for compatibility (One has to start removing the crap from the old formats at some point...). + [Mod] <js> Envelope release nodes cannot be enabled for IT files anymore, but they are still played for compatibility (One has to start removing the crap from the old formats at some point...). Tree view [Imp] <js> Ask for confirmation when deleting patterns, samples, instruments, sequences. Modified: trunk/OpenMPT/packageTemplate/OMPT_1.24_ReleaseNotes.html =================================================================== --- trunk/OpenMPT/packageTemplate/OMPT_1.24_ReleaseNotes.html 2015-02-16 10:16:25 UTC (rev 4760) +++ trunk/OpenMPT/packageTemplate/OMPT_1.24_ReleaseNotes.html 2015-02-16 22:32:57 UTC (rev 4761) @@ -122,6 +122,7 @@ <h3>Pattern Editor</h3> <ul> + <li><strong>Custom pattern fonts</strong> can now be used. The built-in fonts can also be zoomed in for High-DPI devices.</li> <li>Ctrl+(Shift+)<strong>Scroll wheel</strong> can now be used as a replacement for the "(Coarse) Data Entry" shortcuts.</li> </ul> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-17 09:16:44
|
Revision: 4764 http://sourceforge.net/p/modplug/code/4764 Author: manxorist Date: 2015-02-17 09:16:38 +0000 (Tue, 17 Feb 2015) Log Message: ----------- [Mod] libopenmpt: Update for -beta10. Modified Paths: -------------- trunk/OpenMPT/build/autotools/Makefile.am trunk/OpenMPT/libopenmpt/dox/changelog.md Modified: trunk/OpenMPT/build/autotools/Makefile.am =================================================================== --- trunk/OpenMPT/build/autotools/Makefile.am 2015-02-17 09:12:56 UTC (rev 4763) +++ trunk/OpenMPT/build/autotools/Makefile.am 2015-02-17 09:16:38 UTC (rev 4764) @@ -68,7 +68,7 @@ pkgconfig_DATA += libopenmpt/libopenmpt.pc lib_LTLIBRARIES += libopenmpt.la -libopenmpt_la_LDFLAGS = -version-info 0:9:0 +libopenmpt_la_LDFLAGS = -version-info 0:10:0 nobase_include_HEADERS += libopenmpt/libopenmpt.h libopenmpt/libopenmpt.hpp libopenmpt/libopenmpt_version.h libopenmpt/libopenmpt_config.h libopenmpt/libopenmpt_stream_callbacks_fd.h libopenmpt/libopenmpt_stream_callbacks_file.h libopenmpt/libopenmpt_ext.hpp libopenmpt_la_CPPFLAGS = -DLIBOPENMPT_BUILD -I$(srcdir)/build/svn_version -I$(srcdir)/ -I$(srcdir)/common $(ZLIB_CFLAGS) $(LTDL_CPPFLAGS) libopenmpt_la_CXXFLAGS = $(ZLIB_CFLAGS) Modified: trunk/OpenMPT/libopenmpt/dox/changelog.md =================================================================== --- trunk/OpenMPT/libopenmpt/dox/changelog.md 2015-02-17 09:12:56 UTC (rev 4763) +++ trunk/OpenMPT/libopenmpt/dox/changelog.md 2015-02-17 09:16:38 UTC (rev 4764) @@ -5,7 +5,7 @@ For fully detailed change log, please see the source repository directly. This is just a high-level summary. -### libopenmpt-svn +### 2015-02-17 - libopenmpt 0.2-beta10 * Makefile configuration filenames changed from `build/make/Makefile.config.*` to `build/make/config-*.mk`. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-18 09:26:26
|
Revision: 4767 http://sourceforge.net/p/modplug/code/4767 Author: manxorist Date: 2015-02-18 09:25:46 +0000 (Wed, 18 Feb 2015) Log Message: ----------- [Mod] sounddev: Allow smaller buffer sizes for WaveOut. [Fix] sounddev: Properly clamp buffer size at the upper limit. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2015-02-17 12:56:47 UTC (rev 4766) +++ trunk/OpenMPT/common/misc_util.h 2015-02-18 09:25:46 UTC (rev 4767) @@ -510,7 +510,18 @@ return (a >= 0) ? mpt::saturate_cast<int32>(a / c) : mpt::saturate_cast<int32>((a - (c - 1)) / c); } + // rounds x up to multiples of target + forceinline uint32 AlignUp(uint32 x, uint32 target) + { + return ((x + (target - 1)) / target) * target; + } + // rounds x down to multiples of target + forceinline uint32 AlignDown(uint32 x, uint32 target) + { + return (x / target) * target; + } + // Greatest Common Divisor. Always returns non-negative number. template <class T> T gcd(T a, T b) Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-02-17 12:56:47 UTC (rev 4766) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-02-18 09:25:46 UTC (rev 4767) @@ -220,8 +220,8 @@ } m_bMixRunning = FALSE; m_nDSoundBufferSize = Util::Round<int32>(m_Settings.Latency * pwfx->nAvgBytesPerSec); - m_nDSoundBufferSize = Clamp(m_nDSoundBufferSize, (DWORD)DSBSIZE_MIN, (DWORD)DSBSIZE_MAX); - m_nDSoundBufferSize = (m_nDSoundBufferSize + (bytesPerFrame-1)) / bytesPerFrame * bytesPerFrame; // round up to full frame + m_nDSoundBufferSize = Util::AlignUp(m_nDSoundBufferSize, bytesPerFrame); + m_nDSoundBufferSize = Clamp(m_nDSoundBufferSize, Util::AlignUp(DSBSIZE_MIN, bytesPerFrame), Util::AlignDown(DSBSIZE_MAX, bytesPerFrame)); if(!m_Settings.ExclusiveMode) { // Set the format of the primary buffer Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2015-02-17 12:56:47 UTC (rev 4766) +++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2015-02-18 09:25:46 UTC (rev 4767) @@ -32,9 +32,9 @@ static const std::size_t WAVEOUT_MINBUFFERS = 3; -static const std::size_t WAVEOUT_MAXBUFFERS = 256; -static const std::size_t WAVEOUT_MINBUFFERSIZE = 1024; -static const std::size_t WAVEOUT_MAXBUFFERSIZE = 65536; +static const std::size_t WAVEOUT_MAXBUFFERS = 4096; +static const std::size_t WAVEOUT_MINBUFFERFRAMECOUNT = 8; +static const std::size_t WAVEOUT_MAXBUFFERSIZE = 16384; // fits in int16 CWaveDevice::CWaveDevice(SoundDevice::Info info) @@ -155,8 +155,8 @@ return false; } m_nWaveBufferSize = Util::Round<int32>(m_Settings.UpdateInterval * pwfx->nAvgBytesPerSec); - m_nWaveBufferSize = Clamp(m_nWaveBufferSize, WAVEOUT_MINBUFFERSIZE, WAVEOUT_MAXBUFFERSIZE); - m_nWaveBufferSize = ((m_nWaveBufferSize + pwfx->nBlockAlign - 1) / pwfx->nBlockAlign) * pwfx->nBlockAlign; + m_nWaveBufferSize = Util::AlignUp(m_nWaveBufferSize, pwfx->nBlockAlign); + m_nWaveBufferSize = Clamp(m_nWaveBufferSize, WAVEOUT_MINBUFFERFRAMECOUNT * pwfx->nBlockAlign, Util::AlignDown(WAVEOUT_MAXBUFFERSIZE, pwfx->nBlockAlign)); std::size_t numBuffers = Util::Round<int32>(m_Settings.Latency * pwfx->nAvgBytesPerSec / m_nWaveBufferSize); numBuffers = Clamp(numBuffers, WAVEOUT_MINBUFFERS, WAVEOUT_MAXBUFFERS); m_nPreparedHeaders = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-19 14:14:26
|
Revision: 4773 http://sourceforge.net/p/modplug/code/4773 Author: manxorist Date: 2015-02-19 14:14:09 +0000 (Thu, 19 Feb 2015) Log Message: ----------- [Fix] ASIO: ASIO specification demands a valid window handle to be provided for driver intialization. When initializiung an ASIO driver in order to check for availability or query its capabilities, OpenMPT did only provide a NULL window handle. Add a struct SoundDevice::AppInfo which gets provided on sound device initialization instead of on opening. [Ref] sounddev: Add an application name field to SoundDevice::AppInfo which will be useful for APIs that name ports after the application they belong to. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp trunk/OpenMPT/sounddev/SoundDeviceManager.cpp trunk/OpenMPT/sounddev/SoundDeviceManager.h Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2015-02-19 14:14:09 UTC (rev 4773) @@ -998,7 +998,7 @@ m_pMainWnd->DragAcceptFiles(); // Load sound APIs - m_pSoundDevicesManager = new SoundDevice::Manager(TrackerSettings::Instance().GetEnabledSoundDeviceTypes()); + m_pSoundDevicesManager = new SoundDevice::Manager(SoundDevice::AppInfo().SetName(MPT_USTRING("OpenMPT")).SetHWND(*m_pMainWnd), TrackerSettings::Instance().GetEnabledSoundDeviceTypes()); if(TrackerSettings::Instance().m_SoundDeviceSettingsUseOldDefaults) { // get the old default device Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-02-19 14:14:09 UTC (rev 4773) @@ -709,7 +709,6 @@ } const SoundDevice::Caps deviceCaps = theApp.GetSoundDevicesManager()->GetDeviceCaps(device, CMainFrame::GetMainFrame()->gpSoundDevice); SoundDevice::Settings settings = StoredSoundDeviceSettings(conf, deviceInfo, deviceCaps.DefaultSettings); - settings.hWnd = CMainFrame::GetMainFrame()->m_hWnd; return settings; } Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-19 14:14:09 UTC (rev 4773) @@ -176,14 +176,15 @@ } -bool Base::Init() -//--------------- +bool Base::Init(const SoundDevice::AppInfo &appInfo) +//-------------------------------------------------- { MPT_TRACE(); if(IsInited()) { return true; } + m_AppInfo = appInfo; m_Caps = InternalGetDeviceCaps(); return m_Caps.Available; } Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2015-02-19 14:14:09 UTC (rev 4773) @@ -289,9 +289,26 @@ }; +struct AppInfo +{ + mpt::ustring Name; + uintptr_t UIHandle; // HWND on Windows + AppInfo() + : UIHandle(0) + { + return; + } + AppInfo &SetName(const mpt::ustring &name) { Name = name; return *this; } + mpt::ustring GetName() const { return Name; } +#if MPT_OS_WINDOWS + AppInfo &SetHWND(HWND hwnd) { UIHandle = reinterpret_cast<uintptr_t>(hwnd); return *this; } + HWND GetHWND() const { return reinterpret_cast<HWND>(UIHandle); } +#endif // MPT_OS_WINDOWS +}; + + struct Settings { - HWND hWnd; double Latency; // seconds double UpdateInterval; // seconds uint32 Samplerate; @@ -304,8 +321,7 @@ int DitherType; SoundDevice::ChannelMapping ChannelMapping; Settings() - : hWnd(NULL) - , Latency(0.1) + : Latency(0.1) , UpdateInterval(0.005) , Samplerate(48000) , Channels(2) @@ -321,7 +337,6 @@ bool operator == (const SoundDevice::Settings &cmp) const { return true - && hWnd == cmp.hWnd && Util::Round<int64>(Latency * 1000000000.0) == Util::Round<int64>(cmp.Latency * 1000000000.0) // compare in nanoseconds && Util::Round<int64>(UpdateInterval * 1000000000.0) == Util::Round<int64>(cmp.UpdateInterval * 1000000000.0) // compare in nanoseconds && Samplerate == cmp.Samplerate @@ -492,7 +507,7 @@ virtual SoundDevice::Caps GetDeviceCaps() const = 0; virtual SoundDevice::DynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates) = 0; - virtual bool Init() = 0; + virtual bool Init(const SoundDevice::AppInfo &appInfo) = 0; virtual bool Open(const SoundDevice::Settings &settings) = 0; virtual bool Close() = 0; virtual bool Start() = 0; @@ -542,6 +557,7 @@ protected: + SoundDevice::AppInfo m_AppInfo; SoundDevice::Settings m_Settings; SoundDevice::Flags m_Flags; bool m_DeviceUnavailableOnOpen; @@ -624,7 +640,7 @@ SoundDevice::Caps GetDeviceCaps() const { return m_Caps; } virtual SoundDevice::DynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates); - bool Init(); + bool Init(const SoundDevice::AppInfo &appInfo); bool Open(const SoundDevice::Settings &settings); bool Close(); bool Start(); Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-02-19 14:14:09 UTC (rev 4773) @@ -684,7 +684,7 @@ } try { - if(m_pAsioDrv->init((void *)m_Settings.hWnd) != ASIOTrue) + if(m_pAsioDrv->init((void *)m_AppInfo.GetHWND()) != ASIOTrue) { Log("ASIO: init() failed!"); CloseDriver(); Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-02-19 14:14:09 UTC (rev 4773) @@ -213,7 +213,7 @@ GUID guid = internalID.empty() ? GUID() : Util::StringToGUID(mpt::ToWide(internalID)); if(DirectSoundCreate(internalID.empty() ? NULL : &guid, &m_piDS, NULL) != DS_OK) return false; if(!m_piDS) return false; - if(m_piDS->SetCooperativeLevel(m_Settings.hWnd, m_Settings.ExclusiveMode ? DSSCL_WRITEPRIMARY : DSSCL_PRIORITY) != DS_OK) + if(m_piDS->SetCooperativeLevel(m_AppInfo.GetHWND(), m_Settings.ExclusiveMode ? DSSCL_WRITEPRIMARY : DSSCL_PRIORITY) != DS_OK) { Close(); return false; Modified: trunk/OpenMPT/sounddev/SoundDeviceManager.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceManager.cpp 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/sounddev/SoundDeviceManager.cpp 2015-02-19 14:14:09 UTC (rev 4773) @@ -332,7 +332,7 @@ { return nullptr; } - if(!result->Init()) + if(!result->Init(m_AppInfo)) { delete result; result = nullptr; @@ -343,8 +343,9 @@ } -Manager::Manager(SoundDevice::TypesSet enabledTypes) -//-------------------------------------------------- +Manager::Manager(SoundDevice::AppInfo appInfo, SoundDevice::TypesSet enabledTypes) +//-------------------------------------------------------------------------------- + : m_AppInfo(appInfo) { ReEnumerate(enabledTypes); } Modified: trunk/OpenMPT/sounddev/SoundDeviceManager.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceManager.h 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/sounddev/SoundDeviceManager.h 2015-02-19 14:14:09 UTC (rev 4773) @@ -31,6 +31,8 @@ { private: + const SoundDevice::AppInfo m_AppInfo; + #ifndef NO_PORTAUDIO ComponentHandle<ComponentPortAudio> m_PortAudio; #endif // NO_PORTAUDIO @@ -41,7 +43,7 @@ std::map<SoundDevice::Identifier, SoundDevice::DynamicCaps> m_DeviceDynamicCaps; public: - Manager(SoundDevice::TypesSet enabledTypes); + Manager(SoundDevice::AppInfo appInfo, SoundDevice::TypesSet enabledTypes); ~Manager(); public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-20 11:33:20
|
Revision: 4774 http://sourceforge.net/p/modplug/code/4774 Author: manxorist Date: 2015-02-20 11:33:14 +0000 (Fri, 20 Feb 2015) Log Message: ----------- [Ref] sounddev: Add log level to SoundDevice::IMessageReceiver. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Reporting.cpp trunk/OpenMPT/mptrack/Reporting.h trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2015-02-19 14:14:09 UTC (rev 4773) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2015-02-20 11:33:14 UTC (rev 4774) @@ -630,11 +630,11 @@ } -void CMainFrame::AudioMessage(const mpt::ustring &str) -//---------------------------------------------------- +void CMainFrame::SoundDeviceMessage(LogLevel level, const mpt::ustring &str) +//-------------------------------------------------------------------------- { MPT_TRACE(); - Reporting::Notification(str); + Reporting::Message(level, str); } Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2015-02-19 14:14:09 UTC (rev 4773) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2015-02-20 11:33:14 UTC (rev 4774) @@ -401,7 +401,7 @@ void AudioDone(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, int64 streamPosition); // from SoundDevice::IMessageReceiver - void AudioMessage(const mpt::ustring &str); + void SoundDeviceMessage(LogLevel level, const mpt::ustring &str); bool InGuiThread() const { return theApp.InGuiThread(); } bool InAudioThread() const { return GetCurrentThreadId() == m_AudioThreadId; } Modified: trunk/OpenMPT/mptrack/Reporting.cpp =================================================================== --- trunk/OpenMPT/mptrack/Reporting.cpp 2015-02-19 14:14:09 UTC (rev 4773) +++ trunk/OpenMPT/mptrack/Reporting.cpp 2015-02-20 11:33:14 UTC (rev 4774) @@ -149,6 +149,18 @@ } +void Reporting::Message(LogLevel level, const AnyStringLocale &text, const CWnd *parent) +//-------------------------------------------------------------------------------------- +{ + ShowNotificationImpl(mpt::ToWide(text), FillEmptyCaption(std::wstring(), level), LogLevelToFlags(level), parent); +} +void Reporting::Message(LogLevel level, const AnyStringLocale &text, const AnyStringLocale &caption, const CWnd *parent) +//---------------------------------------------------------------------------------------------------------------------- +{ + ShowNotificationImpl(mpt::ToWide(text), FillEmptyCaption(mpt::ToWide(caption), level), LogLevelToFlags(level), parent); +} + + ConfirmAnswer Reporting::Confirm(const AnyStringLocale &text, bool showCancel, bool defaultNo, const CWnd *parent) //---------------------------------------------------------------------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/Reporting.h =================================================================== --- trunk/OpenMPT/mptrack/Reporting.h 2015-02-19 14:14:09 UTC (rev 4773) +++ trunk/OpenMPT/mptrack/Reporting.h 2015-02-20 11:33:14 UTC (rev 4774) @@ -55,6 +55,10 @@ static void Error(const AnyStringLocale &text, const CWnd *parent = nullptr); static void Error(const AnyStringLocale &text, const AnyStringLocale &caption, const CWnd *parent = nullptr); + // Simplified version of the above + static void Message(LogLevel level, const AnyStringLocale &text, const CWnd *parent = nullptr); + static void Message(LogLevel level, const AnyStringLocale &text, const AnyStringLocale &caption, const CWnd *parent = nullptr); + // Show a confirmation dialog. static ConfirmAnswer Confirm(const AnyStringLocale &text, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); static ConfirmAnswer Confirm(const AnyStringLocale &text, const AnyStringLocale &caption, bool showCancel = false, bool defaultNo = false, const CWnd *parent = nullptr); Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-19 14:14:09 UTC (rev 4773) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-20 11:33:14 UTC (rev 4774) @@ -315,13 +315,14 @@ } -void Base::AudioSendMessage(const mpt::ustring &str) -//-------------------------------------------------- +void Base::SendDeviceMessage(LogLevel level, const mpt::ustring &str) +//------------------------------------------------------------------- { MPT_TRACE(); + Log(level, str); if(m_MessageReceiver) { - m_MessageReceiver->AudioMessage(str); + m_MessageReceiver->SoundDeviceMessage(level, str); } } Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2015-02-19 14:14:09 UTC (rev 4773) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2015-02-20 11:33:14 UTC (rev 4774) @@ -42,7 +42,7 @@ //==================== { public: - virtual void AudioMessage(const mpt::ustring &str) = 0; + virtual void SoundDeviceMessage(LogLevel level, const mpt::ustring &str) = 0; }; @@ -597,7 +597,7 @@ void RequestReset() { m_RequestFlags.fetch_or(RequestFlagReset); } void RequestRestart() { m_RequestFlags.fetch_or(RequestFlagRestart); } - void AudioSendMessage(const mpt::ustring &str); + void SendDeviceMessage(LogLevel level, const mpt::ustring &str); protected: Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-02-19 14:14:09 UTC (rev 4773) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-02-20 11:33:14 UTC (rev 4774) @@ -1362,8 +1362,7 @@ //----------------------------------------------------------- { MPT_TRACE(); - AudioSendMessage(mpt::ToUnicode(mpt::CharsetLocale, str)); - Log("%s", str.c_str()); + SendDeviceMessage(LogError, mpt::ToUnicode(mpt::CharsetLocale, str)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-20 12:07:27
|
Revision: 4775 http://sourceforge.net/p/modplug/code/4775 Author: manxorist Date: 2015-02-20 12:07:13 +0000 (Fri, 20 Feb 2015) Log Message: ----------- [Ref] sounddev: Move the multimedia reference clock out of the individual devices. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2015-02-20 11:33:14 UTC (rev 4774) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2015-02-20 12:07:13 UTC (rev 4775) @@ -638,6 +638,30 @@ } +void CMainFrame::SoundSourcePreStartCallback() +//-------------------------------------------- +{ + MPT_TRACE(); + m_SoundDeviceClock.SetResolution(1); +} + + +void CMainFrame::SoundSourcePostStopCallback() +//-------------------------------------------- +{ + MPT_TRACE(); + m_SoundDeviceClock.SetResolution(0); +} + + +uint64 CMainFrame::SoundSourceGetReferenceClockNowNanoseconds() const +//------------------------------------------------------------------- +{ + MPT_TRACE(); + return m_SoundDeviceClock.NowNanoseconds(); +} + + void CMainFrame::FillAudioBufferLocked(SoundDevice::IFillAudioBuffer &callback) //----------------------------------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2015-02-20 11:33:14 UTC (rev 4774) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2015-02-20 12:07:13 UTC (rev 4775) @@ -342,6 +342,7 @@ public: // Low-Level Audio + Util::MultimediaClock m_SoundDeviceClock; SoundDevice::IBase *gpSoundDevice; UINT_PTR m_NotifyTimer; Dither m_Dither; @@ -396,6 +397,9 @@ static void UpdateAudioParameters(CSoundFile &sndFile, bool reset=false); // from SoundDevice::ISource + uint64 SoundSourceGetReferenceClockNowNanoseconds() const; + void SoundSourcePreStartCallback(); + void SoundSourcePostStopCallback(); void FillAudioBufferLocked(SoundDevice::IFillAudioBuffer &callback); void AudioRead(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, void *buffer); void AudioDone(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, int64 streamPosition); Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-20 11:33:14 UTC (rev 4774) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-20 12:07:13 UTC (rev 4775) @@ -245,6 +245,40 @@ } +uint64 Base::SourceGetReferenceClockNowNanoseconds() const +//-------------------------------------------------------- +{ + MPT_TRACE(); + if(!m_Source) + { + return 0; + } + return m_Source->SoundSourceGetReferenceClockNowNanoseconds(); +} + + +void Base::SourceNotifyPreStart() +//------------------------------- +{ + MPT_TRACE(); + if(m_Source) + { + m_Source->SoundSourcePreStartCallback(); + } +} + + +void Base::SourceNotifyPostStop() +//------------------------------- +{ + MPT_TRACE(); + if(m_Source) + { + m_Source->SoundSourcePostStopCallback(); + } +} + + void Base::SourceFillAudioBufferLocked() //-------------------------------------- { @@ -266,7 +300,7 @@ { SoundDevice::TimeInfo timeInfo; timeInfo.StreamFrames = InternalHasGetStreamPosition(); - timeInfo.SystemTimestamp = Clock().NowNanoseconds(); + timeInfo.SystemTimestamp = SourceGetReferenceClockNowNanoseconds(); timeInfo.Speed = 1.0; UpdateTimeInfo(timeInfo); } else @@ -276,7 +310,7 @@ Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex); timeInfo.StreamFrames = m_StreamPositionRenderFrames + numFrames; } - timeInfo.SystemTimestamp = Clock().NowNanoseconds() + Util::Round<int64>(GetEffectiveBufferAttributes().Latency * 1000000000.0); + timeInfo.SystemTimestamp = SourceGetReferenceClockNowNanoseconds() + Util::Round<int64>(GetEffectiveBufferAttributes().Latency * 1000000000.0); timeInfo.Speed = 1.0; UpdateTimeInfo(timeInfo); } @@ -340,11 +374,11 @@ m_StreamPositionRenderFrames = 0; m_StreamPositionOutputFrames = 0; } - m_Clock.SetResolution(1); + SourceNotifyPreStart(); m_RequestFlags.fetch_and((~RequestFlagRestart).as_bits()); if(!InternalStart()) { - m_Clock.SetResolution(0); + SourceNotifyPostStop(); return false; } m_IsPlaying = true; @@ -368,7 +402,7 @@ InternalStop(); } m_RequestFlags.fetch_and((~RequestFlagRestart).as_bits()); - m_Clock.SetResolution(0); + SourceNotifyPostStop(); m_IsPlaying = false; { Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex); Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2015-02-20 11:33:14 UTC (rev 4774) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2015-02-20 12:07:13 UTC (rev 4775) @@ -71,6 +71,9 @@ //=========== { public: + virtual uint64 SoundSourceGetReferenceClockNowNanoseconds() const = 0; // timeGetTime()*1000000 on Windows + virtual void SoundSourcePreStartCallback() = 0; + virtual void SoundSourcePostStopCallback() = 0; virtual void FillAudioBufferLocked(SoundDevice::IFillAudioBuffer &callback) = 0; // take any locks needed while rendering audio and then call FillAudioBuffer virtual void AudioRead(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, void *buffer) = 0; virtual void AudioDone(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, int64 streamPosition) = 0; // in sample frames @@ -566,7 +569,6 @@ bool m_IsPlaying; - Util::MultimediaClock m_Clock; SoundDevice::TimeInfo m_TimeInfo; mutable Util::mutex m_StreamPositionMutex; @@ -588,6 +590,9 @@ void FillAudioBuffer(); + uint64 SourceGetReferenceClockNowNanoseconds() const; + void SourceNotifyPreStart(); + void SourceNotifyPostStop(); void SourceFillAudioBufferLocked(); void SourceAudioPreRead(std::size_t numFrames); void SourceAudioRead(void *buffer, std::size_t numFrames); @@ -601,8 +606,6 @@ protected: - const Util::MultimediaClock & Clock() const { return m_Clock; } - void UpdateTimeInfo(SoundDevice::TimeInfo timeInfo); virtual bool InternalHasTimeInfo() const { return false; } Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-02-20 11:33:14 UTC (rev 4774) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-02-20 12:07:13 UTC (rev 4775) @@ -1027,7 +1027,7 @@ MPT_TRACE(); if(m_Settings.UseHardwareTiming) { - const uint64 asioNow = Clock().NowNanoseconds(); + const uint64 asioNow = SourceGetReferenceClockNowNanoseconds(); SoundDevice::TimeInfo timeInfo = GetTimeInfo(); int64 currentStreamPositionFrames = Util::Round<int64>( @@ -1076,7 +1076,7 @@ SoundDevice::Base::UpdateTimeInfo(timeInfo); } else { // spec violation or nothing provided at all, better to estimate this stuff ourselves - const uint64 asioNow = Clock().NowNanoseconds(); + const uint64 asioNow = SourceGetReferenceClockNowNanoseconds(); SoundDevice::TimeInfo timeInfo; timeInfo.StreamFrames = m_TotalFramesWritten + m_nAsioBufferLen - m_StreamPositionOffset; timeInfo.SystemTimestamp = asioNow + Util::Round<int64>(m_BufferLatency * 1000.0 * 1000.0 * 1000.0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-02-21 01:06:29
|
Revision: 4777 http://sourceforge.net/p/modplug/code/4777 Author: saga-games Date: 2015-02-21 01:06:22 +0000 (Sat, 21 Feb 2015) Log Message: ----------- [Mod] Make installer generation scripts a bit more reliable. Modified Paths: -------------- trunk/OpenMPT/build/auto/build_openmpt_release_packages.py trunk/OpenMPT/installer/install.iss trunk/OpenMPT/mptrack/manual_generator/wiki.py Modified: trunk/OpenMPT/build/auto/build_openmpt_release_packages.py =================================================================== --- trunk/OpenMPT/build/auto/build_openmpt_release_packages.py 2015-02-20 12:45:18 UTC (rev 4776) +++ trunk/OpenMPT/build/auto/build_openmpt_release_packages.py 2015-02-21 01:06:22 UTC (rev 4777) @@ -3,7 +3,7 @@ # http://openmpt.org/ # Requires pywin32 (https://sourceforge.net/projects/pywin32/) -from win32api import GetFileVersionInfo, LOWORD, HIWORD +from win32api import GetFileVersionInfo from subprocess import Popen from sys import executable import os, shutil, hashlib @@ -70,6 +70,8 @@ copy_other(openmpt_zip_64bit_path, openmpt_version_short) pManual.communicate() +if(pManual.returncode != 0): + raise Exception("Something went wrong during manual creation!") print("Creating zip files and installers...") p7z32 = Popen(["C:\\Program Files\\7-Zip\\7z.exe", "a", "-tzip", "-mx=9", "../" + openmpt_version_name + ".zip", openmpt_version_name + "/"], cwd=openmpt_zip_32bit_basepath) @@ -82,7 +84,7 @@ pInno64.communicate() if(p7z32.returncode != 0 or p7z64.returncode != 0 or pInno32.returncode != 0 or pInno64.returncode != 0): - raise error("Something went wrong during packaging!") + raise Exception("Something went wrong during packaging!") def hash_file(filename): md5 = hashlib.md5() Modified: trunk/OpenMPT/installer/install.iss =================================================================== --- trunk/OpenMPT/installer/install.iss 2015-02-20 12:45:18 UTC (rev 4776) +++ trunk/OpenMPT/installer/install.iss 2015-02-21 01:06:22 UTC (rev 4777) @@ -7,9 +7,9 @@ ; win32.iss - For generating the standard Win32 setup. ; win64.iss - For generating the standard Win64 setup. ; install-unmo3-free-itd.iss - For generating the unmo3-free setup with InnoTools Downloader. -; install-unmo3-free.iss - For generating the unmo3-free setup with ISTool downloader. +; install-unmo3-free.iss - For generating the unmo3-free setup with Inno Download Plugin. -#define GetAppVersion StringChange(GetFileProductVersion("..\bin\Win32\mptrack.exe"), ",", ".") +#define GetAppVersion StringChange(GetFileProductVersion("..\bin\" + PlatformFolder + "\mptrack.exe"), ",", ".") #define GetAppVersionShort Copy(GetAppVersion, 1, 4) #ifndef PlatformName Modified: trunk/OpenMPT/mptrack/manual_generator/wiki.py =================================================================== --- trunk/OpenMPT/mptrack/manual_generator/wiki.py 2015-02-20 12:45:18 UTC (rev 4776) +++ trunk/OpenMPT/mptrack/manual_generator/wiki.py 2015-02-21 01:06:22 UTC (rev 4777) @@ -158,7 +158,8 @@ """) toc.close() -subprocess.call(['htmlhelp/hhc.exe', '"html/OpenMPT Manual.hhp"']) +if(subprocess.call(['htmlhelp/hhc.exe', '"html/OpenMPT Manual.hhp"']) != 1): + raise Exception("Something went wrong during manual creation!") try: os.remove('../../packageTemplate/html/OpenMPT Manual.chm') except OSError: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-21 17:46:48
|
Revision: 4780 http://sourceforge.net/p/modplug/code/4780 Author: manxorist Date: 2015-02-21 17:46:36 +0000 (Sat, 21 Feb 2015) Log Message: ----------- [Ref] test: More test cases for mpt::saturate_cast. [Fix] mpt::sturate_cast was wrong for Tsrc unsigned and Tdst signed. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2015-02-21 17:39:59 UTC (rev 4779) +++ trunk/OpenMPT/common/misc_util.h 2015-02-21 17:46:36 UTC (rev 4780) @@ -216,11 +216,15 @@ return static_cast<Tdst>(std::min<Tsrc>(src, std::numeric_limits<Tdst>::max())); } else if(std::numeric_limits<Tdst>::is_signed && !std::numeric_limits<Tsrc>::is_signed) { - if(sizeof(Tdst) >= sizeof(Tsrc)) + if(sizeof(Tdst) > sizeof(Tsrc)) { + return static_cast<Tdst>(src); + } + if(sizeof(Tdst) == sizeof(Tsrc)) + { return static_cast<Tdst>(std::min<Tsrc>(src, static_cast<Tsrc>(std::numeric_limits<Tdst>::max()))); } - return static_cast<Tdst>(std::max<Tsrc>(std::numeric_limits<Tdst>::min(), std::min<Tsrc>(src, std::numeric_limits<Tdst>::max()))); + return static_cast<Tdst>(std::min<Tsrc>(src, static_cast<Tsrc>(std::numeric_limits<Tdst>::max()))); } else // Tdst unsigned, Tsrc signed { if(sizeof(Tdst) >= sizeof(Tsrc)) Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2015-02-21 17:39:59 UTC (rev 4779) +++ trunk/OpenMPT/test/test.cpp 2015-02-21 17:46:36 UTC (rev 4780) @@ -614,7 +614,36 @@ VERIFY_EQUAL( mpt::saturate_cast<uint16>(std::numeric_limits<int16>::max() + 1), (uint16)std::numeric_limits<int16>::max() + 1 ); VERIFY_EQUAL( mpt::saturate_cast<uint32>(std::numeric_limits<int32>::min() - int64(1)), std::numeric_limits<uint32>::min() ); VERIFY_EQUAL( mpt::saturate_cast<uint32>(std::numeric_limits<int32>::max() + int64(1)), (uint32)std::numeric_limits<int32>::max() + 1 ); + + VERIFY_EQUAL( mpt::saturate_cast<int8>( int16(32000) ), 127 ); + VERIFY_EQUAL( mpt::saturate_cast<int8>( int16(-32000) ), -128 ); + VERIFY_EQUAL( mpt::saturate_cast<int8>( uint16(32000) ), 127 ); + VERIFY_EQUAL( mpt::saturate_cast<int8>( uint16(64000) ), 127 ); + VERIFY_EQUAL( mpt::saturate_cast<uint8>( int16(32000) ), 255 ); + VERIFY_EQUAL( mpt::saturate_cast<uint8>( int16(-32000) ), 0 ); + VERIFY_EQUAL( mpt::saturate_cast<uint8>( uint16(32000) ), 255 ); + VERIFY_EQUAL( mpt::saturate_cast<uint8>( uint16(64000) ), 255 ); + VERIFY_EQUAL( mpt::saturate_cast<int16>( int16(32000) ), 32000 ); + VERIFY_EQUAL( mpt::saturate_cast<int16>( int16(-32000) ), -32000 ); + VERIFY_EQUAL( mpt::saturate_cast<int16>( uint16(32000) ), 32000 ); + VERIFY_EQUAL( mpt::saturate_cast<int16>( uint16(64000) ), 32767 ); + VERIFY_EQUAL( mpt::saturate_cast<uint16>( int16(32000) ), 32000 ); + VERIFY_EQUAL( mpt::saturate_cast<uint16>( int16(-32000) ), 0 ); + VERIFY_EQUAL( mpt::saturate_cast<uint16>( uint16(32000) ), 32000 ); + VERIFY_EQUAL( mpt::saturate_cast<uint16>( uint16(64000) ), 64000 ); + VERIFY_EQUAL( mpt::saturate_cast<int32>( int16(32000) ), 32000 ); + VERIFY_EQUAL( mpt::saturate_cast<int32>( int16(-32000) ), -32000 ); + VERIFY_EQUAL( mpt::saturate_cast<int32>( uint16(32000) ), 32000 ); + VERIFY_EQUAL( mpt::saturate_cast<int32>( uint16(64000) ), 64000 ); + VERIFY_EQUAL( mpt::saturate_cast<uint32>( int16(32000) ), 32000 ); + VERIFY_EQUAL( mpt::saturate_cast<uint32>( int16(-32000) ), 0 ); + VERIFY_EQUAL( mpt::saturate_cast<uint32>( uint16(32000) ), 32000 ); + VERIFY_EQUAL( mpt::saturate_cast<uint32>( uint16(64000) ), 64000 ); + + VERIFY_EQUAL( mpt::saturate_cast<uint32>(std::numeric_limits<int64>::max() - 1), std::numeric_limits<uint32>::max() ); + VERIFY_EQUAL( mpt::saturate_cast<int32>(std::numeric_limits<uint64>::max() - 1), std::numeric_limits<int32>::max() ); + VERIFY_EQUAL( mpt::saturate_cast<uint32>(static_cast<double>(std::numeric_limits<int64>::max())), std::numeric_limits<uint32>::max() ); VERIFY_EQUAL( mpt::String::LTrim(std::string(" ")), "" ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-21 18:29:30
|
Revision: 4782 http://sourceforge.net/p/modplug/code/4782 Author: manxorist Date: 2015-02-21 18:29:17 +0000 (Sat, 21 Feb 2015) Log Message: ----------- [Ref] Unarchiver: Silence 64bit warning in unlha. Modified Paths: -------------- trunk/OpenMPT/common/FileReader.h trunk/OpenMPT/unarchiver/unlha.cpp Modified: trunk/OpenMPT/common/FileReader.h =================================================================== --- trunk/OpenMPT/common/FileReader.h 2015-02-21 18:13:10 UTC (rev 4781) +++ trunk/OpenMPT/common/FileReader.h 2015-02-21 18:29:17 UTC (rev 4782) @@ -281,6 +281,14 @@ streamPos += result; return result; } + std::size_t ReadRaw(void *dst, std::size_t count) + { + return ReadRaw(reinterpret_cast<char*>(dst), count); + } + std::size_t ReadRaw(uint8 *dst, std::size_t count) + { + return ReadRaw(reinterpret_cast<char*>(dst), count); + } protected: Modified: trunk/OpenMPT/unarchiver/unlha.cpp =================================================================== --- trunk/OpenMPT/unarchiver/unlha.cpp 2015-02-21 18:13:10 UTC (rev 4781) +++ trunk/OpenMPT/unarchiver/unlha.cpp 2015-02-21 18:29:17 UTC (rev 4782) @@ -18,7 +18,8 @@ static int LHAreadFileReader(void *handle, void *buf, size_t buf_len) { FileReader *f = reinterpret_cast<FileReader*>(handle); - int result = f->ReadRaw((char*)buf, buf_len); + int read_len = mpt::saturate_cast<int>(buf_len); + int result = mpt::saturate_cast<int>(f->ReadRaw(buf, read_len)); if(result == 0) { return -1; @@ -39,6 +40,7 @@ static void LHAcloseFileReader(void * /*handle*/) { + return; } static LHAInputStreamType vtable = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-21 21:34:45
|
Revision: 4785 http://sourceforge.net/p/modplug/code/4785 Author: manxorist Date: 2015-02-21 21:34:40 +0000 (Sat, 21 Feb 2015) Log Message: ----------- [Fix] Unarchiver: Doh, and now fix unzip for 32bit again. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/unarchiver/unzip.cpp Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2015-02-21 19:00:26 UTC (rev 4784) +++ trunk/OpenMPT/common/misc_util.h 2015-02-21 21:34:40 UTC (rev 4785) @@ -268,6 +268,20 @@ } // namespace mpt +namespace Util +{ + +// Returns true iff Tdst can represent the value val. +// Use as if(Util::TypeCanHold<uin8>(-1)). +template <typename Tdst, typename Tsrc> +inline bool TypeCanHoldValue(Tsrc val) +{ + return (static_cast<Tsrc>(mpt::saturate_cast<Tdst>(val)) == val); +} + +} //namespace Util + + // Limits 'val' to given range. If 'val' is less than 'lowerLimit', 'val' is set to value 'lowerLimit'. // Similarly if 'val' is greater than 'upperLimit', 'val' is set to value 'upperLimit'. // If 'lowerLimit' > 'upperLimit', 'val' won't be modified. Modified: trunk/OpenMPT/unarchiver/unzip.cpp =================================================================== --- trunk/OpenMPT/unarchiver/unzip.cpp 2015-02-21 19:00:26 UTC (rev 4784) +++ trunk/OpenMPT/unarchiver/unzip.cpp 2015-02-21 21:34:40 UTC (rev 4785) @@ -65,7 +65,7 @@ static long ZCALLBACK fseek64_mem(voidpf opaque, voidpf, ZPOS64_T offset, int origin) { FileReader &file = *static_cast<FileReader *>(opaque); - FileReader::off_t destination = 0; + ZPOS64_T destination = 0; switch(origin) { case ZLIB_FILEFUNC_SEEK_CUR: @@ -80,7 +80,11 @@ default: return -1; } - return (file.Seek(destination) ? 0 : 1); + if(!Util::TypeCanHoldValue<FileReader::off_t>(destination)) + { + return 1; + } + return (file.Seek(static_cast<FileReader::off_t>(destination)) ? 0 : 1); } static int ZCALLBACK fclose_mem(voidpf, voidpf) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2015-02-22 13:12:07
|
Revision: 4786 http://sourceforge.net/p/modplug/code/4786 Author: manxorist Date: 2015-02-22 13:11:53 +0000 (Sun, 22 Feb 2015) Log Message: ----------- [Mod] openmpt123: When both, PortAudio and SDL, are available, default to SDL backend now. SDL is more widespread and generally more reliable. PortAudio support is still valuable because it has no dependency on X11 on Unix-like systems. [Fix] openmpt123: SDL requires power-of-2 buffer sizes and there are backends which enforce this. Round up the buffer size accordingly. [Mod] openmpt123: Make the default buffer sizes for SDL and WaveOut slightly more aggressive. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/dox/changelog.md trunk/OpenMPT/openmpt123/openmpt123.cpp trunk/OpenMPT/openmpt123/openmpt123.hpp trunk/OpenMPT/openmpt123/openmpt123_sdl.hpp trunk/OpenMPT/openmpt123/openmpt123_waveout.hpp Modified: trunk/OpenMPT/libopenmpt/dox/changelog.md =================================================================== --- trunk/OpenMPT/libopenmpt/dox/changelog.md 2015-02-21 21:34:40 UTC (rev 4785) +++ trunk/OpenMPT/libopenmpt/dox/changelog.md 2015-02-22 13:11:53 UTC (rev 4786) @@ -5,6 +5,12 @@ For fully detailed change log, please see the source repository directly. This is just a high-level summary. +### libopenmpt svn + + * openmpt123: When both, SDL1.2 and PortAudio, are available, SDL is now the + preferred backend because SDL is more widespread and better tested on all + kinds of different platforms, and in generel, SDL is just more reliable. + ### 2015-02-17 - libopenmpt 0.2-beta10 * Makefile configuration filenames changed from Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2015-02-21 21:34:40 UTC (rev 4785) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2015-02-22 13:11:53 UTC (rev 4786) @@ -383,9 +383,6 @@ } log << " libopenmpt Features: " << openmpt::string::get( openmpt::string::library_features ) << std::endl; log << " libopenmpt Build: " << openmpt::string::get( openmpt::string::build ) << std::endl; -#ifdef MPT_WITH_PORTAUDIO - log << " " << Pa_GetVersionText() << " (" << Pa_GetVersion() << ") <http://portaudio.com/>" << std::endl; -#endif #ifdef MPT_WITH_SDL const SDL_version * linked_sdlver = SDL_Linked_Version(); log << " libSDL "; @@ -398,6 +395,9 @@ log << "(API: " << static_cast<int>( sdlver.major ) << "." << static_cast<int>( sdlver.minor ) << "." << static_cast<int>( sdlver.patch ) << ")"; log << " <https://libsdl.org/>" << std::endl; #endif +#ifdef MPT_WITH_PORTAUDIO + log << " " << Pa_GetVersionText() << " (" << Pa_GetVersion() << ") <http://portaudio.com/>" << std::endl; +#endif #ifdef MPT_WITH_FLAC log << " FLAC " << FLAC__VERSION_STRING << ", " << FLAC__VENDOR_STRING << ", API " << FLAC_API_VERSION_CURRENT << "." << FLAC_API_VERSION_REVISION << "." << FLAC_API_VERSION_AGE << " <https://xiph.org/flac/>" << std::endl; #endif @@ -1470,7 +1470,7 @@ mod.select_subsong( -1 ); // play all subsongs consecutively silentlog.str( std::string() ); // clear, loader messages get stored to get_metadata( "warnings" ) by libopenmpt internally render_mod_file( flags, filename, filesize, mod, log, audio_stream ); - } + } } catch ( prev_file & ) { throw; @@ -1628,12 +1628,12 @@ std::ostringstream drivers; drivers << " Available drivers:" << std::endl; drivers << " " << "default" << std::endl; +#if defined( MPT_WITH_SDL ) + drivers << " " << "sdl" << std::endl; +#endif #if defined( MPT_WITH_PORTAUDIO ) drivers << " " << "portaudio" << std::endl; #endif -#if defined( MPT_WITH_SDL ) - drivers << " " << "sdl" << std::endl; -#endif #if defined( WIN32 ) drivers << " " << "waveout" << std::endl; #endif @@ -1935,20 +1935,18 @@ flags.apply_default_buffer_sizes(); file_audio_stream_raii file_audio_stream( flags, flags.output_filename, log ); render_files( flags, log, file_audio_stream ); +#if defined( MPT_WITH_SDL ) + } else if ( flags.driver == "sdl" || flags.driver.empty() ) { + sdl_stream_raii sdl_stream( flags, log ); + render_files( flags, log, sdl_stream ); +#endif #if defined( MPT_WITH_PORTAUDIO ) } else if ( flags.driver == "portaudio" || flags.driver.empty() ) { portaudio_stream_raii portaudio_stream( flags, log ); render_files( flags, log, portaudio_stream ); #endif -#if defined( MPT_WITH_SDL ) - } else if ( flags.driver == "sdl" || flags.driver.empty() ) { - flags.apply_default_buffer_sizes(); - sdl_stream_raii sdl_stream( flags ); - render_files( flags, log, sdl_stream ); -#endif #if defined( WIN32 ) } else if ( flags.driver == "waveout" || flags.driver.empty() ) { - flags.apply_default_buffer_sizes(); waveout_stream_raii waveout_stream( flags ); render_files( flags, log, waveout_stream ); #endif Modified: trunk/OpenMPT/openmpt123/openmpt123.hpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.hpp 2015-02-21 21:34:40 UTC (rev 4785) +++ trunk/OpenMPT/openmpt123/openmpt123.hpp 2015-02-22 13:11:53 UTC (rev 4786) @@ -279,7 +279,7 @@ bool paused; void apply_default_buffer_sizes() { if ( ui_redraw_interval == default_high ) { - ui_redraw_interval = 40; + ui_redraw_interval = 50; } else if ( ui_redraw_interval == default_low ) { ui_redraw_interval = 10; } @@ -296,11 +296,11 @@ } commandlineflags() { mode = ModeUI; - ui_redraw_interval = default_high; // 50 ... (-2 == 10) + ui_redraw_interval = default_high; driver = ""; device = -1; - buffer = default_high; // 250 ... (-2 == 50) - period = default_high; // 50 ... (-2 == 10) + buffer = default_high; + period = default_high; samplerate = 48000; channels = 2; use_float = true; Modified: trunk/OpenMPT/openmpt123/openmpt123_sdl.hpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123_sdl.hpp 2015-02-21 21:34:40 UTC (rev 4785) +++ trunk/OpenMPT/openmpt123/openmpt123_sdl.hpp 2015-02-22 13:11:53 UTC (rev 4786) @@ -16,8 +16,12 @@ #if defined(MPT_WITH_SDL) #include <SDL.h> +#ifdef main #undef main +#endif +#ifdef SDL_main #undef SDL_main +#endif namespace openmpt123 { @@ -27,6 +31,7 @@ class sdl_stream_raii : public write_buffers_blocking_wrapper { private: + std::ostream & log; std::size_t channels; protected: void check_sdl_error( int e ) { @@ -35,12 +40,31 @@ return; } } + std::uint32_t round_up_power2(std::uint32_t x) + { + std::uint32_t result = 1; + while ( result < x ) { + result *= 2; + } + return result; + } public: - sdl_stream_raii( const commandlineflags & flags ) + sdl_stream_raii( commandlineflags & flags, std::ostream & log ) : write_buffers_blocking_wrapper(flags) + , log(log) , channels(flags.channels) { - double bufferSeconds = flags.buffer * 0.001; + if ( flags.buffer == default_high ) { + flags.buffer = 160; + } else if ( flags.buffer == default_low ) { + flags.buffer = 80; + } + if ( flags.period == default_high ) { + flags.period = 20; + } else if ( flags.period == default_low ) { + flags.period = 10; + } + flags.apply_default_buffer_sizes(); check_sdl_error( SDL_Init( SDL_INIT_NOPARACHUTE | SDL_INIT_TIMER | SDL_INIT_AUDIO ) ); SDL_AudioSpec audiospec; std::memset( &audiospec, 0, sizeof( SDL_AudioSpec ) ); @@ -48,12 +72,17 @@ audiospec.format = AUDIO_S16SYS; audiospec.channels = flags.channels; audiospec.silence = 0; - audiospec.samples = bufferSeconds * 0.5 * flags.samplerate; + audiospec.samples = round_up_power2( ( flags.buffer * flags.samplerate ) / ( 1000 * 2 ) ); audiospec.size = audiospec.samples * audiospec.channels * sizeof( std::int16_t ); audiospec.callback = &sdl_callback_wrapper; audiospec.userdata = this; + if ( flags.verbose ) { + log << "SDL:" << std::endl; + log << " latency: " << ( audiospec.samples * 2.0 / flags.samplerate ) << " (2 * " << audiospec.samples << ")" << std::endl; + log << std::endl; + } + set_queue_size_frames( round_up_power2( ( flags.buffer * flags.samplerate ) / ( 1000 * 2 ) ) ); check_sdl_error( SDL_OpenAudio( &audiospec, NULL ) ); - set_queue_size_frames( static_cast<std::size_t>( bufferSeconds * 0.5 * flags.samplerate ) ); SDL_PauseAudio( 0 ); } ~sdl_stream_raii() { Modified: trunk/OpenMPT/openmpt123/openmpt123_waveout.hpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123_waveout.hpp 2015-02-21 21:34:40 UTC (rev 4785) +++ trunk/OpenMPT/openmpt123/openmpt123_waveout.hpp 2015-02-22 13:11:53 UTC (rev 4786) @@ -32,13 +32,24 @@ std::vector<std::vector<char> > wavebuffers; std::deque<char> byte_queue; public: - waveout_stream_raii( const commandlineflags & flags ) + waveout_stream_raii( commandlineflags & flags ) : waveout(NULL) , num_channels(0) , num_chunks(0) , frames_per_chunk(0) , bytes_per_chunk(0) { + if ( flags.buffer == default_high ) { + flags.buffer = 150; + } else if ( flags.buffer == default_low ) { + flags.buffer = 50; + } + if ( flags.period == default_high ) { + flags.period = 30; + } else if ( flags.period == default_low ) { + flags.period = 10; + } + flags.apply_default_buffer_sizes(); WAVEFORMATEX wfx; ZeroMemory( &wfx, sizeof( wfx ) ); wfx.wFormatTag = flags.use_float ? WAVE_FORMAT_IEEE_FLOAT : WAVE_FORMAT_PCM; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-02-22 16:19:04
|
Revision: 4787 http://sourceforge.net/p/modplug/code/4787 Author: saga-games Date: 2015-02-22 16:18:51 +0000 (Sun, 22 Feb 2015) Log Message: ----------- [Fix] Something made be believe that out-of-range global volume commands are ignored in XM. Undo previous fix (which is as old as OpenMPT 1.17.03.02). Modules made with OpenMPT since this version are now auto-fixed instead of old modules. Fixed "Reflecter" by Zodiak. [Mod] OpenMPT: Version is now 1.24.02.02 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/UpgradeModule.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-02-22 13:11:53 UTC (rev 4786) +++ trunk/OpenMPT/common/versionNumber.h 2015-02-22 16:18:51 UTC (rev 4787) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 02 -#define VER_MINORMINOR 01 +#define VER_MINORMINOR 02 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-02-22 13:11:53 UTC (rev 4786) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-02-22 16:18:51 UTC (rev 4787) @@ -519,10 +519,13 @@ // } if(!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1; - // IT compatibility 16. FT2, ST3 and IT ignore out-of-range values + // IT compatibility 16. ST3 and IT ignore out-of-range values if(param <= 128) { memory.state.m_nGlobalVolume = param << 1; + } else if(!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_S3M))) + { + memory.state.m_nGlobalVolume = 256; } break; // Global Volume Slide @@ -2711,11 +2714,14 @@ if (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param *= 2; - // IT compatibility 16. FT2, ST3 and IT ignore out-of-range values. + // IT compatibility 16. ST3 and IT ignore out-of-range values. // Test case: globalvol-invalid.it - if (param <= 128) + if(param <= 128) { m_PlayState.m_nGlobalVolume = param * 2; + } else if(!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_S3M))) + { + m_PlayState.m_nGlobalVolume = 256; } break; Modified: trunk/OpenMPT/soundlib/UpgradeModule.cpp =================================================================== --- trunk/OpenMPT/soundlib/UpgradeModule.cpp 2015-02-22 13:11:53 UTC (rev 4786) +++ trunk/OpenMPT/soundlib/UpgradeModule.cpp 2015-02-22 16:18:51 UTC (rev 4787) @@ -70,32 +70,44 @@ return; } - if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 17, 03, 02) || - (!sndFile.IsCompatibleMode(TRK_ALLTRACKERS) && sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00))) + if(sndFile.GetType() == MOD_TYPE_S3M) { - if(m.command == CMD_GLOBALVOLUME) + // Out-of-range global volume commands should be ignored in S3M. Fixed in OpenMPT 1.19 (r831). + // So for tracks made with older versions of OpenMPT, we limit invalid global volume commands. + if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 19, 00, 00) && m.command == CMD_GLOBALVOLUME) { - // Out-of-range global volume commands should be ignored. - // OpenMPT 1.17.03.02 fixed this in compatible mode, OpenMPT 1.20 fixes it in normal mode as well. - // So for tracks made with older versions than OpenMPT 1.17.03.02 or tracks made with 1.17.03.02 <= version < 1.20, we limit invalid global volume commands. - LimitMax(m.param, ModCommand::PARAM((sndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) ? 128: 64)); - } else if(m.command == CMD_S3MCMDEX && (sndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT))) + LimitMax(m.param, ModCommand::PARAM(64)); + } + } + + else if((sndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT))) + { + if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 17, 03, 02) || + (!sndFile.IsCompatibleMode(TRK_IMPULSETRACKER) && sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00))) { + if(m.command == CMD_GLOBALVOLUME) + { + // Out-of-range global volume commands should be ignored in IT. + // OpenMPT 1.17.03.02 fixed this in compatible mode, OpenMPT 1.20 fixes it in normal mode as well. + // So for tracks made with older versions than OpenMPT 1.17.03.02 or tracks made with 1.17.03.02 <= version < 1.20, we limit invalid global volume commands. + LimitMax(m.param, ModCommand::PARAM(128)); + } + // SC0 and SD0 should be interpreted as SC1 and SD1 in IT files. // OpenMPT 1.17.03.02 fixed this in compatible mode, OpenMPT 1.20 fixes it in normal mode as well. - if(m.param == 0xC0) + else if(m.command == CMD_S3MCMDEX) { - m.command = CMD_NONE; - m.note = NOTE_NOTECUT; - } else if(m.param == 0xD0) - { - m.command = CMD_NONE; + if(m.param == 0xC0) + { + m.command = CMD_NONE; + m.note = NOTE_NOTECUT; + } else if(m.param == 0xD0) + { + m.command = CMD_NONE; + } } } - } - if((sndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT))) - { // In the IT format, slide commands with both nibbles set should be ignored. // For note volume slides, OpenMPT 1.18 fixes this in compatible mode, OpenMPT 1.20 fixes this in normal mode as well. const bool noteVolSlide = @@ -129,6 +141,50 @@ } } + else if(sndFile.GetType() == MOD_TYPE_XM) + { + // Something made be believe that out-of-range global volume commands are ignored in XM + // just like they are ignored in IT, but apparently they are not. Aaaaaargh! + if(((sndFile.m_dwLastSavedWithVersion >= MAKE_VERSION_NUMERIC(1, 17, 03, 02) && sndFile.IsCompatibleMode(TRK_FASTTRACKER2)) || (sndFile.m_dwLastSavedWithVersion >= MAKE_VERSION_NUMERIC(1, 20, 00, 00))) + && sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 24, 02, 02) + && m.command == CMD_GLOBALVOLUME + && m.param > 64) + { + m.command = CMD_NONE; + } + + if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 19, 00, 00) + || (!sndFile.IsCompatibleMode(TRK_FASTTRACKER2) && sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00))) + { + if(m.command == CMD_OFFSET && m.volcmd == VOLCMD_TONEPORTAMENTO) + { + // If there are both a portamento and an offset effect, the portamento should be preferred in XM files. + // OpenMPT 1.19 fixed this in compatible mode, OpenMPT 1.20 fixes it in normal mode as well. + m.command = CMD_NONE; + } + } + + if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 01, 10) + && sndFile.m_dwLastSavedWithVersion != MAKE_VERSION_NUMERIC(1, 20, 00, 00) // Ignore compatibility export + && m.volcmd == VOLCMD_TONEPORTAMENTO && m.command == CMD_TONEPORTAMENTO + && (m.vol != 0 || sndFile.IsCompatibleMode(TRK_FASTTRACKER2)) && m.param != 0) + { + // Mx and 3xx on the same row does weird things in FT2: 3xx is completely ignored and the Mx parameter is doubled. Fixed in revision 1312 / OpenMPT 1.20.01.10 + // Previously the values were just added up, so let's fix this! + m.volcmd = VOLCMD_NONE; + const uint16 param = static_cast<uint16>(m.param) + static_cast<uint16>(m.vol << 4); + m.param = mpt::saturate_cast<ModCommand::PARAM>(param); + } + + if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 22, 07, 09) + && sndFile.m_dwLastSavedWithVersion != MAKE_VERSION_NUMERIC(1, 22, 00, 00) // Ignore compatibility export + && m.command == CMD_SPEED && m.param == 0) + { + // OpenMPT can emulate FT2's F00 behaviour now. + m.command = CMD_NONE; + } + } + if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00)) { // Pattern Delay fixes @@ -167,40 +223,6 @@ } } - if(sndFile.GetType() == MOD_TYPE_XM) - { - if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 19, 00, 00) - || (!sndFile.IsCompatibleMode(TRK_FASTTRACKER2) && sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00))) - { - if(m.command == CMD_OFFSET && m.volcmd == VOLCMD_TONEPORTAMENTO) - { - // If there are both a portamento and an offset effect, the portamento should be preferred in XM files. - // OpenMPT 1.19 fixed this in compatible mode, OpenMPT 1.20 fixes it in normal mode as well. - m.command = CMD_NONE; - } - } - - if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 01, 10) - && sndFile.m_dwLastSavedWithVersion != MAKE_VERSION_NUMERIC(1, 20, 00, 00) // Ignore compatibility export - && m.volcmd == VOLCMD_TONEPORTAMENTO && m.command == CMD_TONEPORTAMENTO - && (m.vol != 0 || sndFile.IsCompatibleMode(TRK_FASTTRACKER2)) && m.param != 0) - { - // Mx and 3xx on the same row does weird things in FT2: 3xx is completely ignored and the Mx parameter is doubled. Fixed in revision 1312 / OpenMPT 1.20.01.10 - // Previously the values were just added up, so let's fix this! - m.volcmd = VOLCMD_NONE; - const uint16 param = static_cast<uint16>(m.param) + static_cast<uint16>(m.vol << 4); - m.param = mpt::saturate_cast<ModCommand::PARAM>(param); - } - - if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 22, 07, 09) - && sndFile.m_dwLastSavedWithVersion != MAKE_VERSION_NUMERIC(1, 22, 00, 00) // Ignore compatibility export - && m.command == CMD_SPEED && m.param == 0) - { - // OpenMPT can emulate FT2's F00 behaviour now. - m.command = CMD_NONE; - } - } - // Volume column offset in IT/XM is bad, mkay? if(sndFile.GetType() != MOD_TYPE_MPT && m.volcmd == VOLCMD_OFFSET && m.command == CMD_NONE) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2015-02-22 21:37:44
|
Revision: 4788 http://sourceforge.net/p/modplug/code/4788 Author: saga-games Date: 2015-02-22 21:37:31 +0000 (Sun, 22 Feb 2015) Log Message: ----------- [Mod] Apply DNA and NNA settings when previewing notes in the instrument editor (http://bugs.openmpt.org/view.php?id=437) Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2015-02-22 16:18:51 UTC (rev 4787) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2015-02-22 21:37:31 UTC (rev 4788) @@ -1060,8 +1060,6 @@ { CriticalSection cs; - //OnPlayerPause(); // pause song - pausing VSTis is too slow - // All notes off for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) { @@ -1140,14 +1138,12 @@ chn.nLength = chn.nLoopEnd = chn.pModSample->nLength; } - //rewbs.vstiLive + // VSTi preview if (nins <= m_SndFile.GetNumInstruments()) { const ModInstrument *pIns = m_SndFile.Instruments[nins]; if (pIns && pIns->HasValidMIDIChannel()) // instro sends to a midi chan { - // UINT nPlugin = m_SndFile.GetBestPlugin(nChn, PRIORITISE_INSTRUMENT, EVEN_IF_MUTED); - PLUGINDEX nPlugin = 0; if (chn.pModInstrument) nPlugin = chn.pModInstrument->nMixPlug; // First try instrument plugin @@ -1165,8 +1161,6 @@ } } } - //end rewbs.vstiLive - } else { CriticalSection cs; Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2015-02-22 16:18:51 UTC (rev 4787) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2015-02-22 21:37:31 UTC (rev 4788) @@ -15,13 +15,12 @@ #include "InputHandler.h" #include "Childfrm.h" #include "Moddoc.h" -#include "globals.h" -#include "ctrl_ins.h" -#include "view_ins.h" +#include "Globals.h" +#include "Ctrl_ins.h" +#include "View_ins.h" #include "Dlsbank.h" #include "channelManagerDlg.h" #include "ScaleEnvPointsDlg.h" -#include "view_ins.h" #include "../soundlib/MIDIEvents.h" #include "../common/StringFixer.h" @@ -1933,28 +1932,56 @@ } else if (m_nInstrument && !m_baPlayingNote[note]) { - //rewbs.instViewNNA - /* CSoundFile *pSoundFile = pModDoc->GetSoundFile(); - if (pSoundFile && m_baPlayingNote>0 && m_nPlayingChannel>=0) + CSoundFile &sndFile = pModDoc->GetrSoundFile(); + ModInstrument *pIns = sndFile.Instruments[m_nInstrument]; + if ((!pIns) || (!pIns->Keyboard[note - NOTE_MIN] && !pIns->nMixPlug)) return; + { - ModChannel *pChn = &(pSoundFile->Chn[m_nPlayingChannel]); //Get pointer to channel playing last note. - if (pChn->pHeader) //is it valid? + if (pMainFrm->GetModPlaying() != pModDoc) { - DWORD tempflags = pChn->dwFlags; - pChn->dwFlags = 0; - pModDoc->GetSoundFile()->CheckNNA(m_nPlayingChannel, m_nInstrument, note, FALSE); //if so, apply NNA - pChn->dwFlags = tempflags; + sndFile.m_SongFlags.set(SONG_PAUSED); + pMainFrm->PlayMod(pModDoc); } + CriticalSection cs; + // Apply NNA/DNA + for(CHANNELINDEX chn = sndFile.GetNumChannels(); chn < MAX_CHANNELS; chn++) + { + const ModChannel &channel = sndFile.m_PlayState.Chn[chn]; + if(channel.pModInstrument == pIns && channel.nMasterChn == 0 && ModCommand::IsNote(channel.nNote) + && (channel.nLength || pIns->HasValidMIDIChannel()) && !m_baPlayingNote[channel.nNote]) + { + CHANNELINDEX nnaChn = sndFile.CheckNNA(chn, m_nInstrument, note, false); + // We need to update this mix channel immediately since new notes may be triggered between ticks, in which case + // ChnMix may not contain the moved channel yet and the past note will stop playing for the rest of this tick! + if(nnaChn != CHANNELINDEX_INVALID) + { + CHANNELINDEX origChnPos = CHANNELINDEX_INVALID; + for(CHANNELINDEX i = 0; i < sndFile.m_nMixChannels; i++) + { + if(sndFile.m_PlayState.ChnMix[i] == nnaChn) + { + // Nothing to do + origChnPos = CHANNELINDEX_INVALID; + break; + } else if(sndFile.m_PlayState.ChnMix[i] == chn) + { + origChnPos = i; + } + } + if(origChnPos != CHANNELINDEX_INVALID) + { + sndFile.m_PlayState.ChnMix[origChnPos] = nnaChn; + } + } + } + } + m_baPlayingNote[note] = true; + pModDoc->PlayNote(note, m_nInstrument, 0, false); } - */ - ModInstrument *pIns = pModDoc->GetrSoundFile().Instruments[m_nInstrument]; - if ((!pIns) || (!pIns->Keyboard[note - NOTE_MIN] && !pIns->nMixPlug)) return; - m_baPlayingNote[note] = true; //rewbs.instViewNNA - pModDoc->PlayNote(note, m_nInstrument, 0, false); //rewbs.instViewNNA s[0] = 0; if ((note) && (note <= NOTE_MAX)) { - const std::string temp = pModDoc->GetrSoundFile().GetNoteName(note, m_nInstrument); + const std::string temp = sndFile.GetNoteName(note, m_nInstrument); mpt::String::Copy(s, temp.c_str()); } pMainFrm->SetInfoText(s); Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-02-22 16:18:51 UTC (rev 4787) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-02-22 21:37:31 UTC (rev 4788) @@ -1589,13 +1589,13 @@ if (!pChn->nFadeOutVol) return 0; // All channels are used: check for lowest volume CHANNELINDEX result = 0; - DWORD vol = 64*65536; // 25% - DWORD envpos = 0xFFFFFF; + uint32_t vol = 64*65536; // 25% + uint32_t envpos = int32_max; const ModChannel *pj = &m_PlayState.Chn[m_nChannels]; for (CHANNELINDEX j=m_nChannels; j<MAX_CHANNELS; j++, pj++) { if (!pj->nFadeOutVol) return j; - DWORD v = pj->nVolume; + uint32_t v = pj->nVolume; if(pj->dwFlags[CHN_NOTEFADE]) v = v * pj->nFadeOutVol; else @@ -1612,26 +1612,27 @@ } -void CSoundFile::CheckNNA(CHANNELINDEX nChn, UINT instr, int note, bool forceCut) -//------------------------------------------------------------------------------- +CHANNELINDEX CSoundFile::CheckNNA(CHANNELINDEX nChn, UINT instr, int note, bool forceCut) +//--------------------------------------------------------------------------------------- { + CHANNELINDEX nnaChn = CHANNELINDEX_INVALID; ModChannel *pChn = &m_PlayState.Chn[nChn]; const ModInstrument *pIns = nullptr; if(!ModCommand::IsNote(note)) { - return; + return nnaChn; } // Always NNA cut - using if(!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_MT2)) || !m_nInstruments || forceCut) { if(!pChn->nLength || pChn->dwFlags[CHN_MUTE] || !(pChn->rightVol | pChn->leftVol)) { - return; + return CHANNELINDEX_INVALID; } - CHANNELINDEX n = GetNNAChannel(nChn); - if(!n) return; - ModChannel &chn = m_PlayState.Chn[n]; + nnaChn = GetNNAChannel(nChn); + if(!nnaChn) return CHANNELINDEX_INVALID; + ModChannel &chn = m_PlayState.Chn[nnaChn]; // Copy Channel chn = *pChn; chn.dwFlags.reset(CHN_VIBRATO | CHN_TREMOLO | CHN_MUTE | CHN_PORTAMENTO); @@ -1646,7 +1647,7 @@ pChn->nLength = pChn->nPos = pChn->nPosLo = 0; pChn->nROfs = pChn->nLOfs = 0; pChn->rightVol = pChn->leftVol = 0; - return; + return nnaChn; } if(instr >= MAX_INSTRUMENTS) instr = 0; const ModSample *pSample = pChn->pModSample; @@ -1669,14 +1670,14 @@ // Impulse Tracker ignores empty slots. // We won't ignore them if a plugin is assigned to this slot, so that VSTis still work as intended. // Test case: emptyslot.it, PortaInsNum.it, gxsmp.it, gxsmp2.it - return; + return CHANNELINDEX_INVALID; } } } else pSample = nullptr; } ModChannel *p = pChn; //if (!pIns) return; - if (pChn->dwFlags[CHN_MUTE]) return; + if (pChn->dwFlags[CHN_MUTE]) return CHANNELINDEX_INVALID; bool applyDNAtoPlug; //rewbs.VSTiNNA @@ -1794,20 +1795,16 @@ //if ((pChn->nVolume) && (pChn->nLength)) if((pChn->nVolume != 0 && pChn->nLength != 0) || applyNNAtoPlug) //rewbs.VSTiNNA { - CHANNELINDEX n = GetNNAChannel(nChn); - if(n != 0) + nnaChn = GetNNAChannel(nChn); + if(nnaChn != 0) { - ModChannel *p = &m_PlayState.Chn[n]; + ModChannel *p = &m_PlayState.Chn[nnaChn]; // Copy Channel *p = *pChn; - p->dwFlags.reset(CHN_VIBRATO | CHN_TREMOLO | CHN_MUTE | CHN_PORTAMENTO); + p->dwFlags.reset(CHN_VIBRATO | CHN_TREMOLO | CHN_PORTAMENTO); p->nPanbrelloOffset = 0; - //rewbs: Copy mute and FX status from master chan. - //I'd like to copy other flags too, but this would change playback behaviour. - p->dwFlags.set(pChn->dwFlags & (CHN_MUTE | CHN_NOFX)); - - p->nMasterChn = nChn + 1; + p->nMasterChn = nChn < GetNumChannels() ? nChn + 1 : 0; p->nCommand = CMD_NONE; //rewbs.VSTiNNA if(applyNNAtoPlug && pPlugin) @@ -1849,6 +1846,7 @@ pChn->nROfs = pChn->nLOfs = 0; } } + return nnaChn; } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2015-02-22 16:18:51 UTC (rev 4787) +++ trunk/OpenMPT/soundlib/Sndfile.h 2015-02-22 21:37:31 UTC (rev 4788) @@ -486,9 +486,8 @@ public: bool m_bPositionChanged; // Report to plugins that we jumped around in the module - protected: + public: CHANNELINDEX ChnMix[MAX_CHANNELS]; // Channels to be mixed - public: ModChannel Chn[MAX_CHANNELS]; // Mixing channels... First m_nChannel channels are master channels (i.e. they are never NNA channels)! protected: @@ -772,7 +771,7 @@ bool ProcessRow(); bool ProcessEffects(); CHANNELINDEX GetNNAChannel(CHANNELINDEX nChn) const; - void CheckNNA(CHANNELINDEX nChn, UINT instr, int note, bool forceCut); + CHANNELINDEX CheckNNA(CHANNELINDEX nChn, UINT instr, int note, bool forceCut); void NoteChange(ModChannel *pChn, int note, bool bPorta = false, bool bResetEnv = true, bool bManual = false) const; void InstrumentChange(ModChannel *pChn, UINT instr, bool bPorta = false, bool bUpdVol = true, bool bResetEnv = true) const; void ApplyInstrumentPanning(ModChannel *pChn, const ModInstrument *instr, const ModSample *smp) const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |