diff options
author | Torbjörn Andersson | 2006-05-21 20:25:22 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2006-05-21 20:25:22 +0000 |
commit | a1f5bddaa8644630d71dd6a497d653c677a35351 (patch) | |
tree | e52ddf148676afa6c0e4a35ff3c976d2722ab49b /engines | |
parent | 71ba5c0f584c80f6018c4f1696cd3dfe505fbc30 (diff) | |
download | scummvm-rg350-a1f5bddaa8644630d71dd6a497d653c677a35351.tar.gz scummvm-rg350-a1f5bddaa8644630d71dd6a497d653c677a35351.tar.bz2 scummvm-rg350-a1f5bddaa8644630d71dd6a497d653c677a35351.zip |
If possible, sync the frame to getSoundElapsedTime().
svn-id: r22566
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/vqa.cpp | 29 | ||||
-rw-r--r-- | engines/kyra/vqa.h | 4 |
2 files changed, 19 insertions, 14 deletions
diff --git a/engines/kyra/vqa.cpp b/engines/kyra/vqa.cpp index c10a28f930..83eedea694 100644 --- a/engines/kyra/vqa.cpp +++ b/engines/kyra/vqa.cpp @@ -341,9 +341,7 @@ void VQAMovie::open(const char *filename) { if (_header.flags & 1) { // A 2-second buffer ought to be enough _stream = Audio::makeAppendableAudioStream(_header.freq, Audio::Mixer::FLAG_UNSIGNED, 2 * _header.freq * _header.channels); - _sound = new Audio::SoundHandle; } else { - _sound = NULL; _stream = NULL; } @@ -422,11 +420,8 @@ void VQAMovie::close() { delete [] _partialCodeBook; delete [] _vectorPointers; - if (_sound) { - _vm->_mixer->stopHandle(*_sound); - delete _sound; - _stream = NULL; - _sound = NULL; + if (_vm->_mixer->isSoundHandleActive(_sound)) { + _vm->_mixer->stopHandle(_sound); } _frameInfo = NULL; @@ -445,7 +440,7 @@ void VQAMovie::close() { } } -void VQAMovie::displayFrame(int frameNum) { +void VQAMovie::displayFrame(uint frameNum) { debugC(9, kDebugLevelMovie, "VQAMovie::displayFrame(%d)", frameNum); if (frameNum >= _header.numFrames || !_opened) return; @@ -717,15 +712,25 @@ void VQAMovie::play() { } } - _vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, _sound, _stream); + _vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_sound, _stream); - for (int i = 0; i < _header.numFrames; i++) { + for (uint i = 0; i < _header.numFrames; i++) { displayFrame(i); - // TODO: We ought to sync this to how much sound we've played. // TODO: Implement frame skipping? - while (_system->getMillis() < startTick + (i * 1000) / _header.frameRate) { + while (1) { + uint32 elapsedTime; + + if (_vm->_mixer->isSoundHandleActive(_sound)) { + elapsedTime = _vm->_mixer->getSoundElapsedTime(_sound); + } else { + elapsedTime = _system->getMillis() - startTick; + } + + if (elapsedTime >= (i * 1000) / _header.frameRate) + break; + OSystem::Event event; while (_system->pollEvent(event)) { diff --git a/engines/kyra/vqa.h b/engines/kyra/vqa.h index 05371d4869..f5d7cc5399 100644 --- a/engines/kyra/vqa.h +++ b/engines/kyra/vqa.h @@ -94,7 +94,7 @@ protected: int decodeFormat80(byte *inbuf, byte *outbuf); void decodeSND1(byte *inbuf, uint32 insize, byte *outbuf, uint32 outsize); - void displayFrame(int frameNum); + void displayFrame(uint frameNum); Common::File _file; @@ -112,7 +112,7 @@ protected: byte *_frame; Audio::AppendableAudioStream *_stream; - Audio::SoundHandle *_sound; + Audio::SoundHandle _sound; uint32 readTag(); }; |