[Scummvm-cvs-logs] SF.net SVN: scummvm:[33822] scummvm/trunk/engines/agi
buddha_ at users.sourceforge.net
buddha_ at users.sourceforge.net
Wed Aug 13 13:57:49 CEST 2008
Revision: 33822
http://scummvm.svn.sourceforge.net/scummvm/?rev=33822&view=rev
Author: buddha_
Date: 2008-08-13 11:57:48 +0000 (Wed, 13 Aug 2008)
Log Message:
-----------
Fixed initialization of some SoundMgr-class's member variables. Moved _sndBuffer's allocation to SoundMgr's constructor and its deallocation to the destructor. Made fillAudio SoundMgr's method and removed a superfluous global static variable 'int16 *buffer'. Should help with the occasional crashes when starting the first sound in an AGI game.
Modified Paths:
--------------
scummvm/trunk/engines/agi/sound.cpp
scummvm/trunk/engines/agi/sound.h
Modified: scummvm/trunk/engines/agi/sound.cpp
===================================================================
--- scummvm/trunk/engines/agi/sound.cpp 2008-08-13 11:46:08 UTC (rev 33821)
+++ scummvm/trunk/engines/agi/sound.cpp 2008-08-13 11:57:48 UTC (rev 33822)
@@ -435,13 +435,10 @@
_gsChannels.clear();
}
-static int16 *buffer;
-
int SoundMgr::initSound() {
int r = -1;
- buffer = _sndBuffer = (int16 *)calloc(2, BUFFER_SIZE);
-
+ memset(_sndBuffer, 0, BUFFER_SIZE << 1);
_env = false;
switch (_vm->_soundemu) {
@@ -478,7 +475,6 @@
void SoundMgr::deinitSound() {
debugC(3, kDebugLevelSound, "()");
_mixer->stopHandle(_soundHandle);
- free(_sndBuffer);
}
void SoundMgr::stopNote(int i) {
@@ -1185,7 +1181,7 @@
return _gsSound.loadWaveFile(waveFsnode->getPath(), *exeInfo) && _gsSound.loadInstrumentHeaders(exeFsnode->getPath(), *exeInfo);
}
-static void fillAudio(void *udata, int16 *stream, uint len) {
+void SoundMgr::fillAudio(void *udata, int16 *stream, uint len) {
SoundMgr *soundMgr = (SoundMgr *)udata;
uint32 p = 0;
static uint32 n = 0, s = 0;
@@ -1193,22 +1189,22 @@
len <<= 2;
debugC(5, kDebugLevelSound, "(%p, %p, %d)", (void *)udata, (void *)stream, len);
- memcpy(stream, (uint8 *)buffer + s, p = n);
+ memcpy(stream, (uint8 *)_sndBuffer + s, p = n);
for (n = 0, len -= p; n < len; p += n, len -= n) {
soundMgr->playSound();
n = soundMgr->mixSound() << 1;
if (len < n) {
- memcpy((uint8 *)stream + p, buffer, len);
+ memcpy((uint8 *)stream + p, _sndBuffer, len);
s = len;
n -= s;
return;
} else {
- memcpy((uint8 *)stream + p, buffer, n);
+ memcpy((uint8 *)stream + p, _sndBuffer, n);
}
}
soundMgr->playSound();
n = soundMgr->mixSound() << 1;
- memcpy((uint8 *)stream + p, buffer, s = len);
+ memcpy((uint8 *)stream + p, _sndBuffer, s = len);
n -= s;
}
@@ -1218,7 +1214,9 @@
_sampleRate = pMixer->getOutputRate();
_endflag = -1;
_playingSound = -1;
- _sndBuffer = 0;
+ _env = false;
+ _playing = false;
+ _sndBuffer = (int16 *)calloc(2, BUFFER_SIZE);
_waveform = 0;
}
@@ -1231,6 +1229,7 @@
}
SoundMgr::~SoundMgr() {
+ free(_sndBuffer);
}
} // End of namespace Agi
Modified: scummvm/trunk/engines/agi/sound.h
===================================================================
--- scummvm/trunk/engines/agi/sound.h 2008-08-13 11:46:08 UTC (rev 33821)
+++ scummvm/trunk/engines/agi/sound.h 2008-08-13 11:57:48 UTC (rev 33822)
@@ -472,6 +472,7 @@
const int16 *_waveform;
void premixerCall(int16 *buf, uint len);
+ void fillAudio(void *udata, int16 *stream, uint len);
public:
void unloadSound(int);
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