aboutsummaryrefslogtreecommitdiff
path: root/sound/vorbis.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sound/vorbis.cpp')
-rw-r--r--sound/vorbis.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/sound/vorbis.cpp b/sound/vorbis.cpp
index 9a4904e5ad..99600f8747 100644
--- a/sound/vorbis.cpp
+++ b/sound/vorbis.cpp
@@ -172,6 +172,7 @@ class VorbisInputStream : public AudioStream {
int16 _buffer[4096];
const int16 *_bufferEnd;
const int16 *_pos;
+ int _played;
void refill();
inline bool eosIntern() const;
@@ -184,6 +185,8 @@ public:
bool isStereo() const { return _numChannels >= 2; }
int getRate() const { return ov_info(_ov_file, -1)->rate; }
+ int getSamplesPlayed() const { return _played / _numChannels; }
+
};
@@ -193,7 +196,7 @@ public:
VorbisInputStream::VorbisInputStream(OggVorbis_File *file, int duration)
- : _ov_file(file), _bufferEnd(_buffer + ARRAYSIZE(_buffer)) {
+ : _ov_file(file), _bufferEnd(_buffer + ARRAYSIZE(_buffer)), _played(0) {
// Check the header, determine if this is a stereo stream
_numChannels = ov_info(_ov_file, -1)->channels;
@@ -215,6 +218,7 @@ inline int16 VorbisInputStream::read() {
if (_pos >= _bufferEnd) {
refill();
}
+ _played++;
return sample;
}
@@ -234,6 +238,7 @@ int VorbisInputStream::readBuffer(int16 *buffer, const int numSamples) {
refill();
}
}
+ _played += samples;
return samples;
}