From: <man...@us...> - 2013-10-24 12:55:06
|
Revision: 3005 http://sourceforge.net/p/modplug/code/3005 Author: manxorist Date: 2013-10-24 12:54:57 +0000 (Thu, 24 Oct 2013) Log Message: ----------- [Ref] gpSoundDevice is only ever accessed from the main gui thread. So m_SoundDeviceMutex actually protects nothing at all. Remove it. Modified Paths: -------------- trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mpdlgs.cpp Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-10-24 12:13:39 UTC (rev 3004) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-10-24 12:54:57 UTC (rev 3005) @@ -141,7 +141,6 @@ { try { - // do not take m_SoundDeviceMutex here, just try closing it, no matter what if(pMainFrame->gpSoundDevice) { pMainFrame->gpSoundDevice->Reset(); Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-24 12:13:39 UTC (rev 3004) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-24 12:54:57 UTC (rev 3005) @@ -454,13 +454,10 @@ if (IsPlaying()) PauseMod(); if (pMDIActive) pMDIActive->SavePosition(TRUE); + if(gpSoundDevice) { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); - if(gpSoundDevice) - { - delete gpSoundDevice; - gpSoundDevice = nullptr; - } + delete gpSoundDevice; + gpSoundDevice = nullptr; } // Save Settings @@ -655,12 +652,9 @@ Notification PendingNotification; bool found = false; int64 currenttotalsamples = 0; + if(gpSoundDevice) { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); - if(gpSoundDevice) - { - currenttotalsamples = gpSoundDevice->GetStreamPositionSamples(); - } + currenttotalsamples = gpSoundDevice->GetStreamPositionSamples(); } { // advance to the newest notification, drop the obsolete ones @@ -809,7 +803,6 @@ bool CMainFrame::audioTryOpeningDevice() //-------------------------------------- { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); const SoundDeviceID deviceID = TrackerSettings::Instance().m_nWaveDevice; if(gpSoundDevice && (gpSoundDevice->GetDeviceID() != deviceID)) { @@ -837,7 +830,6 @@ bool CMainFrame::IsAudioDeviceOpen() const //---------------------------------------- { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); return gpSoundDevice && gpSoundDevice->IsOpen(); } @@ -853,11 +845,7 @@ { if(audioTryOpeningDevice()) { - SampleFormat actualSampleFormat = SampleFormatInvalid; - { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); - actualSampleFormat = gpSoundDevice->GetActualSampleFormat(); - } + SampleFormat actualSampleFormat = gpSoundDevice->GetActualSampleFormat(); if(actualSampleFormat.IsValid()) { TrackerSettings::Instance().m_SampleFormat = actualSampleFormat; @@ -883,7 +871,6 @@ void CMainFrame::audioCloseDevice() //--------------------------------- { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); if(gpSoundDevice) { gpSoundDevice->Reset(); @@ -1243,10 +1230,7 @@ { if(!m_pSndFile) return false; // nothing to play if(!IsAudioDeviceOpen()) return false; - { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); - gpSoundDevice->Start(); - } + gpSoundDevice->Start(); if(!m_NotifyTimer) { m_NotifyTimer = SetTimer(TIMERID_NOTIFY, TrackerSettings::Instance().m_UpdateIntervalMS, NULL); @@ -1259,10 +1243,7 @@ //----------------------------- { if(!IsAudioDeviceOpen()) return; - { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); - gpSoundDevice->Stop(); - } + gpSoundDevice->Stop(); if(m_NotifyTimer) { KillTimer(m_NotifyTimer); @@ -1276,10 +1257,7 @@ //------------------------------ { if(!IsAudioDeviceOpen()) return false; - { - Util::lock_guard<Util::mutex> lock(m_SoundDeviceMutex); - gpSoundDevice->Stop(); - } + gpSoundDevice->Stop(); if(m_NotifyTimer) { KillTimer(m_NotifyTimer); Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-24 12:13:39 UTC (rev 3004) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-24 12:54:57 UTC (rev 3005) @@ -273,7 +273,6 @@ public: // Low-Level Audio - mutable Util::mutex m_SoundDeviceMutex; ISoundDevice *gpSoundDevice; UINT_PTR m_NotifyTimer; Dither m_Dither; Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-24 12:13:39 UTC (rev 3004) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-24 12:54:57 UTC (rev 3005) @@ -417,13 +417,8 @@ { m_CbnMixingFreq.ResetContent(); - std::vector<uint32> samplerates; + std::vector<uint32> samplerates = theApp.GetSoundDevicesManager()->GetDeviceCaps(dev, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice).supportedSampleRates; - { - Util::lock_guard<Util::mutex> lock(CMainFrame::GetMainFrame()->m_SoundDeviceMutex); - samplerates = theApp.GetSoundDevicesManager()->GetDeviceCaps(dev, TrackerSettings::Instance().GetSampleRates(), CMainFrame::GetMainFrame(), CMainFrame::GetMainFrame()->gpSoundDevice).supportedSampleRates; - } - if(samplerates.empty()) { // We have no valid list of supported playback rates! Assume all rates supported by OpenMPT are possible... @@ -542,22 +537,19 @@ { if (!m_EditStatistics) return; CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); + if(pMainFrm->gpSoundDevice && pMainFrm->IsPlaying()) { - Util::lock_guard<Util::mutex> lock(pMainFrm->m_SoundDeviceMutex); - if(pMainFrm->gpSoundDevice && pMainFrm->IsPlaying()) - { - CHAR s[256]; - _snprintf(s, 255, "Buffers: %d\r\nUpdate interval: %4.1f ms\r\nLatency: %4.1f ms\r\nCurrent Latency: %4.1f ms", - pMainFrm->gpSoundDevice->GetNumBuffers(), - (float)pMainFrm->gpSoundDevice->GetRealUpdateIntervalMS(), - (float)pMainFrm->gpSoundDevice->GetRealLatencyMS(), - (float)pMainFrm->gpSoundDevice->GetCurrentRealLatencyMS() - ); - m_EditStatistics.SetWindowText(s); - } else - { - m_EditStatistics.SetWindowText(""); - } + CHAR s[256]; + _snprintf(s, 255, "Buffers: %d\r\nUpdate interval: %4.1f ms\r\nLatency: %4.1f ms\r\nCurrent Latency: %4.1f ms", + pMainFrm->gpSoundDevice->GetNumBuffers(), + (float)pMainFrm->gpSoundDevice->GetRealUpdateIntervalMS(), + (float)pMainFrm->gpSoundDevice->GetRealLatencyMS(), + (float)pMainFrm->gpSoundDevice->GetCurrentRealLatencyMS() + ); + m_EditStatistics.SetWindowText(s); + } else + { + m_EditStatistics.SetWindowText(""); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |