From cc5fb7fc58283512a344dc1f49698e1426788602 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sun, 25 Apr 2004 17:24:17 +0000 Subject: dropped pull method for imuse svn-id: r13628 --- scumm/imuse_digi/dimuse.cpp | 174 +------------------------------------- scumm/imuse_digi/dimuse.h | 14 --- scumm/imuse_digi/dimuse_track.cpp | 21 ----- 3 files changed, 1 insertion(+), 208 deletions(-) (limited to 'scumm/imuse_digi') diff --git a/scumm/imuse_digi/dimuse.cpp b/scumm/imuse_digi/dimuse.cpp index 83c1688bf4..23bf682865 100644 --- a/scumm/imuse_digi/dimuse.cpp +++ b/scumm/imuse_digi/dimuse.cpp @@ -78,177 +78,6 @@ void IMuseDigital::resetState() { _nextSeqToPlay = 0; } -#ifdef ENABLE_PULLMETHOD - -int IMuseDigital::pullProcCallback(void *refCon, CustomProcInputStream *stream, byte *mixerBuffer, int pullSize) { - IMuseDigital *imuseDigital = (IMuseDigital *)refCon; - return imuseDigital->pullProc(stream, mixerBuffer, pullSize); -} - -int IMuseDigital::pullProc(CustomProcInputStream *stream, byte *mixerBuffer, int pullSize) { - Common::StackLock lock(_mutex, "IMuseDigital::pullProc()"); - debug(5, "pullProc() pullSize:%d", pullSize); - for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) { - if ((_track[l]->used) && (_track[l]->stream == stream)) { - if (_track[l]->toBeRemoved) { - debug(5, "IMuseDigital::pullProc() stopped sound: %d", _track[l]->soundId); - _track[l]->stream->finish(); - _track[l]->stream = NULL; - _sound->closeSound(_track[l]->soundHandle); - _track[l]->soundHandle = NULL; - _track[l]->used = false; - return 0; - } - _vm->_mixer->setChannelVolume(_track[l]->handle, _track[l]->mixerVol); - _vm->_mixer->setChannelBalance(_track[l]->handle, _track[l]->mixerPan); - int32 mixer_size = pullSize; - byte *data = NULL; - int32 result = 0, pos = 0; - - if (_track[l]->curRegion == -1) { - switchToNextRegion(l); - if (_track[l]->toBeRemoved) { - return 0; - } - } - - int bits = _sound->getBits(_track[l]->soundHandle); - int channels = _sound->getChannels(_track[l]->soundHandle); - - if ((bits == 16) && (channels == 2)) - assert((pullSize & 3) == 0); - else if ((bits == 16) || (channels == 2)) - assert((pullSize & 1) == 0); - - do { - if (bits == 12) { - byte *ptr = NULL; - - mixer_size += _track[l]->mod; - int mixer_size_12 = (mixer_size * 3) / 4; - int length = (mixer_size_12 / 3) * 4; - _track[l]->mod = mixer_size - length; - - int32 offset = (_track[l]->regionOffset * 3) / 4; - int result2 = _sound->getDataFromRegion(_track[l]->soundHandle, _track[l]->curRegion, &ptr, offset, mixer_size_12); - result = BundleCodecs::decode12BitsSample(ptr, &data, result2); - - free(ptr); - } else if (bits == 16) { - result = _sound->getDataFromRegion(_track[l]->soundHandle, _track[l]->curRegion, &data, _track[l]->regionOffset, mixer_size); - if (_sound->getChannels(_track[l]->soundHandle) == 1) { - result &= ~1; - } - if (_sound->getChannels(_track[l]->soundHandle) == 2) { - if (result & 2) - result &= ~2; - } - } else if (bits == 8) { - result = _sound->getDataFromRegion(_track[l]->soundHandle, _track[l]->curRegion, &data, _track[l]->regionOffset, mixer_size); - if (_sound->getChannels(_track[l]->soundHandle) == 2) { - result &= ~1; - } - } - - if (result > mixer_size) - result = mixer_size; - - memcpy(mixerBuffer + pos, data, result); - pos += result; - free(data); - - _track[l]->regionOffset += result; - _track[l]->trackOffset += result; - - if (_sound->isEndOfRegion(_track[l]->soundHandle, _track[l]->curRegion)) { - switchToNextRegion(l); - if (_track[l]->toBeRemoved) { - mixer_size -= result; - return pullSize - mixer_size; - } - } - mixer_size -= result; - assert(mixer_size >= 0); - } while (mixer_size != 0); - return pullSize; - } - } - error("IMuseDigital::pullProc() Can't match streams"); -} - -void IMuseDigital::callback() { - Common::StackLock lock(_mutex, "IMuseDigital::callback()"); - int l = 0; - - if (_pause || !_vm) - return; - - for (l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) { - if (_track[l]->used) { - if (_track[l]->stream2) { - if (!_track[l]->handle.isActive() && _track[l]->started) { - debug(5, "IMuseDigital::callback() A: stopped sound: %d", _track[l]->soundId); - delete _track[l]->stream2; - _track[l]->stream2 = NULL; - _track[l]->used = false; - continue; - } - } - - if (_track[l]->volFadeUsed) { - if (_track[l]->volFadeStep < 0) { - if (_track[l]->vol > _track[l]->volFadeDest) { - _track[l]->vol += _track[l]->volFadeStep; - if (_track[l]->vol < _track[l]->volFadeDest) { - _track[l]->vol = _track[l]->volFadeDest; - _track[l]->volFadeUsed = false; - } - if (_track[l]->vol == 0) { - _track[l]->toBeRemoved = true; - } - } - } else if (_track[l]->volFadeStep > 0) { - if (_track[l]->vol < _track[l]->volFadeDest) { - _track[l]->vol += _track[l]->volFadeStep; - if (_track[l]->vol > _track[l]->volFadeDest) { - _track[l]->vol = _track[l]->volFadeDest; - _track[l]->volFadeUsed = false; - } - } - } - debug(5, "Fade: sound(%d), Vol(%d)", _track[l]->soundId, _track[l]->vol / 1000); - } - - int pan = (_track[l]->pan != 64) ? 2 * _track[l]->pan - 127 : 0; - int vol = _track[l]->vol / 1000; - - if (_track[l]->volGroupId == 1) - vol = (vol * _volVoice) / 128; - if (_track[l]->volGroupId == 2) - vol = (vol * _volSfx) / 128; - if (_track[l]->volGroupId == 3) - vol = (vol * _volMusic) / 128; - - _track[l]->mixerVol = vol; - _track[l]->mixerPan = pan; - - if (_vm->_mixer->isReady()) { - if (_track[l]->stream2) { - if (!_track[l]->started) { - _track[l]->started = true; - _vm->_mixer->playInputStream(&_track[l]->handle, _track[l]->stream2, false, _track[l]->vol / 1000, _track[l]->pan, -1, false); - } else { - _vm->_mixer->setChannelVolume(_track[l]->handle, vol); - _vm->_mixer->setChannelBalance(_track[l]->handle, pan); - } - } - } - } - } -} - -#else - void IMuseDigital::callback() { Common::StackLock lock(_mutex, "IMuseDigital::callback()"); int l = 0; @@ -382,7 +211,7 @@ void IMuseDigital::callback() { _track[l]->trackOffset += result; free(data); } - + if (_sound->isEndOfRegion(_track[l]->soundHandle, _track[l]->curRegion)) { switchToNextRegion(l); if (_track[l]->toBeRemoved) @@ -395,7 +224,6 @@ void IMuseDigital::callback() { } } } -#endif void IMuseDigital::switchToNextRegion(int track) { debug(5, "switchToNextRegion(track:%d)", track); diff --git a/scumm/imuse_digi/dimuse.h b/scumm/imuse_digi/dimuse.h index c49ff6bdf2..8d9d8f6c8d 100644 --- a/scumm/imuse_digi/dimuse.h +++ b/scumm/imuse_digi/dimuse.h @@ -33,10 +33,6 @@ namespace Scumm { -// enable below for pullmethod data transfer from imuse to sound mixer, -// it's experimental and buggy -//#define ENABLE_PULLMETHOD - #define MAX_DIGITAL_TRACKS 8 #define MAX_DIGITAL_FADETRACKS 8 @@ -67,20 +63,14 @@ private: int volGroupId; int iteration; int mod; -#ifndef ENABLE_PULLMETHOD int32 pullSize; -#endif int32 mixerFlags; int mixerVol; int mixerPan; ImuseDigiSndMgr::soundStruct *soundHandle; PlayingSoundHandle handle; -#ifndef ENABLE_PULLMETHOD AppendableAudioStream *stream; -#else - CustomProcInputStream *stream; -#endif AudioStream *stream2; Track(); @@ -105,10 +95,6 @@ private: int _curMusicCue; static void timer_handler(void *refConf); -#ifdef ENABLE_PULLMETHOD - static int pullProcCallback(void *refCon, CustomProcInputStream *stream, byte *mixerBuffer, int pullSize); - int pullProc(CustomProcInputStream *stream, byte *mixerBuffer, int pullSize); -#endif void callback(); void switchToNextRegion(int track); void allocSlot(int priority); diff --git a/scumm/imuse_digi/dimuse_track.cpp b/scumm/imuse_digi/dimuse_track.cpp index ccac2296fd..7052b2aa88 100644 --- a/scumm/imuse_digi/dimuse_track.cpp +++ b/scumm/imuse_digi/dimuse_track.cpp @@ -58,14 +58,9 @@ void IMuseDigital::allocSlot(int priority) { } } assert(track_id != -1); -#ifndef ENABLE_PULLMETHOD _track[track_id]->stream->finish(); _track[track_id]->stream = NULL; _vm->_mixer->stopHandle(_track[track_id]->handle); -#else - _vm->_mixer->stopHandle(_track[track_id]->handle); - _track[track_id]->stream = NULL; -#endif _sound->closeSound(_track[track_id]->soundHandle); _track[track_id]->used = false; assert(!_track[track_id]->handle.isActive()); @@ -144,26 +139,20 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, freq -= (freq % 25); _track[l]->iteration = freq * channels; -#ifndef ENABLE_PULLMETHOD _track[l]->pullSize = _track[l]->iteration; -#endif if (channels == 2) _track[l]->mixerFlags = SoundMixer::FLAG_STEREO | SoundMixer::FLAG_REVERSE_STEREO; if ((bits == 12) || (bits == 16)) { _track[l]->mixerFlags |= SoundMixer::FLAG_16BITS; _track[l]->iteration *= 2; -#ifndef ENABLE_PULLMETHOD _track[l]->pullSize = _track[l]->iteration; -#endif } else if (bits == 8) { _track[l]->mixerFlags |= SoundMixer::FLAG_UNSIGNED; } else error("IMuseDigital::startSound(): Can't handle %d bit samples", bits); -#ifndef ENABLE_PULLMETHOD _track[l]->pullSize /= 25; // We want a "frame rate" of 25 audio blocks per second -#endif } if (input) { @@ -172,11 +161,7 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, _track[l]->started = false; } else { _track[l]->stream2 = NULL; -#ifndef ENABLE_PULLMETHOD _track[l]->stream = makeAppendableAudioStream(freq, _track[l]->mixerFlags, 100000); -#else - _track[l]->stream = new CustomProcInputStream(freq, _track[l]->mixerFlags, (CustomProcInputStream::CustomInputProc)pullProcCallback, this); -#endif _vm->_mixer->playInputStream(&_track[l]->handle, _track[l]->stream, false, _track[l]->vol / 1000, _track[l]->pan, -1); _track[l]->started = true; } @@ -299,9 +284,7 @@ int IMuseDigital::cloneToFadeOutTrack(int track, int fadeDelay, int killNormalTr _track[track]->mixerVol = _track[fadeTrack]->mixerVol; _track[track]->mixerPan = _track[fadeTrack]->mixerPan; _track[track]->mod = _track[fadeTrack]->mod; -#ifndef ENABLE_PULLMETHOD _track[track]->pullSize = _track[fadeTrack]->pullSize; -#endif _track[track]->used = _track[fadeTrack]->used; _track[track]->toBeRemoved = _track[fadeTrack]->toBeRemoved; _track[track]->started = _track[fadeTrack]->started; @@ -319,11 +302,7 @@ int IMuseDigital::cloneToFadeOutTrack(int track, int fadeDelay, int killNormalTr _track[track]->used = false; } else { _track[track]->soundHandle = _sound->cloneSound(_track[fadeTrack]->soundHandle); -#ifndef ENABLE_PULLMETHOD _track[track]->stream = makeAppendableAudioStream(_sound->getFreq(_track[track]->soundHandle), _track[track]->mixerFlags, 100000); -#else - _track[track]->stream = new CustomProcInputStream(_sound->getFreq(_track[track]->soundHandle), _track[track]->mixerFlags, (CustomProcInputStream::CustomInputProc)pullProcCallback, this); -#endif _vm->_mixer->playInputStream(&_track[track]->handle, _track[track]->stream, false, _track[track]->vol / 1000, _track[track]->pan, -1); _track[track]->started = true; } -- cgit v1.2.3