From 8fb41ed93ced59032c1aba89b52349a38e73cd41 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 24 Aug 2004 23:51:43 +0000 Subject: [PATCH] clamp "lesser position" output --- stepmania/src/RageSound.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index edb0fd4ab6..235a2827eb 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -743,8 +743,17 @@ int64_t RageSound::GetPositionSecondsInternal( bool *approximate ) const * error, so let's clamp the result here instead. Be sure to reset this on stop, * since the position may reset. */ if( cur_frame < max_driver_frame ) - LOG->Trace( "Sound %s: driver returned a lesser position (%i < %i)", - this->GetLoadedFilePath().c_str(), (int) cur_frame, (int) max_driver_frame ); + { + /* Clamp the output to one per second, so one underruns don't cascade due to + * output spam. */ + static RageTimer last(RageZeroTimer); + if( last.IsZero() || last.Ago() > 1.0f ) + { + LOG->Trace( "Sound %s: driver returned a lesser position (%i < %i)", + this->GetLoadedFilePath().c_str(), (int) cur_frame, (int) max_driver_frame ); + last.Touch(); + } + } max_driver_frame = cur_frame = max( cur_frame, max_driver_frame ); return pos_map.Search( cur_frame, approximate );