aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/agi/sound.cpp12
-rw-r--r--engines/agi/sound.h17
2 files changed, 21 insertions, 8 deletions
diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp
index 87e3440ad1..3e1bfb9c30 100644
--- a/engines/agi/sound.cpp
+++ b/engines/agi/sound.cpp
@@ -389,8 +389,8 @@ static int noteToPeriod(int note) {
void SoundMgr::unloadSound(int resnum) {
if (_vm->_game.dirSound[resnum].flags & RES_LOADED) {
- if (_vm->_game.sounds[resnum].flags & SOUND_PLAYING) {
- /* FIXME: Stop playing */
+ if (_vm->_game.sounds[resnum].isPlaying()) {
+ _vm->_game.sounds[resnum].stop();
}
/* Release RAW data for sound */
@@ -431,7 +431,7 @@ void SoundMgr::startSound(int resnum, int flag) {
struct SoundIIgsSample *smp;
#endif
- if (_vm->_game.sounds[resnum].flags & SOUND_PLAYING)
+ if (_vm->_game.sounds[resnum].isPlaying())
return;
stopSound();
@@ -444,7 +444,7 @@ void SoundMgr::startSound(int resnum, int flag) {
if (type != AGI_SOUND_SAMPLE && type != AGI_SOUND_MIDI && type != AGI_SOUND_4CHN)
return;
- _vm->_game.sounds[resnum].flags |= SOUND_PLAYING;
+ _vm->_game.sounds[resnum].play();
_vm->_game.sounds[resnum].type = type;
playingSound = resnum;
song = (uint8 *)_vm->_game.sounds[resnum].rdata;
@@ -516,7 +516,7 @@ void SoundMgr::stopSound() {
stopNote(i);
if (playingSound != -1) {
- _vm->_game.sounds[playingSound].flags &= ~SOUND_PLAYING;
+ _vm->_game.sounds[playingSound].stop();
playingSound = -1;
}
}
@@ -734,7 +734,7 @@ void SoundMgr::playSound() {
_vm->setflag(endflag, true);
if (playingSound != -1)
- _vm->_game.sounds[playingSound].flags &= ~SOUND_PLAYING;
+ _vm->_game.sounds[playingSound].stop();
playingSound = -1;
endflag = -1;
}
diff --git a/engines/agi/sound.h b/engines/agi/sound.h
index 426cbf5f1d..adde156f75 100644
--- a/engines/agi/sound.h
+++ b/engines/agi/sound.h
@@ -39,7 +39,6 @@ namespace Agi {
#define SOUND_EMU_MAC 3
#define SOUND_EMU_AMIGA 4
-#define SOUND_PLAYING 0x01
#define WAVEFORM_SIZE 64
#define ENV_ATTACK 10000 /**< envelope attack rate */
#define ENV_DECAY 1000 /**< envelope decay rate */
@@ -53,8 +52,22 @@ namespace Agi {
struct AgiSound {
uint32 flen; /**< size of raw data */
uint8 *rdata; /**< raw sound data */
- uint8 flags; /**< sound flags */
uint16 type; /**< sound resource type */
+
+ void play() {
+ _isPlaying = true;
+ }
+
+ void stop() {
+ _isPlaying = false;
+ }
+
+ bool isPlaying() {
+ return _isPlaying;
+ }
+
+private:
+ bool _isPlaying; ///< Is the sound playing?
};
#include "common/pack-start.h"