From: <man...@us...> - 2014-09-23 10:21:37
|
Revision: 4304 http://sourceforge.net/p/modplug/code/4304 Author: manxorist Date: 2014-09-23 10:21:29 +0000 (Tue, 23 Sep 2014) Log Message: ----------- [Mod] Soundcard settings: When changing between mono/stereo/quad channel configurations, always reset the channel mapping to default instead of basing the new one on the previous one. [Fix] sounddev: Add stricter validation of channel mapping. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-09-23 07:11:50 UTC (rev 4303) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-09-23 10:21:29 UTC (rev 4304) @@ -491,6 +491,11 @@ //-------------------------------------------- { int usedChannels = m_CbnChannels.GetItemData(m_CbnChannels.GetCurSel()); + if(!m_Settings.ChannelMapping.IsValid(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(); + } GetDlgItem(IDC_STATIC_CHANNELMAPPING)->EnableWindow(m_CurrentDeviceCaps.CanChannelMapping ? TRUE : FALSE); for(int mch = 0; mch < NUM_CHANNELCOMBOBOXES; mch++) // Host channels { Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-09-23 07:11:50 UTC (rev 4303) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-09-23 10:21:29 UTC (rev 4304) @@ -91,7 +91,7 @@ { return true; } - if(ChannelToDeviceChannel.size() < channels) + if(ChannelToDeviceChannel.size() != channels) { return false; } Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2014-09-23 07:11:50 UTC (rev 4303) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2014-09-23 10:21:29 UTC (rev 4304) @@ -183,12 +183,16 @@ bool IsValid(uint32 channels) const; // Get the number of required device channels for this mapping. Derived from the maximum mapped-to channel number. - uint32 GetRequiredDeviceChannels() const + uint32 GetRequiredDeviceChannels(uint32 numHostChannels) const { - if(ChannelToDeviceChannel.empty()) + if(!IsValid(numHostChannels)) { return 0; } + if(ChannelToDeviceChannel.empty()) + { + return numHostChannels; + } uint32 maxChannel = 0; for(uint32 channel = 0; channel < ChannelToDeviceChannel.size(); ++channel) { Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2014-09-23 07:11:50 UTC (rev 4303) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2014-09-23 10:21:29 UTC (rev 4304) @@ -272,8 +272,12 @@ { throw ASIOException("Not enough output channels."); } - if(m_Settings.ChannelMapping.GetRequiredDeviceChannels() > (std::size_t)outputChannels) + if(!m_Settings.ChannelMapping.IsValid(m_Settings.Channels)) { + throw ASIOException("Channel mapping has wrong channel count."); + } + if(m_Settings.ChannelMapping.GetRequiredDeviceChannels(m_Settings.Channels) > (std::size_t)outputChannels) + { throw ASIOException("Channel mapping requires more channels than available."); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |