aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2005-03-12 18:56:09 +0000
committerMax Horn2005-03-12 18:56:09 +0000
commit7cd2cb2b1700b85d48aed8898b08b49b9b46ebf8 (patch)
tree7849605aa45912d9cbe65dbb68b2b450bd32b023
parent8de216f3aec1dcee16fc0ab9974da4087bac5252 (diff)
downloadscummvm-rg350-7cd2cb2b1700b85d48aed8898b08b49b9b46ebf8.tar.gz
scummvm-rg350-7cd2cb2b1700b85d48aed8898b08b49b9b46ebf8.tar.bz2
scummvm-rg350-7cd2cb2b1700b85d48aed8898b08b49b9b46ebf8.zip
PlayingSoundHandle -> SoundHandle; also, turned the handle activity check into a mixer method
svn-id: r17106
-rw-r--r--graphics/animation.cpp2
-rw-r--r--graphics/animation.h2
-rw-r--r--queen/sound.cpp4
-rw-r--r--queen/sound.h8
-rw-r--r--saga/music.cpp5
-rw-r--r--saga/music.h2
-rw-r--r--saga/sound.cpp2
-rw-r--r--saga/sound.h6
-rw-r--r--scumm/imuse_digi/dimuse.h2
-rw-r--r--scumm/imuse_digi/dimuse_script.cpp2
-rw-r--r--scumm/smush/smush_mixer.cpp4
-rw-r--r--scumm/smush/smush_mixer.h2
-rw-r--r--scumm/smush/smush_player.cpp2
-rw-r--r--scumm/smush/smush_player.h4
-rw-r--r--scumm/sound.cpp4
-rw-r--r--scumm/sound.h4
-rw-r--r--scumm/string.cpp2
-rw-r--r--simon/sound.cpp26
-rw-r--r--simon/sound.h6
-rw-r--r--simon/vga.cpp4
-rw-r--r--sky/intro.cpp2
-rw-r--r--sky/intro.h2
-rw-r--r--sky/sound.cpp2
-rw-r--r--sky/sound.h12
-rw-r--r--sound/audiocd.cpp2
-rw-r--r--sound/audiocd.h4
-rw-r--r--sound/flac.cpp4
-rw-r--r--sound/mixer.cpp26
-rw-r--r--sound/mixer.h32
-rw-r--r--sound/mp3.cpp4
-rw-r--r--sound/softsynth/mt32.cpp2
-rw-r--r--sound/vorbis.cpp4
-rw-r--r--sword1/animation.cpp2
-rw-r--r--sword1/credits.cpp2
-rw-r--r--sword1/sound.cpp4
-rw-r--r--sword1/sound.h4
-rw-r--r--sword2/driver/animation.cpp18
-rw-r--r--sword2/driver/animation.h2
-rw-r--r--sword2/driver/d_sound.cpp10
-rw-r--r--sword2/sound.cpp9
-rw-r--r--sword2/sound.h6
41 files changed, 127 insertions, 119 deletions
diff --git a/graphics/animation.cpp b/graphics/animation.cpp
index 18f294fa08..3ba6179ffd 100644
--- a/graphics/animation.cpp
+++ b/graphics/animation.cpp
@@ -185,7 +185,7 @@ bool BaseAnimationState::decodeFrame() {
*/
/* Avoid deadlock is sound was too far ahead */
- if (_bgSoundStream && !_bgSound.isActive())
+ if (_bgSoundStream && !_snd->isSoundHandleActive(_bgSound))
return false;
if (checkPaletteSwitch() || (_bgSoundStream == NULL) ||
diff --git a/graphics/animation.h b/graphics/animation.h
index 71546746c6..5efb3797d8 100644
--- a/graphics/animation.h
+++ b/graphics/animation.h
@@ -84,7 +84,7 @@ protected:
File *_mpegFile;
- PlayingSoundHandle _bgSound;
+ SoundHandle _bgSound;
AudioStream *_bgSoundStream;
#ifdef BACKEND_8BIT
diff --git a/queen/sound.cpp b/queen/sound.cpp
index a93650ea7f..f982ce9d6c 100644
--- a/queen/sound.cpp
+++ b/queen/sound.cpp
@@ -83,10 +83,10 @@ Sound *Sound::giveSound(SoundMixer *mixer, QueenEngine *vm, uint8 compression) {
void Sound::waitFinished(bool isSpeech) {
if (isSpeech)
- while (_speechHandle.isActive())
+ while (_mixer->isSoundHandleActive(_speechHandle))
_vm->input()->delay(10);
else
- while (_sfxHandle.isActive())
+ while (_mixer->isSoundHandleActive(_sfxHandle))
_vm->input()->delay(10);
}
diff --git a/queen/sound.h b/queen/sound.h
index 1311848310..6aaee1d2bf 100644
--- a/queen/sound.h
+++ b/queen/sound.h
@@ -74,8 +74,8 @@ public:
void musicToggle(bool val) { _musicToggle = val; }
void toggleMusic() { _musicToggle ^= true; }
- bool isSpeechActive() const { return _speechHandle.isActive(); }
- bool isSfxActive() const { return _sfxHandle.isActive(); }
+ bool isSpeechActive() const { return _mixer->isSoundHandleActive(_speechHandle); }
+ bool isSfxActive() const { return _mixer->isSoundHandleActive(_sfxHandle); }
bool speechSfxExists() const { return _speechSfxExists; }
@@ -112,8 +112,8 @@ protected:
bool _speechSfxExists;
int16 _lastOverride;
- PlayingSoundHandle _sfxHandle;
- PlayingSoundHandle _speechHandle;
+ SoundHandle _sfxHandle;
+ SoundHandle _speechHandle;
};
class SilentSound : public Sound {
diff --git a/saga/music.cpp b/saga/music.cpp
index d58c39676f..0e239fa81c 100644
--- a/saga/music.cpp
+++ b/saga/music.cpp
@@ -350,7 +350,7 @@ Music::~Music() {
}
bool Music::isPlaying() {
- return _musicHandle.isActive() || _player->isPlaying();
+ return _mixer->isSoundHandleActive(_musicHandle) || _player->isPlaying();
}
// The Wyrmkeep release of Inherit The Earth features external MIDI files, so
@@ -409,8 +409,7 @@ int Music::play(uint32 music_rn, uint16 flags) {
_player->stopMusic();
- if (_musicHandle.isActive())
- _mixer->stopHandle(_musicHandle);
+ _mixer->stopHandle(_musicHandle);
AudioStream *audioStream = NULL;
MidiParser *parser;
diff --git a/saga/music.h b/saga/music.h
index 707da30727..993df56a27 100644
--- a/saga/music.h
+++ b/saga/music.h
@@ -125,7 +125,7 @@ private:
SoundMixer *_mixer;
MusicPlayer *_player;
- PlayingSoundHandle _musicHandle;
+ SoundHandle _musicHandle;
uint32 _trackNumber;
static const MUSIC_MIDITABLE _midiTableITECD[26];
diff --git a/saga/sound.cpp b/saga/sound.cpp
index 9db219934c..0a6a2bd061 100644
--- a/saga/sound.cpp
+++ b/saga/sound.cpp
@@ -152,7 +152,7 @@ Sound::~Sound() {
_soundInitialized = 0;
}
-int Sound::playSoundBuffer(PlayingSoundHandle *handle, SOUNDBUFFER *buf, int volume, bool loop) {
+int Sound::playSoundBuffer(SoundHandle *handle, SOUNDBUFFER *buf, int volume, bool loop) {
byte flags;
if (!_soundInitialized) {
diff --git a/saga/sound.h b/saga/sound.h
index 7b0fee51c8..a0b73d69e0 100644
--- a/saga/sound.h
+++ b/saga/sound.h
@@ -64,7 +64,7 @@ public:
private:
- int playSoundBuffer(PlayingSoundHandle *handle, SOUNDBUFFER *buf, int volume, bool loop);
+ int playSoundBuffer(SoundHandle *handle, SOUNDBUFFER *buf, int volume, bool loop);
int _soundInitialized;
int _enabled;
@@ -72,8 +72,8 @@ public:
SagaEngine *_vm;
SoundMixer *_mixer;
- PlayingSoundHandle _effectHandle;
- PlayingSoundHandle _voiceHandle;
+ SoundHandle _effectHandle;
+ SoundHandle _voiceHandle;
};
diff --git a/scumm/imuse_digi/dimuse.h b/scumm/imuse_digi/dimuse.h
index bbdc56a089..cb8e9892c6 100644
--- a/scumm/imuse_digi/dimuse.h
+++ b/scumm/imuse_digi/dimuse.h
@@ -77,7 +77,7 @@ private:
int32 mixerFlags;
ImuseDigiSndMgr::soundStruct *soundHandle;
- PlayingSoundHandle handle;
+ SoundHandle handle;
AppendableAudioStream *stream;
AudioStream *stream2;
diff --git a/scumm/imuse_digi/dimuse_script.cpp b/scumm/imuse_digi/dimuse_script.cpp
index 356e004bdb..8a2e77f283 100644
--- a/scumm/imuse_digi/dimuse_script.cpp
+++ b/scumm/imuse_digi/dimuse_script.cpp
@@ -279,7 +279,7 @@ int IMuseDigital::getSoundStatus(int sound) const {
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l];
if (track->soundId == sound) {
- if ((track->stream2 && track->handle.isActive()) ||
+ if ((track->stream2 && _vm->_mixer->isSoundHandleActive(track->handle)) ||
(track->stream && track->used && !track->readyToRemove)) {
return 1;
}
diff --git a/scumm/smush/smush_mixer.cpp b/scumm/smush/smush_mixer.cpp
index 791b689491..c787f3aafc 100644
--- a/scumm/smush/smush_mixer.cpp
+++ b/scumm/smush/smush_mixer.cpp
@@ -69,7 +69,7 @@ void SmushMixer::addChannel(SmushChannel *c) {
}
for (i = 0; i < NUM_CHANNELS; i++) {
- if ((_channels[i].chan == NULL || _channels[i].id == -1) && !_channels[i].handle.isActive()) {
+ if ((_channels[i].chan == NULL || _channels[i].id == -1) && !_mixer->isSoundHandleActive(_channels[i].handle)) {
_channels[i].chan = c;
_channels[i].id = track;
return;
@@ -120,7 +120,7 @@ bool SmushMixer::handleFrame() {
}
if (_mixer->isReady()) {
- if (!_channels[i].handle.isActive()) {
+ if (!_mixer->isSoundHandleActive(_channels[i].handle)) {
_channels[i].stream = makeAppendableAudioStream(rate, flags, 500000);
_mixer->playInputStream(SoundMixer::kSFXSoundType, &_channels[i].handle, _channels[i].stream);
}
diff --git a/scumm/smush/smush_mixer.h b/scumm/smush/smush_mixer.h
index 051303997e..b46366d182 100644
--- a/scumm/smush/smush_mixer.h
+++ b/scumm/smush/smush_mixer.h
@@ -39,7 +39,7 @@ private:
struct channels {
int id;
SmushChannel *chan;
- PlayingSoundHandle handle;
+ SoundHandle handle;
AppendableAudioStream *stream;
} _channels[NUM_CHANNELS];
diff --git a/scumm/smush/smush_player.cpp b/scumm/smush/smush_player.cpp
index 093108082e..bf67ee2ed0 100644
--- a/scumm/smush/smush_player.cpp
+++ b/scumm/smush/smush_player.cpp
@@ -507,7 +507,7 @@ void SmushPlayer::handleIACT(Chunk &b) {
}
} while (--count);
- if (!_IACTchannel.isActive()) {
+ if (!_vm->_mixer->isSoundHandleActive(_IACTchannel)) {
_IACTstream = makeAppendableAudioStream(22050, SoundMixer::FLAG_STEREO | SoundMixer::FLAG_16BITS, 400000);
_vm->_mixer->playInputStream(SoundMixer::kSFXSoundType, &_IACTchannel, _IACTstream);
}
diff --git a/scumm/smush/smush_player.h b/scumm/smush/smush_player.h
index eeb99a2d4f..1b3a656ef1 100644
--- a/scumm/smush/smush_player.h
+++ b/scumm/smush/smush_player.h
@@ -56,10 +56,10 @@ private:
bool _skips[37];
int32 _frame;
- PlayingSoundHandle _IACTchannel;
+ SoundHandle _IACTchannel;
AppendableAudioStream *_IACTstream;
- PlayingSoundHandle _compressedFileSoundHandle;
+ SoundHandle _compressedFileSoundHandle;
bool _compressedFileMode;
File _compressedFile;
byte _IACToutput[4096];
diff --git a/scumm/sound.cpp b/scumm/sound.cpp
index f665736b72..e6bbd889df 100644
--- a/scumm/sound.cpp
+++ b/scumm/sound.cpp
@@ -572,7 +572,7 @@ void Sound::processSfxQueues() {
if (_vm->_imuseDigital) {
finished = !isSoundRunning(kTalkSoundID);
} else {
- finished = !_talkChannelHandle.isActive();
+ finished = !_vm->_mixer->isSoundHandleActive(_talkChannelHandle);
}
if ((uint) act < 0x80 && ((_vm->_version == 8) || (_vm->_version <= 7 && !_vm->_string[0].no_talk_anim))) {
@@ -609,7 +609,7 @@ static int compareMP3OffsetTable(const void *a, const void *b) {
return ((const MP3OffsetTable *)a)->org_offset - ((const MP3OffsetTable *)b)->org_offset;
}
-void Sound::startTalkSound(uint32 offset, uint32 b, int mode, PlayingSoundHandle *handle) {
+void Sound::startTalkSound(uint32 offset, uint32 b, int mode, SoundHandle *handle) {
int num = 0, i;
int size = 0;
byte *sound;
diff --git a/scumm/sound.h b/scumm/sound.h
index 6b3830d323..d86b7c5c45 100644
--- a/scumm/sound.h
+++ b/scumm/sound.h
@@ -84,7 +84,7 @@ protected:
int16 _currentCDSound;
int16 _currentMusic;
public:
- PlayingSoundHandle _talkChannelHandle; // Handle of mixer channel actor is talking on
+ SoundHandle _talkChannelHandle; // Handle of mixer channel actor is talking on
bool _soundsPaused;
byte _sfxMode;
@@ -97,7 +97,7 @@ public:
void processSoundQues();
void setOverrideFreq(int freq);
void playSound(int soundID, int heOffset, int heChannel, int heFlags);
- void startTalkSound(uint32 offset, uint32 b, int mode, PlayingSoundHandle *handle = NULL);
+ void startTalkSound(uint32 offset, uint32 b, int mode, SoundHandle *handle = NULL);
void stopTalkSound();
bool isMouthSyncOff(uint pos);
int isSoundRunning(int sound) const;
diff --git a/scumm/string.cpp b/scumm/string.cpp
index c1748e3669..992179791e 100644
--- a/scumm/string.cpp
+++ b/scumm/string.cpp
@@ -370,7 +370,7 @@ loc_avoid_ks_fe:
// Special case for games using imuse digital.for sound
} else if ((_gameId == GID_LOOM256) && !ConfMan.getBool("subtitles") && (_sound->pollCD())) {
// Special case for loomcd, since it only uses CD audio.for sound
- } else if (!ConfMan.getBool("subtitles") && (_haveMsg == 0xFE || _sound->_talkChannelHandle.isActive())) {
+ } else if (!ConfMan.getBool("subtitles") && (_haveMsg == 0xFE || _mixer->isSoundHandleActive(_sound->_talkChannelHandle))) {
// Subtitles are turned off, and there is a voice version
// of this message -> don't print it.
} else
diff --git a/simon/sound.cpp b/simon/sound.cpp
index 4c2cb6a924..93dc9fddf9 100644
--- a/simon/sound.cpp
+++ b/simon/sound.cpp
@@ -45,25 +45,25 @@ public:
BaseSound(SoundMixer *mixer, File *file, uint32 base = 0, bool bigendian = false);
BaseSound(SoundMixer *mixer, File *file, uint32 *offsets, bool bigendian = false);
virtual ~BaseSound();
- virtual void playSound(uint sound, PlayingSoundHandle *handle, byte flags) = 0;
+ virtual void playSound(uint sound, SoundHandle *handle, byte flags) = 0;
};
class WavSound : public BaseSound {
public:
WavSound(SoundMixer *mixer, File *file, uint32 base = 0, bool bigendian = false) : BaseSound(mixer, file, base, bigendian) {};
WavSound(SoundMixer *mixer, File *file, uint32 *offsets) : BaseSound(mixer, file, offsets) {};
- void playSound(uint sound, PlayingSoundHandle *handle, byte flags);
+ void playSound(uint sound, SoundHandle *handle, byte flags);
};
class VocSound : public BaseSound {
public:
VocSound(SoundMixer *mixer, File *file, uint32 base = 0, bool bigendian = false) : BaseSound(mixer, file, base, bigendian) {};
- void playSound(uint sound, PlayingSoundHandle *handle, byte flags);
+ void playSound(uint sound, SoundHandle *handle, byte flags);
};
class RawSound : public BaseSound {
public:
RawSound(SoundMixer *mixer, File *file, uint32 base = 0, bool bigendian = false) : BaseSound(mixer, file, base, bigendian) {};
- void playSound(uint sound, PlayingSoundHandle *handle, byte flags);
+ void playSound(uint sound, SoundHandle *handle, byte flags);
};
BaseSound::BaseSound(SoundMixer *mixer, File *file, uint32 base, bool bigendian) {
@@ -117,7 +117,7 @@ BaseSound::~BaseSound() {
delete _file;
}
-void WavSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
+void WavSound::playSound(uint sound, SoundHandle *handle, byte flags) {
if (_offsets == NULL)
return;
@@ -132,7 +132,7 @@ void WavSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
_mixer->playInputStream(SoundMixer::kSFXSoundType, handle, stream);
}
-void VocSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
+void VocSound::playSound(uint sound, SoundHandle *handle, byte flags) {
if (_offsets == NULL)
return;
@@ -144,7 +144,7 @@ void VocSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
_mixer->playRaw(handle, buffer, size, samples_per_sec, flags | SoundMixer::FLAG_AUTOFREE);
}
-void RawSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
+void RawSound::playSound(uint sound, SoundHandle *handle, byte flags) {
if (_offsets == NULL)
return;
@@ -161,10 +161,10 @@ void RawSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
class MP3Sound : public BaseSound {
public:
MP3Sound(SoundMixer *mixer, File *file, uint32 base = 0) : BaseSound(mixer, file, base) {};
- void playSound(uint sound, PlayingSoundHandle *handle, byte flags);
+ void playSound(uint sound, SoundHandle *handle, byte flags);
};
-void MP3Sound::playSound(uint sound, PlayingSoundHandle *handle, byte flags)
+void MP3Sound::playSound(uint sound, SoundHandle *handle, byte flags)
{
if (_offsets == NULL)
return;
@@ -185,10 +185,10 @@ void MP3Sound::playSound(uint sound, PlayingSoundHandle *handle, byte flags)
class VorbisSound : public BaseSound {
public:
VorbisSound(SoundMixer *mixer, File *file, uint32 base = 0) : BaseSound(mixer, file, base) {};
- void playSound(uint sound, PlayingSoundHandle *handle, byte flags);
+ void playSound(uint sound, SoundHandle *handle, byte flags);
};
-void VorbisSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags)
+void VorbisSound::playSound(uint sound, SoundHandle *handle, byte flags)
{
if (_offsets == NULL)
return;
@@ -209,10 +209,10 @@ void VorbisSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags)
class FlacSound : public BaseSound {
public:
FlacSound(SoundMixer *mixer, File *file, uint32 base = 0) : BaseSound(mixer, file, base) {};
- void playSound(uint sound, PlayingSoundHandle *handle, byte flags);
+ void playSound(uint sound, SoundHandle *handle, byte flags);
};
-void FlacSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags)
+void FlacSound::playSound(uint sound, SoundHandle *handle, byte flags)
{
if (_offsets == NULL)
return;
diff --git a/simon/sound.h b/simon/sound.h
index 228b4addea..28c988d1d3 100644
--- a/simon/sound.h
+++ b/simon/sound.h
@@ -45,9 +45,9 @@ private:
uint16 _last_voice_file;
public:
- PlayingSoundHandle _voice_handle;
- PlayingSoundHandle _effects_handle;
- PlayingSoundHandle _ambient_handle;
+ SoundHandle _voice_handle;
+ SoundHandle _effects_handle;
+ SoundHandle _ambient_handle;
bool _voice_file;
uint _ambient_playing;
diff --git a/simon/vga.cpp b/simon/vga.cpp
index 5ff57296a4..3f2e44a6c4 100644
--- a/simon/vga.cpp
+++ b/simon/vga.cpp
@@ -1606,7 +1606,7 @@ void SimonEngine::vc_59() {
vc_kill_sprite(file, start);
} while (++start != end);
} else {
- if (!_sound->_voice_handle.isActive())
+ if (!_mixer->isSoundHandleActive(_sound->_voice_handle))
vc_skip_next_instruction();
}
}
@@ -1789,7 +1789,7 @@ void SimonEngine::vc_63_palette_thing_2() {
void SimonEngine::vc_64_skip_if_no_speech() {
// Simon2
- if (!_sound->_voice_handle.isActive() || (_subtitles && _language != 20))
+ if (!_mixer->isSoundHandleActive(_sound->_voice_handle) || (_subtitles && _language != 20))
vc_skip_next_instruction();
}
diff --git a/sky/intro.cpp b/sky/intro.cpp
index 39f06688dc..e4a517b0e9 100644
--- a/sky/intro.cpp
+++ b/sky/intro.cpp
@@ -742,7 +742,7 @@ bool Intro::nextPart(uint16 *&data) {
SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_UNSIGNED, SOUND_VOICE);
return true;
case WAITVOICE:
- while (_voice.isActive())
+ while (_mixer->isSoundHandleActive(_voice))
if (!escDelay(50))
return false;
return true;
diff --git a/sky/intro.h b/sky/intro.h
index 2072426e35..2e97663781 100644
--- a/sky/intro.h
+++ b/sky/intro.h
@@ -56,7 +56,7 @@ private:
uint8 *_textBuf, *_saveBuf;
uint8 *_bgBuf;
uint32 _bgSize;
- PlayingSoundHandle _voice, _bgSfx;
+ SoundHandle _voice, _bgSfx;
int32 _relDelay;
diff --git a/sky/sound.cpp b/sky/sound.cpp
index 0ee872ea32..0efc41bf9e 100644
--- a/sky/sound.cpp
+++ b/sky/sound.cpp
@@ -1031,7 +1031,7 @@ Sound::~Sound(void) {
if (_soundData) free(_soundData);
}
-void Sound::playSound(uint32 id, byte *sound, uint32 size, PlayingSoundHandle *handle) {
+void Sound::playSound(uint32 id, byte *sound, uint32 size, SoundHandle *handle) {
byte flags = 0;
flags |= SoundMixer::FLAG_UNSIGNED|SoundMixer::FLAG_AUTOFREE;
diff --git a/sky/sound.h b/sky/sound.h
index 0ca220f5cf..b6888977c7 100644
--- a/sky/sound.h
+++ b/sky/sound.h
@@ -50,16 +50,16 @@ protected:
public:
SoundMixer *_mixer;
- PlayingSoundHandle _voiceHandle;
- PlayingSoundHandle _effectHandle;
- PlayingSoundHandle _bgSoundHandle;
- PlayingSoundHandle _ingameSound0, _ingameSound1, _ingameSpeech;
+ SoundHandle _voiceHandle;
+ SoundHandle _effectHandle;
+ SoundHandle _bgSoundHandle;
+ SoundHandle _ingameSound0, _ingameSound1, _ingameSpeech;
uint16 _saveSounds[2];
protected:
- void playSound(uint32 id, byte *sound, uint32 size, PlayingSoundHandle *handle);
+ void playSound(uint32 id, byte *sound, uint32 size, SoundHandle *handle);
public:
Sound(SoundMixer *mixer, Disk *pDisk, uint8 pVolume);
@@ -69,7 +69,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.isActive(); };
+ bool speechFinished(void) { return !_mixer->isSoundHandleActive(_ingameSpeech); };
void fnPauseFx(void);
void fnUnPauseFx(void);
void fnStopFx(void);
diff --git a/sound/audiocd.cpp b/sound/audiocd.cpp
index e8a74d062c..3188d03cee 100644
--- a/sound/audiocd.cpp
+++ b/sound/audiocd.cpp
@@ -105,7 +105,7 @@ bool AudioCDManager::isPlaying() const {
void AudioCDManager::updateCD() {
if (_cd.playing) {
// If the sound handle is 0, then playback stopped.
- if (!_cd.handle.isActive()) {
+ if (!g_engine->_mixer->isSoundHandleActive(_cd.handle)) {
// 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.
diff --git a/sound/audiocd.h b/sound/audiocd.h
index d523bc5a46..8d2ffdc364 100644
--- a/sound/audiocd.h
+++ b/sound/audiocd.h
@@ -30,7 +30,7 @@
class DigitalTrackInfo {
public:
virtual bool error() = 0;
- virtual void play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration) = 0;
+ virtual void play(SoundMixer *mixer, SoundHandle *handle, int startFrame, int duration) = 0;
virtual ~DigitalTrackInfo() { }
};
@@ -62,7 +62,7 @@ private:
private:
/* used for emulated CD music */
struct ExtStatus : Status {
- PlayingSoundHandle handle;
+ SoundHandle handle;
};
ExtStatus _cd;
diff --git a/sound/flac.cpp b/sound/flac.cpp
index eb8e0a1bec..409bb293a1 100644
--- a/sound/flac.cpp
+++ b/sound/flac.cpp
@@ -746,7 +746,7 @@ public:
FlacTrackInfo(File *file);
~FlacTrackInfo();
bool error() { return _file == NULL; }
- void play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration);
+ void play(SoundMixer *mixer, SoundHandle *handle, int startFrame, int duration);
};
FlacTrackInfo::FlacTrackInfo(File *file) : _file(NULL), _firstStream(NULL)
@@ -760,7 +760,7 @@ FlacTrackInfo::FlacTrackInfo(File *file) : _file(NULL), _firstStream(NULL)
delete tempStream;
}
-void FlacTrackInfo::play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration) {
+void FlacTrackInfo::play(SoundMixer *mixer, SoundHandle *handle, int startFrame, int duration) {
if (error()) {
debug(1, "FlacTrackInfo::play: invalid state, method should not been called");
}
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index 78a2e9f7dd..0ea88373a1 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -47,7 +47,7 @@ public:
const SoundMixer::SoundType _type;
private:
SoundMixer *_mixer;
- PlayingSoundHandle *_handle;
+ SoundHandle *_handle;
bool _autofreeStream;
bool _permanent;
byte _volume;
@@ -64,8 +64,8 @@ protected:
public:
- Channel(SoundMixer *mixer, PlayingSoundHandle *handle, SoundMixer::SoundType type, int id = -1);
- Channel(SoundMixer *mixer, PlayingSoundHandle *handle, SoundMixer::SoundType type, AudioStream *input, bool autofreeStream, bool reverseStereo = false, int id = -1, bool permanent = false);
+ Channel(SoundMixer *mixer, SoundHandle *handle, SoundMixer::SoundType type, int id = -1);
+ Channel(SoundMixer *mixer, SoundHandle *handle, SoundMixer::SoundType type, AudioStream *input, bool autofreeStream, bool reverseStereo = false, int id = -1, bool permanent = false);
virtual ~Channel();
void mix(int16 *data, uint len);
@@ -148,7 +148,7 @@ void SoundMixer::setupPremix(AudioStream *stream, SoundType type) {
_premixChannel = new Channel(this, 0, type, stream, false);
}
-void SoundMixer::insertChannel(PlayingSoundHandle *handle, Channel *chan) {
+void SoundMixer::insertChannel(SoundHandle *handle, Channel *chan) {
int index = -1;
for (int i = 0; i != NUM_CHANNELS; i++) {
@@ -168,7 +168,7 @@ void SoundMixer::insertChannel(PlayingSoundHandle *handle, Channel *chan) {
handle->setIndex(index);
}
-void SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags,
+void SoundMixer::playRaw(SoundHandle *handle, void *sound, uint32 size, uint rate, byte flags,
int id, byte volume, int8 balance, uint32 loopStart, uint32 loopEnd, SoundType type) {
Common::StackLock lock(_mutex);
@@ -202,7 +202,7 @@ void SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, u
insertChannel(handle, chan);
}
-void SoundMixer::playInputStream(SoundType type, PlayingSoundHandle *handle, AudioStream *input,
+void SoundMixer::playInputStream(SoundType type, SoundHandle *handle, AudioStream *input,
int id, byte volume, int8 balance, bool autofreeStream, bool permanent) {
Common::StackLock lock(_mutex);
@@ -279,7 +279,7 @@ void SoundMixer::stopID(int id) {
}
}
-void SoundMixer::stopHandle(PlayingSoundHandle handle) {
+void SoundMixer::stopHandle(SoundHandle handle) {
Common::StackLock lock(_mutex);
// Simply ignore stop requests for handles of sounds that already terminated
@@ -299,7 +299,7 @@ void SoundMixer::stopHandle(PlayingSoundHandle handle) {
}
}
-void SoundMixer::setChannelVolume(PlayingSoundHandle handle, byte volume) {
+void SoundMixer::setChannelVolume(SoundHandle handle, byte volume) {
Common::StackLock lock(_mutex);
if (!handle.isActive())
@@ -316,7 +316,7 @@ void SoundMixer::setChannelVolume(PlayingSoundHandle handle, byte volume) {
_channels[index]->setVolume(volume);
}
-void SoundMixer::setChannelBalance(PlayingSoundHandle handle, int8 balance) {
+void SoundMixer::setChannelBalance(SoundHandle handle, int8 balance) {
Common::StackLock lock(_mutex);
if (!handle.isActive())
@@ -341,7 +341,7 @@ uint32 SoundMixer::getSoundElapsedTimeOfSoundID(int id) {
return 0;
}
-uint32 SoundMixer::getSoundElapsedTime(PlayingSoundHandle handle) {
+uint32 SoundMixer::getSoundElapsedTime(SoundHandle handle) {
Common::StackLock lock(_mutex);
if (!handle.isActive())
@@ -375,7 +375,7 @@ void SoundMixer::pauseID(int id, bool paused) {
}
}
-void SoundMixer::pauseHandle(PlayingSoundHandle handle, bool paused) {
+void SoundMixer::pauseHandle(SoundHandle handle, bool paused) {
Common::StackLock lock(_mutex);
// Simply ignore pause/unpause requests for handles of sound that alreayd terminated
@@ -436,14 +436,14 @@ int SoundMixer::getVolumeForSoundType(SoundType type) const {
#pragma mark -
-Channel::Channel(SoundMixer *mixer, PlayingSoundHandle *handle, SoundMixer::SoundType type, int id)
+Channel::Channel(SoundMixer *mixer, SoundHandle *handle, SoundMixer::SoundType type, int id)
: _type(type), _mixer(mixer), _handle(handle), _autofreeStream(true),
_volume(SoundMixer::kMaxChannelVolume), _balance(0), _paused(false), _id(id), _samplesConsumed(0),
_samplesDecoded(0), _mixerTimeStamp(0), _converter(0), _input(0) {
assert(mixer);
}
-Channel::Channel(SoundMixer *mixer, PlayingSoundHandle *handle, SoundMixer::SoundType type, AudioStream *input,
+Channel::Channel(SoundMixer *mixer, SoundHandle *handle, SoundMixer::SoundType type, AudioStream *input,
bool autofreeStream, bool reverseStereo, int id, bool permanent)
: _type(type), _mixer(mixer), _handle(handle), _autofreeStream(autofreeStream),
_volume(SoundMixer::kMaxChannelVolume), _balance(0), _paused(false), _id(id), _samplesConsumed(0),
diff --git a/sound/mixer.h b/sound/mixer.h
index aef5602c03..8121cee08c 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -33,16 +33,16 @@ class Channel;
class File;
class OSystem;
-class PlayingSoundHandle {
+class SoundHandle {
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; }
+public:
+ SoundHandle() { resetIndex(); }
};
class SoundMixer {
@@ -136,7 +136,7 @@ public:
* (using the makeLinearInputStream factory function), which is then
* passed on to playInputStream.
*/
- void playRaw(PlayingSoundHandle *handle,
+ void playRaw(SoundHandle *handle,
void *sound, uint32 size, uint rate, byte flags,
int id = -1, byte volume = 255, int8 balance = 0,
uint32 loopStart = 0, uint32 loopEnd = 0,
@@ -145,7 +145,7 @@ public:
/**
* Start playing the given audio input stream.
*/
- void playInputStream(SoundType type, PlayingSoundHandle *handle, AudioStream *input,
+ void playInputStream(SoundType type, SoundHandle *handle, AudioStream *input,
int id = -1, byte volume = 255, int8 balance = 0,
bool autofreeStream = true, bool permanent = false);
@@ -168,7 +168,7 @@ public:
*
* @param handle the sound to affect
*/
- void stopHandle(PlayingSoundHandle handle);
+ void stopHandle(SoundHandle handle);
@@ -194,7 +194,7 @@ public:
* @param handle the sound to affect
* @param paused true to pause the sound, false to unpause it
*/
- void pauseHandle(PlayingSoundHandle handle, bool paused);
+ void pauseHandle(SoundHandle handle, bool paused);
@@ -207,6 +207,16 @@ public:
bool isSoundIDActive(int id);
/**
+ * Check if a sound with the given hANDLE is active.
+ *
+ * @param handle the sound to query
+ * @return true if the sound is active
+ */
+ bool isSoundHandleActive(SoundHandle handle) {
+ return handle.isActive();
+ }
+
+ /**
* Check if the mixer is paused (using pauseAll).
*
* @return true if the mixer is paused
@@ -221,7 +231,7 @@ public:
* @param handle the sound to affect
* @param volume the new channel volume (0 - 255)
*/
- void setChannelVolume(PlayingSoundHandle handle, byte volume);
+ void setChannelVolume(SoundHandle handle, byte volume);
/**
* Set the channel balance for the given handle.
@@ -230,7 +240,7 @@ public:
* @param balance the new channel balance:
* (-127 ... 0 ... 127) corresponds to (left ... center ... right)
*/
- void setChannelBalance(PlayingSoundHandle handle, int8 balance);
+ void setChannelBalance(SoundHandle handle, int8 balance);
/**
* Get approximation of for how long the Sound ID has been playing.
@@ -240,7 +250,7 @@ public:
/**
* Get approximation of for how long the channel has been playing.
*/
- uint32 getSoundElapsedTime(PlayingSoundHandle handle);
+ uint32 getSoundElapsedTime(SoundHandle handle);
/**
* Check whether any channel of the given sound type is active.
@@ -275,7 +285,7 @@ public:
uint getOutputRate() const { return _outputRate; }
private:
- void insertChannel(PlayingSoundHandle *handle, Channel *chan);
+ void insertChannel(SoundHandle *handle, Channel *chan);
/**
* Internal main method -- all the actual mixing work is done from here.
diff --git a/sound/mp3.cpp b/sound/mp3.cpp
index 708d3396b9..79a4635be1 100644
--- a/sound/mp3.cpp
+++ b/sound/mp3.cpp
@@ -285,7 +285,7 @@ public:
MP3TrackInfo(File *file);
~MP3TrackInfo();
bool error() { return _error_flag; }
- void play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration);
+ void play(SoundMixer *mixer, SoundHandle *handle, int startFrame, int duration);
};
@@ -360,7 +360,7 @@ error:
delete file;
}
-void MP3TrackInfo::play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration) {
+void MP3TrackInfo::play(SoundMixer *mixer, SoundHandle *handle, int startFrame, int duration) {
unsigned int offset;
mad_timer_t durationTime;
diff --git a/sound/softsynth/mt32.cpp b/sound/softsynth/mt32.cpp
index ad3f41af6d..a62b2459f5 100644
--- a/sound/softsynth/mt32.cpp
+++ b/sound/softsynth/mt32.cpp
@@ -43,7 +43,7 @@ class MidiChannel_MT32 : public MidiChannel_MPU401 {
class MidiDriver_MT32 : public MidiDriver_Emulated {
private:
- PlayingSoundHandle _handle;
+ SoundHandle _handle;
MidiChannel_MT32 _midiChannels[16];
uint16 _channelMask;
MT32Emu::Synth *_synth;
diff --git a/sound/vorbis.cpp b/sound/vorbis.cpp
index 8886a63a05..deca2c62c3 100644
--- a/sound/vorbis.cpp
+++ b/sound/vorbis.cpp
@@ -50,7 +50,7 @@ public:
~VorbisTrackInfo();
bool openTrack();
bool error() { return _error_flag; }
- void play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration);
+ void play(SoundMixer *mixer, SoundHandle *handle, int startFrame, int duration);
};
@@ -166,7 +166,7 @@ VorbisTrackInfo::~VorbisTrackInfo() {
#define VORBIS_TREMOR
#endif
-void VorbisTrackInfo::play(SoundMixer *mixer, PlayingSoundHandle *handle, int startFrame, int duration) {
+void VorbisTrackInfo::play(SoundMixer *mixer, SoundHandle *handle, int startFrame, int duration) {
bool err = openTrack();
assert(!err);
diff --git a/sword1/animation.cpp b/sword1/animation.cpp
index 927bdc7543..7dcf01e70a 100644
--- a/sword1/animation.cpp
+++ b/sword1/animation.cpp
@@ -70,7 +70,7 @@ OverlayColor *AnimationState::giveRgbBuffer(void) {
}
bool AnimationState::soundFinished(void) {
- return !_bgSound.isActive();
+ return !_snd->isSoundHandleActive(_bgSound);
}
AudioStream *AnimationState::createAudioStream(const char *name, void *arg) {
diff --git a/sword1/credits.cpp b/sword1/credits.cpp
index 9db7217156..3ab89bbe11 100644
--- a/sword1/credits.cpp
+++ b/sword1/credits.cpp
@@ -112,7 +112,7 @@ void CreditsPlayer::play(void) {
_system->updateScreen();
// everything's initialized, time to render and show the credits.
- PlayingSoundHandle bgSound;
+ SoundHandle bgSound;
_mixer->playInputStream(SoundMixer::kMusicSoundType, &bgSound, bgSoundStream, 0);
int relDelay = 0;
diff --git a/sword1/sound.cpp b/sword1/sound.cpp
index a55c476448..cde9e867dc 100644
--- a/sword1/sound.cpp
+++ b/sword1/sound.cpp
@@ -100,7 +100,7 @@ void Sound::engine(void) {
if (_fxQueue[cnt2].delay == 0)
playSample(&_fxQueue[cnt2]);
} else {
- if (!_fxQueue[cnt2].handle.isActive()) { // sound finished
+ if (!_mixer->isSoundHandleActive(_fxQueue[cnt2].handle)) { // sound finished
_resMan->resClose(_fxList[_fxQueue[cnt2].id].sampleId);
if (cnt2 != _endOfQueue-1)
_fxQueue[cnt2] = _fxQueue[_endOfQueue - 1];
@@ -130,7 +130,7 @@ bool Sound::amISpeaking(void) {
}
bool Sound::speechFinished(void) {
- return !_speechHandle.isActive();
+ return !_mixer->isSoundHandleActive(_speechHandle);
}
void Sound::newScreen(uint32 screen) {
diff --git a/sword1/sound.h b/sword1/sound.h
index de0f82c08c..982a941a4b 100644
--- a/sword1/sound.h
+++ b/sword1/sound.h
@@ -42,7 +42,7 @@ namespace Sword1 {
struct QueueElement {
uint32 id, delay;
- PlayingSoundHandle handle;
+ SoundHandle handle;
};
struct RoomVol {
@@ -101,7 +101,7 @@ private:
uint32 _cowHeaderSize;
uint8 _currentCowFile;
CowMode _cowMode;
- PlayingSoundHandle _speechHandle, _fxHandle;
+ SoundHandle _speechHandle, _fxHandle;
Common::RandomSource _rnd;
QueueElement _fxQueue[MAX_FXQ_LENGTH];
diff --git a/sword2/driver/animation.cpp b/sword2/driver/animation.cpp
index 90da608e69..4dd939be5b 100644
--- a/sword2/driver/animation.cpp
+++ b/sword2/driver/animation.cpp
@@ -167,7 +167,7 @@ void MoviePlayer::drawTextObject(AnimationState *anim, MovieTextObject *obj) {
*/
int32 MoviePlayer::play(const char *filename, MovieTextObject *text[], int32 leadInRes, int32 leadOutRes) {
- PlayingSoundHandle leadInHandle;
+ SoundHandle leadInHandle;
// This happens if the user quits during the "eye" smacker
if (_vm->_quit)
@@ -205,10 +205,10 @@ int32 MoviePlayer::play(const char *filename, MovieTextObject *text[], int32 lea
playDummy(filename, text, leadOut, leadOutLen);
#endif
- _vm->_mixer->stopHandle(leadInHandle);
+ _snd->stopHandle(leadInHandle);
// Wait for the lead-out to stop, if there is any.
- while (_leadOutHandle.isActive()) {
+ while (_vm->_mixer->isSoundHandleActive(_leadOutHandle)) {
_vm->_screen->updateDisplay();
_vm->_system->delayMillis(30);
}
@@ -224,7 +224,7 @@ int32 MoviePlayer::play(const char *filename, MovieTextObject *text[], int32 lea
void MoviePlayer::playMPEG(const char *filename, MovieTextObject *text[], byte *leadOut, uint32 leadOutLen) {
uint frameCounter = 0, textCounter = 0;
- PlayingSoundHandle handle;
+ SoundHandle handle;
bool skipCutscene = false, textVisible = false;
uint32 flags = SoundMixer::FLAG_16BITS;
bool startNextText = false;
@@ -282,7 +282,7 @@ void MoviePlayer::playMPEG(const char *filename, MovieTextObject *text[], byte *
}
}
- if (startNextText && !handle.isActive()) {
+ if (startNextText && !_snd->isSoundHandleActive(handle)) {
_snd->playRaw(&handle, text[textCounter]->speech, text[textCounter]->speechBufferSize, 22050, flags);
startNextText = false;
}
@@ -339,7 +339,7 @@ void MoviePlayer::playMPEG(const char *filename, MovieTextObject *text[], byte *
// If the speech is still playing, redraw the subtitles. At least in
// the English version this is most noticeable in the "carib" cutscene.
- if (textVisible && handle.isActive())
+ if (textVisible && _snd->isSoundHandleActive(handle))
drawTextObject(anim, text[textCounter]);
if (text)
@@ -354,7 +354,7 @@ void MoviePlayer::playMPEG(const char *filename, MovieTextObject *text[], byte *
if (skipCutscene)
_snd->stopHandle(handle);
- while (handle.isActive()) {
+ while (_snd->isSoundHandleActive(handle)) {
_vm->_screen->updateDisplay(false);
_sys->delayMillis(100);
}
@@ -441,7 +441,7 @@ void MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], byte
tmpPal[255 * 4 + 2] = 255;
_vm->_screen->setPalette(0, 256, tmpPal, RDPAL_INSTANT);
- PlayingSoundHandle handle;
+ SoundHandle handle;
bool skipCutscene = false;
@@ -493,7 +493,7 @@ void MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], byte
// don't cut off the speech in mid-sentence, and - even more
// importantly - that we don't free the sound buffer while it's in use.
- while (handle.isActive()) {
+ while (_snd->isSoundHandleActive(handle)) {
_vm->_screen->updateDisplay(false);
_sys->delayMillis(100);
}
diff --git a/sword2/driver/animation.h b/sword2/driver/animation.h
index 0dcac3fc81..c9d75da66e 100644
--- a/sword2/driver/animation.h
+++ b/sword2/driver/animation.h
@@ -77,7 +77,7 @@ private:
byte *_textSurface;
- PlayingSoundHandle _leadOutHandle;
+ SoundHandle _leadOutHandle;
static struct MovieInfo _movies[];
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp
index 755aa1d73c..774f33c5cf 100644
--- a/sword2/driver/d_sound.cpp
+++ b/sword2/driver/d_sound.cpp
@@ -642,7 +642,7 @@ int32 Sound::musicTimeRemaining(void) {
void Sound::muteSpeech(bool mute) {
_speechMuted = mute;
- if (_soundHandleSpeech.isActive()) {
+ if (_vm->_mixer->isSoundHandleActive(_soundHandleSpeech)) {
uint volume = mute ? 0 : SoundMixer::kMaxChannelVolume;
_vm->_mixer->setChannelVolume(_soundHandleSpeech, volume);
@@ -672,7 +672,7 @@ void Sound::unpauseSpeech(void) {
*/
int32 Sound::stopSpeech() {
- if (_soundHandleSpeech.isActive()) {
+ if (_vm->_mixer->isSoundHandleActive(_soundHandleSpeech)) {
_vm->_mixer->stopHandle(_soundHandleSpeech);
return RD_OK;
}
@@ -685,7 +685,7 @@ int32 Sound::stopSpeech() {
*/
int32 Sound::getSpeechStatus() {
- return _soundHandleSpeech.isActive() ? RDSE_SAMPLEPLAYING : RDSE_SAMPLEFINISHED;
+ return _vm->_mixer->isSoundHandleActive(_soundHandleSpeech) ? RDSE_SAMPLEPLAYING : RDSE_SAMPLEFINISHED;
}
/**
@@ -693,7 +693,7 @@ int32 Sound::getSpeechStatus() {
*/
int32 Sound::amISpeaking() {
- if (!_speechMuted && !_speechPaused && _soundHandleSpeech.isActive())
+ if (!_speechMuted && !_speechPaused && _vm->_mixer->isSoundHandleActive(_soundHandleSpeech))
return RDSE_SPEAKING;
return RDSE_QUIET;
@@ -818,7 +818,7 @@ int32 Sound::setFxIdVolumePan(int32 i, int vol, int pan) {
_fxQueue[i].pan = (pan * 127) / 16;
}
- if (!_fxMuted && _fxQueue[i].handle.isActive()) {
+ if (!_fxMuted && _vm->_mixer->isSoundHandleActive(_fxQueue[i].handle)) {
_vm->_mixer->setChannelVolume(_fxQueue[i].handle, _fxQueue[i].volume);
if (pan != -1)
_vm->_mixer->setChannelBalance(_fxQueue[i].handle, _fxQueue[i].pan);
diff --git a/sword2/sound.cpp b/sword2/sound.cpp
index 9955eb5490..addaba928c 100644
--- a/sword2/sound.cpp
+++ b/sword2/sound.cpp
@@ -156,7 +156,7 @@ void Sound::processFxQueue() {
break;
case FX_SPOT2:
// Once the FX has finished remove it from the queue.
- if (!_fxQueue[i].handle.isActive()) {
+ if (!_vm->_mixer->isSoundHandleActive(_fxQueue[i].handle)) {
_vm->_resman->closeResource(_fxQueue[i].resource);
_fxQueue[i].resource = 0;
}
@@ -250,11 +250,11 @@ int32 Sound::playFx(FxQueueEntry *fx) {
return playFx(&fx->handle, fx->data, fx->len, fx->volume, fx->pan, (fx->type == FX_LOOP), SoundMixer::kSFXSoundType);
}
-int32 Sound::playFx(PlayingSoundHandle *handle, byte *data, uint32 len, uint8 vol, int8 pan, bool loop, SoundMixer::SoundType soundType) {
+int32 Sound::playFx(SoundHandle *handle, byte *data, uint32 len, uint8 vol, int8 pan, bool loop, SoundMixer::SoundType soundType) {
if (_fxMuted)
return RD_OK;
- if (handle->isActive())
+ if (_vm->_mixer->isSoundHandleActive(*handle))
return RDERR_FXALREADYOPEN;
Common::MemoryReadStream stream(data, len);
@@ -287,8 +287,7 @@ int32 Sound::stopFx(int32 i) {
if (!_fxQueue[i].resource)
return RDERR_FXNOTOPEN;
- if (_fxQueue[i].handle.isActive())
- _vm->_mixer->stopHandle(_fxQueue[i].handle);
+ _vm->_mixer->stopHandle(_fxQueue[i].handle);
_vm->_resman->closeResource(_fxQueue[i].resource);
_fxQueue[i].resource = 0;
diff --git a/sword2/sound.h b/sword2/sound.h
index 07a8b40c35..f34ba70014 100644
--- a/sword2/sound.h
+++ b/sword2/sound.h
@@ -172,7 +172,7 @@ private:
Common::Mutex _mutex;
struct FxQueueEntry {
- PlayingSoundHandle handle; // sound handle
+ SoundHandle handle; // sound handle
uint32 resource; // resource id of sample
byte *data; // pointer to WAV data
uint32 len; // WAV data length
@@ -198,7 +198,7 @@ private:
int32 _loopingMusicId;
- PlayingSoundHandle _soundHandleSpeech;
+ SoundHandle _soundHandleSpeech;
MusicInputStream *_music[MAXMUS];
//File _musicFile[MAXMUS];
@@ -253,7 +253,7 @@ public:
void queueFx(int32 res, int32 type, int32 delay, int32 volume, int32 pan);
int32 playFx(FxQueueEntry *fx);
- int32 playFx(PlayingSoundHandle *handle, byte *data, uint32 len, uint8 vol, int8 pan, bool loop, SoundMixer::SoundType soundType);
+ int32 playFx(SoundHandle *handle, byte *data, uint32 len, uint8 vol, int8 pan, bool loop, SoundMixer::SoundType soundType);
int32 stopFx(int32 i);
int32 setFxIdVolumePan(int32 id, int vol, int pan = 255);