diff options
author | Filippos Karapetis | 2015-12-27 14:34:51 +0200 |
---|---|---|
committer | Filippos Karapetis | 2015-12-27 14:36:01 +0200 |
commit | 764d261873592605e142e2341850f2d1abcf8f85 (patch) | |
tree | 6b8096a1fcea70d4f4fcd00ee844413719d3eff4 /engines/lab | |
parent | 684830082b51ae1112c775e5c23b8a3e18727609 (diff) | |
download | scummvm-rg350-764d261873592605e142e2341850f2d1abcf8f85.tar.gz scummvm-rg350-764d261873592605e142e2341850f2d1abcf8f85.tar.bz2 scummvm-rg350-764d261873592605e142e2341850f2d1abcf8f85.zip |
LAB: Unify the sound flags code for music and sound effects
Diffstat (limited to 'engines/lab')
-rw-r--r-- | engines/lab/music.cpp | 26 | ||||
-rw-r--r-- | engines/lab/music.h | 2 |
2 files changed, 14 insertions, 14 deletions
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp index bcc534cafd..2bc51d3a92 100644 --- a/engines/lab/music.cpp +++ b/engines/lab/music.cpp @@ -60,6 +60,16 @@ Music::Music(LabEngine *vm) : _vm(vm) { _curRoomMusic = 1; } +byte Music::getSoundFlags() { + byte soundFlags = Audio::FLAG_LITTLE_ENDIAN; + if (_vm->getPlatform() == Common::kPlatformWindows) + soundFlags |= Audio::FLAG_16BITS; + else if (_vm->getPlatform() == Common::kPlatformDOS) + soundFlags |= Audio::FLAG_UNSIGNED; + + return soundFlags; +} + void Music::updateMusic() { if (!_musicOn || (getPlayingBufferCount() >= MAXBUFFERS)) return; @@ -77,13 +87,7 @@ void Music::updateMusic() { startMusicFlag = true; } - byte soundFlags = Audio::FLAG_LITTLE_ENDIAN; - if (_vm->getPlatform() == Common::kPlatformWindows) - soundFlags |= Audio::FLAG_16BITS; - else if (_vm->getPlatform() == Common::kPlatformDOS) - soundFlags |= Audio::FLAG_UNSIGNED; - - _queuingAudioStream->queueBuffer(musicBuffer, MUSICBUFSIZE, DisposeAfterUse::YES, soundFlags); + _queuingAudioStream->queueBuffer(musicBuffer, MUSICBUFSIZE, DisposeAfterUse::YES, getSoundFlags()); if (startMusicFlag) _vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _queuingAudioStream); @@ -100,18 +104,12 @@ void Music::playSoundEffect(uint16 sampleSpeed, uint32 length, bool loop, Common if (sampleSpeed < 4000) sampleSpeed = 4000; - byte soundFlags = Audio::FLAG_LITTLE_ENDIAN; - if (_vm->getPlatform() == Common::kPlatformWindows) - soundFlags |= Audio::FLAG_16BITS; - else - soundFlags |= Audio::FLAG_UNSIGNED; - // NOTE: We need to use malloc(), cause this will be freed with free() // by the music code byte *soundData = (byte *)malloc(length); dataFile->read(soundData, length); - Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)soundData, length, sampleSpeed, soundFlags); + Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)soundData, length, sampleSpeed, getSoundFlags()); uint loops = (loop) ? 0 : 1; Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, loops); _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, loopingAudioStream); diff --git a/engines/lab/music.h b/engines/lab/music.h index a25d965bfb..ae217d42bd 100644 --- a/engines/lab/music.h +++ b/engines/lab/music.h @@ -80,6 +80,8 @@ private: */ void startMusic(bool restartFl); + byte getSoundFlags(); + public: Music(LabEngine *vm); |