From: <man...@us...> - 2015-05-19 10:34:57
|
Revision: 5121 http://sourceforge.net/p/modplug/code/5121 Author: manxorist Date: 2015-05-19 10:34:45 +0000 (Tue, 19 May 2015) Log Message: ----------- [Ref] sounddev: Merge Settings::Channels and Settings::ChannelMapping. Standard channel layout is just a special case of a ChannelMapping. [Mod] OpenMPT: Version is now 1.25.00.06 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/Mpdlgs.cpp 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 Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-05-18 21:37:26 UTC (rev 5120) +++ trunk/OpenMPT/common/versionNumber.h 2015-05-19 10:34:45 UTC (rev 5121) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 25 #define VER_MINOR 00 -#define VER_MINORMINOR 05 +#define VER_MINORMINOR 06 //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/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2015-05-18 21:37:26 UTC (rev 5120) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2015-05-19 10:34:45 UTC (rev 5121) @@ -574,10 +574,10 @@ } } int usedChannels = static_cast<int>(m_CbnChannels.GetItemData(m_CbnChannels.GetCurSel())); - if(m_Settings.ChannelMapping.GetNumHostChannels() != static_cast<uint32>(usedChannels)) + if(m_Settings.Channels.GetNumHostChannels() != static_cast<uint32>(usedChannels)) { // If the channel mapping is not valid for the selected number of channels, reset it to default identity mapping. - m_Settings.ChannelMapping = SoundDevice::ChannelMapping(); + m_Settings.Channels = SoundDevice::ChannelMapping(usedChannels); } GetDlgItem(IDC_STATIC_CHANNELMAPPING)->EnableWindow(m_CurrentDeviceCaps.CanChannelMapping ? TRUE : FALSE); for(int mch = 0; mch < NUM_CHANNELCOMBOBOXES; mch++) // Host channels @@ -597,7 +597,7 @@ { const int pos = (int)::SendMessageW(combo->m_hWnd, CB_ADDSTRING, 0, (LPARAM)m_CurrentDeviceDynamicCaps.channelNames[dch].c_str()); combo->SetItemData(pos, (DWORD_PTR)dch); - if(static_cast<int32>(dch) == m_Settings.ChannelMapping.ToDevice(mch)) + if(static_cast<int32>(dch) == m_Settings.Channels.ToDevice(mch)) { combo->SetCurSel(pos); } @@ -822,7 +822,7 @@ // Channels { DWORD_PTR n = m_CbnChannels.GetItemData(m_CbnChannels.GetCurSel()); - m_Settings.Channels = static_cast<uint8>(n); + m_Settings.Channels = n; if((m_Settings.Channels != 1) && (m_Settings.Channels != 4)) { m_Settings.Channels = 2; @@ -869,10 +869,7 @@ CComboBox *combo = &m_CbnChannelMapping[mch]; channels[mch] = static_cast<int32>(combo->GetItemData(combo->GetCurSel())); } - m_Settings.ChannelMapping = SoundDevice::ChannelMapping(channels); - } else - { - m_Settings.ChannelMapping = SoundDevice::ChannelMapping(); + m_Settings.Channels = channels; } } CMainFrame::GetMainFrame()->SetupSoundCard(m_Settings, m_CurrentDeviceInfo.GetIdentifier(), (SoundDeviceStopMode)m_CbnStoppedMode.GetCurSel()); Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2015-05-18 21:37:26 UTC (rev 5120) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2015-05-19 10:34:45 UTC (rev 5121) @@ -1032,7 +1032,7 @@ 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->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", @@ -1046,7 +1046,7 @@ 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)); + m_pSettings->Read(L"Sound Settings", mpt::ToWide(oldIdentifier) + L"_" + L"ChannelMapping", defaults.Channels)); } } } Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-05-18 21:37:26 UTC (rev 5120) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-05-19 10:34:45 UTC (rev 5121) @@ -434,7 +434,7 @@ Setting<bool> m_SoundDeviceExclusiveMode(conf, "Sound Settings", "ExclusiveMode", SoundDevice::Settings().ExclusiveMode); Setting<bool> m_SoundDeviceBoostThreadPriority(conf, "Sound Settings", "BoostThreadPriority", SoundDevice::Settings().BoostThreadPriority); Setting<bool> m_SoundDeviceUseHardwareTiming(conf, "Sound Settings", "UseHardwareTiming", SoundDevice::Settings().UseHardwareTiming); - Setting<SoundDevice::ChannelMapping> m_SoundDeviceChannelMapping(conf, "Sound Settings", "ChannelMapping", SoundDevice::Settings().ChannelMapping); + Setting<SoundDevice::ChannelMapping> m_SoundDeviceChannelMapping(conf, "Sound Settings", "ChannelMapping", SoundDevice::Settings().Channels); if(storedVersion < MAKE_VERSION_NUMERIC(1,21,01,26)) { if(m_BufferLength_DEPRECATED != 0) @@ -469,17 +469,15 @@ m_SoundDeviceSettingsDefaults.Latency = m_LatencyMS / 1000.0; m_SoundDeviceSettingsDefaults.UpdateInterval = m_UpdateIntervalMS / 1000.0; m_SoundDeviceSettingsDefaults.Samplerate = MixerSamplerate; - m_SoundDeviceSettingsDefaults.Channels = (uint8)MixerOutputChannels; + if(m_SoundDeviceSettingsDefaults.Channels.GetNumHostChannels() != MixerOutputChannels) + { + // reset invalid channel mapping to default + m_SoundDeviceSettingsDefaults.Channels = SoundDevice::ChannelMapping(MixerOutputChannels); + } m_SoundDeviceSettingsDefaults.sampleFormat = m_SampleFormat; m_SoundDeviceSettingsDefaults.ExclusiveMode = m_SoundDeviceExclusiveMode; m_SoundDeviceSettingsDefaults.BoostThreadPriority = m_SoundDeviceBoostThreadPriority; m_SoundDeviceSettingsDefaults.UseHardwareTiming = m_SoundDeviceUseHardwareTiming; - m_SoundDeviceSettingsDefaults.ChannelMapping = m_SoundDeviceChannelMapping; - if(m_SoundDeviceSettingsDefaults.ChannelMapping.GetNumHostChannels() != m_SoundDeviceSettingsDefaults.Channels) - { - // reset invalid channel mapping to default - m_SoundDeviceSettingsDefaults.ChannelMapping = SoundDevice::ChannelMapping(m_SoundDeviceSettingsDefaults.Channels); - } m_SoundDeviceSettingsUseOldDefaults = true; } if(storedVersion < MAKE_VERSION_NUMERIC(1,25,00,04)) @@ -612,19 +610,19 @@ SettingsContainer &conf; const SoundDevice::Info deviceInfo; -public: +private: Setting<uint32> LatencyUS; Setting<uint32> UpdateIntervalUS; Setting<uint32> Samplerate; - Setting<uint8> Channels; + Setting<uint8> ChannelsOld; // compatibility with older versions + Setting<SoundDevice::ChannelMapping> ChannelMapping; Setting<SampleFormat> sampleFormat; Setting<bool> ExclusiveMode; Setting<bool> BoostThreadPriority; Setting<bool> KeepDeviceRunning; Setting<bool> UseHardwareTiming; Setting<int> DitherType; - Setting<SoundDevice::ChannelMapping> ChannelMapping; public: @@ -634,19 +632,20 @@ , 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) + , ChannelsOld(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"Channels", mpt::saturate_cast<uint8>((int)defaults.Channels)) + , ChannelMapping(conf, L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"ChannelMapping", 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) + if(ChannelMapping.Get().GetNumHostChannels() != ChannelsOld) { - // reset invalid chanel mapping to default - ChannelMapping = SoundDevice::ChannelMapping(Channels); + // If the stored channel count and the count of channels used in the channel mapping do not match, + // construct a default mapping from the channel count. + ChannelMapping = SoundDevice::ChannelMapping(ChannelsOld); } // store informational data (not read back, just to allow the user to mock with the raw ini file) conf.Write(L"Sound Settings", mpt::ToWide(deviceInfo.GetIdentifier()) + L"_" + L"Type", deviceInfo.type); @@ -660,14 +659,14 @@ LatencyUS = Util::Round<int32>(settings.Latency * 1000000.0); UpdateIntervalUS = Util::Round<int32>(settings.UpdateInterval * 1000000.0); Samplerate = settings.Samplerate; - Channels = settings.Channels; + ChannelsOld = mpt::saturate_cast<uint8>((int)settings.Channels); + ChannelMapping = settings.Channels; sampleFormat = settings.sampleFormat; ExclusiveMode = settings.ExclusiveMode; BoostThreadPriority = settings.BoostThreadPriority; KeepDeviceRunning = settings.KeepDeviceRunning; UseHardwareTiming = settings.UseHardwareTiming; DitherType = settings.DitherType; - ChannelMapping = settings.ChannelMapping; return *this; } @@ -677,14 +676,13 @@ settings.Latency = LatencyUS / 1000000.0; settings.UpdateInterval = UpdateIntervalUS / 1000000.0; settings.Samplerate = Samplerate; - settings.Channels = Channels; + settings.Channels = ChannelMapping; settings.sampleFormat = sampleFormat; settings.ExclusiveMode = ExclusiveMode; settings.BoostThreadPriority = BoostThreadPriority; settings.KeepDeviceRunning = KeepDeviceRunning; settings.UseHardwareTiming = UseHardwareTiming; settings.DitherType = DitherType; - settings.ChannelMapping = ChannelMapping; return settings; } Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-05-18 21:37:26 UTC (rev 5120) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-05-19 10:34:45 UTC (rev 5121) @@ -25,13 +25,6 @@ namespace SoundDevice { -ChannelMapping::ChannelMapping() -//------------------------------ -{ - return; -} - - ChannelMapping::ChannelMapping(uint32 numHostChannels) //---------------------------------------------------- { @@ -172,21 +165,6 @@ if(m_Settings.UpdateInterval == 0.0) m_Settings.UpdateInterval = m_Caps.DefaultSettings.UpdateInterval; m_Settings.Latency = Clamp(m_Settings.Latency, m_Caps.LatencyMin, m_Caps.LatencyMax); m_Settings.UpdateInterval = Clamp(m_Settings.UpdateInterval, m_Caps.UpdateIntervalMin, m_Caps.UpdateIntervalMax); - if(m_Caps.CanChannelMapping) - { - if(m_Settings.ChannelMapping.GetNumHostChannels() == 0) - { - // default mapping - m_Settings.ChannelMapping = SoundDevice::ChannelMapping(m_Settings.Channels); - } - if(m_Settings.ChannelMapping.GetNumHostChannels() != m_Settings.Channels) - { - return false; - } - } else - { - m_Settings.ChannelMapping = SoundDevice::ChannelMapping(m_Settings.Channels); - } m_Flags = SoundDevice::Flags(); m_DeviceUnavailableOnOpen = false; m_RequestFlags.store(0); Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2015-05-18 21:37:26 UTC (rev 5120) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2015-05-19 10:34:45 UTC (rev 5121) @@ -170,11 +170,8 @@ public: - // Construct default empty mapping - ChannelMapping(); - // Construct default identity mapping - ChannelMapping(uint32 numHostChannels); + ChannelMapping(uint32 numHostChannels = 2); // Construct mapping from given vector. // Silently fall back to identity mapping if mapping is invalid. @@ -190,6 +187,16 @@ public: + operator int () const + { + return GetNumHostChannels(); + } + + ChannelMapping & operator = (int channels) + { + return (*this = ChannelMapping(channels)); + } + bool operator == (const SoundDevice::ChannelMapping &cmp) const { return (ChannelToDeviceChannel == cmp.ChannelToDeviceChannel); @@ -258,14 +265,13 @@ double Latency; // seconds double UpdateInterval; // seconds uint32 Samplerate; - uint8 Channels; + SoundDevice::ChannelMapping Channels; SampleFormat sampleFormat; bool ExclusiveMode; // Use hardware buffers directly bool BoostThreadPriority; // Boost thread priority for glitch-free audio rendering bool KeepDeviceRunning; bool UseHardwareTiming; int DitherType; - SoundDevice::ChannelMapping ChannelMapping; Settings() : Latency(0.1) , UpdateInterval(0.005) @@ -292,7 +298,6 @@ && BoostThreadPriority == cmp.BoostThreadPriority && KeepDeviceRunning == cmp.KeepDeviceRunning && UseHardwareTiming == cmp.UseHardwareTiming - && ChannelMapping == cmp.ChannelMapping && DitherType == cmp.DitherType ; } Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-05-18 21:37:26 UTC (rev 5120) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-05-19 10:34:45 UTC (rev 5121) @@ -284,7 +284,7 @@ { throw ASIOException("Not enough output channels."); } - if(m_Settings.ChannelMapping.GetRequiredDeviceChannels() > outputChannels) + if(m_Settings.Channels.GetRequiredDeviceChannels() > outputChannels) { throw ASIOException("Channel mapping requires more channels than available."); } @@ -365,7 +365,7 @@ { MemsetZero(m_BufferInfo[channel]); m_BufferInfo[channel].isInput = ASIOFalse; - m_BufferInfo[channel].channelNum = m_Settings.ChannelMapping.ToDevice(channel); + m_BufferInfo[channel].channelNum = m_Settings.Channels.ToDevice(channel); } m_Callbacks.bufferSwitch = CallbackBufferSwitch; m_Callbacks.sampleRateDidChange = CallbackSampleRateDidChange; @@ -382,13 +382,13 @@ { MemsetZero(m_ChannelInfo[channel]); m_ChannelInfo[channel].isInput = ASIOFalse; - m_ChannelInfo[channel].channel = m_Settings.ChannelMapping.ToDevice(channel); + m_ChannelInfo[channel].channel = m_Settings.Channels.ToDevice(channel); asioCall(getChannelInfo(&m_ChannelInfo[channel])); MPT_ASSERT(m_ChannelInfo[channel].isActive); mpt::String::SetNullTerminator(m_ChannelInfo[channel].name); Log(mpt::String::Print("ASIO: getChannelInfo(isInput=%1 channel=%2) => isActive=%3 channelGroup=%4 type=%5 name='%6'" , ASIOFalse - , m_Settings.ChannelMapping.ToDevice(channel) + , m_Settings.Channels.ToDevice(channel) , m_ChannelInfo[channel].isActive , m_ChannelInfo[channel].channelGroup , m_ChannelInfo[channel].type This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |