diff options
Diffstat (limited to 'engines/made/pmvplayer.cpp')
-rw-r--r-- | engines/made/pmvplayer.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/engines/made/pmvplayer.cpp b/engines/made/pmvplayer.cpp index cf450f7e25..453e2a4872 100644 --- a/engines/made/pmvplayer.cpp +++ b/engines/made/pmvplayer.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -37,16 +37,18 @@ namespace Made { -PmvPlayer::PmvPlayer(MadeEngine *vm, Audio::Mixer *mixer) : _fd(NULL), _vm(vm), _mixer(mixer) { +PmvPlayer::PmvPlayer(MadeEngine *vm, Audio::Mixer *mixer) : _fd(nullptr), _vm(vm), _mixer(mixer) { + _audioStream = nullptr; + _surface = nullptr; + _aborted = false; } PmvPlayer::~PmvPlayer() { } bool PmvPlayer::play(const char *filename) { - _aborted = false; - _surface = NULL; + _surface = nullptr; _fd = new Common::File(); if (!_fd->open(filename)) { @@ -81,8 +83,11 @@ bool PmvPlayer::play(const char *filename) { // results to sound being choppy. Therefore, we set them to more // "common" values here (11025 instead of 11127 and 22050 instead // of 22254) - if (soundFreq == 11127) soundFreq = 11025; - if (soundFreq == 22254) soundFreq = 22050; + if (soundFreq == 11127) + soundFreq = 11025; + + if (soundFreq == 22254) + soundFreq = 22050; for (int i = 0; i < 22; i++) { int unk = _fd->readUint16LE(); @@ -113,6 +118,8 @@ bool PmvPlayer::play(const char *filename) { // get it to work well? _audioStream = Audio::makeQueuingAudioStream(soundFreq, false); + SoundDecoderData *soundDecoderData = new SoundDecoderData(); + while (!_vm->shouldQuit() && !_aborted && !_fd->eos() && frameNumber < frameCount) { int32 frameTime = _vm->_system->getMillis(); @@ -148,7 +155,7 @@ bool PmvPlayer::play(const char *filename) { soundSize = chunkCount * chunkSize; soundData = (byte *)malloc(soundSize); - decompressSound(audioData + 8, soundData, chunkSize, chunkCount); + decompressSound(audioData + 8, soundData, chunkSize, chunkCount, NULL, soundDecoderData); _audioStream->queueBuffer(soundData, soundSize, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED); } @@ -208,6 +215,7 @@ bool PmvPlayer::play(const char *filename) { } + delete soundDecoderData; delete[] frameData; _audioStream->finish(); @@ -248,7 +256,7 @@ void PmvPlayer::handleEvents() { } void PmvPlayer::updateScreen() { - _vm->_system->copyRectToScreen(_surface->pixels, _surface->pitch, + _vm->_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, (320 - _surface->w) / 2, (200 - _surface->h) / 2, _surface->w, _surface->h); _vm->_system->updateScreen(); } |