Removing bApproximate (part 2)

This should wrap up removing this flag from the code base.
This commit is contained in:
sukibaby
2024-09-20 22:03:15 -07:00
committed by teejusb
parent 221752215c
commit 53cd968b90
13 changed files with 29 additions and 34 deletions
+4 -6
View File
@@ -601,12 +601,10 @@ void GameSoundManager::Update( float fDeltaTime )
} }
/* There's a delay between us calling Play() and the sound actually playing. /* There's a delay between us calling Play() and the sound actually playing.
* During this time, m_bApproximate will be true. Keep using the previous timing * Keep using the previous timing data until we get a non-approximate time,
* data until we get a non-approximate time, indicating that the sound has actually * indicating that the sound has actually started playing. */
* started playing. */
bool m_bApproximate;
RageTimer tm; RageTimer tm;
const float fSeconds = g_Playing->m_Music->GetPositionSeconds( &m_bApproximate, &tm ); const float fSeconds = g_Playing->m_Music->GetPositionSeconds( &tm );
// Check for song timing skips. // Check for song timing skips.
if( PREFSMAN->m_bLogSkips && !g_Playing->m_bTimingDelayed ) if( PREFSMAN->m_bLogSkips && !g_Playing->m_bTimingDelayed )
@@ -627,7 +625,7 @@ void GameSoundManager::Update( float fDeltaTime )
// If g_Playing->m_bTimingDelayed, we're waiting for the new music to actually start // If g_Playing->m_bTimingDelayed, we're waiting for the new music to actually start
// playing. // playing.
if( g_Playing->m_bTimingDelayed && !m_bApproximate ) if( g_Playing->m_bTimingDelayed )
{ {
/* Load up the new timing data. */ /* Load up the new timing data. */
g_Playing->m_Timing = g_Playing->m_NewTiming; g_Playing->m_Timing = g_Playing->m_NewTiming;
+5 -8
View File
@@ -473,16 +473,13 @@ float RageSound::GetLengthSeconds()
return iLength / 1000.f; // ms -> secs return iLength / 1000.f; // ms -> secs
} }
int RageSound::GetSourceFrameFromHardwareFrame( std::int64_t iHardwareFrame, bool *bApproximate ) const int RageSound::GetSourceFrameFromHardwareFrame( std::int64_t iHardwareFrame ) const
{ {
if( m_HardwareToStreamMap.IsEmpty() || m_StreamToSourceMap.IsEmpty() ) if( m_HardwareToStreamMap.IsEmpty() || m_StreamToSourceMap.IsEmpty() )
return 0; return 0;
// TODO(sukibaby): The nullptrs passed to the functions below are part of a gradual std::int64_t iStreamFrame = m_HardwareToStreamMap.Search( iHardwareFrame );
// procedure to remove bApproximate from the code base. Until it's fully removed, return static_cast<int>(m_StreamToSourceMap.Search( iStreamFrame ));
// this will remain nullptr for now. In the future, these nullptr's should be removed.
std::int64_t iStreamFrame = m_HardwareToStreamMap.Search( iHardwareFrame, nullptr );
return static_cast<int>(m_StreamToSourceMap.Search( iStreamFrame, nullptr ));
} }
/* If non-nullptr, approximate is set to true if the returned time is approximated because of /* If non-nullptr, approximate is set to true if the returned time is approximated because of
@@ -492,7 +489,7 @@ int RageSound::GetSourceFrameFromHardwareFrame( std::int64_t iHardwareFrame, boo
* position. We might take a variable amount of time before grabbing the timestamp (to * position. We might take a variable amount of time before grabbing the timestamp (to
* lock SOUNDMAN); we might lose the scheduler after grabbing it, when releasing SOUNDMAN. * lock SOUNDMAN); we might lose the scheduler after grabbing it, when releasing SOUNDMAN.
*/ */
float RageSound::GetPositionSeconds( bool *bApproximate, RageTimer *pTimestamp ) const float RageSound::GetPositionSeconds( RageTimer *pTimestamp ) const
{ {
// Get our current hardware position. // Get our current hardware position.
std::int64_t iCurrentHardwareFrame = SOUNDMAN->GetPosition(pTimestamp); std::int64_t iCurrentHardwareFrame = SOUNDMAN->GetPosition(pTimestamp);
@@ -514,7 +511,7 @@ float RageSound::GetPositionSeconds( bool *bApproximate, RageTimer *pTimestamp )
return static_cast<float>(m_iStoppedSourceFrame) / fSampleRate; return static_cast<float>(m_iStoppedSourceFrame) / fSampleRate;
} }
int iSourceFrame = GetSourceFrameFromHardwareFrame( iCurrentHardwareFrame, bApproximate ); int iSourceFrame = GetSourceFrameFromHardwareFrame( iCurrentHardwareFrame );
return static_cast<float>(iSourceFrame) / fSampleRate; return static_cast<float>(iSourceFrame) / fSampleRate;
} }
+2 -2
View File
@@ -131,7 +131,7 @@ public:
bool Pause( bool bPause ); bool Pause( bool bPause );
float GetLengthSeconds(); float GetLengthSeconds();
float GetPositionSeconds( bool *approximate=nullptr, RageTimer *Timestamp=nullptr ) const; float GetPositionSeconds( RageTimer *Timestamp=nullptr ) const;
RString GetLoadedFilePath() const { return m_sFilePath; } RString GetLoadedFilePath() const { return m_sFilePath; }
bool IsPlaying() const { return m_bPlaying; } bool IsPlaying() const { return m_bPlaying; }
@@ -175,7 +175,7 @@ private:
RString m_sError; RString m_sError;
int GetSourceFrameFromHardwareFrame( std::int64_t iHardwareFrame, bool *bApproximate = nullptr ) const; int GetSourceFrameFromHardwareFrame( std::int64_t iHardwareFrame ) const;
bool SetPositionFrames( int frames = -1 ); bool SetPositionFrames( int frames = -1 );
RageSoundParams::StopMode_t GetStopMode() const; // resolves M_AUTO RageSoundParams::StopMode_t GetStopMode() const; // resolves M_AUTO
+1 -1
View File
@@ -108,7 +108,7 @@ void pos_map_impl::Cleanup()
m_Queue.erase(m_Queue.begin(), it); m_Queue.erase(m_Queue.begin(), it);
} }
std::int64_t pos_map_queue::Search( std::int64_t iSourceFrame, bool *bApproximate ) const std::int64_t pos_map_queue::Search( std::int64_t iSourceFrame ) const
{ {
if( IsEmpty() ) if( IsEmpty() )
{ {
+1 -1
View File
@@ -19,7 +19,7 @@ public:
void Insert( std::int64_t iSourceFrame, std::int64_t iFrames, std::int64_t iDestFrame, double fSourceToDestRatio = 1.0 ); void Insert( std::int64_t iSourceFrame, std::int64_t iFrames, std::int64_t iDestFrame, double fSourceToDestRatio = 1.0 );
/* Return the iDestFrame for the given iSourceFrame. */ /* Return the iDestFrame for the given iSourceFrame. */
std::int64_t Search( std::int64_t iSourceFrame, bool *bApproximate ) const; std::int64_t Search( std::int64_t iSourceFrame ) const;
/* Erase all mappings. */ /* Erase all mappings. */
void Clear(); void Clear();
+7 -7
View File
@@ -35,11 +35,11 @@ const std::int64_t ONE_SECOND_IN_MICROSECONDS_LL = 1000000LL;
const double ONE_SECOND_IN_MICROSECONDS_DBL = 1000000.0; const double ONE_SECOND_IN_MICROSECONDS_DBL = 1000000.0;
const RageTimer RageZeroTimer(0,0); const RageTimer RageZeroTimer(0,0);
static std::uint64_t g_iStartTime = ArchHooks::GetMicrosecondsSinceStart( true ); static std::uint64_t g_iStartTime = ArchHooks::GetMicrosecondsSinceStart();
static std::uint64_t GetTime( bool /* bAccurate */ ) static std::uint64_t GetTime()
{ {
return ArchHooks::GetMicrosecondsSinceStart( true ); return ArchHooks::GetMicrosecondsSinceStart();
} }
/* The accuracy of RageTimer::GetTimeSinceStart() is directly tied to the /* The accuracy of RageTimer::GetTimeSinceStart() is directly tied to the
@@ -50,21 +50,21 @@ static std::uint64_t GetTime( bool /* bAccurate */ )
* values truncated or rounded when they shouldn't be can cause errors when * values truncated or rounded when they shouldn't be can cause errors when
* this is calculated and manifest as a _sudden_ drift of sync. Use caution * this is calculated and manifest as a _sudden_ drift of sync. Use caution
* and do thorough testing if you change anything here. -sukibaby */ * and do thorough testing if you change anything here. -sukibaby */
double RageTimer::GetTimeSinceStart(bool bAccurate) double RageTimer::GetTimeSinceStart()
{ {
std::uint64_t usecs = GetTime(bAccurate); std::uint64_t usecs = GetTime();
usecs -= g_iStartTime; usecs -= g_iStartTime;
return usecs / ONE_SECOND_IN_MICROSECONDS_DBL; return usecs / ONE_SECOND_IN_MICROSECONDS_DBL;
} }
std::uint64_t RageTimer::GetUsecsSinceStart() std::uint64_t RageTimer::GetUsecsSinceStart()
{ {
return GetTime(true) - g_iStartTime; return GetTime() - g_iStartTime;
} }
void RageTimer::Touch() void RageTimer::Touch()
{ {
std::uint64_t usecs = GetTime( true ); std::uint64_t usecs = GetTime();
this->m_secs = std::uint64_t(usecs / ONE_SECOND_IN_MICROSECONDS_ULL); this->m_secs = std::uint64_t(usecs / ONE_SECOND_IN_MICROSECONDS_ULL);
this->m_us = std::uint64_t(usecs % ONE_SECOND_IN_MICROSECONDS_ULL); this->m_us = std::uint64_t(usecs % ONE_SECOND_IN_MICROSECONDS_ULL);
+2 -2
View File
@@ -23,8 +23,8 @@ public:
/* (alias) */ /* (alias) */
float PeekDeltaTime() const { return Ago(); } float PeekDeltaTime() const { return Ago(); }
static double GetTimeSinceStart( bool bAccurate = true ); // seconds since the program was started static double GetTimeSinceStart(); // seconds since the program was started
static float GetTimeSinceStartFast() { return GetTimeSinceStart(false); } static float GetTimeSinceStartFast() { return GetTimeSinceStart(); }
static std::uint64_t GetUsecsSinceStart(); static std::uint64_t GetUsecsSinceStart();
/* Get a timer representing half of the time ago as this one. */ /* Get a timer representing half of the time ago as this one. */
+1 -1
View File
@@ -1660,7 +1660,7 @@ void ScreenEdit::Update( float fDeltaTime )
if( m_pSoundMusic->IsPlaying() ) if( m_pSoundMusic->IsPlaying() )
{ {
RageTimer tm; RageTimer tm;
const float fSeconds = m_pSoundMusic->GetPositionSeconds( nullptr, &tm ); const float fSeconds = m_pSoundMusic->GetPositionSeconds( &tm );
GAMESTATE->UpdateSongPosition( fSeconds, GAMESTATE->m_pCurSong->m_SongTiming, tm ); GAMESTATE->UpdateSongPosition( fSeconds, GAMESTATE->m_pCurSong->m_SongTiming, tm );
} }
+1 -1
View File
@@ -1583,7 +1583,7 @@ void ScreenGameplay::UpdateSongPosition( float fDeltaTime )
return; return;
RageTimer tm; RageTimer tm;
const float fSeconds = m_pSoundMusic->GetPositionSeconds( nullptr, &tm ); const float fSeconds = m_pSoundMusic->GetPositionSeconds( &tm );
const float fAdjust = SOUND->GetFrameTimingAdjustment( fDeltaTime ); const float fAdjust = SOUND->GetFrameTimingAdjustment( fDeltaTime );
GAMESTATE->UpdateSongPosition( fSeconds+fAdjust, GAMESTATE->m_pCurSong->m_SongTiming, tm+fAdjust ); GAMESTATE->UpdateSongPosition( fSeconds+fAdjust, GAMESTATE->m_pCurSong->m_SongTiming, tm+fAdjust );
} }
+1 -1
View File
@@ -87,7 +87,7 @@ public:
* underlying timers may be 32-bit, but implementations should try to avoid * underlying timers may be 32-bit, but implementations should try to avoid
* wrapping if possible. * wrapping if possible.
*/ */
static std::int64_t GetMicrosecondsSinceStart( bool bAccurate ); static std::int64_t GetMicrosecondsSinceStart();
/* /*
* Add file search paths, higher priority first. * Add file search paths, higher priority first.
+1 -1
View File
@@ -258,7 +258,7 @@ bool ArchHooks_MacOSX::GoToURL( RString sUrl )
return result == 0; return result == 0;
} }
std::int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate ) std::int64_t ArchHooks::GetMicrosecondsSinceStart()
{ {
// http://developer.apple.com/qa/qa2004/qa1398.html // http://developer.apple.com/qa/qa2004/qa1398.html
static double factor = 0.0; static double factor = 0.0;
+2 -2
View File
@@ -149,7 +149,7 @@ clockid_t ArchHooks_Unix::GetClock()
return g_Clock; return g_Clock;
} }
std::int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate ) std::int64_t ArchHooks::GetMicrosecondsSinceStart()
{ {
OpenGetTime(); OpenGetTime();
@@ -162,7 +162,7 @@ std::int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
return iRet; return iRet;
} }
#else #else
std::int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate ) std::int64_t ArchHooks::GetMicrosecondsSinceStart()
{ {
struct timeval tv; struct timeval tv;
gettimeofday( &tv, nullptr ); gettimeofday( &tv, nullptr );
+1 -1
View File
@@ -39,7 +39,7 @@ static void InitTimer()
QueryPerformanceFrequency(&g_liFrequency); QueryPerformanceFrequency(&g_liFrequency);
} }
std::int64_t ArchHooks::GetMicrosecondsSinceStart(bool bAccurate) std::int64_t ArchHooks::GetMicrosecondsSinceStart()
{ {
// Make sure the timer is initialized. // Make sure the timer is initialized.
if (!g_bTimerInitialized) { if (!g_bTimerInitialized) {