diff options
author | Johannes Schickel | 2008-05-24 23:39:13 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-05-24 23:39:13 +0000 |
commit | aba5082d192f04db6d23804a766dddbdcf98fa2d (patch) | |
tree | d37bd15aeb1ca6d44b1b0f9f01c4f7f03bbd9d48 /sound/flac.cpp | |
parent | 64910f8c5fb3a9e39e356fc2856d311d8ad77bd6 (diff) | |
download | scummvm-rg350-aba5082d192f04db6d23804a766dddbdcf98fa2d.tar.gz scummvm-rg350-aba5082d192f04db6d23804a766dddbdcf98fa2d.tar.bz2 scummvm-rg350-aba5082d192f04db6d23804a766dddbdcf98fa2d.zip |
Implementation of AudioStream::getTotalPlayTime for FLAC and OGG/Vorbis streams.
svn-id: r32263
Diffstat (limited to 'sound/flac.cpp')
-rw-r--r-- | sound/flac.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sound/flac.cpp b/sound/flac.cpp index 8dc3586142..a43deedcfb 100644 --- a/sound/flac.cpp +++ b/sound/flac.cpp @@ -141,6 +141,26 @@ public: 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: |