mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 07:53:36 +00:00
'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
This commit is contained in:
parent
1c80f2ffa0
commit
73188b4716
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user