[Scummvm-cvs-logs] SF.net SVN: scummvm: [25884] scummvm/trunk/engines/gob

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Feb 26 21:41:53 CET 2007


Revision: 25884
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25884&view=rev
Author:   fingolfin
Date:     2007-02-26 12:41:52 -0800 (Mon, 26 Feb 2007)

Log Message:
-----------
'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 ... ;-)

Modified Paths:
--------------
    scummvm/trunk/engines/gob/gob.cpp
    scummvm/trunk/engines/gob/sound.cpp
    scummvm/trunk/engines/gob/sound.h

Modified: scummvm/trunk/engines/gob/gob.cpp
===================================================================
--- scummvm/trunk/engines/gob/gob.cpp	2007-02-26 20:32:43 UTC (rev 25883)
+++ scummvm/trunk/engines/gob/gob.cpp	2007-02-26 20:41:52 UTC (rev 25884)
@@ -95,8 +95,8 @@
 }
 
 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 @@
 	delete _scenery;
 	delete _gtimer;
 	delete _util;
-	if (_adlib)
-		delete _adlib;
+	delete _adlib;
 	delete _video;
 	delete[] _startTot;
 	delete[] _startTot0;

Modified: scummvm/trunk/engines/gob/sound.cpp
===================================================================
--- scummvm/trunk/engines/gob/sound.cpp	2007-02-26 20:32:43 UTC (rev 25883)
+++ scummvm/trunk/engines/gob/sound.cpp	2007-02-26 20:41:52 UTC (rev 25884)
@@ -77,11 +77,8 @@
 }
 
 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 @@
 			_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 @@
 			&_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 @@
 	_speakerStream.update(milis);
 }
 
-void Snd::stopSound(int16 fadeLength)
-{
+void Snd::stopSound(int16 fadeLength) {
 	Common::StackLock slock(_mutex);
 
 	if (fadeLength <= 0) {
@@ -224,10 +224,6 @@
 	nextCompositionPos();
 }
 
-void Snd::writeAdlib(int16 port, int16 data) {
-	return;
-}
-
 Snd::SoundDesc *Snd::loadSoundData(const char *path) {
 	Snd::SoundDesc *sndDesc;
 

Modified: scummvm/trunk/engines/gob/sound.h
===================================================================
--- scummvm/trunk/engines/gob/sound.h	2007-02-26 20:32:43 UTC (rev 25883)
+++ scummvm/trunk/engines/gob/sound.h	2007-02-26 20:41:52 UTC (rev 25884)
@@ -48,8 +48,8 @@
 	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 @@
 
 	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);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list