[Scummvm-cvs-logs] SF.net SVN: scummvm:[47082] scummvm/trunk

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Wed Jan 6 16:40:50 CET 2010


Revision: 47082
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47082&view=rev
Author:   lordhoto
Date:     2010-01-06 15:40:49 +0000 (Wed, 06 Jan 2010)

Log Message:
-----------
- Simplify Audio::calculateSampleOffset.
- Made Audio::calculateSampleOffset accessable from outside audiostream.cpp.
- Adapt KYRA's AUDStream to use Audio::calculateSampleOffset.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/sound_digital.cpp
    scummvm/trunk/sound/audiostream.cpp
    scummvm/trunk/sound/audiostream.h

Modified: scummvm/trunk/engines/kyra/sound_digital.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_digital.cpp	2010-01-06 15:33:54 UTC (rev 47081)
+++ scummvm/trunk/engines/kyra/sound_digital.cpp	2010-01-06 15:40:49 UTC (rev 47082)
@@ -121,7 +121,7 @@
 
 	int getRate() const { return _rate; }
 
-	bool seek(const Audio::Timestamp &);
+	bool seek(const Audio::Timestamp &where);
 	Audio::Timestamp getLength() const { return _length; }
 private:
 	Common::SeekableReadStream *_stream;
@@ -356,8 +356,7 @@
 }
 
 bool AUDStream::seek(const Audio::Timestamp &where) {
-	// TODO: A more exact implementation would be nice
-	const uint32 seekSample = where.msecs() * getRate() / 1000;
+	const uint32 seekSample = Audio::calculateSampleOffset(where, getRate());
 
 	_stream->seek(_streamStart);
 	_processedSize = 0;

Modified: scummvm/trunk/sound/audiostream.cpp
===================================================================
--- scummvm/trunk/sound/audiostream.cpp	2010-01-06 15:33:54 UTC (rev 47081)
+++ scummvm/trunk/sound/audiostream.cpp	2010-01-06 15:40:49 UTC (rev 47082)
@@ -109,14 +109,8 @@
 }
 
 uint32 calculateSampleOffset(const Timestamp &where, int rate) {
-	const uint32 msecs = where.msecs();
-
-	const Timestamp msecStamp(msecs, rate);
-	const uint32 seconds = msecs / 1000;
-	const uint32 millis = msecs % 1000;
-	const uint32 samples = msecStamp.frameDiff(where) + (millis * rate) / 1000;
-
-	return seconds * rate + samples;
+	const Timestamp whereRate = where.convertToFramerate(rate);
+	return whereRate.secs() * rate + whereRate.getNumberOfFrames();
 }
 
 /**

Modified: scummvm/trunk/sound/audiostream.h
===================================================================
--- scummvm/trunk/sound/audiostream.h	2010-01-06 15:33:54 UTC (rev 47081)
+++ scummvm/trunk/sound/audiostream.h	2010-01-06 15:40:49 UTC (rev 47082)
@@ -205,6 +205,15 @@
  */
 AppendableAudioStream *makeAppendableAudioStream(int rate, byte flags);
 
+/**
+ * Calculates the sample, which the timestamp describes in a
+ * AudioStream with the given framerate.
+ *
+ * @param where point in time
+ * @param rate rate of the AudioStream
+ * @return sample index
+ */
+uint32 calculateSampleOffset(const Timestamp &where, int rate);
 
 } // 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