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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Tue Jan 5 21:13:31 CET 2010


Revision: 47036
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47036&view=rev
Author:   lordhoto
Date:     2010-01-05 20:13:31 +0000 (Tue, 05 Jan 2010)

Log Message:
-----------
Add a "getLength" function to SeekableAudioStream.

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

Modified: scummvm/trunk/engines/kyra/sound_digital.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_digital.cpp	2010-01-05 19:55:05 UTC (rev 47035)
+++ scummvm/trunk/engines/kyra/sound_digital.cpp	2010-01-05 20:13:31 UTC (rev 47036)
@@ -122,6 +122,7 @@
 	// GROSS HACK, if anyone sees this, be aware that you should
 	// never copy this! This is just a temporary hack...
 	bool seek(const Audio::Timestamp &) { return false; }
+	Audio::Timestamp getLength() const { return Audio::Timestamp(0, getRate()); }
 private:
 	Common::SeekableReadStream *_stream;
 	bool _loop;

Modified: scummvm/trunk/sound/audiostream.cpp
===================================================================
--- scummvm/trunk/sound/audiostream.cpp	2010-01-05 19:55:05 UTC (rev 47035)
+++ scummvm/trunk/sound/audiostream.cpp	2010-01-05 20:13:31 UTC (rev 47036)
@@ -175,6 +175,8 @@
 	}
 
 	bool seek(const Timestamp &where);
+	// TODO: We can definitly increase the precision here, since we know the exact sample count
+	Timestamp getLength() const { return Timestamp(_playtime, getRate()); }
 
 	void setNumLoops(uint numLoops) {
 		_numLoops = numLoops;
@@ -334,6 +336,8 @@
 			return kUnknownPlayTime;
 		return _playtime * _numLoops;
 	}
+	// TODO: We can definitly increase the precision here, since we know the exact sample count
+	Timestamp getLength() const { return Timestamp(_playtime, getRate()); }
 
 	bool seek(const Timestamp &where);
 };

Modified: scummvm/trunk/sound/audiostream.h
===================================================================
--- scummvm/trunk/sound/audiostream.h	2010-01-05 19:55:05 UTC (rev 47035)
+++ scummvm/trunk/sound/audiostream.h	2010-01-05 20:13:31 UTC (rev 47036)
@@ -157,6 +157,13 @@
 	 * @return true on success, false on failure.
 	 */
 	virtual bool seek(const Timestamp &where) = 0;
+
+	/**
+	 * Returns the length of the stream.
+	 *
+	 * @return length as Timestamp.
+	 */
+	virtual Timestamp getLength() const = 0;
 };
 
 

Modified: scummvm/trunk/sound/flac.cpp
===================================================================
--- scummvm/trunk/sound/flac.cpp	2010-01-05 19:55:05 UTC (rev 47035)
+++ scummvm/trunk/sound/flac.cpp	2010-01-05 20:13:31 UTC (rev 47036)
@@ -150,6 +150,8 @@
 	}
 
 	bool seek(const Timestamp &where);
+	// TODO: We can definitly increase the precision here, since FLAC allows us to catch the sample count
+	Timestamp getLength() const { return Timestamp(_totalPlayTime, getRate()); }
 
 	bool isStreamDecoderReady() const { return getStreamDecoderState() == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC ; }
 

Modified: scummvm/trunk/sound/mp3.cpp
===================================================================
--- scummvm/trunk/sound/mp3.cpp	2010-01-05 19:55:05 UTC (rev 47035)
+++ scummvm/trunk/sound/mp3.cpp	2010-01-05 20:13:31 UTC (rev 47036)
@@ -100,6 +100,8 @@
 	}
 
 	bool seek(const Timestamp &where);
+	// TODO: Maybe we can have a more precise implementation of this
+	Timestamp getLength() const { return Timestamp(_totalPlayTime, getRate()); }
 
 	void setNumLoops(uint numLoops) {
 		_numLoops = numLoops;

Modified: scummvm/trunk/sound/vorbis.cpp
===================================================================
--- scummvm/trunk/sound/vorbis.cpp	2010-01-05 19:55:05 UTC (rev 47035)
+++ scummvm/trunk/sound/vorbis.cpp	2010-01-05 20:13:31 UTC (rev 47036)
@@ -139,6 +139,14 @@
 	}
 
 	bool seek(const Timestamp &where);
+	// TODO: Maybe we can have a more precise implementation of this
+	Timestamp getLength() const {
+#ifdef USE_TREMOR
+		return Timestamp(_endTime, getRate());
+#else
+		return Timestamp((uint32)(_endTime * 1000.0), getRate());
+#endif
+	}
 
 protected:
 	bool refill();


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