aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lab/music.cpp15
-rw-r--r--engines/lab/music.h2
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();
/**