[Scummvm-cvs-logs] SF.net SVN: scummvm: [32263] scummvm/trunk/sound
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Sun May 25 01:39:13 CEST 2008
Revision: 32263
http://scummvm.svn.sourceforge.net/scummvm/?rev=32263&view=rev
Author: lordhoto
Date: 2008-05-24 16:39:13 -0700 (Sat, 24 May 2008)
Log Message:
-----------
Implementation of AudioStream::getTotalPlayTime for FLAC and OGG/Vorbis streams.
Modified Paths:
--------------
scummvm/trunk/sound/flac.cpp
scummvm/trunk/sound/vorbis.cpp
Modified: scummvm/trunk/sound/flac.cpp
===================================================================
--- scummvm/trunk/sound/flac.cpp 2008-05-24 23:05:01 UTC (rev 32262)
+++ scummvm/trunk/sound/flac.cpp 2008-05-24 23:39:13 UTC (rev 32263)
@@ -141,6 +141,26 @@
return _streaminfo.channels == 0 || (_lastSampleWritten && _sampleCache.bufFill == 0);
}
+ int32 getTotalPlayTime() const {
+ int32 samples = 0;
+
+ if (!_lastSample) {
+ if (!_streaminfo.total_samples)
+ return AudioStream::kUnknownPlayTime;
+
+ samples = _streaminfo.total_samples - _firstSample;
+ } else {
+ samples = _lastSample - _firstSample - 1;
+ }
+
+ const int32 rate = _streaminfo.sample_rate;
+
+ int32 seconds = samples / rate;
+ int32 milliseconds = (1000 * (samples % rate)) / rate;
+
+ return seconds * 1000 + milliseconds;
+ }
+
bool isStreamDecoderReady() const { return getStreamDecoderState() == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC ; }
protected:
Modified: scummvm/trunk/sound/vorbis.cpp
===================================================================
--- scummvm/trunk/sound/vorbis.cpp 2008-05-24 23:05:01 UTC (rev 32262)
+++ scummvm/trunk/sound/vorbis.cpp 2008-05-24 23:39:13 UTC (rev 32263)
@@ -118,6 +118,14 @@
bool isStereo() const { return _isStereo; }
int getRate() const { return _rate; }
+ int32 getTotalPlayTime() const {
+#ifdef USE_TREMOR
+ return _endTime - _startTime;
+#else
+ return (int32)((_endTime - _startTime) * 1000.0);
+#endif
+ }
+
protected:
void 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