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. |