mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 12:39:56 +00:00
Implementation of AudioStream::getTotalPlayTime for FLAC and OGG/Vorbis streams.
svn-id: r32263
This commit is contained in:
parent
64910f8c5f
commit
aba5082d19
@ -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:
|
||||
|
@ -118,6 +118,14 @@ public:
|
||||
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();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user