diff options
author | Max Horn | 2007-02-26 20:41:52 +0000 |
---|---|---|
committer | Max Horn | 2007-02-26 20:41:52 +0000 |
commit | 73188b47161462e8de10539bc64a58ee11563a84 (patch) | |
tree | 17364dbdbc950c8f34556c59b0b02434a479ed81 | |
parent | 1c80f2ffa0d22c39fce5da342b72f890415aec8c (diff) | |
download | scummvm-rg350-73188b47161462e8de10539bc64a58ee11563a84.tar.gz scummvm-rg350-73188b47161462e8de10539bc64a58ee11563a84.tar.bz2 scummvm-rg350-73188b47161462e8de10539bc64a58ee11563a84.zip |
'Optimized' SquareWaveStream::readBuffer a bit, removed some dead code, and changed Snd::terminate to a destructor (this ensures client code can't forget to do just that -- not that we'd ever forget ... ;-)
svn-id: r25884
-rw-r--r-- | engines/gob/gob.cpp | 7 | ||||
-rw-r--r-- | engines/gob/sound.cpp | 30 | ||||
-rw-r--r-- | engines/gob/sound.h | 10 |
3 files changed, 17 insertions, 30 deletions
diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index 37a6032cd6..9bc29c49a2 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -95,8 +95,8 @@ GobEngine::GobEngine(OSystem *syst) : Engine(syst) { } GobEngine::~GobEngine() { - if (_snd) - _snd->terminate(); + // Stop all mixer streams (except for the permanent ones). + _vm->_mixer->stopAll(); delete _mult; delete _game; @@ -116,8 +116,7 @@ GobEngine::~GobEngine() { delete _scenery; delete _gtimer; delete _util; - if (_adlib) - delete _adlib; + delete _adlib; delete _video; delete[] _startTot; delete[] _startTot0; diff --git a/engines/gob/sound.cpp b/engines/gob/sound.cpp index af5bc59661..0832702a94 100644 --- a/engines/gob/sound.cpp +++ b/engines/gob/sound.cpp @@ -77,11 +77,8 @@ void Snd::SquareWaveStream::update(uint32 milis) { } int Snd::SquareWaveStream::readBuffer(int16 *buffer, const int numSamples) { - for (int i = 0; i < numSamples; i++) { - if (!_remainingSamples) { - buffer[i] = 0; - continue; - } + int i; + for (i = 0; _remainingSamples && i < numSamples; i++) { buffer[i] = _sampleValue; if (_periodSamples++ > _periodLength) { _periodSamples = 0; @@ -91,6 +88,10 @@ int Snd::SquareWaveStream::readBuffer(int16 *buffer, const int numSamples) { _remainingSamples--; _mixedSamples++; } + + // Clear the rest of the buffer + if (i < numSamples) + memset(buffer + i, 0, (numSamples - i) * sizeof(int16)); return numSamples; } @@ -128,16 +129,16 @@ Snd::Snd(GobEngine *vm) : _vm(vm) { &_speakerStream, -1, 255, 0, false, true); } -void Snd::terminate() { - // stop permanent streams manually - _vm->_mixer->stopHandle(_handle); +Snd::~Snd() { + // stop permanent streams manually: + + // First the speaker stream _vm->_mixer->stopHandle(_speakerHandle); - _vm->_mixer->stopAll(); + // Next, this stream (class Snd is an AudioStream, too) + _vm->_mixer->stopHandle(_handle); } -void Snd::setBlasterPort(int16 port) {return;} - void Snd::speakerOn(int16 frequency, int32 length) { _speakerStream.playNote(frequency, length, _vm->_mixer->getOutputRate()); _speakerStartTimeKey = _vm->_util->getTimeKey(); @@ -151,8 +152,7 @@ void Snd::speakerOnUpdate(uint32 milis) { _speakerStream.update(milis); } -void Snd::stopSound(int16 fadeLength) -{ +void Snd::stopSound(int16 fadeLength) { Common::StackLock slock(_mutex); if (fadeLength <= 0) { @@ -224,10 +224,6 @@ void Snd::playComposition(int16 *composition, int16 freqVal, SoundDesc **sndDesc nextCompositionPos(); } -void Snd::writeAdlib(int16 port, int16 data) { - return; -} - Snd::SoundDesc *Snd::loadSoundData(const char *path) { Snd::SoundDesc *sndDesc; diff --git a/engines/gob/sound.h b/engines/gob/sound.h index e11d42f1a3..2ce4f3cd3d 100644 --- a/engines/gob/sound.h +++ b/engines/gob/sound.h @@ -48,8 +48,8 @@ public: char _playingSound; Snd(GobEngine *vm); + ~Snd(); - void terminate(); void speakerOn(int16 frequency, int32 length); void speakerOff(void); void speakerOnUpdate(uint32 milis); @@ -138,14 +138,6 @@ protected: GobEngine *_vm; - void cleanupFuncCallback() {;} - int16 checkProAudio(void) {return 0;} - int16 checkAdlib(void) {return 0;} - int16 checkBlaster(void) {return 0;} - - void writeAdlib(int16 port, int16 data); - void setBlasterPort(int16 port); - void setResetTimerFlag(char flag){return;} void setSample(Snd::SoundDesc *sndDesc, int16 repCount, int16 frequency, int16 fadeLength); void checkEndSample(void); void nextCompositionPos(void); |