aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2015-12-13 13:22:54 +0100
committerWillem Jan Palenstijn2015-12-23 21:34:02 +0100
commit47368c157ebf870248a61de4b81e181fa7713671 (patch)
treee6c3377d601576b47345c1a1eda07b6356fa8a93 /engines
parent6668b76edcb0d0be70314f417c13f535756b0d2c (diff)
downloadscummvm-rg350-47368c157ebf870248a61de4b81e181fa7713671.tar.gz
scummvm-rg350-47368c157ebf870248a61de4b81e181fa7713671.tar.bz2
scummvm-rg350-47368c157ebf870248a61de4b81e181fa7713671.zip
LAB: Review Music declaration, some refactoring and renaming
Diffstat (limited to 'engines')
-rw-r--r--engines/lab/dispman.cpp2
-rw-r--r--engines/lab/map.cpp2
-rw-r--r--engines/lab/music.cpp57
-rw-r--r--engines/lab/music.h72
-rw-r--r--engines/lab/processroom.cpp6
5 files changed, 71 insertions, 68 deletions
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 83022ba8dd..4cc3c24395 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -103,7 +103,7 @@ void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData
_vm->_music->updateMusic();
- if (!_vm->_music->_doNotFilestopSoundEffect)
+ if (!_vm->_music->_unstoppableSoundEffect)
_vm->_music->stopSoundEffect();
_dispBitMap->_bytesPerRow = _screenWidth;
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index db995504a2..5d978b72fe 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -87,7 +87,7 @@ void LabEngine::loadMapData() {
Common::File *mapFile = _resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
_music->updateMusic();
- if (!_music->_doNotFilestopSoundEffect)
+ if (!_music->_unstoppableSoundEffect)
_music->stopSoundEffect();
_maxRooms = mapFile->readUint16LE();
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index a996f3169c..cca7633e67 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -50,16 +50,16 @@ Music::Music(LabEngine *vm) : _vm(vm) {
_tFile = 0;
_musicPaused = false;
- _tMusicOn = false;
+ _oldMusicOn = false;
_tLeftInFile = 0;
- _leftinfile = 0;
+ _leftInFile = 0;
_musicOn = false;
- _winmusic = false;
+ _winMusic = false;
_loopSoundEffect = false;
_queuingAudioStream = NULL;
- _doNotFilestopSoundEffect = false;
+ _unstoppableSoundEffect = false;
_lastMusicRoom = 1;
_doReset = true;
_waitTillFinished = false;
@@ -104,12 +104,12 @@ uint16 Music::getPlayingBufferCount() {
return (_queuingAudioStream) ? _queuingAudioStream->numQueuedStreams() : 0;
}
-void Music::playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data) {
+void Music::playSoundEffect(uint16 sampleSpeed, uint32 length, void *data) {
pauseBackMusic();
stopSoundEffect();
- if (SampleSpeed < 4000)
- SampleSpeed = 4000;
+ if (sampleSpeed < 4000)
+ sampleSpeed = 4000;
byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
if (_vm->getPlatform() == Common::kPlatformWindows)
@@ -117,7 +117,7 @@ void Music::playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data) {
else
soundFlags |= Audio::FLAG_UNSIGNED;
- Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)Data, Length, SampleSpeed, soundFlags, DisposeAfterUse::NO);
+ Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)data, length, sampleSpeed, soundFlags, DisposeAfterUse::NO);
uint loops = (_loopSoundEffect) ? 0 : 1;
Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, loops);
_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, loopingAudioStream);
@@ -133,16 +133,16 @@ bool Music::isSoundEffectActive() const {
}
void Music::fillbuffer(byte *musicBuffer) {
- if (MUSICBUFSIZE < _leftinfile) {
+ if (MUSICBUFSIZE < _leftInFile) {
_file->read(musicBuffer, MUSICBUFSIZE);
- _leftinfile -= MUSICBUFSIZE;
+ _leftInFile -= MUSICBUFSIZE;
} else {
- _file->read(musicBuffer, _leftinfile);
+ _file->read(musicBuffer, _leftInFile);
- memset((char *)musicBuffer + _leftinfile, 0, MUSICBUFSIZE - _leftinfile);
+ memset((char *)musicBuffer + _leftInFile, 0, MUSICBUFSIZE - _leftInFile);
_file->seek(0);
- _leftinfile = _file->size();
+ _leftInFile = _file->size();
}
}
@@ -157,7 +157,7 @@ void Music::startMusic(bool restartFl) {
if (restartFl) {
_file->seek(0);
- _leftinfile = _file->size();
+ _leftInFile = _file->size();
}
_musicOn = true;
@@ -173,7 +173,7 @@ bool Music::initMusic() {
const char *filename;
- if (_winmusic)
+ if (_winMusic)
filename = "Music:WinGame";
else
filename = "Music:BackGrou";
@@ -267,11 +267,11 @@ void Music::checkRoomMusic() {
void Music::changeMusic(const char *newmusic) {
if (!_tFile) {
_tFile = _file;
- _tMusicOn = _musicOn;
- _tLeftInFile = _leftinfile + 65536L;
+ _oldMusicOn = _musicOn;
+ _tLeftInFile = _leftInFile + 65536L;
if (_tLeftInFile > (uint32)_tFile->size())
- _tLeftInFile = _leftinfile;
+ _tLeftInFile = _leftInFile;
}
_file = _vm->_resource->openDataFile(newmusic);
@@ -295,20 +295,20 @@ void Music::resetMusic() {
_file->close();
_file = _tFile;
- _leftinfile = _tLeftInFile;
+ _leftInFile = _tLeftInFile;
- _file->seek(_file->size() - _leftinfile);
+ _file->seek(_file->size() - _leftInFile);
_musicOn = true;
setMusic(false);
updateMusic();
- if (!_tMusicOn) {
+ if (!_oldMusicOn) {
_tFile = 0;
return;
}
- _musicOn = _tMusicOn;
+ _musicOn = _oldMusicOn;
startMusic(false);
_tFile = 0;
@@ -320,7 +320,7 @@ void Music::resetMusic() {
bool Music::readMusic(const char *filename, bool waitTillFinished) {
Common::File *file = _vm->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
updateMusic();
- if (!_doNotFilestopSoundEffect)
+ if (!_unstoppableSoundEffect)
stopSoundEffect();
if (!file)
@@ -334,9 +334,10 @@ bool Music::readMusic(const char *filename, bool waitTillFinished) {
void Music::readSound(bool waitTillFinished, Common::File *file) {
uint32 magicBytes = file->readUint32LE();
- if (magicBytes != 1219009121L)
+ if (magicBytes != 1219009121L) {
+ warning("readSound: Bad signature, skipping");
return;
-
+ }
uint32 soundTag = file->readUint32LE();
uint32 soundSize = file->readUint32LE();
@@ -367,16 +368,14 @@ void Music::readSound(bool waitTillFinished, Common::File *file) {
byte *soundData = (byte *)malloc(soundSize);
file->read(soundData, soundSize);
playSoundEffect(sampleRate, soundSize, soundData);
- }
- else if (soundTag == 65535L) {
+ } else if (soundTag == 65535L) {
if (waitTillFinished) {
while (isSoundEffectActive()) {
updateMusic();
_vm->waitTOF();
}
}
- }
- else
+ } else
file->skip(soundSize);
}
}
diff --git a/engines/lab/music.h b/engines/lab/music.h
index 5efd2e3045..57524ba953 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -46,52 +46,56 @@ class LabEngine;
#define MAXBUFFERS 5L
class Music {
-public:
- Music(LabEngine *vm);
-
- bool initMusic();
- void freeMusic();
- void updateMusic();
- uint16 getPlayingBufferCount();
- void closeMusic();
- void setMusic(bool on);
- void resumeBackMusic();
- void pauseBackMusic();
- void changeMusic(const char *newmusic);
- void checkRoomMusic();
- void resetMusic();
- void setMusicReset(bool reset) { _doReset = reset; }
- void playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data);
- void stopSoundEffect();
- bool isSoundEffectActive() const;
- bool readMusic(const char *filename, bool waitTillFinished);
-
- bool _winmusic, _doNotFilestopSoundEffect;
- bool _musicOn;
- bool _loopSoundEffect;
- bool _waitTillFinished;
- uint16 _lastMusicRoom ;
- bool _doReset;
-
private:
- void fillbuffer(byte *musicBuffer);
- void startMusic(bool restartFl);
- void readSound(bool waitTillFinished, Common::File *file);
-
LabEngine *_vm;
Common::File *_file;
Common::File *_tFile;
+
+ bool _doReset;
+ bool _musicOn;
bool _musicPaused;
+ bool _oldMusicOn;
+ bool _winMusic;
+
+ uint16 _lastMusicRoom ;
- bool _tMusicOn;
uint32 _tLeftInFile;
- uint32 _leftinfile;
+ uint32 _leftInFile;
Audio::SoundHandle _musicHandle;
Audio::SoundHandle _sfxHandle;
-
Audio::QueuingAudioStream *_queuingAudioStream;
+
+private:
+ void fillbuffer(byte *musicBuffer);
+ uint16 getPlayingBufferCount();
+ void pauseBackMusic();
+ void readSound(bool waitTillFinished, Common::File *file);
+ void startMusic(bool restartFl);
+
+public:
+ bool _unstoppableSoundEffect;
+ bool _loopSoundEffect;
+ bool _waitTillFinished;
+
+public:
+ Music(LabEngine *vm);
+
+ void changeMusic(const char *newmusic);
+ void checkRoomMusic();
+ void freeMusic();
+ bool initMusic();
+ bool isSoundEffectActive() const;
+ void playSoundEffect(uint16 sampleSpeed, uint32 length, void *data);
+ bool readMusic(const char *filename, bool waitTillFinished);
+ void resetMusic();
+ void resumeBackMusic();
+ void setMusic(bool on);
+ void setMusicReset(bool reset) { _doReset = reset; }
+ void setWinMusic() { _winMusic = true; }
+ void stopSoundEffect();
+ void updateMusic();
};
} // End of namespace Lab
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index bd9d02ef8c..c09d918fcb 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -296,7 +296,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
break;
case PLAYSOUNDCONT:
- _music->_doNotFilestopSoundEffect = true;
+ _music->_unstoppableSoundEffect = true;
_music->_loopSoundEffect = true;
_music->readMusic((char *)actionList->_data, _music->_waitTillFinished);
break;
@@ -476,7 +476,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
break;
case WINMUSIC:
- _music->_winmusic = true;
+ _music->setWinMusic();
_music->freeMusic();
_music->initMusic();
break;
@@ -544,7 +544,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
}
}
- _music->_doNotFilestopSoundEffect = false;
+ _music->_unstoppableSoundEffect = false;
}
/**