diff options
author | Filippos Karapetis | 2007-07-15 03:13:15 +0000 |
---|---|---|
committer | Filippos Karapetis | 2007-07-15 03:13:15 +0000 |
commit | 198b6ac8e64044823922420afaeb948508f41775 (patch) | |
tree | 8c5fdcaee0ea2e9fc7629b6ab4e30b941831e17f /engines/saga/music.cpp | |
parent | af21e132a25655239071b3da53841253b6db59c9 (diff) | |
download | scummvm-rg350-198b6ac8e64044823922420afaeb948508f41775.tar.gz scummvm-rg350-198b6ac8e64044823922420afaeb948508f41775.tar.bz2 scummvm-rg350-198b6ac8e64044823922420afaeb948508f41775.zip |
ITE: Music looping works now with compressed digital music. However, there's still a small pause when a track restarts
svn-id: r28082
Diffstat (limited to 'engines/saga/music.cpp')
-rw-r--r-- | engines/saga/music.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index c8b8b1ea6b..01e3e3f805 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -148,10 +148,6 @@ void DigitalMusicInputStream::createCompressedStream() { } int DigitalMusicInputStream::readBuffer(int16 *buffer, const int numSamples) { - // TODO/FIXME: Add looping support for compressed digital music - remove this once it's done - // Currently, an illegal read is made, leading to a crash. Therefore, it's disabled for now - if (_compressedStream != NULL) _looping = false; - if (!_looping && _compressedStream != NULL) return _compressedStream->readBuffer(buffer, numSamples); @@ -161,20 +157,27 @@ int DigitalMusicInputStream::readBuffer(int16 *buffer, const int numSamples) { if (_compressedStream != NULL) { len = _compressedStream->readBuffer(buffer, numSamples); if (len < numSamples) { + // FIXME: When a looping compressed track finishes and before it restarts, there's a slight pause. + // This might be caused by the time it takes to reset the compressed stream + + // Skip to the beginning of the track in the data file + _filePos = _startPos; + _file->seek(_filePos, SEEK_SET); + // Reset the compressed stream delete _compressedStream; createCompressedStream(); - //_file->seek(_startPos, SEEK_SET); - //_pos = 0; + len = _compressedStream->readBuffer(buffer, numSamples); } + samples += len; } else { len = MIN(numSamples - samples, (int) (_bufferEnd - _pos)); memcpy(buffer, _pos, len * 2); + buffer += len; + _pos += len; + samples += len; + if (_pos >= _bufferEnd) + refill(); } - buffer += len; - _pos += len; - samples += len; - if (_pos >= _bufferEnd) - refill(); } return samples; } |