From: <man...@us...> - 2015-05-23 15:25:25
|
Revision: 5144 http://sourceforge.net/p/modplug/code/5144 Author: manxorist Date: 2015-05-23 15:25:19 +0000 (Sat, 23 May 2015) Log Message: ----------- [Mod] sounddev: Sort default devices for each API type before other devices of the same API (fixes rather annoying ordering of WASAPI devices). [Ref] sounddev: Cleanup combobox filling code in the soundcard settings dialog. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/sounddev/SoundDeviceManager.cpp Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2015-05-23 15:10:15 UTC (rev 5143) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2015-05-23 15:25:19 UTC (rev 5144) @@ -362,56 +362,52 @@ { COMBOBOXEXITEM cbi; MemsetZero(cbi); - CString name = mpt::ToCString(it->name); - cbi.mask = CBEIF_LPARAM | CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_OVERLAY; cbi.iItem = iItem; cbi.cchTextMax = 0; - if(it->type == SoundDevice::TypeWAVEOUT) + cbi.mask = CBEIF_LPARAM | CBEIF_TEXT; + cbi.lParam = theApp.GetSoundDevicesManager()->GetGlobalID(it->GetIdentifier()); + if(it->type == SoundDevice::TypeWAVEOUT || it->type == SoundDevice::TypePORTAUDIO_WMME) { + cbi.mask |= CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_OVERLAY; cbi.iImage = IMAGE_WAVEOUT; - } else if(it->type == SoundDevice::TypePORTAUDIO_WMME) + } else if(it->type == SoundDevice::TypeDSOUND || it->type == SoundDevice::TypePORTAUDIO_DS) { - cbi.iImage = IMAGE_WAVEOUT; - } else if(it->type == SoundDevice::TypeDSOUND) - { + cbi.mask |= CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_OVERLAY; cbi.iImage = IMAGE_DIRECTX; - } else if(it->type == SoundDevice::TypePORTAUDIO_DS) - { - cbi.iImage = IMAGE_DIRECTX; } else if(it->type == SoundDevice::TypeASIO) { + cbi.mask |= CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_OVERLAY; cbi.iImage = IMAGE_ASIO; } else if(it->type == SoundDevice::TypePORTAUDIO_WASAPI) { - // No real image available for now, - // prepend API name to name and misuse another icon - cbi.iImage = IMAGE_SAMPLEMUTE; - name = mpt::ToCString(it->apiName) + _T(" - ") + name; + cbi.mask |= CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_OVERLAY; + cbi.iImage = IMAGE_SAMPLEMUTE; // // No real image available for now, } else if(it->type == SoundDevice::TypePORTAUDIO_WDMKS) { - // No real image available for now, - // prepend API name to name and misuse another icon. - cbi.iImage = IMAGE_CHIP; - name = mpt::ToCString(it->apiName) + _T(" - ") + name; + cbi.mask |= CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_OVERLAY; + cbi.iImage = IMAGE_CHIP; // No real image available for now, } else { - cbi.mask &= ~(CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_OVERLAY); - std::vector<mpt::ustring> api = it->apiPath; - api.push_back(it->apiName); - name = mpt::ToCString(mpt::String::Combine(api, MPT_USTRING(" - "))) + _T(" - ") + name; + cbi.iImage = 0; } - if(it->isDefault) + cbi.iSelectedImage = cbi.iImage; + cbi.iOverlay = cbi.iImage; + mpt::ustring name = it->name + (it->isDefault ? MPT_USTRING(" [default]") : MPT_USTRING("")); + if(it->type == SoundDevice::TypeWAVEOUT || it->type == SoundDevice::TypeDSOUND || it->type == SoundDevice::TypeASIO) { - name += _T(" (Default)"); + // leave name alone + } else if(it->type == SoundDevice::TypePORTAUDIO_WASAPI || it->type == SoundDevice::TypePORTAUDIO_WDMKS) + { + name = it->apiName + MPT_USTRING(" - ") + name; + } else + { + name = ((it->apiPath.size() > 0) ? mpt::String::Combine(it->apiPath, MPT_USTRING(" - ")) + MPT_USTRING(" - ") : MPT_USTRING("")) + it->apiName + MPT_USTRING(" - ") + name; } - cbi.iSelectedImage = cbi.iImage; - cbi.iOverlay = cbi.iImage; - cbi.iIndent = 0; - cbi.lParam = theApp.GetSoundDevicesManager()->GetGlobalID(it->GetIdentifier()); TCHAR tmp[1024]; MemsetZero(tmp); - lstrcpyn(tmp, name, 1023); + lstrcpyn(tmp, mpt::ToCString(name), 1023); cbi.pszText = tmp; + cbi.iIndent = 0; int pos = m_CbnDevice.InsertItem(&cbi); if(static_cast<SoundDevice::Manager::GlobalID>(cbi.lParam) == theApp.GetSoundDevicesManager()->GetGlobalID(m_CurrentDeviceInfo.GetIdentifier())) { Modified: trunk/OpenMPT/sounddev/SoundDeviceManager.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceManager.cpp 2015-05-23 15:10:15 UTC (rev 5143) +++ trunk/OpenMPT/sounddev/SoundDeviceManager.cpp 2015-05-23 15:25:19 UTC (rev 5144) @@ -26,19 +26,21 @@ namespace SoundDevice { - struct CompareType +struct CompareInfo +{ + std::map<SoundDevice::Type, int> ordering; + CompareInfo(const std::map<SoundDevice::Type, int> &ordering) + : ordering(ordering) { - std::map<SoundDevice::Type, int> ordering; - CompareType(const std::map<SoundDevice::Type, int> &ordering) - : ordering(ordering) - { - return; - } - bool operator () (const SoundDevice::Info &x, const SoundDevice::Info &y) - { - return (ordering[x.type] > ordering[y.type]); - } - }; + return; + } + bool operator () (const SoundDevice::Info &x, const SoundDevice::Info &y) + { + return (ordering[x.type] > ordering[y.type]) + || ((ordering[x.type] == ordering[y.type]) && (x.isDefault && !y.isDefault)) + ; + } +}; template <typename Tdevice> @@ -114,10 +116,10 @@ { // Wine typePriorities[SoundDevice::TypeDSOUND] = 29; typePriorities[SoundDevice::TypeWAVEOUT] = 28; - typePriorities[SoundDevice::TypePORTAUDIO_WASAPI] = 21; + typePriorities[SoundDevice::TypePORTAUDIO_WASAPI] = 27; + typePriorities[SoundDevice::TypeASIO] = 21; typePriorities[SoundDevice::TypePORTAUDIO_WMME] = 19; typePriorities[SoundDevice::TypePORTAUDIO_DS] = 18; - typePriorities[SoundDevice::TypeASIO] = 10; typePriorities[SoundDevice::TypePORTAUDIO_WDMKS] = -1; } else if(mpt::Windows::Version::Is9x()) { // Win9x @@ -147,7 +149,7 @@ typePriorities[SoundDevice::TypeDSOUND] = -1; typePriorities[SoundDevice::TypePORTAUDIO_DS] = -2; } - std::stable_sort(m_SoundDevices.begin(), m_SoundDevices.end(), CompareType(typePriorities)); + std::stable_sort(m_SoundDevices.begin(), m_SoundDevices.end(), CompareInfo(typePriorities)); Log(LogDebug, MPT_USTRING("Sound Devices enumerated:")); for(std::size_t i = 0; i < m_SoundDevices.size(); ++i) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |