From: <man...@us...> - 2014-10-01 07:16:33
|
Revision: 4337 http://sourceforge.net/p/modplug/code/4337 Author: manxorist Date: 2014-10-01 07:16:19 +0000 (Wed, 01 Oct 2014) Log Message: ----------- [Mod] Soundcard settings: Avoid modal dialog boxes and just disable the whole property page when an unavailable device gets selected. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-09-30 13:51:10 UTC (rev 4336) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-10-01 07:16:19 UTC (rev 4337) @@ -840,11 +840,10 @@ { if(!gpSoundDevice->IsAvailable()) { - theApp.GetSoundDevicesManager()->SetDeviceUnavailable(deviceIdentifier); Reporting::Error("Unable to open sound device: Device not available."); } else { - Reporting::Error("Unable to open sound device: Could not open sound device."); + Reporting::Error("Unable to open sound device."); } return false; } Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-09-30 13:51:10 UTC (rev 4336) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-10-01 07:16:19 UTC (rev 4337) @@ -161,28 +161,7 @@ void COptionsSoundcard::SetInitialDevice() //---------------------------------------- { - bool ok = false; - std::set<SoundDevice::Identifier> triedSet; - while(!ok) - { - m_CurrentDeviceInfo = theApp.GetSoundDevicesManager()->FindDeviceInfoBestMatch(m_InitialDeviceIdentifier, TrackerSettings::Instance().m_SoundDevicePreferSameTypeIfDeviceUnavailable); - SoundDevice::Identifier dev = m_CurrentDeviceInfo.GetIdentifier(); - if(triedSet.find(dev) != triedSet.end()) - { - Reporting::Error("No sound device available."); - break; - } - m_CurrentDeviceCaps = theApp.GetSoundDevicesManager()->GetDeviceCaps(dev, CMainFrame::GetMainFrame()->gpSoundDevice); - m_CurrentDeviceDynamicCaps = theApp.GetSoundDevicesManager()->GetDeviceDynamicCaps(dev, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice, true); - m_Settings = TrackerSettings::Instance().GetSoundDeviceSettings(dev); - if(theApp.GetSoundDevicesManager()->IsDeviceUnavailable(dev)) - { - triedSet.insert(dev); - m_InitialDeviceIdentifier = m_CurrentDeviceInfo.GetIdentifier(); - continue; // makes progress because FindDeviceInfoBestMatch will not return devices again that were found out to be unavailable - } - ok = true; - } + SetDevice(m_InitialDeviceIdentifier, true); } @@ -193,28 +172,22 @@ SoundDevice::Info newInfo; SoundDevice::Caps newCaps; SoundDevice::DynamicCaps newDynamicCaps; - SoundDevice::Settings newSettigs; + SoundDevice::Settings newSettings; newInfo = theApp.GetSoundDevicesManager()->FindDeviceInfo(dev); newCaps = theApp.GetSoundDevicesManager()->GetDeviceCaps(dev, CMainFrame::GetMainFrame()->gpSoundDevice); newDynamicCaps = theApp.GetSoundDevicesManager()->GetDeviceDynamicCaps(dev, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice, true); bool deviceChanged = (dev != olddev); if(deviceChanged || forceReload) { - newSettigs = TrackerSettings::Instance().GetSoundDeviceSettings(dev); + newSettings = TrackerSettings::Instance().GetSoundDeviceSettings(dev); } else { - newSettigs = m_Settings; + newSettings = m_Settings; } - if(theApp.GetSoundDevicesManager()->IsDeviceUnavailable(dev)) - { - Reporting::Information("Device not available. Reverting to old device."); - UpdateEverything(); - return; - } m_CurrentDeviceInfo = newInfo; m_CurrentDeviceCaps = newCaps; m_CurrentDeviceDynamicCaps = newDynamicCaps; - m_Settings = newSettigs; + m_Settings = newSettings; } @@ -228,6 +201,7 @@ CMainFrame::GetMainFrame()->gpSoundDevice = nullptr; } theApp.GetSoundDevicesManager()->ReEnumerate(); + SetDevice(m_CurrentDeviceInfo.GetIdentifier(), true); UpdateEverything(); } @@ -245,6 +219,10 @@ void COptionsSoundcard::UpdateLatency() //------------------------------------- { + { + GetDlgItem(IDC_STATIC_LATENCY)->EnableWindow(TRUE); + m_CbnLatencyMS.EnableWindow(TRUE); + } // latency { static const double latencies [] = { @@ -276,12 +254,20 @@ } } } + if(theApp.GetSoundDevicesManager()->IsDeviceUnavailable(m_CurrentDeviceInfo.GetIdentifier())) + { + GetDlgItem(IDC_STATIC_LATENCY)->EnableWindow(FALSE); + m_CbnLatencyMS.EnableWindow(FALSE); + } } void COptionsSoundcard::UpdateUpdateInterval() //-------------------------------------------- { + { + m_CbnUpdateIntervalMS.EnableWindow(TRUE); + } // update interval { static const double updateIntervals [] = { @@ -304,12 +290,21 @@ } } } + if(theApp.GetSoundDevicesManager()->IsDeviceUnavailable(m_CurrentDeviceInfo.GetIdentifier())) + { + m_CbnUpdateIntervalMS.EnableWindow(FALSE); + } } void COptionsSoundcard::UpdateGeneral() //------------------------------------- { + { + m_CbnStoppedMode.EnableWindow(TRUE); + CPropertySheet *sheet = dynamic_cast<CPropertySheet *>(GetParent()); + if(sheet) sheet->GetDlgItem(IDOK)->EnableWindow(TRUE); + } // General { if(m_CurrentDeviceCaps.CanKeepDeviceRunning) @@ -331,6 +326,12 @@ } CheckDlgButton(IDC_CHECK7, TrackerSettings::Instance().m_SoundSettingsOpenDeviceAtStartup ? BST_CHECKED : BST_UNCHECKED); } + if(theApp.GetSoundDevicesManager()->IsDeviceUnavailable(m_CurrentDeviceInfo.GetIdentifier())) + { + m_CbnStoppedMode.EnableWindow(FALSE); + CPropertySheet *sheet = dynamic_cast<CPropertySheet *>(GetParent()); + if(sheet) sheet->GetDlgItem(IDOK)->EnableWindow(FALSE); + } } @@ -358,12 +359,7 @@ } } - if(theApp.GetSoundDevicesManager()->IsDeviceUnavailable(it->GetIdentifier())) { - continue; - } - - { CString name = mpt::ToCString(it->name); cbi.mask = CBEIF_IMAGE | CBEIF_LPARAM | CBEIF_TEXT | CBEIF_SELECTEDIMAGE | CBEIF_OVERLAY; cbi.iItem = iItem; @@ -442,6 +438,9 @@ void COptionsSoundcard::UpdateChannels() //-------------------------------------- { + { + m_CbnChannels.EnableWindow(TRUE); + } m_CbnChannels.ResetContent(); UINT maxChannels = 0; if(m_CurrentDeviceDynamicCaps.channelNames.size() > 0) @@ -462,12 +461,19 @@ } } m_CbnChannels.SetCurSel(sel); + if(theApp.GetSoundDevicesManager()->IsDeviceUnavailable(m_CurrentDeviceInfo.GetIdentifier())) + { + m_CbnChannels.EnableWindow(FALSE); + } } void COptionsSoundcard::UpdateSampleFormat() //------------------------------------------ { + { + m_CbnSampleFormat.EnableWindow(TRUE); + } UINT n = 0; m_CbnSampleFormat.ResetContent(); m_CbnSampleFormat.EnableWindow(m_CurrentDeviceCaps.CanSampleFormat ? TRUE : FALSE); @@ -498,12 +504,19 @@ } } m_CbnSampleFormat.SetCurSel(n); + if(theApp.GetSoundDevicesManager()->IsDeviceUnavailable(m_CurrentDeviceInfo.GetIdentifier())) + { + m_CbnSampleFormat.EnableWindow(FALSE); + } } void COptionsSoundcard::UpdateDither() //------------------------------------ { + { + m_CbnDither.EnableWindow(TRUE); + } m_CbnDither.ResetContent(); SampleFormat sampleFormat = static_cast<SampleFormatEnum>(m_CbnSampleFormat.GetItemData(m_CbnSampleFormat.GetCurSel())); if(sampleFormat.IsInt() && sampleFormat.GetBitsPerSample() < 32) @@ -533,12 +546,26 @@ { m_CbnDither.SetCurSel(m_Settings.DitherType); } + if(theApp.GetSoundDevicesManager()->IsDeviceUnavailable(m_CurrentDeviceInfo.GetIdentifier())) + { + m_CbnDither.EnableWindow(FALSE); + } } void COptionsSoundcard::UpdateChannelMapping() //-------------------------------------------- { + { + GetDlgItem(IDC_STATIC_CHANNELMAPPING)->EnableWindow(TRUE); + for(int mch = 0; mch < NUM_CHANNELCOMBOBOXES; mch++) + { + CStatic *statictext = &m_StaticChannelMapping[mch]; + CComboBox *combo = &m_CbnChannelMapping[mch]; + statictext->EnableWindow(TRUE); + combo->EnableWindow(TRUE); + } + } int usedChannels = m_CbnChannels.GetItemData(m_CbnChannels.GetCurSel()); if(m_Settings.ChannelMapping.GetNumHostChannels() != static_cast<uint32>(usedChannels)) { @@ -571,6 +598,17 @@ } } } + if(theApp.GetSoundDevicesManager()->IsDeviceUnavailable(m_CurrentDeviceInfo.GetIdentifier())) + { + GetDlgItem(IDC_STATIC_CHANNELMAPPING)->EnableWindow(FALSE); + for(int mch = 0; mch < NUM_CHANNELCOMBOBOXES; mch++) + { + CStatic *statictext = &m_StaticChannelMapping[mch]; + CComboBox *combo = &m_CbnChannelMapping[mch]; + statictext->EnableWindow(FALSE); + combo->EnableWindow(FALSE); + } + } } @@ -670,6 +708,11 @@ void COptionsSoundcard::UpdateSampleRates() //----------------------------------------- { + { + GetDlgItem(IDC_STATIC_FORMAT)->EnableWindow(TRUE); + m_CbnMixingFreq.EnableWindow(TRUE); + } + m_CbnMixingFreq.ResetContent(); std::vector<uint32> samplerates; @@ -701,12 +744,25 @@ } } m_CbnMixingFreq.SetCurSel(n); + if(theApp.GetSoundDevicesManager()->IsDeviceUnavailable(m_CurrentDeviceInfo.GetIdentifier())) + { + GetDlgItem(IDC_STATIC_FORMAT)->EnableWindow(FALSE); + m_CbnMixingFreq.EnableWindow(FALSE); + } } void COptionsSoundcard::UpdateControls() //-------------------------------------- { + { + m_BtnDriverPanel.EnableWindow(TRUE); + GetDlgItem(IDC_CHECK4)->EnableWindow(TRUE); + GetDlgItem(IDC_CHECK5)->EnableWindow(TRUE); + GetDlgItem(IDC_CHECK9)->EnableWindow(TRUE); + GetDlgItem(IDC_STATIC_UPDATEINTERVAL)->EnableWindow(TRUE); + GetDlgItem(IDC_COMBO_UPDATEINTERVAL)->EnableWindow(TRUE); + } if(!m_CurrentDeviceCaps.CanKeepDeviceRunning) { m_Settings.KeepDeviceRunning = false; @@ -721,6 +777,15 @@ CheckDlgButton(IDC_CHECK4, m_CurrentDeviceCaps.CanExclusiveMode && m_Settings.ExclusiveMode ? MF_CHECKED : MF_UNCHECKED); CheckDlgButton(IDC_CHECK5, m_CurrentDeviceCaps.CanBoostThreadPriority && m_Settings.BoostThreadPriority ? MF_CHECKED : MF_UNCHECKED); CheckDlgButton(IDC_CHECK9, m_CurrentDeviceCaps.CanUseHardwareTiming && m_Settings.UseHardwareTiming ? MF_CHECKED : MF_UNCHECKED); + if(theApp.GetSoundDevicesManager()->IsDeviceUnavailable(m_CurrentDeviceInfo.GetIdentifier())) + { + m_BtnDriverPanel.EnableWindow(FALSE); + GetDlgItem(IDC_CHECK4)->EnableWindow(FALSE); + GetDlgItem(IDC_CHECK5)->EnableWindow(FALSE); + GetDlgItem(IDC_CHECK9)->EnableWindow(FALSE); + GetDlgItem(IDC_STATIC_UPDATEINTERVAL)->EnableWindow(FALSE); + GetDlgItem(IDC_COMBO_UPDATEINTERVAL)->EnableWindow(FALSE); + } } @@ -735,6 +800,9 @@ void COptionsSoundcard::OnOK() //---------------------------- { + if(!theApp.GetSoundDevicesManager()->IsDeviceUnavailable(m_CurrentDeviceInfo.GetIdentifier())) + { + // General { TrackerSettings::Instance().m_SoundSettingsOpenDeviceAtStartup = IsDlgButtonChecked(IDC_CHECK7) ? true : false; @@ -806,6 +874,14 @@ SetDevice(m_CurrentDeviceInfo.GetIdentifier(), true); // Poll changed ASIO sample format and channel names UpdateDevice(); UpdateStatistics(); + + } else + { + + Reporting::Error("Sound card currently not available."); + + } + CPropertyPage::OnOK(); } @@ -835,7 +911,13 @@ m_EditStatistics.SetWindowText(s.c_str()); } else { - m_EditStatistics.SetWindowText(""); + if(theApp.GetSoundDevicesManager()->IsDeviceUnavailable(m_CurrentDeviceInfo.GetIdentifier())) + { + m_EditStatistics.SetWindowText("Device currently unavailable."); + } else + { + m_EditStatistics.SetWindowText(""); + } } } Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2014-09-30 13:51:10 UTC (rev 4336) +++ trunk/OpenMPT/mptrack/mptrack.rc 2014-10-01 07:16:19 UTC (rev 4337) @@ -1331,11 +1331,11 @@ CONTROL "",IDC_COMBO1,"ComboBoxEx32",CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP,12,18,264,96 PUSHBUTTON "&Setup device ...",IDC_BUTTON2,48,36,72,12 PUSHBUTTON "&Rescan device list",IDC_BUTTON1,204,36,72,12 - LTEXT "&Latency:",IDC_STATIC,12,54,30,12,SS_CENTERIMAGE + LTEXT "&Latency:",IDC_STATIC_LATENCY,12,54,30,12,SS_CENTERIMAGE COMBOBOX IDC_COMBO2,48,54,54,83,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP LTEXT "&Period:",IDC_STATIC_UPDATEINTERVAL,12,72,30,12,SS_CENTERIMAGE COMBOBOX IDC_COMBO_UPDATEINTERVAL,48,72,54,83,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - LTEXT "&Format:",IDC_STATIC,12,90,30,12,SS_CENTERIMAGE + LTEXT "&Format:",IDC_STATIC_FORMAT,12,90,30,12,SS_CENTERIMAGE COMBOBOX IDC_COMBO3,48,90,54,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBO5,108,90,42,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBO6,156,90,42,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2014-09-30 13:51:10 UTC (rev 4336) +++ trunk/OpenMPT/mptrack/resource.h 2014-10-01 07:16:19 UTC (rev 4337) @@ -964,6 +964,8 @@ #define IDC_COMBO_CHANNEL_REARRIGHT 2478 #define IDC_SCANTEXT 2479 #define IDC_STATIC_CHANNELMAPPING 2480 +#define IDC_STATIC_LATENCY 2481 +#define IDC_STATIC_FORMAT 2482 #define ID_FILE_NEWMOD 32771 #define ID_FILE_NEWXM 32772 #define ID_FILE_NEWS3M 32773 @@ -1247,7 +1249,7 @@ #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 537 #define _APS_NEXT_COMMAND_VALUE 44644 -#define _APS_NEXT_CONTROL_VALUE 2481 +#define _APS_NEXT_CONTROL_VALUE 2483 #define _APS_NEXT_SYMED_VALUE 901 #endif #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |