From: <man...@us...> - 2014-11-03 20:14:48
|
Revision: 4546 http://sourceforge.net/p/modplug/code/4546 Author: manxorist Date: 2014-11-03 20:14:36 +0000 (Mon, 03 Nov 2014) Log Message: ----------- [Ref] sounddev: Convert from std::wstring to mpt::ustring. Modified Paths: -------------- 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/SoundDevicePortAudio.cpp trunk/OpenMPT/sounddev/SoundDevicePortAudio.h trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-11-03 20:14:36 UTC (rev 4546) @@ -598,17 +598,17 @@ StoredSoundDeviceSettings(SettingsContainer &conf, const SoundDevice::Info & deviceInfo, const SoundDevice::Settings & defaults) : conf(conf) , deviceInfo(deviceInfo) - , LatencyUS(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"Latency", Util::Round<int32>(defaults.Latency * 1000000.0)) - , UpdateIntervalUS(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"UpdateInterval", Util::Round<int32>(defaults.UpdateInterval * 1000000.0)) - , Samplerate(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"SampleRate", defaults.Samplerate) - , Channels(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"Channels", defaults.Channels) - , sampleFormat(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"SampleFormat", defaults.sampleFormat) - , ExclusiveMode(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"ExclusiveMode", defaults.ExclusiveMode) - , BoostThreadPriority(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"BoostThreadPriority", defaults.BoostThreadPriority) - , KeepDeviceRunning(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"KeepDeviceRunning", defaults.KeepDeviceRunning) - , UseHardwareTiming(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"UseHardwareTiming", defaults.UseHardwareTiming) - , DitherType(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"DitherType", defaults.DitherType) - , ChannelMapping(conf, L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"ChannelMapping", defaults.ChannelMapping) + , LatencyUS(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"Latency", Util::Round<int32>(defaults.Latency * 1000000.0)) + , UpdateIntervalUS(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"UpdateInterval", Util::Round<int32>(defaults.UpdateInterval * 1000000.0)) + , Samplerate(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"SampleRate", defaults.Samplerate) + , Channels(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"Channels", defaults.Channels) + , sampleFormat(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"SampleFormat", defaults.sampleFormat) + , ExclusiveMode(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"ExclusiveMode", defaults.ExclusiveMode) + , BoostThreadPriority(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"BoostThreadPriority", defaults.BoostThreadPriority) + , KeepDeviceRunning(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"KeepDeviceRunning", defaults.KeepDeviceRunning) + , UseHardwareTiming(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"UseHardwareTiming", defaults.UseHardwareTiming) + , DitherType(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"DitherType", defaults.DitherType) + , ChannelMapping(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"ChannelMapping", defaults.ChannelMapping) { if(ChannelMapping.Get().GetNumHostChannels() != Channels) { @@ -616,10 +616,10 @@ ChannelMapping = SoundDevice::ChannelMapping(Channels); } // store informational data (not read back, just to allow the user to mock with the raw ini file) - conf.Write(L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"ID", deviceInfo.id); - conf.Write(L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"InternalID", deviceInfo.internalID); - conf.Write(L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"API", deviceInfo.apiName); - conf.Write(L"Sound Settings", deviceInfo.GetIdentifier() + L"_" + L"Name", deviceInfo.name); + conf.Write(L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"ID", deviceInfo.id); + conf.Write(L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"InternalID", deviceInfo.internalID); + conf.Write(L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"API", deviceInfo.apiName); + conf.Write(L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"Name", deviceInfo.name); } StoredSoundDeviceSettings & operator = (const SoundDevice::Settings &settings) Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-11-03 20:14:36 UTC (rev 4546) @@ -33,21 +33,21 @@ namespace SoundDevice { -std::wstring TypeToString(SoundDevice::Type type) +mpt::ustring TypeToString(SoundDevice::Type type) //----------------------------------------------- { switch(type) { - case TypeWAVEOUT: return L"WaveOut"; break; - case TypeDSOUND: return L"DirectSound"; break; - case TypeASIO: return L"ASIO"; break; - case TypePORTAUDIO_WASAPI: return L"WASAPI"; break; - case TypePORTAUDIO_WDMKS: return L"WDM-KS"; break; - case TypePORTAUDIO_WMME: return L"MME"; break; - case TypePORTAUDIO_DS: return L"DS"; break; - case TypePORTAUDIO_ASIO: return L"ASIO"; break; + case TypeWAVEOUT: return MPT_USTRING("WaveOut"); break; + case TypeDSOUND: return MPT_USTRING("DirectSound"); break; + case TypeASIO: return MPT_USTRING("ASIO"); break; + case TypePORTAUDIO_WASAPI: return MPT_USTRING("WASAPI"); break; + case TypePORTAUDIO_WDMKS: return MPT_USTRING("WDM-KS"); break; + case TypePORTAUDIO_WMME: return MPT_USTRING("MME"); break; + case TypePORTAUDIO_DS: return MPT_USTRING("DS"); break; + case TypePORTAUDIO_ASIO: return MPT_USTRING("ASIO"); break; } - return std::wstring(); + return mpt::ustring(); } @@ -551,7 +551,7 @@ { for(int i = 0; i < TypeNUM_DEVTYPES; ++i) { - const std::wstring api = SoundDevice::TypeToString(static_cast<SoundDevice::Type>(i)); + const mpt::ustring api = SoundDevice::TypeToString(static_cast<SoundDevice::Type>(i)); if(identifier.find(api) == 0) { return static_cast<SoundDevice::Type>(i); Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2014-11-03 20:14:36 UTC (rev 4546) @@ -95,7 +95,7 @@ TypeNUM_DEVTYPES }; -std::wstring TypeToString(SoundDevice::Type type); +mpt::ustring TypeToString(SoundDevice::Type type); typedef uint8 Index; @@ -154,7 +154,7 @@ }; -typedef std::wstring Identifier; +typedef mpt::ustring Identifier; SoundDevice::Type ParseType(const SoundDevice::Identifier &identifier); @@ -162,12 +162,12 @@ struct Info { SoundDevice::ID id; - std::wstring name; - std::wstring apiName; - std::wstring internalID; + mpt::ustring name; + mpt::ustring apiName; + mpt::ustring internalID; bool isDefault; Info() : id(TypeINVALID, 0), isDefault(false) { } - Info(SoundDevice::ID id, const std::wstring &name, const std::wstring &apiName, const std::wstring &internalID = std::wstring()) + Info(SoundDevice::ID id, const mpt::ustring &name, const mpt::ustring &apiName, const mpt::ustring &internalID = mpt::ustring()) : id(id) , name(name) , apiName(apiName) @@ -184,10 +184,10 @@ { if(!IsValid()) { - return std::wstring(); + return mpt::ustring(); } - std::wstring result = apiName; - result += L"_"; + mpt::ustring result = apiName; + result += MPT_USTRING("_"); if(!internalID.empty()) { result += internalID; // safe to not contain special characters @@ -196,11 +196,11 @@ // UTF8-encode the name and convert the utf8 to hex. // This ensures that no special characters are contained in the configuration key. std::string utf8String = mpt::ToCharset(mpt::CharsetUTF8, name); - std::wstring hexString = Util::BinToHex(std::vector<char>(utf8String.begin(), utf8String.end())); + mpt::ustring hexString = mpt::ToUnicode(Util::BinToHex(std::vector<char>(utf8String.begin(), utf8String.end()))); result += hexString; } else { - result += mpt::ToWString(id.GetIndex()); + result += mpt::ufmt::dec(id.GetIndex()); } return result; } @@ -385,7 +385,7 @@ bool CanChannelMapping; bool CanDriverPanel; bool HasInternalDither; - std::wstring ExclusiveModeDescription; + mpt::ustring ExclusiveModeDescription; double LatencyMin; double LatencyMax; double UpdateIntervalMin; @@ -402,7 +402,7 @@ , CanChannelMapping(false) , CanDriverPanel(false) , HasInternalDither(false) - , ExclusiveModeDescription(L"Use device exclusively") + , ExclusiveModeDescription(MPT_USTRING("Use device exclusively")) , LatencyMin(0.002) // 2ms , LatencyMax(0.5) // 500ms , UpdateIntervalMin(0.001) // 1ms @@ -418,7 +418,7 @@ uint32 currentSampleRate; std::vector<uint32> supportedSampleRates; std::vector<uint32> supportedExclusiveSampleRates; - std::vector<std::wstring> channelNames; + std::vector<mpt::ustring> channelNames; DynamicCaps() : currentSampleRate(0) { @@ -557,7 +557,7 @@ SoundDevice::ID GetDeviceID() const { return m_Info.id; } SoundDevice::Type GetDeviceType() const { return m_Info.id.GetType(); } SoundDevice::Index GetDeviceIndex() const { return m_Info.id.GetIndex(); } - std::wstring GetDeviceInternalID() const { return m_Info.internalID; } + mpt::ustring GetDeviceInternalID() const { return m_Info.internalID; } SoundDevice::Identifier GetDeviceIdentifier() const { return m_Info.GetIdentifier(); } virtual void InternalFillAudioBuffer() = 0; Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2014-11-03 20:14:36 UTC (rev 4546) @@ -139,14 +139,14 @@ WCHAR descriptionBuf[ASIO_MAXDRVNAMELEN]; DWORD datatype = REG_SZ; DWORD datasize = sizeof(descriptionBuf); - std::wstring description; + mpt::ustring description; if(ERROR_SUCCESS == RegQueryValueExW(hksub, L"Description", 0, &datatype, (LPBYTE)descriptionBuf, &datasize)) { Log(mpt::String::Print("ASIO: description='%1'", mpt::ToLocale(description))); - description = descriptionBuf; + description = mpt::ToUnicode(descriptionBuf); } else { - description = keyname; + description = mpt::ToUnicode(keyname); } WCHAR idBuf[256]; @@ -154,8 +154,8 @@ datasize = sizeof(idBuf); if(ERROR_SUCCESS == RegQueryValueExW(hksub, L"CLSID", 0, &datatype, (LPBYTE)idBuf, &datasize)) { - const std::wstring internalID = idBuf; - if(Util::IsCLSID(internalID)) + const mpt::ustring internalID = mpt::ToUnicode(idBuf); + if(Util::IsCLSID(mpt::ToWide(internalID))) { Log(mpt::String::Print("ASIO: clsid=%1", mpt::ToLocale(internalID))); if(SoundDevice::IndexIsValid(devices.size())) @@ -669,7 +669,7 @@ { return; } - CLSID clsid = Util::StringToCLSID(GetDeviceInternalID()); + CLSID clsid = Util::StringToCLSID(mpt::ToWide(GetDeviceInternalID())); try { if(CoCreateInstance(clsid,0,CLSCTX_INPROC_SERVER, clsid, (void **)&m_pAsioDrv) != S_OK) @@ -1434,12 +1434,12 @@ MemsetZero(channelInfo); channelInfo.channel = i; channelInfo.isInput = ASIOFalse; - std::wstring name = mpt::ToWString(i); + mpt::ustring name = mpt::ufmt::dec(i); try { asioCall(getChannelInfo(&channelInfo)); mpt::String::SetNullTerminator(channelInfo.name); - name = mpt::ToWide(mpt::CharsetLocale, channelInfo.name); + name = mpt::ToUnicode(mpt::CharsetLocale, channelInfo.name); } catch(...) { // continue Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2014-11-03 20:14:36 UTC (rev 4546) @@ -53,11 +53,11 @@ } SoundDevice::Info info; info.id = SoundDevice::ID(TypeDSOUND, static_cast<SoundDevice::Index>(devices.size())); - info.name = lpstrDescription; + info.name = mpt::ToUnicode(lpstrDescription); info.apiName = SoundDevice::TypeToString(TypeDSOUND); if(lpGuid) { - info.internalID = Util::GUIDToString(*lpGuid); + info.internalID = mpt::ToUnicode(Util::GUIDToString(*lpGuid)); } devices.push_back(info); return TRUE; @@ -107,7 +107,7 @@ caps.CanUseHardwareTiming = false; caps.CanChannelMapping = false; caps.CanDriverPanel = false; - caps.ExclusiveModeDescription = L"Use primary buffer"; + caps.ExclusiveModeDescription = MPT_USTRING("Use primary buffer"); caps.DefaultSettings.sampleFormat = SampleFormatInt16; IDirectSound *dummy = nullptr; IDirectSound *ds = nullptr; @@ -116,8 +116,8 @@ ds = m_piDS; } else { - const std::wstring internalID = GetDeviceInternalID(); - GUID guid = internalID.empty() ? GUID() : Util::StringToGUID(internalID); + const mpt::ustring internalID = GetDeviceInternalID(); + GUID guid = internalID.empty() ? GUID() : Util::StringToGUID(mpt::ToWide(internalID)); if(DirectSoundCreate(internalID.empty() ? NULL : &guid, &dummy, NULL) != DS_OK) { return caps; @@ -159,8 +159,8 @@ ds = m_piDS; } else { - const std::wstring internalID = GetDeviceInternalID(); - GUID guid = internalID.empty() ? GUID() : Util::StringToGUID(internalID); + const mpt::ustring internalID = GetDeviceInternalID(); + GUID guid = internalID.empty() ? GUID() : Util::StringToGUID(mpt::ToWide(internalID)); if(DirectSoundCreate(internalID.empty() ? NULL : &guid, &dummy, NULL) != DS_OK) { return caps; @@ -214,8 +214,8 @@ DSBCAPS dsc; if(m_piDS) return true; - const std::wstring internalID = GetDeviceInternalID(); - GUID guid = internalID.empty() ? GUID() : Util::StringToGUID(internalID); + const mpt::ustring internalID = GetDeviceInternalID(); + 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) Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2014-11-03 20:14:36 UTC (rev 4546) @@ -426,13 +426,13 @@ } -std::wstring CPortaudioDevice::HostApiToString(PaHostApiIndex hostapi) +mpt::ustring CPortaudioDevice::HostApiToString(PaHostApiIndex hostapi) //-------------------------------------------------------------------- { SoundDevice::Type type = HostApiToSndDevType(hostapi); if(type == TypeINVALID) { - return L"PortAudio"; + return MPT_USTRING("PortAudio"); } return SoundDevice::TypeToString(type); } @@ -448,7 +448,7 @@ if(!Pa_GetDeviceInfo(dev)) return false; result.id = SoundDevice::ID(HostApiToSndDevType(hostapi), index); - result.name = mpt::ToWide(mpt::CharsetUTF8, Pa_GetDeviceInfo(dev)->name); + result.name = mpt::ToUnicode(mpt::CharsetUTF8, Pa_GetDeviceInfo(dev)->name); result.apiName = HostApiToString(Pa_GetDeviceInfo(dev)->hostApi); result.isDefault = (Pa_GetHostApiInfo(Pa_GetDeviceInfo(dev)->hostApi)->defaultOutputDevice == (PaDeviceIndex)dev); PALOG(mpt::String::Print("PortAudio: %1, %2, %3, %4", result.id.GetIdRaw(), mpt::ToLocale(result.name), mpt::ToLocale(result.apiName), result.isDefault)); Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2014-11-03 20:14:36 UTC (rev 4546) @@ -77,7 +77,7 @@ void *userData ); - static std::wstring HostApiToString(PaHostApiIndex hostapi); + static mpt::ustring HostApiToString(PaHostApiIndex hostapi); static PaDeviceIndex HostApiOutputIndexToGlobalDeviceIndex(int hostapioutputdeviceindex, PaHostApiIndex hostapi); static SoundDevice::Type HostApiToSndDevType(PaHostApiIndex hostapi); Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2014-11-03 19:29:38 UTC (rev 4545) +++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2014-11-03 20:14:36 UTC (rev 4546) @@ -75,7 +75,7 @@ caps.CanChannelMapping = false; caps.CanDriverPanel = false; caps.HasInternalDither = false; - caps.ExclusiveModeDescription = L"Use direct mode"; + caps.ExclusiveModeDescription = MPT_USTRING("Use direct mode"); if(mpt::Windows::Version::IsWine()) { caps.DefaultSettings.sampleFormat = SampleFormatInt16; @@ -327,17 +327,17 @@ { if(waveOutGetDevCapsW(WAVE_MAPPER, &woc, sizeof(woc)) == MMSYSERR_NOERROR) { - info.name = woc.szPname; + info.name = mpt::ToUnicode(woc.szPname); } else { - info.name = L"Auto (Wave Mapper)"; + info.name = MPT_USTRING("Auto (Wave Mapper)"); } info.isDefault = true; } else { if(waveOutGetDevCapsW(index-1, &woc, sizeof(woc)) == MMSYSERR_NOERROR) { - info.name = woc.szPname; + info.name = mpt::ToUnicode(woc.szPname); } } devices.push_back(info); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |