diff options
| author | Johannes Schickel | 2010-02-09 21:52:27 +0000 | 
|---|---|---|
| committer | Johannes Schickel | 2010-02-09 21:52:27 +0000 | 
| commit | 6a624df560aae04b990a64dc6d8b34f960365787 (patch) | |
| tree | 2d7ae05fa98b7af75bc4d9d81d3de6b7e15f1265 | |
| parent | fa2a1cd22dd3a7a7192bfcdfccff3df80e2f3297 (diff) | |
| download | scummvm-rg350-6a624df560aae04b990a64dc6d8b34f960365787.tar.gz scummvm-rg350-6a624df560aae04b990a64dc6d8b34f960365787.tar.bz2 scummvm-rg350-6a624df560aae04b990a64dc6d8b34f960365787.zip  | |
Make Audio::convertTimeToStreamPos return a frame-precision based result instead of a sub-frame-precision based result. This fixes the SubLoopingAudioStream tests.
svn-id: r48020
| -rw-r--r-- | sound/audiostream.cpp | 19 | 
1 files changed, 16 insertions, 3 deletions
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index 57db44de1f..16c3eaca1a 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -373,9 +373,22 @@ Timestamp convertTimeToStreamPos(const Timestamp &where, int rate, bool isStereo  	// 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  | 
