From: <man...@us...> - 2015-06-18 20:16:54
|
Revision: 5334 http://sourceforge.net/p/modplug/code/5334 Author: manxorist Date: 2015-06-18 20:16:48 +0000 (Thu, 18 Jun 2015) Log Message: ----------- [Ref] sounddev: Move migration of old global defaults and migration of default DirectSound device from the general startup code in InitInstance into a separate function in class TrackerSettings. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2015-06-18 10:05:07 UTC (rev 5333) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2015-06-18 20:16:48 UTC (rev 5334) @@ -991,58 +991,7 @@ // Load sound APIs m_pSoundDevicesManager = new SoundDevice::Manager(SoundDevice::AppInfo().SetName(MPT_USTRING("OpenMPT")).SetHWND(*m_pMainWnd)); - if(TrackerSettings::Instance().m_SoundDeviceSettingsUseOldDefaults) - { - // get the old default device - TrackerSettings::Instance().SetSoundDeviceIdentifier(SoundDevice::Legacy::FindDeviceInfo(*m_pSoundDevicesManager, TrackerSettings::Instance().m_SoundDeviceID_DEPRECATED).GetIdentifier()); - // apply old global sound device settings to each found device - for(std::vector<SoundDevice::Info>::const_iterator it = m_pSoundDevicesManager->begin(); it != m_pSoundDevicesManager->end(); ++it) - { - TrackerSettings::Instance().SetSoundDeviceSettings(it->GetIdentifier(), TrackerSettings::Instance().GetSoundDeviceSettingsDefaults()); - } - } -#ifndef NO_DSOUND - 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.GetNumHostChannels())); - 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.Channels)); - } - } - } -#endif // !NO_DSOUND + m_pTrackerSettings->MigrateOldSoundDeviceSettings(*m_pSoundDevicesManager); // Load static tunings CSoundFile::LoadStaticTunings(); @@ -1072,7 +1021,11 @@ m_bInitialized = TRUE; + EndWaitCursor(); + + // Perform startup tasks. + if(TrackerSettings::Instance().FirstRun) { @@ -1099,8 +1052,6 @@ } - EndWaitCursor(); - #ifdef _DEBUG if(!cmdInfo.m_bNoTests) Test::DoTests(); @@ -1113,6 +1064,7 @@ pMainFrame->PlayPreview(); } + return TRUE; } Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-06-18 10:05:07 UTC (rev 5333) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-06-18 20:16:48 UTC (rev 5334) @@ -631,6 +631,64 @@ } +void TrackerSettings::MigrateOldSoundDeviceSettings(SoundDevice::Manager &manager) +//-------------------------------------------------------------------------------- +{ + if(m_SoundDeviceSettingsUseOldDefaults) + { + // get the old default device + SetSoundDeviceIdentifier(SoundDevice::Legacy::FindDeviceInfo(manager, m_SoundDeviceID_DEPRECATED).GetIdentifier()); + // apply old global sound device settings to each found device + for(std::vector<SoundDevice::Info>::const_iterator it = manager.begin(); it != manager.end(); ++it) + { + SetSoundDeviceSettings(it->GetIdentifier(), GetSoundDeviceSettingsDefaults()); + } + } +#ifndef NO_DSOUND + if(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 = manager.FindDeviceInfo(newIdentifier); + if(info.IsValid()) + { + SoundDevice::Settings defaults = + m_SoundDeviceSettingsUseOldDefaults ? + GetSoundDeviceSettingsDefaults() + : + manager.GetDeviceCaps(newIdentifier).DefaultSettings + ; + conf.Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"Latency", + conf.Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"Latency", Util::Round<int32>(defaults.Latency * 1000000.0))); + conf.Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"UpdateInterval", + conf.Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"UpdateInterval", Util::Round<int32>(defaults.UpdateInterval * 1000000.0))); + conf.Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"SampleRate", + conf.Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"SampleRate", defaults.Samplerate)); + conf.Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"Channels", + conf.Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"Channels", defaults.Channels.GetNumHostChannels())); + conf.Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"SampleFormat", + conf.Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"SampleFormat", defaults.sampleFormat)); + conf.Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"ExclusiveMode", + conf.Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"ExclusiveMode", defaults.ExclusiveMode)); + conf.Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"BoostThreadPriority", + conf.Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"BoostThreadPriority", defaults.BoostThreadPriority)); + conf.Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"KeepDeviceRunning", + conf.Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"KeepDeviceRunning", defaults.KeepDeviceRunning)); + conf.Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"UseHardwareTiming", + conf.Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"UseHardwareTiming", defaults.UseHardwareTiming)); + conf.Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"DitherType", + conf.Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"DitherType", defaults.DitherType)); + conf.Write(L"Sound Settings", mpt::ToWide(newIdentifier) + L"_" + L"ChannelMapping", + conf.Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"ChannelMapping", defaults.Channels)); + } + } + } +#endif // !NO_DSOUND +} + + struct StoredSoundDeviceSettings { Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2015-06-18 10:05:07 UTC (rev 5333) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2015-06-18 20:16:48 UTC (rev 5334) @@ -29,7 +29,11 @@ OPENMPT_NAMESPACE_BEGIN +namespace SoundDevice { +class Manager; +} // namespace SoundDevice + // User-defined colors enum { @@ -686,6 +690,8 @@ TrackerSettings(SettingsContainer &conf); + void MigrateOldSoundDeviceSettings(SoundDevice::Manager &manager); + void SaveSettings(); static void GetDefaultColourScheme(COLORREF (&colours)[MAX_MODCOLORS]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |