From: <man...@us...> - 2014-12-31 11:35:56
|
Revision: 4691 http://sourceforge.net/p/modplug/code/4691 Author: manxorist Date: 2014-12-31 11:35:42 +0000 (Wed, 31 Dec 2014) Log Message: ----------- [Imp] sounddev: Allow disabling individual sound device types via hidden settings [Sound Settings]EnableFOO=0 . Modified Paths: -------------- trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-12-31 02:28:44 UTC (rev 4690) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-12-31 11:35:42 UTC (rev 4691) @@ -200,7 +200,7 @@ delete CMainFrame::GetMainFrame()->gpSoundDevice; CMainFrame::GetMainFrame()->gpSoundDevice = nullptr; } - theApp.GetSoundDevicesManager()->ReEnumerate(); + theApp.GetSoundDevicesManager()->ReEnumerate(TrackerSettings::Instance().GetEnabledSoundDeviceTypes()); SetDevice(m_CurrentDeviceInfo.GetIdentifier(), true); UpdateEverything(); } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2014-12-31 02:28:44 UTC (rev 4690) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2014-12-31 11:35:42 UTC (rev 4691) @@ -997,7 +997,7 @@ m_pMainWnd->DragAcceptFiles(); // Load sound APIs - m_pSoundDevicesManager = new SoundDevice::Manager(); + m_pSoundDevicesManager = new SoundDevice::Manager(TrackerSettings::Instance().GetEnabledSoundDeviceTypes()); if(TrackerSettings::Instance().m_SoundDeviceSettingsUseOldDefaults) { // get the old default device Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-12-31 02:28:44 UTC (rev 4690) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-12-31 11:35:42 UTC (rev 4691) @@ -725,6 +725,19 @@ } +SoundDevice::TypesSet TrackerSettings::GetEnabledSoundDeviceTypes() const +//----------------------------------------------------------------------- +{ + SoundDevice::TypesSet result; + for(int i = 0; i < SoundDevice::TypeNUM_DEVTYPES; ++i) + { + SoundDevice::Type type = static_cast<SoundDevice::Type>(i); + result[i] = conf.Read<bool>(MPT_USTRING("Sound Settings"), MPT_USTRING("Enable") + SoundDevice::TypeToString(type, true), true); + } + return result; +} + + MixerSettings TrackerSettings::GetMixerSettings() const //----------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2014-12-31 02:28:44 UTC (rev 4690) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2014-12-31 11:35:42 UTC (rev 4691) @@ -451,6 +451,8 @@ SoundDevice::Settings GetSoundDeviceSettings(const SoundDevice::Identifier &device) const; void SetSoundDeviceSettings(const SoundDevice::Identifier &device, const SoundDevice::Settings &settings); + SoundDevice::TypesSet GetEnabledSoundDeviceTypes() const; + Setting<uint32> MixerMaxChannels; Setting<uint32> MixerDSPMask; Setting<uint32> MixerFlags; Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-12-31 02:28:44 UTC (rev 4690) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2014-12-31 11:35:42 UTC (rev 4691) @@ -33,19 +33,19 @@ namespace SoundDevice { -mpt::ustring TypeToString(SoundDevice::Type type) -//----------------------------------------------- +mpt::ustring TypeToString(SoundDevice::Type type, bool verbose) +//------------------------------------------------------------- { switch(type) { case TypeWAVEOUT: return MPT_USTRING("WaveOut"); break; case TypeDSOUND: return MPT_USTRING("DirectSound"); break; case TypeASIO: return MPT_USTRING("ASIO"); break; - case TypePORTAUDIO_WASAPI: return MPT_USTRING("WASAPI"); break; - case TypePORTAUDIO_WDMKS: return MPT_USTRING("WDM-KS"); break; - case TypePORTAUDIO_WMME: return MPT_USTRING("MME"); break; - case TypePORTAUDIO_DS: return MPT_USTRING("DS"); break; - case TypePORTAUDIO_ASIO: return MPT_USTRING("ASIO"); break; + case TypePORTAUDIO_WASAPI: return (verbose ? MPT_USTRING("PortAudio") : MPT_USTRING("")) + MPT_USTRING("WASAPI"); break; + case TypePORTAUDIO_WDMKS: return (verbose ? MPT_USTRING("PortAudio") : MPT_USTRING("")) + MPT_USTRING("WDM-KS"); break; + case TypePORTAUDIO_WMME: return (verbose ? MPT_USTRING("PortAudio") : MPT_USTRING("")) + MPT_USTRING("MME"); break; + case TypePORTAUDIO_DS: return (verbose ? MPT_USTRING("PortAudio") : MPT_USTRING("")) + MPT_USTRING("DS"); break; + case TypePORTAUDIO_ASIO: return (verbose ? MPT_USTRING("PortAudio") : MPT_USTRING("")) + MPT_USTRING("ASIO"); break; } return mpt::ustring(); } @@ -466,8 +466,8 @@ // -void Manager::ReEnumerate() -//------------------------- +void Manager::ReEnumerate(SoundDevice::TypesSet enabledTypes) +//----------------------------------------------------------- { m_SoundDevices.clear(); m_DeviceUnavailable.clear(); @@ -481,23 +481,25 @@ } #endif // NO_PORTAUDIO + if(enabledTypes[SoundDevice::TypeWAVEOUT]) { const std::vector<SoundDevice::Info> infos = CWaveDevice::EnumerateDevices(); std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); } #ifndef NO_ASIO + if(enabledTypes[SoundDevice::TypeASIO]) { const std::vector<SoundDevice::Info> infos = CASIODevice::EnumerateDevices(); std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); } #endif // NO_ASIO #ifndef NO_PORTAUDIO - if(IsComponentAvailable(m_PortAudio)) + if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_WASAPI]) { const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_WASAPI); std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); } - if(IsComponentAvailable(m_PortAudio)) + if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_WDMKS]) { const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_WDMKS); std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); @@ -506,6 +508,7 @@ // kind of deprecated by now #ifndef NO_DSOUND + if(enabledTypes[SoundDevice::TypeDSOUND]) { const std::vector<SoundDevice::Info> infos = CDSoundDevice::EnumerateDevices(); std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); @@ -514,17 +517,17 @@ // duplicate devices, only used if [Sound Settings]MorePortaudio=1 #ifndef NO_PORTAUDIO - if(IsComponentAvailable(m_PortAudio)) + if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_WMME]) { const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_WMME); std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); } - if(IsComponentAvailable(m_PortAudio)) + if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_ASIO]) { const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_ASIO); std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); } - if(IsComponentAvailable(m_PortAudio)) + if(IsComponentAvailable(m_PortAudio) && enabledTypes[SoundDevice::TypePORTAUDIO_DS]) { const std::vector<SoundDevice::Info> infos = CPortaudioDevice::EnumerateDevices(TypePORTAUDIO_DS); std::copy(infos.begin(), infos.end(), std::back_inserter(m_SoundDevices)); @@ -774,10 +777,10 @@ } -Manager::Manager() -//---------------- +Manager::Manager(SoundDevice::TypesSet enabledTypes) +//-------------------------------------------------- { - ReEnumerate(); + ReEnumerate(enabledTypes); } Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2014-12-31 02:28:44 UTC (rev 4690) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2014-12-31 11:35:42 UTC (rev 4691) @@ -17,6 +17,7 @@ #include "../common/ComponentManager.h" #include "../soundlib/SampleFormat.h" +#include <bitset> #include <map> #include <vector> @@ -95,9 +96,11 @@ TypePORTAUDIO_ASIO = 7, TypeNUM_DEVTYPES }; +typedef std::bitset<TypeNUM_DEVTYPES> TypesSet; -mpt::ustring TypeToString(SoundDevice::Type type); +mpt::ustring TypeToString(SoundDevice::Type type, bool verbose = false); + typedef uint8 Index; template<typename T> @@ -656,12 +659,12 @@ std::map<SoundDevice::Identifier, SoundDevice::DynamicCaps> m_DeviceDynamicCaps; public: - Manager(); + Manager(SoundDevice::TypesSet enabledTypes); ~Manager(); public: - void ReEnumerate(); + void ReEnumerate(SoundDevice::TypesSet enabledTypes); std::vector<SoundDevice::Info>::const_iterator begin() const { return m_SoundDevices.begin(); } std::vector<SoundDevice::Info>::const_iterator end() const { return m_SoundDevices.end(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |