diff options
author | Kari Salminen | 2008-08-13 11:36:45 +0000 |
---|---|---|
committer | Kari Salminen | 2008-08-13 11:36:45 +0000 |
commit | f69cc559b9d35526b25ac76bcc82046471b39d06 (patch) | |
tree | 215371ddf5fac40025da8e5bb30a413cab0eb27a | |
parent | 9b8665fa85ae2a65d448ad9dba06dd27455f48d1 (diff) | |
download | scummvm-rg350-f69cc559b9d35526b25ac76bcc82046471b39d06.tar.gz scummvm-rg350-f69cc559b9d35526b25ac76bcc82046471b39d06.tar.bz2 scummvm-rg350-f69cc559b9d35526b25ac76bcc82046471b39d06.zip |
Reverted r33815 (But not r33816).
svn-id: r33819
-rw-r--r-- | engines/agi/sound.cpp | 19 | ||||
-rw-r--r-- | engines/agi/sound.h | 3 |
2 files changed, 13 insertions, 9 deletions
diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp index ec56763a93..cfa87d2c98 100644 --- a/engines/agi/sound.cpp +++ b/engines/agi/sound.cpp @@ -435,9 +435,13 @@ void IIgsMidiChannel::stopSounds() { _gsChannels.clear(); } +static int16 *buffer; + int SoundMgr::initSound() { int r = -1; + buffer = _sndBuffer = (int16 *)calloc(2, BUFFER_SIZE); + _env = false; switch (_vm->_soundemu) { @@ -474,6 +478,7 @@ int SoundMgr::initSound() { void SoundMgr::deinitSound() { debugC(3, kDebugLevelSound, "()"); _mixer->stopHandle(_soundHandle); + free(_sndBuffer); } void SoundMgr::stopNote(int i) { @@ -1180,7 +1185,7 @@ bool SoundMgr::loadInstruments() { return _gsSound.loadWaveFile(waveFsnode->getPath(), *exeInfo) && _gsSound.loadInstrumentHeaders(exeFsnode->getPath(), *exeInfo); } -void SoundMgr::fillAudio(void *udata, int16 *stream, uint len) { +static void fillAudio(void *udata, int16 *stream, uint len) { SoundMgr *soundMgr = (SoundMgr *)udata; uint32 p = 0; static uint32 n = 0, s = 0; @@ -1188,32 +1193,32 @@ void SoundMgr::fillAudio(void *udata, int16 *stream, uint len) { len <<= 2; debugC(5, kDebugLevelSound, "(%p, %p, %d)", (void *)udata, (void *)stream, len); - memcpy(stream, ((uint8 *)&_sndBuffer[0]) + s, p = n); + memcpy(stream, (uint8 *)buffer + 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, _sndBuffer, len); + memcpy((uint8 *)stream + p, buffer, len); s = len; n -= s; return; } else { - memcpy((uint8 *)stream + p, _sndBuffer, n); + memcpy((uint8 *)stream + p, buffer, n); } } soundMgr->playSound(); n = soundMgr->mixSound() << 1; - memcpy((uint8 *)stream + p, _sndBuffer, s = len); + memcpy((uint8 *)stream + p, buffer, s = len); n -= s; } -SoundMgr::SoundMgr(AgiBase *agi, Audio::Mixer *pMixer) : _sndBuffer(), _chn() { +SoundMgr::SoundMgr(AgiBase *agi, Audio::Mixer *pMixer) : _chn() { _vm = agi; _mixer = pMixer; _sampleRate = pMixer->getOutputRate(); _endflag = -1; - _playing = false; _playingSound = -1; + _sndBuffer = 0; _waveform = 0; } diff --git a/engines/agi/sound.h b/engines/agi/sound.h index 9b71ac388e..f1c2782421 100644 --- a/engines/agi/sound.h +++ b/engines/agi/sound.h @@ -468,11 +468,10 @@ private: int _playingSound; uint8 _env; - int16 _sndBuffer[BUFFER_SIZE]; + int16 *_sndBuffer; const int16 *_waveform; void premixerCall(int16 *buf, uint len); - void fillAudio(void *udata, int16 *stream, uint len); public: void unloadSound(int); |