aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorChristopher Page2008-08-16 04:30:01 +0000
committerChristopher Page2008-08-16 04:30:01 +0000
commit909b66ef54f8d6d6dfeb0fdee2aa018f2065b6c9 (patch)
treec2f2668391fa3026a6a79b38ebfad797ce1b376c /engines/agi
parentc22f9b23588121d41fe0a12ce44926d683d7a18d (diff)
parentf2111eeb45dc8c41afb3e63bf3b86a09bf9a3532 (diff)
downloadscummvm-rg350-909b66ef54f8d6d6dfeb0fdee2aa018f2065b6c9.tar.gz
scummvm-rg350-909b66ef54f8d6d6dfeb0fdee2aa018f2065b6c9.tar.bz2
scummvm-rg350-909b66ef54f8d6d6dfeb0fdee2aa018f2065b6c9.zip
Merged revisions 33777,33781-33788,33790,33792-33793,33795,33797,33805,33807-33812,33815-33817,33819,33822,33826,33829,33837,33839,33844,33847,33858-33861,33864,33871-33873,33875,33877-33879,33886,33889-33892,33894,33896,33900,33902-33903,33919 via svnmerge from
https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk svn-id: r33924
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/sound.cpp23
-rw-r--r--engines/agi/sound.h1
2 files changed, 12 insertions, 12 deletions
diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp
index 77f79272f8..9fe8fbf41a 100644
--- a/engines/agi/sound.cpp
+++ b/engines/agi/sound.cpp
@@ -435,13 +435,10 @@ void IIgsMidiChannel::stopSounds() {
_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 @@ int SoundMgr::initSound() {
void SoundMgr::deinitSound() {
debugC(3, kDebugLevelSound, "()");
_mixer->stopHandle(_soundHandle);
- free(_sndBuffer);
}
void SoundMgr::stopNote(int i) {
@@ -1185,7 +1181,7 @@ bool SoundMgr::loadInstruments() {
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,32 +1189,34 @@ static void fillAudio(void *udata, int16 *stream, uint len) {
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;
}
-SoundMgr::SoundMgr(AgiBase *agi, Audio::Mixer *pMixer) {
+SoundMgr::SoundMgr(AgiBase *agi, Audio::Mixer *pMixer) : _chn() {
_vm = agi;
_mixer = pMixer;
_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 @@ void SoundMgr::setVolume(uint8 volume) {
}
SoundMgr::~SoundMgr() {
+ free(_sndBuffer);
}
} // End of namespace Agi
diff --git a/engines/agi/sound.h b/engines/agi/sound.h
index f1c2782421..a1f079891f 100644
--- a/engines/agi/sound.h
+++ b/engines/agi/sound.h
@@ -472,6 +472,7 @@ private:
const int16 *_waveform;
void premixerCall(int16 *buf, uint len);
+ void fillAudio(void *udata, int16 *stream, uint len);
public:
void unloadSound(int);