diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index 51ee0db147..86395bfdae 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -38,6 +38,7 @@ #include "RageLog.h" #include "RageException.h" #include "PrefsManager.h" +#include "arch/ArchHooks/ArchHooks.h" #include @@ -654,9 +655,21 @@ int RageSound::GetPositionSecondsInternal( bool *approximate ) const return SearchPosMap( pos_map, cur_sample, approximate ); } -float RageSound::GetPositionSeconds( bool *approximate ) const +float RageSound::GetPositionSeconds( bool *approximate, RageTimer *Timestamp ) const { + LockMut(SOUNDMAN->lock); + + if( Timestamp ) + { + HOOKS->EnterTimeCriticalSection(); + Timestamp->Touch(); + } + const float pos = GetPositionSecondsInternal( approximate ) / float(samplerate()); + + if( Timestamp ) + HOOKS->ExitTimeCriticalSection(); + const float fixed_pos = pos + Sample->GetOffsetFix(); return GetPlaybackRate() * fixed_pos; } diff --git a/stepmania/src/RageSound.h b/stepmania/src/RageSound.h index 49fe0564dd..d3ef645ab6 100644 --- a/stepmania/src/RageSound.h +++ b/stepmania/src/RageSound.h @@ -68,7 +68,7 @@ public: void Stop(); float GetLengthSeconds(); - float GetPositionSeconds( bool *approximate=NULL ) const; + float GetPositionSeconds( bool *approximate=NULL, RageTimer *Timestamp=NULL ) const; int GetSampleRate() const; bool SetPositionSeconds( float fSeconds = -1); void SetAccurateSync(bool yes=true) { AccurateSync = yes; }