diff options
author | James Brown | 2004-01-17 14:20:32 +0000 |
---|---|---|
committer | James Brown | 2004-01-17 14:20:32 +0000 |
commit | 04f2bc0276aa10f083ed1fca64b2da705311ae67 (patch) | |
tree | 93f1afd0dd73eee871f906ad1492feec65afaeff /sound | |
parent | ccd5f0842fbc540dda21dbefd6dab34da804107b (diff) | |
download | scummvm-rg350-04f2bc0276aa10f083ed1fca64b2da705311ae67.tar.gz scummvm-rg350-04f2bc0276aa10f083ed1fca64b2da705311ae67.tar.bz2 scummvm-rg350-04f2bc0276aa10f083ed1fca64b2da705311ae67.zip |
Update BS2 cutscene player with changes from roever: overlay support (default, 8bit backends should define BACKEND_8BIT for fast colour remapping) and sound syncronisation.
svn-id: r12456
Diffstat (limited to 'sound')
-rw-r--r-- | sound/audiostream.h | 13 | ||||
-rw-r--r-- | sound/vorbis.cpp | 7 |
2 files changed, 19 insertions, 1 deletions
diff --git a/sound/audiostream.h b/sound/audiostream.h index 97822c0c26..0dde9a61b5 100644 --- a/sound/audiostream.h +++ b/sound/audiostream.h @@ -74,6 +74,19 @@ public: /** Sample rate of the stream. */ virtual int getRate() const = 0; + + /** + * This function returns the number of samples that were delivered to + * the mixer which is a rough estimate of how moch time of the stream + * has been played. + * The exact value is not available as it needs information from the + * audio device on how many samples have been already played + * As our buffer is relatively short the estimate is exact enough + * The return -1 is kind of a hack as this function is only required + * for the video audio sync in the bs2 cutscenes I am to lazy to + * implement it for all subclasses + */ + virtual int getSamplesPlayed() const { return -1; } }; class AppendableAudioStream : public AudioStream { 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; } |