aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorJames Brown2002-04-22 08:16:16 +0000
committerJames Brown2002-04-22 08:16:16 +0000
commitd447f057094084f55b19a9806ce70a3ed44b96c6 (patch)
treeff83e720762c0353cca39182427f86f1e27f3996 /sound
parentd0d33166345bbe1d98d4e3b766af2b74713f0fc7 (diff)
downloadscummvm-rg350-d447f057094084f55b19a9806ce70a3ed44b96c6.tar.gz
scummvm-rg350-d447f057094084f55b19a9806ce70a3ed44b96c6.tar.bz2
scummvm-rg350-d447f057094084f55b19a9806ce70a3ed44b96c6.zip
Add voice channel tracking to stop script race in BumpusVille VR.
svn-id: r4048
Diffstat (limited to 'sound')
-rw-r--r--sound/mixer.cpp13
-rw-r--r--sound/mixer.h4
2 files changed, 10 insertions, 7 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index ec8c0caae3..f27910d17d 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -38,24 +38,26 @@ void SoundMixer::uninsert(Channel *chan) {
error("SoundMixer::channel_deleted chan not found");
}
-void SoundMixer::insert(PlayingSoundHandle *handle, Channel *chan) {
+int SoundMixer::insert(PlayingSoundHandle *handle, Channel *chan) {
for(int i=0; i!=NUM_CHANNELS; i++) {
if (_channels[i] == NULL) {
_channels[i] = chan;
_handles[i] = handle;
if (handle)
*handle = i + 1;
- return;
+ return i;
}
}
warning("SoundMixer::insert out of mixer slots");
chan->destroy();
+
+ return -1;
}
-void SoundMixer::play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags) {
- insert(handle, new Channel_RAW(this, sound, size, rate, flags));
+int SoundMixer::play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags) {
+ return insert(handle, new Channel_RAW(this, sound, size, rate, flags));
}
#ifdef COMPRESSED_SOUND_FILE
@@ -202,8 +204,9 @@ void SoundMixer::Channel_RAW::mix(int16 *data, uint len) {
free(s_org);
}
- if (!_size)
+ if (_size < 1)
destroy();
+
}
void SoundMixer::Channel_RAW::destroy() {
diff --git a/sound/mixer.h b/sound/mixer.h
index 272cdb670f..cf8d21f22f 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -115,7 +115,7 @@ public:
Channel *_channels[NUM_CHANNELS];
PlayingSoundHandle *_handles[NUM_CHANNELS];
- void insert(PlayingSoundHandle *handle, Channel *chan);
+ int insert(PlayingSoundHandle *handle, Channel *chan);
void uninsert(Channel *chan);
/* start playing a raw sound */
@@ -124,7 +124,7 @@ public:
FLAG_UNSIGNED = 2, /* unsigned samples */
FLAG_FILE = 4, /* sound is a FILE * that's read from */
};
- void play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags);
+ int play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags);
#ifdef COMPRESSED_SOUND_FILE
void play_mp3(PlayingSoundHandle *handle, void *sound, uint32 size, byte flags);
void play_mp3_cdtrack(PlayingSoundHandle *handle, FILE* file, void *buffer, uint32 buffer_size, mad_timer_t duration);