diff options
author | Filippos Karapetis | 2015-12-27 14:35:30 +0200 |
---|---|---|
committer | Filippos Karapetis | 2015-12-27 14:36:02 +0200 |
commit | 662649319b717632c66df840093eae37849effc4 (patch) | |
tree | 095ceeeaceacce79016163f3fb06087e0b93b5d9 | |
parent | 764d261873592605e142e2341850f2d1abcf8f85 (diff) | |
download | scummvm-rg350-662649319b717632c66df840093eae37849effc4.tar.gz scummvm-rg350-662649319b717632c66df840093eae37849effc4.tar.bz2 scummvm-rg350-662649319b717632c66df840093eae37849effc4.zip |
LAB: Simplify fillBuffer()
-rw-r--r-- | engines/lab/music.cpp | 15 | ||||
-rw-r--r-- | engines/lab/music.h | 2 |
2 files changed, 9 insertions, 8 deletions
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp index 2bc51d3a92..ddb6fc9613 100644 --- a/engines/lab/music.cpp +++ b/engines/lab/music.cpp @@ -74,11 +74,6 @@ void Music::updateMusic() { if (!_musicOn || (getPlayingBufferCount() >= MAXBUFFERS)) return; - // NOTE: We need to use malloc(), cause this will be freed with free() - // by the music code - byte *musicBuffer = (byte *)malloc(MUSICBUFSIZE); - fillbuffer(musicBuffer); - // Queue a music block, and start the music, if needed bool startMusicFlag = false; @@ -87,7 +82,7 @@ void Music::updateMusic() { startMusicFlag = true; } - _queuingAudioStream->queueBuffer(musicBuffer, MUSICBUFSIZE, DisposeAfterUse::YES, getSoundFlags()); + _queuingAudioStream->queueBuffer(fillBuffer(), MUSICBUFSIZE, DisposeAfterUse::YES, getSoundFlags()); if (startMusicFlag) _vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _queuingAudioStream); @@ -124,7 +119,11 @@ bool Music::isSoundEffectActive() const { return _vm->_mixer->isSoundHandleActive(_sfxHandle); } -void Music::fillbuffer(byte *musicBuffer) { +byte *Music::fillBuffer() { + // NOTE: We need to use malloc(), cause this will be freed with free() + // by the music code + byte *musicBuffer = (byte *)malloc(MUSICBUFSIZE); + if (MUSICBUFSIZE < _leftInFile) { _file->read(musicBuffer, MUSICBUFSIZE); _leftInFile -= MUSICBUFSIZE; @@ -136,6 +135,8 @@ void Music::fillbuffer(byte *musicBuffer) { _file->seek(0); _leftInFile = _file->size(); } + + return musicBuffer; } void Music::startMusic(bool restartFl) { diff --git a/engines/lab/music.h b/engines/lab/music.h index ae217d42bd..47c538ee25 100644 --- a/engines/lab/music.h +++ b/engines/lab/music.h @@ -66,7 +66,7 @@ private: Audio::QueuingAudioStream *_queuingAudioStream; private: - void fillbuffer(byte *musicBuffer); + byte *fillBuffer(); uint16 getPlayingBufferCount(); /** |