From: <man...@us...> - 2013-12-02 15:04:53
|
Revision: 3349 http://sourceforge.net/p/modplug/code/3349 Author: manxorist Date: 2013-12-02 15:04:47 +0000 (Mon, 02 Dec 2013) Log Message: ----------- [Imp] sounddev: Add hidden setting [Sound Settings]KeepDeviceOpen which keeps the sound device open when playback is stopped and thereby avoids pontential latency caused by (re-)opening the device. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-02 14:24:42 UTC (rev 3348) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-02 15:04:47 UTC (rev 3349) @@ -459,6 +459,8 @@ if(gpSoundDevice) { + gpSoundDevice->Stop(); + gpSoundDevice->Close(); delete gpSoundDevice; gpSoundDevice = nullptr; } @@ -786,6 +788,8 @@ const SoundDeviceID deviceID = TrackerSettings::Instance().GetSoundDeviceID(); if(gpSoundDevice && (gpSoundDevice->GetDeviceID() != deviceID)) { + gpSoundDevice->Stop(); + gpSoundDevice->Close(); delete gpSoundDevice; gpSoundDevice = nullptr; } @@ -822,14 +826,6 @@ } -bool CMainFrame::audioReopenDevice() -//---------------------------------- -{ - audioCloseDevice(); - return audioOpenDevice(); -} - - void CMainFrame::audioCloseDevice() //--------------------------------- { @@ -1211,7 +1207,10 @@ m_NotifyTimer = 0; } ResetNotificationBuffer(); - audioCloseDevice(); + if(!TrackerSettings::Instance().m_SoundSettingsKeepDeviceOpen) + { + audioCloseDevice(); + } } @@ -1596,25 +1595,23 @@ BOOL CMainFrame::SetupSoundCard(const SoundDeviceSettings &deviceSettings, SoundDeviceID deviceID) //------------------------------------------------------------------------------------------------ { - const bool isPlaying = IsPlaying(); if((TrackerSettings::Instance().GetSoundDeviceID() != deviceID) || (TrackerSettings::Instance().GetSoundDeviceSettings(deviceID) != deviceSettings)) { - CModDoc *pActiveMod = NULL; - if (isPlaying) + CModDoc *pActiveMod = nullptr; + if(IsPlaying()) { if ((m_pSndFile) && (!m_pSndFile->IsPaused())) pActiveMod = GetModPlaying(); PauseMod(); } + gpSoundDevice->Close(); TrackerSettings::Instance().SetSoundDeviceID(deviceID); TrackerSettings::Instance().SetSoundDeviceSettings(deviceID, deviceSettings); - TrackerSettings::Instance().MixerOutputChannels = deviceSettings.Channels; TrackerSettings::Instance().MixerSamplerate = deviceSettings.Samplerate; + if(pActiveMod) { - CriticalSection cs; - if (pActiveMod) UpdateAudioParameters(pActiveMod->GetrSoundFile(), FALSE); + PlayMod(pActiveMod); } - if (pActiveMod) PlayMod(pActiveMod); UpdateWindow(); } else { Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-12-02 14:24:42 UTC (rev 3348) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-12-02 15:04:47 UTC (rev 3349) @@ -343,7 +343,6 @@ bool InNotifyHandler() const { return m_InNotifyHandler; } bool audioOpenDevice(); - bool audioReopenDevice(); void audioCloseDevice(); bool IsAudioDeviceOpen() const; bool DoNotification(DWORD dwSamplesRead, int64 streamPosition); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-12-02 14:24:42 UTC (rev 3348) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-12-02 15:04:47 UTC (rev 3349) @@ -154,6 +154,7 @@ // Sound Settings , m_SoundSampleRates(conf, "Sound Settings", "SampleRates", GetDefaultSampleRates()) , m_MorePortaudio(conf, "Sound Settings", "MorePortaudio", false) + , m_SoundSettingsKeepDeviceOpen(conf, "Sound Settings", "KeepDeviceOpen", false) , m_SoundDeviceSettingsUseOldDefaults(false) , m_SoundDeviceIdentifier(conf, "Sound Settings", "Device", std::wstring()) , MixerMaxChannels(conf, "Sound Settings", "MixChannels", MixerSettings().m_nMaxMixChannels) Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-12-02 14:24:42 UTC (rev 3348) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-12-02 15:04:47 UTC (rev 3349) @@ -274,6 +274,7 @@ Setting<std::vector<uint32> > m_SoundSampleRates; Setting<bool> m_MorePortaudio; + Setting<bool> m_SoundSettingsKeepDeviceOpen; bool m_SoundDeviceSettingsUseOldDefaults; SoundDeviceID m_SoundDeviceID_DEPRECATED; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |