diff options
-rw-r--r-- | queen/sound.cpp | 4 | ||||
-rw-r--r-- | scumm/imuse_digi.cpp | 7 | ||||
-rw-r--r-- | scumm/player_mod.cpp | 3 | ||||
-rw-r--r-- | scumm/player_mod.h | 6 | ||||
-rw-r--r-- | scumm/smush/smush_mixer.cpp | 11 | ||||
-rw-r--r-- | scumm/smush/smush_player.cpp | 3 | ||||
-rw-r--r-- | scumm/sound.cpp | 3 | ||||
-rw-r--r-- | scumm/string.cpp | 4 | ||||
-rw-r--r-- | simon/simon.h | 1 | ||||
-rw-r--r-- | simon/sound.cpp | 4 | ||||
-rw-r--r-- | simon/vga.cpp | 4 | ||||
-rw-r--r-- | sky/intro.cpp | 2 | ||||
-rw-r--r-- | sky/sound.cpp | 5 | ||||
-rw-r--r-- | sky/sound.h | 2 | ||||
-rw-r--r-- | sound/audiocd.cpp | 4 | ||||
-rw-r--r-- | sound/mixer.cpp | 28 | ||||
-rw-r--r-- | sound/mixer.h | 14 | ||||
-rw-r--r-- | sword1/sound.cpp | 4 | ||||
-rw-r--r-- | sword1/sword1.h | 1 | ||||
-rw-r--r-- | sword2/driver/d_draw.cpp | 4 | ||||
-rw-r--r-- | sword2/driver/d_sound.cpp | 12 | ||||
-rw-r--r-- | sword2/driver/d_sound.h | 3 |
22 files changed, 63 insertions, 66 deletions
diff --git a/queen/sound.cpp b/queen/sound.cpp index f907873246..d1b7e56986 100644 --- a/queen/sound.cpp +++ b/queen/sound.cpp @@ -33,7 +33,7 @@ namespace Queen { Sound::Sound(SoundMixer *mixer, QueenEngine *vm) : - _mixer(mixer), _vm(vm), _sfxToggle(true), _speechToggle(true), _musicToggle(true), _lastOverride(0), _currentSong(0), _sfxHandle(0) { + _mixer(mixer), _vm(vm), _sfxToggle(true), _speechToggle(true), _musicToggle(true), _lastOverride(0), _currentSong(0) { } Sound::~Sound() { @@ -68,7 +68,7 @@ Sound *Sound::giveSound(SoundMixer *mixer, QueenEngine *vm, uint8 compression) { } void Sound::waitSfxFinished() { - while(_sfxHandle != 0) + while(_sfxHandle.isActive()) _vm->input()->delay(10); } diff --git a/scumm/imuse_digi.cpp b/scumm/imuse_digi.cpp index 9b55b1cb8e..fc577011ec 100644 --- a/scumm/imuse_digi.cpp +++ b/scumm/imuse_digi.cpp @@ -805,7 +805,7 @@ void IMuseDigital::mixerCallback() { _channel[l].offset += mixer_size; if (_scumm->_silentDigitalImuse == false) { - if (_channel[l].handle == 0) + if (!_channel[l].handle.isActive()) _scumm->_mixer->newStream(&_channel[l].handle, _channel[l].freq, _channel[l].mixerFlags, 100000); _scumm->_mixer->setChannelVolume(_channel[l].handle, _channel[l].vol / 1000); @@ -821,7 +821,7 @@ void IMuseDigital::startSound(int sound) { int l, r; for (l = 0; l < MAX_DIGITAL_CHANNELS; l++) { - if (!_channel[l].used && !_channel[l].handle) { + if (!_channel[l].used && !_channel[l].handle.isActive()) { byte *ptr = _scumm->getResourceAddress(rtSound, sound); byte *s_ptr = ptr; if (ptr == NULL) { @@ -1290,7 +1290,6 @@ void IMuseDigital::playBundleMusic(const char *song) { _bundleSongPosInMs = 0; _pauseBundleMusic = false; _musicBundleToBeChanged = false; - _bundleMusicTrack = 0; _numberSamplesBundleMusic = _bundle->getNumberOfMusicSamplesByName(song); _nameBundleMusic = song; _scumm->_timer->installTimerProc(&music_handler, 1000000, this); @@ -1423,7 +1422,7 @@ void IMuseDigital::bundleMusicHandler() { _bundleSongPosInMs = (_bundleMusicPosition * 5) / (_outputMixerSize / 200); _bundleMusicPosition += final_size; - if (_bundleMusicTrack == 0) + if (!_bundleMusicTrack.isActive()) _scumm->_mixer->newStream(&_bundleMusicTrack, rate, SoundMixer::FLAG_16BITS | SoundMixer::FLAG_STEREO, 300000); _scumm->_mixer->appendStream(_bundleMusicTrack, buffer, final_size); free(buffer); diff --git a/scumm/player_mod.cpp b/scumm/player_mod.cpp index 509a2b4d43..3e4b922b33 100644 --- a/scumm/player_mod.cpp +++ b/scumm/player_mod.cpp @@ -22,6 +22,9 @@ #include "stdafx.h" #include "scumm/player_mod.h" +#include "sound/audiostream.h" +#include "sound/mixer.h" +#include "sound/rate.h" namespace Scumm { diff --git a/scumm/player_mod.h b/scumm/player_mod.h index 3533a92eee..9157672da8 100644 --- a/scumm/player_mod.h +++ b/scumm/player_mod.h @@ -24,9 +24,9 @@ #define PLAYER_MOD_H #include "scumm/scumm.h" -#include "sound/mixer.h" -#include "sound/audiostream.h" -#include "sound/rate.h" + +class AudioInputStream; +class RateConverter; namespace Scumm { diff --git a/scumm/smush/smush_mixer.cpp b/scumm/smush/smush_mixer.cpp index 10bc983960..3c9b831d78 100644 --- a/scumm/smush/smush_mixer.cpp +++ b/scumm/smush/smush_mixer.cpp @@ -39,7 +39,6 @@ SmushMixer::SmushMixer(SoundMixer *m) : for (int32 i = 0; i < NUM_CHANNELS; i++) { _channels[i].id = -1; _channels[i].chan = NULL; - _channels[i].handle = 0; } } @@ -70,19 +69,17 @@ void SmushMixer::addChannel(SmushChannel *c) { } for (i = 0; i < NUM_CHANNELS; i++) { - if ((_channels[i].chan == NULL || _channels[i].id == -1) && _channels[i].handle == 0) { + if ((_channels[i].chan == NULL || _channels[i].id == -1) && !_channels[i].handle.isActive()) { _channels[i].chan = c; _channels[i].id = track; - _channels[i].handle = 0; return; } } for (i = 0; i < NUM_CHANNELS; i++) { - warning("channel %d : %p(%d, %d) %d %d", i, (void *)_channels[i].chan, + warning("channel %d : %p(%d, %d) %d", i, (void *)_channels[i].chan, _channels[i].chan ? _channels[i].chan->getTrackIdentifier() : -1, - _channels[i].chan ? _channels[i].chan->isTerminated() : 1, - _channels[i].handle); + _channels[i].chan ? _channels[i].chan->isTerminated() : 1); } error("SmushMixer::addChannel(%d): no channel available", track); @@ -122,7 +119,7 @@ bool SmushMixer::handleFrame() { } if (_silentMixer == false) { - if (_channels[i].handle == 0) + if (!_channels[i].handle.isActive()) _mixer->newStream(&_channels[i].handle, rate, flags, 500000); _mixer->appendStream(_channels[i].handle, data, size); } diff --git a/scumm/smush/smush_player.cpp b/scumm/smush/smush_player.cpp index 1935ccff96..aa23b1f15e 100644 --- a/scumm/smush/smush_player.cpp +++ b/scumm/smush/smush_player.cpp @@ -229,7 +229,6 @@ SmushPlayer::SmushPlayer(ScummEngine *scumm, int speed, bool subtitles) { _storeFrame = false; _width = 0; _height = 0; - _IACTchannel = 0; _IACTpos = 0; _soundFrequency = 22050; _speed = speed; @@ -461,7 +460,7 @@ void SmushPlayer::handleIACT(Chunk &b) { } } while (--count); - if (_IACTchannel == 0) + if (!_IACTchannel.isActive()) _scumm->_mixer->newStream(&_IACTchannel, 22050, SoundMixer::FLAG_STEREO | SoundMixer::FLAG_16BITS, 200000); _scumm->_mixer->appendStream(_IACTchannel, output_data, 0x1000); diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 4f241dd340..a8d94d2ba0 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -56,7 +56,6 @@ Sound::Sound(ScummEngine *parent) { memset(this,0,sizeof(Sound)); // palmos _scumm = parent; - _talkChannelHandle = 0; _currentCDSound = 0; _sfxFile = 0; @@ -427,7 +426,7 @@ void Sound::processSfxQueues() { if ((_sfxMode & 2) && _scumm->VAR(_scumm->VAR_TALK_ACTOR)) { act = _scumm->VAR(_scumm->VAR_TALK_ACTOR); - finished = !_talkChannelHandle; + finished = !_talkChannelHandle.isActive(); if (act != 0 && (uint) act < 0x80 && !_scumm->_string[0].no_talk_anim) { a = _scumm->derefActor(act, "processSfxQueues"); diff --git a/scumm/string.cpp b/scumm/string.cpp index f9f01f8f51..69d5ed5e6c 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -163,7 +163,7 @@ void ScummEngine::CHARSET_1() { if (_talkDelay) return; - if ((_gameId == GID_CMI || _gameId == GID_DIG) && _sound->_talkChannelHandle) { + if ((_gameId == GID_CMI || _gameId == GID_DIG) && _sound->_talkChannelHandle.isActive()) { // Keep the 'speech' flag in _sound->_sfxMode set as long as the // _talkChannelHandle is valid. _sound->_sfxMode |= 2; @@ -317,7 +317,7 @@ void ScummEngine::CHARSET_1() { } else { if ((_gameId == GID_LOOM256) && _noSubtitles && (_sound->pollCD())) { // Special case for loomcd, since it only uses CD audio.for sound - } else if (_noSubtitles && (_haveMsg == 0xFE || _sound->_talkChannelHandle)) { + } else if (_noSubtitles && (_haveMsg == 0xFE || _sound->_talkChannelHandle.isActive())) { // Subtitles are turned off, and there is a voice version // of this message -> don't print it. } else diff --git a/simon/simon.h b/simon/simon.h index 081a28524e..28814501d8 100644 --- a/simon/simon.h +++ b/simon/simon.h @@ -26,7 +26,6 @@ #include "base/engine.h" #include "common/util.h" #include "simon/midi.h" -#include "sound/mixer.h" #include "simon/sound.h" class GameDetector; diff --git a/simon/sound.cpp b/simon/sound.cpp index d0f17b3f24..a82fd2bc68 100644 --- a/simon/sound.cpp +++ b/simon/sound.cpp @@ -262,10 +262,6 @@ SimonSound::SimonSound(const byte game, const GameSpecificSettings *gss, const C _last_voice_file = 0; _offsets = 0; - _voice_handle = 0; - _effects_handle = 0; - _ambient_handle = 0; - _voice_file = false; _ambient_playing = 0; diff --git a/simon/vga.cpp b/simon/vga.cpp index 86f8d88ae6..1f66a58e45 100644 --- a/simon/vga.cpp +++ b/simon/vga.cpp @@ -1615,7 +1615,7 @@ void SimonEngine::vc_59() { vc_kill_sprite(file, start); } while (++start != end); } else { - if (_sound->_voice_handle == 0) + if (!_sound->_voice_handle.isActive()) vc_skip_next_instruction(); } } @@ -1798,7 +1798,7 @@ void SimonEngine::vc_63_palette_thing_2() { void SimonEngine::vc_64_skip_if_no_speech() { // Simon2 - if (_sound->_voice_handle == 0) + if (!_sound->_voice_handle.isActive()) vc_skip_next_instruction(); } diff --git a/sky/intro.cpp b/sky/intro.cpp index 764890bc7d..da938a122e 100644 --- a/sky/intro.cpp +++ b/sky/intro.cpp @@ -728,7 +728,7 @@ bool SkyIntro::nextPart(uint16 *&data) { SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_UNSIGNED, SOUND_VOICE); return true; case WAITVOICE: - while (_voice) + while (_voice.isActive()) if (!escDelay(50)) return false; return true; diff --git a/sky/sound.cpp b/sky/sound.cpp index 1e2c3a352c..8b8b1725bd 100644 --- a/sky/sound.cpp +++ b/sky/sound.cpp @@ -1019,11 +1019,6 @@ SkySound::SkySound(SoundMixer *mixer, SkyDisk *pDisk, uint8 pVolume) { _skyDisk = pDisk; _soundData = NULL; _mixer = mixer; - _voiceHandle = 0; - _effectHandle = 0; - _bgSoundHandle = 0; - _ingameSpeech = 0; - _ingameSound0 = _ingameSound1 = 0; _saveSounds[0] = _saveSounds[1] = 0xFFFF; _mainSfxVolume = pVolume; } diff --git a/sky/sound.h b/sky/sound.h index 57636afc01..4191a343d7 100644 --- a/sky/sound.h +++ b/sky/sound.h @@ -67,7 +67,7 @@ public: void playSound(uint16 sound, uint16 volume, uint8 channel); void fnStartFx(uint32 sound, uint8 channel); bool startSpeech(uint16 textNum); - bool speechFinished(void) { return _ingameSpeech == 0; }; + bool speechFinished(void) { return !_ingameSpeech.isActive(); }; void fnPauseFx(void); void fnUnPauseFx(void); void fnStopFx(void); diff --git a/sound/audiocd.cpp b/sound/audiocd.cpp index ca4216b6c6..f2b243b843 100644 --- a/sound/audiocd.cpp +++ b/sound/audiocd.cpp @@ -74,7 +74,7 @@ bool AudioCDManager::isPlaying() const { void AudioCDManager::updateCD() { if (_cd.playing) { // If the sound handle is 0, then playback stopped. - if (!_cd.handle) { + if (!_cd.handle.isActive()) { // If playback just stopped, check if the current track is supposed // to be repeated, and if that's the case, play it again. Else, stop // the CD explicitly. @@ -94,7 +94,7 @@ void AudioCDManager::updateCD() { AudioCDManager::Status AudioCDManager::getStatus() const { // TODO: This could be improved for "real" CD playback. - // But to do that, we have to extend the OSystem interface. + // But to do that, we would have to extend the OSystem interface. Status info = _cd; info.playing = isPlaying(); return info; diff --git a/sound/mixer.cpp b/sound/mixer.cpp index 7fbd030f6f..1d0e13a0c1 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -152,10 +152,10 @@ void SoundMixer::newStream(PlayingSoundHandle *handle, uint rate, byte flags, ui void SoundMixer::appendStream(PlayingSoundHandle handle, void *sound, uint32 size) { Common::StackLock lock(_mutex); - if (handle == 0) + if (!handle.isActive()) return; - int index = handle - 1; + int index = handle.getIndex(); if ((index < 0) || (index >= NUM_CHANNELS)) { warning("soundMixer::appendStream has invalid index %d", index); @@ -179,10 +179,10 @@ void SoundMixer::endStream(PlayingSoundHandle handle) { Common::StackLock lock(_mutex); // Simply ignore stop requests for handles of sounds that already terminated - if (handle == 0) + if (!handle.isActive()) return; - int index = handle - 1; + int index = handle.getIndex(); if ((index < 0) || (index >= NUM_CHANNELS)) { warning("soundMixer::endStream has invalid index %d", index); @@ -219,7 +219,7 @@ void SoundMixer::insertChannel(PlayingSoundHandle *handle, Channel *chan) { _channels[index] = chan; if (handle) - *handle = index + 1; + handle->setIndex(index); } void SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, int id, byte volume, int8 pan, uint32 loopStart, uint32 loopEnd) { @@ -358,10 +358,10 @@ void SoundMixer::stopHandle(PlayingSoundHandle handle) { Common::StackLock lock(_mutex); // Simply ignore stop requests for handles of sounds that already terminated - if (handle == 0) + if (!handle.isActive()) return; - int index = handle - 1; + int index = handle.getIndex(); if ((index < 0) || (index >= NUM_CHANNELS)) { warning("soundMixer::stopHandle has invalid index %d", index); @@ -377,10 +377,10 @@ void SoundMixer::stopHandle(PlayingSoundHandle handle) { void SoundMixer::setChannelVolume(PlayingSoundHandle handle, byte volume) { Common::StackLock lock(_mutex); - if (handle == 0) + if (!handle.isActive()) return; - int index = handle - 1; + int index = handle.getIndex(); if ((index < 0) || (index >= NUM_CHANNELS)) { warning("soundMixer::setChannelVolume has invalid index %d", index); @@ -394,10 +394,10 @@ void SoundMixer::setChannelVolume(PlayingSoundHandle handle, byte volume) { void SoundMixer::setChannelPan(PlayingSoundHandle handle, int8 pan) { Common::StackLock lock(_mutex); - if (handle == 0) + if (!handle.isActive()) return; - int index = handle - 1; + int index = handle.getIndex(); if ((index < 0) || (index >= NUM_CHANNELS)) { warning("soundMixer::setChannelVolume has invalid index %d", index); @@ -426,10 +426,10 @@ void SoundMixer::pauseHandle(PlayingSoundHandle handle, bool paused) { Common::StackLock lock(_mutex); // Simply ignore pause/unpause requests for handles of sound that alreayd terminated - if (handle == 0) + if (!handle.isActive()) return; - int index = handle - 1; + int index = handle.getIndex(); if ((index < 0) || (index >= NUM_CHANNELS)) { warning("soundMixer::pauseHandle has invalid index %d", index); @@ -496,7 +496,7 @@ Channel::~Channel() { delete _converter; delete _input; if (_handle) - *_handle = 0; + _handle->resetIndex(); } /* len indicates the number of sample *pairs*. So a value of diff --git a/sound/mixer.h b/sound/mixer.h index 3ed2cd798f..d1bd379408 100644 --- a/sound/mixer.h +++ b/sound/mixer.h @@ -35,12 +35,22 @@ #endif -typedef uint32 PlayingSoundHandle; - class AudioInputStream; class Channel; class File; +class PlayingSoundHandle { + friend class Channel; + friend class SoundMixer; + int val; + int getIndex() const { return val - 1; } + void setIndex(int i) { val = i + 1; } + void resetIndex() { val = 0; } +public: + PlayingSoundHandle() { resetIndex(); } + bool isActive() const { return val > 0; } +}; + class SoundMixer { public: typedef void PremixProc (void *param, int16 *data, uint len); diff --git a/sword1/sound.cpp b/sword1/sound.cpp index da7ccdd736..2e2fb15a41 100644 --- a/sword1/sound.cpp +++ b/sword1/sound.cpp @@ -79,7 +79,7 @@ void SwordSound::engine(void) { if (_fxQueue[cnt2].delay == 0) playSample(&_fxQueue[cnt2]); } else { - if (!_fxQueue[cnt2].handle) { // sound finished + if (!_fxQueue[cnt2].handle.isActive()) { // sound finished _resMan->resClose(_fxList[_fxQueue[cnt2].id].sampleId); if (cnt2 != _endOfQueue-1) _fxQueue[cnt2] = _fxQueue[_endOfQueue - 1]; @@ -109,7 +109,7 @@ bool SwordSound::amISpeaking(void) { } bool SwordSound::speechFinished(void) { - return (_speechHandle == 0); + return !_speechHandle.isActive(); } void SwordSound::newScreen(uint32 screen) { diff --git a/sword1/sword1.h b/sword1/sword1.h index 1a93a511e0..b169ad861c 100644 --- a/sword1/sword1.h +++ b/sword1/sword1.h @@ -22,7 +22,6 @@ #include <stdio.h> #include "base/engine.h" #include "common/util.h" -#include "sound/mixer.h" #include "base/gameDetector.h" #include "sworddefs.h" diff --git a/sword2/driver/d_draw.cpp b/sword2/driver/d_draw.cpp index 730abd109b..928de7bf71 100644 --- a/sword2/driver/d_draw.cpp +++ b/sword2/driver/d_draw.cpp @@ -173,7 +173,7 @@ int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOu tmpPal[255 * 4 + 2] = 255; _vm->_graphics->setPalette(0, 256, tmpPal, RDPAL_INSTANT); - PlayingSoundHandle handle = 0; + PlayingSoundHandle handle; bool skipCutscene = false; @@ -226,7 +226,7 @@ int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOu // more importantly - that we don't free the sound buffer while // it's in use. - while (handle) { + while (handle.isActive()) { _vm->_system->delay_msecs(100); }; diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp index 7bee4eceaf..082161f7c9 100644 --- a/sword2/driver/d_sound.cpp +++ b/sword2/driver/d_sound.cpp @@ -35,6 +35,7 @@ #include "common/stdafx.h" #include "common/file.h" #include "sword2/sword2.h" +#include "sound/rate.h" namespace Sword2 { @@ -132,7 +133,6 @@ Sound::Sound(Sword2Engine *vm) { memset(_fx, 0, sizeof(_fx)); - _soundHandleSpeech = 0; _soundOn = true; _converter = makeRateConverter(_music[0].getRate(), _vm->_mixer->getOutputRate(), _music[0].isStereo(), false); @@ -243,7 +243,7 @@ void Sound::playLeadOut(uint8 *leadOut) { return; } - while (_fx[i]._handle) { + while (_fx[i]._handle.isActive()) { _vm->_graphics->updateDisplay(); _vm->_system->delay_msecs(30); } @@ -284,7 +284,7 @@ void Sound::fxServer(int16 *data, uint len) { */ int32 Sound::amISpeaking() { - if (!_speechMuted && !_speechPaused && _soundHandleSpeech != 0) + if (!_speechMuted && !_speechPaused && _soundHandleSpeech.isActive()) return RDSE_SPEAKING; return RDSE_QUIET; @@ -441,7 +441,7 @@ int32 Sound::getSpeechStatus(void) { if (_speechPaused) return RDSE_SAMPLEPLAYING; - if (!_soundHandleSpeech) { + if (!_soundHandleSpeech.isActive()) { _speechStatus = false; return RDSE_SAMPLEFINISHED; } @@ -459,7 +459,7 @@ void Sound::setSpeechVolume(uint8 volume) { _speechVol = volume; - if (_soundHandleSpeech != 0 && !_speechMuted && getSpeechStatus() == RDSE_SAMPLEPLAYING) { + if (_soundHandleSpeech.isActive() && !_speechMuted && getSpeechStatus() == RDSE_SAMPLEPLAYING) { _vm->_mixer->setChannelVolume(_soundHandleSpeech, 16 * _speechVol); } } @@ -558,7 +558,7 @@ int32 Sound::openFx(int32 id, uint8 *data) { // between rooms. for (fxi = 0; fxi < MAXFX; fxi++) { - if (!_fx[fxi]._handle) + if (!_fx[fxi]._handle.isActive()) break; } diff --git a/sword2/driver/d_sound.h b/sword2/driver/d_sound.h index a62054853d..068376164d 100644 --- a/sword2/driver/d_sound.h +++ b/sword2/driver/d_sound.h @@ -22,7 +22,8 @@ #include "sound/audiostream.h" #include "sound/mixer.h" -#include "sound/rate.h" + +class RateConverter; namespace Sword2 { |