[Scummvm-cvs-logs] SF.net SVN: scummvm:[48020] scummvm/trunk/sound/audiostream.cpp
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Tue Feb 9 22:52:27 CET 2010
Revision: 48020
http://scummvm.svn.sourceforge.net/scummvm/?rev=48020&view=rev
Author: lordhoto
Date: 2010-02-09 21:52:27 +0000 (Tue, 09 Feb 2010)
Log Message:
-----------
Make Audio::convertTimeToStreamPos return a frame-precision based result instead of a sub-frame-precision based result. This fixes the SubLoopingAudioStream tests.
Modified Paths:
--------------
scummvm/trunk/sound/audiostream.cpp
Modified: scummvm/trunk/sound/audiostream.cpp
===================================================================
--- scummvm/trunk/sound/audiostream.cpp 2010-02-09 21:52:08 UTC (rev 48019)
+++ scummvm/trunk/sound/audiostream.cpp 2010-02-09 21:52:27 UTC (rev 48020)
@@ -373,9 +373,22 @@
// When the Stream is a stereo stream, we have to assure
// that the sample position is an even number.
if (isStereo && (result.totalNumberOfFrames() & 1))
- return result.addFrames(-1); // We cut off one sample here.
- else
- return result;
+ result = result.addFrames(-1); // We cut off one sample here.
+
+ // Since Timestamp allows sub-frame-precision it might lead to odd behaviors
+ // when we would just return result.
+ //
+ // An example is when converting the timestamp 500ms to a 11025 Hz based
+ // stream. It would have an internal frame counter of 5512.5. Now when
+ // doing calculations at frame precision, this might lead to unexpected
+ // results: The frame difference between a timestamp 1000ms and the above
+ // mentioned timestamp (both with 11025 as framerate) would be 5512,
+ // instead of 5513, which is what a frame-precision based code would expect.
+ //
+ // By creating a new Timestamp with the given parameters, we create a
+ // Timestamp with frame-precision, which just drops a sub-frame-precision
+ // information (i.e. rounds down).
+ return Timestamp(result.secs(), result.numberOfFrames(), result.framerate());
}
} // End of namespace Audio
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list