From: <man...@us...> - 2015-03-30 11:39:58
|
Revision: 4913 http://sourceforge.net/p/modplug/code/4913 Author: manxorist Date: 2015-03-30 11:39:45 +0000 (Mon, 30 Mar 2015) Log Message: ----------- [Ref] sounddev: Make the debugging checks agnostic of the actual implementation of the locking mechanism in AudioCriticalSection.h. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2015-03-30 11:18:43 UTC (rev 4912) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2015-03-30 11:39:45 UTC (rev 4913) @@ -662,6 +662,14 @@ } +bool CMainFrame::SoundSourceIsLockedByCurrentThread() const +//--------------------------------------------------------- +{ + MPT_TRACE(); + return CriticalSection::IsLocked(); +} + + void CMainFrame::FillAudioBufferLocked(SoundDevice::IFillAudioBuffer &callback) //----------------------------------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2015-03-30 11:18:43 UTC (rev 4912) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2015-03-30 11:39:45 UTC (rev 4913) @@ -407,6 +407,7 @@ uint64 SoundSourceGetReferenceClockNowNanoseconds() const; void SoundSourcePreStartCallback(); void SoundSourcePostStopCallback(); + bool SoundSourceIsLockedByCurrentThread() const; void FillAudioBufferLocked(SoundDevice::IFillAudioBuffer &callback); void AudioRead(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, void *buffer); void AudioDone(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, int64 streamPosition); Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-03-30 11:18:43 UTC (rev 4912) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-03-30 11:39:45 UTC (rev 4913) @@ -279,6 +279,18 @@ } +bool Base::SourceIsLockedByCurrentThread() const +//---------------------------------------------- +{ + MPT_TRACE(); + if(!m_Source) + { + return false; + } + return m_Source->SoundSourceIsLockedByCurrentThread(); +} + + void Base::SourceFillAudioBufferLocked() //-------------------------------------- { Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2015-03-30 11:18:43 UTC (rev 4912) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2015-03-30 11:39:45 UTC (rev 4913) @@ -74,6 +74,7 @@ virtual uint64 SoundSourceGetReferenceClockNowNanoseconds() const = 0; // timeGetTime()*1000000 on Windows virtual void SoundSourcePreStartCallback() = 0; virtual void SoundSourcePostStopCallback() = 0; + virtual bool SoundSourceIsLockedByCurrentThread() const = 0; virtual void FillAudioBufferLocked(SoundDevice::IFillAudioBuffer &callback) = 0; // take any locks needed while rendering audio and then call FillAudioBuffer virtual void AudioRead(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, void *buffer) = 0; virtual void AudioDone(const SoundDevice::Settings &settings, const SoundDevice::Flags &flags, const SoundDevice::BufferAttributes &bufferAttributes, SoundDevice::TimeInfo timeInfo, std::size_t numFrames, int64 streamPosition) = 0; // in sample frames @@ -593,6 +594,7 @@ uint64 SourceGetReferenceClockNowNanoseconds() const; void SourceNotifyPreStart(); void SourceNotifyPostStop(); + bool SourceIsLockedByCurrentThread() const; void SourceFillAudioBufferLocked(); void SourceAudioPreRead(std::size_t numFrames); void SourceAudioRead(void *buffer, std::size_t numFrames); Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-03-30 11:18:43 UTC (rev 4912) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-03-30 11:39:45 UTC (rev 4913) @@ -19,9 +19,6 @@ #include "../common/StringFixer.h" #include "../soundlib/SampleFormatConverters.h" -// DEBUG: -#include "../common/AudioCriticalSection.h" - #include <algorithm> @@ -514,7 +511,7 @@ { if(silence) { - if(CriticalSection::IsLocked()) + if(SourceIsLockedByCurrentThread()) { MPT_ASSERT_MSG(false, "AudioCriticalSection locked while stopping ASIO"); } else @@ -523,7 +520,7 @@ } } else { - if(CriticalSection::IsLocked()) + if(SourceIsLockedByCurrentThread()) { MPT_ASSERT_MSG(false, "AudioCriticalSection locked while starting ASIO"); } else @@ -542,7 +539,7 @@ //------------------------------- { MPT_TRACE(); - MPT_ASSERT_ALWAYS_MSG(!CriticalSection::IsLocked(), "AudioCriticalSection locked while starting ASIO"); + MPT_ASSERT_ALWAYS_MSG(!SourceIsLockedByCurrentThread(), "AudioCriticalSection locked while starting ASIO"); if(m_Settings.KeepDeviceRunning) { @@ -586,7 +583,7 @@ //-------------------------------------------- { MPT_TRACE(); - MPT_ASSERT_ALWAYS_MSG(!CriticalSection::IsLocked(), "AudioCriticalSection locked while stopping ASIO"); + MPT_ASSERT_ALWAYS_MSG(!SourceIsLockedByCurrentThread(), "AudioCriticalSection locked while stopping ASIO"); if(m_Settings.KeepDeviceRunning && !force) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |