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() {
|
GobEngine::~GobEngine() {
|
||||||
if (_snd)
|
// Stop all mixer streams (except for the permanent ones).
|
||||||
_snd->terminate();
|
_vm->_mixer->stopAll();
|
||||||
|
|
||||||
delete _mult;
|
delete _mult;
|
||||||
delete _game;
|
delete _game;
|
||||||
@ -116,8 +116,7 @@ GobEngine::~GobEngine() {
|
|||||||
delete _scenery;
|
delete _scenery;
|
||||||
delete _gtimer;
|
delete _gtimer;
|
||||||
delete _util;
|
delete _util;
|
||||||
if (_adlib)
|
delete _adlib;
|
||||||
delete _adlib;
|
|
||||||
delete _video;
|
delete _video;
|
||||||
delete[] _startTot;
|
delete[] _startTot;
|
||||||
delete[] _startTot0;
|
delete[] _startTot0;
|
||||||
|
@ -77,11 +77,8 @@ void Snd::SquareWaveStream::update(uint32 milis) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Snd::SquareWaveStream::readBuffer(int16 *buffer, const int numSamples) {
|
int Snd::SquareWaveStream::readBuffer(int16 *buffer, const int numSamples) {
|
||||||
for (int i = 0; i < numSamples; i++) {
|
int i;
|
||||||
if (!_remainingSamples) {
|
for (i = 0; _remainingSamples && i < numSamples; i++) {
|
||||||
buffer[i] = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
buffer[i] = _sampleValue;
|
buffer[i] = _sampleValue;
|
||||||
if (_periodSamples++ > _periodLength) {
|
if (_periodSamples++ > _periodLength) {
|
||||||
_periodSamples = 0;
|
_periodSamples = 0;
|
||||||
@ -91,6 +88,10 @@ int Snd::SquareWaveStream::readBuffer(int16 *buffer, const int numSamples) {
|
|||||||
_remainingSamples--;
|
_remainingSamples--;
|
||||||
_mixedSamples++;
|
_mixedSamples++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear the rest of the buffer
|
||||||
|
if (i < numSamples)
|
||||||
|
memset(buffer + i, 0, (numSamples - i) * sizeof(int16));
|
||||||
|
|
||||||
return numSamples;
|
return numSamples;
|
||||||
}
|
}
|
||||||
@ -128,16 +129,16 @@ Snd::Snd(GobEngine *vm) : _vm(vm) {
|
|||||||
&_speakerStream, -1, 255, 0, false, true);
|
&_speakerStream, -1, 255, 0, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Snd::terminate() {
|
Snd::~Snd() {
|
||||||
// stop permanent streams manually
|
// stop permanent streams manually:
|
||||||
_vm->_mixer->stopHandle(_handle);
|
|
||||||
|
// First the speaker stream
|
||||||
_vm->_mixer->stopHandle(_speakerHandle);
|
_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) {
|
void Snd::speakerOn(int16 frequency, int32 length) {
|
||||||
_speakerStream.playNote(frequency, length, _vm->_mixer->getOutputRate());
|
_speakerStream.playNote(frequency, length, _vm->_mixer->getOutputRate());
|
||||||
_speakerStartTimeKey = _vm->_util->getTimeKey();
|
_speakerStartTimeKey = _vm->_util->getTimeKey();
|
||||||
@ -151,8 +152,7 @@ void Snd::speakerOnUpdate(uint32 milis) {
|
|||||||
_speakerStream.update(milis);
|
_speakerStream.update(milis);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Snd::stopSound(int16 fadeLength)
|
void Snd::stopSound(int16 fadeLength) {
|
||||||
{
|
|
||||||
Common::StackLock slock(_mutex);
|
Common::StackLock slock(_mutex);
|
||||||
|
|
||||||
if (fadeLength <= 0) {
|
if (fadeLength <= 0) {
|
||||||
@ -224,10 +224,6 @@ void Snd::playComposition(int16 *composition, int16 freqVal, SoundDesc **sndDesc
|
|||||||
nextCompositionPos();
|
nextCompositionPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Snd::writeAdlib(int16 port, int16 data) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Snd::SoundDesc *Snd::loadSoundData(const char *path) {
|
Snd::SoundDesc *Snd::loadSoundData(const char *path) {
|
||||||
Snd::SoundDesc *sndDesc;
|
Snd::SoundDesc *sndDesc;
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ public:
|
|||||||
char _playingSound;
|
char _playingSound;
|
||||||
|
|
||||||
Snd(GobEngine *vm);
|
Snd(GobEngine *vm);
|
||||||
|
~Snd();
|
||||||
|
|
||||||
void terminate();
|
|
||||||
void speakerOn(int16 frequency, int32 length);
|
void speakerOn(int16 frequency, int32 length);
|
||||||
void speakerOff(void);
|
void speakerOff(void);
|
||||||
void speakerOnUpdate(uint32 milis);
|
void speakerOnUpdate(uint32 milis);
|
||||||
@ -138,14 +138,6 @@ protected:
|
|||||||
|
|
||||||
GobEngine *_vm;
|
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 setSample(Snd::SoundDesc *sndDesc, int16 repCount, int16 frequency, int16 fadeLength);
|
||||||
void checkEndSample(void);
|
void checkEndSample(void);
|
||||||
void nextCompositionPos(void);
|
void nextCompositionPos(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user