From: <man...@us...> - 2015-05-04 16:01:11
|
Revision: 5042 http://sourceforge.net/p/modplug/code/5042 Author: manxorist Date: 2015-05-04 16:01:05 +0000 (Mon, 04 May 2015) Log Message: ----------- [Ref] sounddev: Avoid empty internalID for the default DirectSound device. Use a zero-GUID instead. [Mod] OpenMPT: Version is now 1.25.00.04 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-05-04 08:01:15 UTC (rev 5041) +++ trunk/OpenMPT/common/versionNumber.h 2015-05-04 16:01:05 UTC (rev 5042) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 25 #define VER_MINOR 00 -#define VER_MINORMINOR 03 +#define VER_MINORMINOR 04 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2015-05-04 08:01:15 UTC (rev 5041) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2015-05-04 16:01:05 UTC (rev 5042) @@ -1010,6 +1010,46 @@ TrackerSettings::Instance().SetSoundDeviceSettings(it->GetIdentifier(), TrackerSettings::Instance().GetSoundDeviceSettingsDefaults()); } } + if(TrackerSettings::Instance().m_SoundDeviceDirectSoundOldDefaultIdentifier) + { + mpt::ustring oldIdentifier = SoundDevice::Legacy::GetDirectSoundDefaultDeviceIdentifierPre_1_25_00_04(); + mpt::ustring newIdentifier = SoundDevice::Legacy::GetDirectSoundDefaultDeviceIdentifier_1_25_00_04(); + if(!oldIdentifier.empty()) + { + SoundDevice::Info info = m_pSoundDevicesManager->FindDeviceInfo(newIdentifier); + if(info.IsValid()) + { + SoundDevice::Settings defaults = + TrackerSettings::Instance().m_SoundDeviceSettingsUseOldDefaults ? + TrackerSettings::Instance().GetSoundDeviceSettingsDefaults() + : + m_pSoundDevicesManager->GetDeviceCaps(newIdentifier).DefaultSettings + ; + m_pSettings->Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"Latency", + m_pSettings->Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"Latency", Util::Round<int32>(defaults.Latency * 1000000.0))); + m_pSettings->Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"UpdateInterval", + m_pSettings->Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"UpdateInterval", Util::Round<int32>(defaults.UpdateInterval * 1000000.0))); + m_pSettings->Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"SampleRate", + m_pSettings->Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"SampleRate", defaults.Samplerate)); + m_pSettings->Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"Channels", + m_pSettings->Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"Channels", defaults.Channels)); + m_pSettings->Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"SampleFormat", + m_pSettings->Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"SampleFormat", defaults.sampleFormat)); + m_pSettings->Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"ExclusiveMode", + m_pSettings->Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"ExclusiveMode", defaults.ExclusiveMode)); + m_pSettings->Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"BoostThreadPriority", + m_pSettings->Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"BoostThreadPriority", defaults.BoostThreadPriority)); + m_pSettings->Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"KeepDeviceRunning", + m_pSettings->Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"KeepDeviceRunning", defaults.KeepDeviceRunning)); + m_pSettings->Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"UseHardwareTiming", + m_pSettings->Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"UseHardwareTiming", defaults.UseHardwareTiming)); + m_pSettings->Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"DitherType", + m_pSettings->Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"DitherType", defaults.DitherType)); + m_pSettings->Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"ChannelMapping", + m_pSettings->Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"ChannelMapping", defaults.ChannelMapping)); + } + } + } // Load DLS Banks if (!cmdInfo.m_bNoDls) LoadDefaultDLSBanks(); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-05-04 08:01:15 UTC (rev 5041) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-05-04 16:01:05 UTC (rev 5042) @@ -178,6 +178,7 @@ , m_SoundSettingsStopMode(conf, "Sound Settings", "StopMode", SoundDeviceStopModeClosed) , m_SoundDeviceSettingsUseOldDefaults(false) , m_SoundDeviceID_DEPRECATED(SoundDevice::ID()) + , m_SoundDeviceDirectSoundOldDefaultIdentifier(false) , m_SoundDeviceIdentifier(conf, "Sound Settings", "Device", SoundDevice::Identifier()) , m_SoundDevicePreferSameTypeIfDeviceUnavailable(conf, "Sound Settings", "PreferSameTypeIfDeviceUnavailable", false) , MixerMaxChannels(conf, "Sound Settings", "MixChannels", MixerSettings().m_nMaxMixChannels) @@ -481,6 +482,10 @@ } m_SoundDeviceSettingsUseOldDefaults = true; } + if(storedVersion < MAKE_VERSION_NUMERIC(1,25,00,04)) + { + m_SoundDeviceDirectSoundOldDefaultIdentifier = true; + } if(storedVersion < MAKE_VERSION_NUMERIC(1,21,01,26)) { MixerFlags &= ~OLD_SOUNDSETUP_REVERSESTEREO; Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2015-05-04 08:01:15 UTC (rev 5041) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2015-05-04 16:01:05 UTC (rev 5042) @@ -445,6 +445,7 @@ SoundDevice::ID m_SoundDeviceID_DEPRECATED; SoundDevice::Settings m_SoundDeviceSettingsDefaults; SoundDevice::Settings GetSoundDeviceSettingsDefaults() const; + bool m_SoundDeviceDirectSoundOldDefaultIdentifier; Setting<SoundDevice::Identifier> m_SoundDeviceIdentifier; Setting<bool> m_SoundDevicePreferSameTypeIfDeviceUnavailable; Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2015-05-04 08:01:15 UTC (rev 5041) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2015-05-04 16:01:05 UTC (rev 5042) @@ -698,6 +698,13 @@ }; +namespace Legacy +{ +mpt::ustring GetDirectSoundDefaultDeviceIdentifierPre_1_25_00_04(); +mpt::ustring GetDirectSoundDefaultDeviceIdentifier_1_25_00_04(); +} + + } // namespace SoundDevice Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-05-04 08:01:15 UTC (rev 5041) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-05-04 16:01:05 UTC (rev 5042) @@ -37,6 +37,46 @@ MPT_REGISTERED_COMPONENT(ComponentDirectSound) + +namespace Legacy +{ +static BOOL WINAPI DSEnumCallbackGetDefaultName(GUID * lpGuid, LPCWSTR lpstrDescription, LPCWSTR, LPVOID lpContext) +{ + mpt::ustring & name = *reinterpret_cast<mpt::ustring*>(lpContext); + if(!lpGuid) + { + if(lpstrDescription) + { + name = mpt::ToUnicode(std::wstring(lpstrDescription)); + return FALSE; + } + } + return TRUE; +} +mpt::ustring GetDirectSoundDefaultDeviceIdentifierPre_1_25_00_04() +{ + mpt::ustring name = mpt::ustring(); + ComponentHandle<ComponentDirectSound> drectSound; + if(!IsComponentAvailable(drectSound)) + { + return name; + } + DirectSoundEnumerateW(DSEnumCallbackGetDefaultName, &name); + if(name.empty()) + { + return name; + } + std::string utf8String = mpt::ToCharset(mpt::CharsetUTF8, name); + mpt::ustring hexString = Util::BinToHex(std::vector<char>(utf8String.begin(), utf8String.end())); + return MPT_USTRING("DirectSound") + MPT_USTRING("_") + hexString; +} +mpt::ustring GetDirectSoundDefaultDeviceIdentifier_1_25_00_04() +{ + return MPT_USTRING("DirectSound_{00000000-0000-0000-0000-000000000000}"); +} +} + + static BOOL WINAPI DSEnumCallbackW(GUID * lpGuid, LPCWSTR lpstrDescription, LPCWSTR, LPVOID lpContext) //---------------------------------------------------------------------------------------------------- { @@ -56,6 +96,9 @@ if(lpGuid) { info.internalID = mpt::ToUnicode(Util::GUIDToString(*lpGuid)); + } else + { + info.internalID = mpt::ToUnicode(Util::GUIDToString(GUID())); } devices.push_back(info); return TRUE; @@ -115,9 +158,8 @@ ds = m_piDS; } else { - 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) + GUID guid = Util::StringToGUID(mpt::ToWide(GetDeviceInternalID())); + if(DirectSoundCreate(Util::IsValid(guid) ? &guid : NULL, &dummy, NULL) != DS_OK) { return caps; } @@ -158,9 +200,8 @@ ds = m_piDS; } else { - 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) + GUID guid = Util::StringToGUID(mpt::ToWide(GetDeviceInternalID())); + if(DirectSoundCreate(Util::IsValid(guid) ? &guid : NULL, &dummy, NULL) != DS_OK) { return caps; } @@ -213,9 +254,8 @@ DSBCAPS dsc; if(m_piDS) return true; - 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; + GUID guid = Util::StringToGUID(mpt::ToWide(GetDeviceInternalID())); + if(DirectSoundCreate(Util::IsValid(guid) ? &guid : NULL, &m_piDS, NULL) != DS_OK) return false; if(!m_piDS) return false; if(m_piDS->SetCooperativeLevel(m_AppInfo.GetHWND(), m_Settings.ExclusiveMode ? DSSCL_WRITEPRIMARY : DSSCL_PRIORITY) != DS_OK) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |