From: <man...@us...> - 2013-11-24 16:02:34
|
Revision: 3304 http://sourceforge.net/p/modplug/code/3304 Author: manxorist Date: 2013-11-24 16:02:25 +0000 (Sun, 24 Nov 2013) Log Message: ----------- [Ref] sounddev: Move knowledge about which device type can set which parameters out of GUI code into the SoundDeviceCaps structure. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-11-24 13:22:10 UTC (rev 3303) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-11-24 16:02:25 UTC (rev 3304) @@ -328,11 +328,10 @@ } } m_CbnChannels.SetCurSel(n); - if(m_CurrentDeviceInfo.id.GetType() == SNDDEV_ASIO) + if(m_CurrentDeviceCaps.CanChannelMapping) { m_CbnBaseChannel.ResetContent(); m_CbnBaseChannel.EnableWindow(TRUE); - m_BtnDriverPanel.ShowWindow(SW_SHOW); int sel = 0; for(std::size_t channel = 0; channel < m_CurrentDeviceCaps.channelNames.size(); ++channel) { @@ -348,8 +347,8 @@ { m_CbnBaseChannel.ResetContent(); m_CbnBaseChannel.EnableWindow(FALSE); - m_BtnDriverPanel.ShowWindow(SW_HIDE); } + m_BtnDriverPanel.ShowWindow(m_CurrentDeviceCaps.CanDriverPanel ? SW_SHOW : SW_HIDE); } @@ -358,17 +357,16 @@ { UINT n = 0; m_CbnSampleFormat.ResetContent(); - const bool asio = m_CurrentDeviceInfo.id.GetType() == SNDDEV_ASIO; - if(asio) + if(m_CurrentDeviceInfo.id.GetType() == SNDDEV_ASIO) { m_Settings.sampleFormat = TrackerSettings::Instance().m_SampleFormat; } - m_CbnSampleFormat.EnableWindow(asio ? FALSE : TRUE); + m_CbnSampleFormat.EnableWindow(m_CurrentDeviceCaps.CanSampleFormat ? TRUE : FALSE); for(UINT bits = 40; bits >= 8; bits -= 8) { if(bits == 40) { - if(!asio || (asio && SampleFormatFloat32 == m_Settings.sampleFormat)) + if(m_CurrentDeviceCaps.CanSampleFormat || (SampleFormatFloat32 == m_Settings.sampleFormat)) { UINT ndx = m_CbnSampleFormat.AddString("Floating Point"); m_CbnSampleFormat.SetItemData(ndx, (32+128)); @@ -379,7 +377,7 @@ } } else { - if(!asio || (asio && (SampleFormat)bits == m_Settings.sampleFormat)) + if(m_CurrentDeviceCaps.CanSampleFormat || ((SampleFormat)bits == m_Settings.sampleFormat)) { UINT ndx = m_CbnSampleFormat.AddString(mpt::String::Format("%d Bit", bits).c_str()); m_CbnSampleFormat.SetItemData(ndx, bits); @@ -507,12 +505,11 @@ void COptionsSoundcard::UpdateControls() //-------------------------------------- { - const SoundDeviceID dev = m_CurrentDeviceInfo.id; - GetDlgItem(IDC_CHECK4)->EnableWindow((dev.GetType() == SNDDEV_DSOUND || dev.GetType() == SNDDEV_PORTAUDIO_WASAPI) ? TRUE : FALSE); - GetDlgItem(IDC_CHECK5)->EnableWindow((dev.GetType() == SNDDEV_WAVEOUT || dev.GetType() == SNDDEV_DSOUND) ? TRUE : FALSE); - GetDlgItem(IDC_STATIC_UPDATEINTERVAL)->EnableWindow((dev.GetType() == SNDDEV_ASIO) ? FALSE : TRUE); - GetDlgItem(IDC_COMBO_UPDATEINTERVAL)->EnableWindow((dev.GetType() == SNDDEV_ASIO) ? FALSE : TRUE); - if(dev.GetType() == SNDDEV_DSOUND) + GetDlgItem(IDC_CHECK4)->EnableWindow(m_CurrentDeviceCaps.CanExclusiveMode ? TRUE : FALSE); + GetDlgItem(IDC_CHECK5)->EnableWindow(m_CurrentDeviceCaps.CanBoostThreadPriority ? TRUE : FALSE); + GetDlgItem(IDC_STATIC_UPDATEINTERVAL)->EnableWindow(m_CurrentDeviceCaps.CanUpdateInterval ? TRUE : FALSE); + GetDlgItem(IDC_COMBO_UPDATEINTERVAL)->EnableWindow(m_CurrentDeviceCaps.CanUpdateInterval ? TRUE : FALSE); + if(m_CurrentDeviceInfo.id.GetType() == SNDDEV_DSOUND) { GetDlgItem(IDC_CHECK4)->SetWindowText("Use primary buffer"); } else Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2013-11-24 13:22:10 UTC (rev 3303) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-11-24 16:02:25 UTC (rev 3304) @@ -299,8 +299,22 @@ uint32 currentSampleRate; std::vector<uint32> supportedSampleRates; // Which samplerates are actually supported by the device. Currently only implemented properly for ASIO, DirectSound and PortAudio. std::vector<std::wstring> channelNames; + bool CanUpdateInterval; + bool CanSampleFormat; + bool CanExclusiveMode; + bool CanBoostThreadPriority; + bool CanUseHardwareTiming; + bool CanChannelMapping; + bool CanDriverPanel; SoundDeviceCaps() : currentSampleRate(0) + , CanUpdateInterval(true) + , CanSampleFormat(true) + , CanExclusiveMode(false) + , CanBoostThreadPriority(true) + , CanUseHardwareTiming(false) + , CanChannelMapping(false) + , CanDriverPanel(false) { return; } Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-11-24 13:22:10 UTC (rev 3303) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-11-24 16:02:25 UTC (rev 3304) @@ -1050,6 +1050,14 @@ { SoundDeviceCaps caps; + caps.CanUpdateInterval = false; + caps.CanSampleFormat = false; + caps.CanExclusiveMode = false; + caps.CanBoostThreadPriority = false; + caps.CanUseHardwareTiming = true; + caps.CanChannelMapping = true; + caps.CanDriverPanel = true; + TemporaryASIODriverOpener opener(*this); if(!IsDriverOpen()) { Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2013-11-24 13:22:10 UTC (rev 3303) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2013-11-24 16:02:25 UTC (rev 3304) @@ -114,6 +114,13 @@ //-------------------------------------------------------------------------------------- { SoundDeviceCaps caps; + caps.CanUpdateInterval = true; + caps.CanSampleFormat = true; + caps.CanExclusiveMode = true; + caps.CanBoostThreadPriority = true; + caps.CanUseHardwareTiming = false; + caps.CanChannelMapping = false; + caps.CanDriverPanel = false; IDirectSound *dummy = nullptr; IDirectSound *ds = nullptr; if(m_piDS) Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-11-24 13:22:10 UTC (rev 3303) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-11-24 16:02:25 UTC (rev 3304) @@ -83,7 +83,7 @@ { if(m_Settings.ExclusiveMode) { - m_StreamParameters.suggestedLatency = 0; // let portaudio choose + m_StreamParameters.suggestedLatency = 0.0; // let portaudio choose framesPerBuffer = paFramesPerBufferUnspecified; // let portaudio choose MemsetZero(m_WasapiStreamInfo); m_WasapiStreamInfo.size = sizeof(PaWasapiStreamInfo); @@ -178,6 +178,20 @@ //----------------------------------------------------------------------------------------- { SoundDeviceCaps caps; + caps.CanUpdateInterval = true; + caps.CanSampleFormat = true; + caps.CanExclusiveMode = false; + caps.CanBoostThreadPriority = false; + caps.CanUseHardwareTiming = false; + caps.CanChannelMapping = false; + caps.CanDriverPanel = false; + if(m_HostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI)) + { + caps.CanExclusiveMode = true; + } else if(m_HostApi == Pa_HostApiTypeIdToHostApiIndex(paWDMKS)) + { + caps.CanUpdateInterval = false; + } PaDeviceIndex device = HostApiOutputIndexToGlobalDeviceIndex(GetDeviceIndex(), m_HostApi); if(device == -1) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |