(mostly) Fix arrow stuttering from repeated positions from audio drivers.
As far as I could tell, this fixed any issues I was having with PulseAudio, it should also fix up DSound on Windows although I've yet to test that.
This commit is contained in:
@@ -912,6 +912,8 @@ const float GameState::MUSIC_SECONDS_INVALID = -5000.0f;
|
|||||||
void GameState::ResetMusicStatistics()
|
void GameState::ResetMusicStatistics()
|
||||||
{
|
{
|
||||||
m_Position.Reset();
|
m_Position.Reset();
|
||||||
|
m_LastPositionTimer.Touch();
|
||||||
|
m_LastPositionSeconds = 0.0f;
|
||||||
|
|
||||||
Actor::SetBGMTime( 0, 0, 0, 0 );
|
Actor::SetBGMTime( 0, 0, 0, 0 );
|
||||||
|
|
||||||
@@ -960,6 +962,20 @@ void GameState::ResetStageStatistics()
|
|||||||
|
|
||||||
void GameState::UpdateSongPosition( float fPositionSeconds, const TimingData &timing, const RageTimer ×tamp, bool bUpdatePlayers )
|
void GameState::UpdateSongPosition( float fPositionSeconds, const TimingData &timing, const RageTimer ×tamp, bool bUpdatePlayers )
|
||||||
{
|
{
|
||||||
|
/* It's not uncommon to get a lot of duplicated positions from the sound
|
||||||
|
* driver, like so: 13.120953,13.130975,13.130975,13.130975,13.140998,...
|
||||||
|
* This causes visual stuttering of the arrows. To compensate, keep a
|
||||||
|
* RageTimer since the last change. */
|
||||||
|
if (fPositionSeconds == m_LastPositionSeconds)
|
||||||
|
fPositionSeconds += m_LastPositionTimer.Ago();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//LOG->Info("Time difference: %+f",
|
||||||
|
// m_LastPositionTimer.Ago() - (fPositionSeconds - m_LastPositionSeconds)
|
||||||
|
//);
|
||||||
|
m_LastPositionTimer.Touch();
|
||||||
|
m_LastPositionSeconds = fPositionSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
m_Position.UpdateSongPosition( fPositionSeconds, timing, timestamp );
|
m_Position.UpdateSongPosition( fPositionSeconds, timing, timestamp );
|
||||||
|
|
||||||
|
|||||||
@@ -394,6 +394,10 @@ private:
|
|||||||
int m_iAwardedExtraStages[NUM_PLAYERS];
|
int m_iAwardedExtraStages[NUM_PLAYERS];
|
||||||
bool m_bEarnedExtraStage;
|
bool m_bEarnedExtraStage;
|
||||||
|
|
||||||
|
// Timing position corrections
|
||||||
|
RageTimer m_LastPositionTimer;
|
||||||
|
float m_LastPositionSeconds;
|
||||||
|
|
||||||
GameState(const GameState& rhs);
|
GameState(const GameState& rhs);
|
||||||
GameState& operator=(const GameState& rhs);
|
GameState& operator=(const GameState& rhs);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user