aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scumm/sound.cpp15
-rw-r--r--sound/mixer.cpp20
-rw-r--r--sound/mixer.h4
3 files changed, 30 insertions, 9 deletions
diff --git a/scumm/sound.cpp b/scumm/sound.cpp
index 13ca9a043a..6a492cbef3 100644
--- a/scumm/sound.cpp
+++ b/scumm/sound.cpp
@@ -234,9 +234,9 @@ void Sound::playSound(int sound) {
return;
}
else if (READ_UINT32_UNALIGNED(ptr) == MKID('Crea')) {
- char * sound = read_creative_voc_file(ptr, size, rate);
- if(sound != NULL) {
- _scumm->_mixer->playRaw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
+ char * sounddata = read_creative_voc_file(ptr, size, rate);
+ if(sounddata != NULL) {
+ _scumm->_mixer->playRaw(NULL, sounddata, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE, sound);
}
return;
}
@@ -553,6 +553,15 @@ int Sound::isSoundRunning(int sound) {
if (_scumm->_imuseDigital) {
return _scumm->_imuseDigital->getSoundStatus(sound);
}
+
+ // Check raw mixer channels, to make sure we're not playing an exotic
+ // sound type manually.
+ for (int i = 0; i < _scumm->_mixer->NUM_CHANNELS; i++) {
+ if (_scumm->_mixer->_channels[i] && (_scumm->_mixer->_channels[i]->_id == sound)) {
+ return 1;
+ }
+ }
+
se = _scumm->_imuse;
if (!se)
return 0;
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index ef5c40af33..c19facc3d9 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -84,11 +84,21 @@ int SoundMixer::insertAt(PlayingSoundHandle * handle, int index, Channel * chan)
return index;
}
-int SoundMixer::playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate,
- byte flags) {
+int SoundMixer::playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags) {
for (int i = 0; i != NUM_CHANNELS; i++) {
if (_channels[i] == NULL) {
- return insertAt(handle, i, new ChannelRaw(this, sound, size, rate, flags));
+ return insertAt(handle, i, new ChannelRaw(this, sound, size, rate, flags, -1));
+ }
+ }
+
+ warning("SoundMixer::out of mixer slots");
+ return -1;
+}
+
+int SoundMixer::playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags, int id) {
+ for (int i = 0; i != NUM_CHANNELS; i++) {
+ if (_channels[i] == NULL) {
+ return insertAt(handle, i, new ChannelRaw(this, sound, size, rate, flags, id));
}
}
@@ -239,8 +249,8 @@ void SoundMixer::Channel::append(void * sound, uint32 size) {
}
/* RAW mixer */
-SoundMixer::ChannelRaw::ChannelRaw(SoundMixer * mixer, void * sound, uint32 size, uint rate,
- byte flags) {
+SoundMixer::ChannelRaw::ChannelRaw(SoundMixer * mixer, void * sound, uint32 size, uint rate, byte flags, int id) {
+ _id = id;
_mixer = mixer;
_flags = flags;
_ptr = sound;
diff --git a/sound/mixer.h b/sound/mixer.h
index 48e0b6b5c4..cdc45a7fee 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -41,6 +41,7 @@ private:
class Channel {
public:
bool _toBeDestroyed;
+ int _id;
virtual void mix(int16 *data, uint len) = 0;
void destroy() {
_toBeDestroyed = true;
@@ -63,7 +64,7 @@ private:
byte _flags;
public:
- ChannelRaw(SoundMixer * mixer, void * sound, uint32 size, uint rate, byte flags);
+ ChannelRaw(SoundMixer * mixer, void * sound, uint32 size, uint rate, byte flags, int id);
void mix(int16 * data, uint len);
void realDestroy();
@@ -178,6 +179,7 @@ public:
FLAG_FILE = 16, /* sound is a FILE * that's read from */
};
int playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags);
+ int playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags, int id);
int playStream(PlayingSoundHandle * handle, int index, void * sound, uint32 size, uint rate,
byte flags);
#ifdef COMPRESSED_SOUND_FILE