Merge pull request #1165 from erwincoumans/master

allow b3Clock to reset to time reference 0, by default reset will set…
This commit is contained in:
erwincoumans
2017-06-02 09:40:22 -07:00
committed by GitHub
2 changed files with 18 additions and 5 deletions

View File

@@ -46,7 +46,6 @@ struct b3ClockData
#ifdef B3_USE_WINDOWS_TIMERS
LARGE_INTEGER mClockFrequency;
DWORD mStartTick;
LARGE_INTEGER mStartTime;
#else
#ifdef __CELLOS_LV2__
@@ -88,11 +87,24 @@ b3Clock& b3Clock::operator=(const b3Clock& other)
/// Resets the initial reference time.
void b3Clock::reset()
void b3Clock::reset(bool zeroReference)
{
if (zeroReference)
{
#ifdef B3_USE_WINDOWS_TIMERS
m_data->mStartTime.QuadPart = 0;
#else
#ifdef __CELLOS_LV2__
m_data->mStartTime = 0;
#else
m_data->mStartTime = (struct timeval){0};
#endif
#endif
} else
{
#ifdef B3_USE_WINDOWS_TIMERS
QueryPerformanceCounter(&m_data->mStartTime);
m_data->mStartTick = GetTickCount();
#else
#ifdef __CELLOS_LV2__
@@ -105,6 +117,7 @@ void b3Clock::reset()
gettimeofday(&m_data->mStartTime, 0);
#endif
#endif
}
}
/// Returns the time in ms since the last call to reset or since

View File

@@ -13,8 +13,8 @@ public:
~b3Clock();
/// Resets the initial reference time.
void reset();
/// Resets the initial reference time. If zeroReference is true, will set reference to absolute 0.
void reset(bool zeroReference=false);
/// Returns the time in ms since the last call to reset or since
/// the b3Clock was created.