aboutsummaryrefslogtreecommitdiff
path: root/sound/mixer.cpp
diff options
context:
space:
mode:
authorMax Horn2003-12-23 19:14:57 +0000
committerMax Horn2003-12-23 19:14:57 +0000
commit43875b42fcefae5e0f009acd87407e8d545623c6 (patch)
tree99c3fcf2db3bc4f2b6e4c6aebf9c5ede5626f777 /sound/mixer.cpp
parent88d7cd586d49aa9133383d95833e7129f1ae22ee (diff)
downloadscummvm-rg350-43875b42fcefae5e0f009acd87407e8d545623c6.tar.gz
scummvm-rg350-43875b42fcefae5e0f009acd87407e8d545623c6.tar.bz2
scummvm-rg350-43875b42fcefae5e0f009acd87407e8d545623c6.zip
Allow sound ID for MP3/Vorbis sounds, too; cleaned up Vorbis playback code a bit
svn-id: r11879
Diffstat (limited to 'sound/mixer.cpp')
-rw-r--r--sound/mixer.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index 1a069bb3b0..7fbd030f6f 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -256,34 +256,50 @@ void SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, u
}
#ifdef USE_MAD
-void SoundMixer::playMP3(PlayingSoundHandle *handle, File *file, uint32 size, byte volume, int8 pan) {
+void SoundMixer::playMP3(PlayingSoundHandle *handle, File *file, uint32 size, byte volume, int8 pan, int id) {
// Create the input stream
AudioInputStream *input = makeMP3Stream(file, mad_timer_zero, size);
- playInputStream(handle, input, false, volume, pan);
+ playInputStream(handle, input, false, volume, pan, id);
}
-void SoundMixer::playMP3CDTrack(PlayingSoundHandle *handle, File *file, mad_timer_t duration, byte volume, int8 pan) {
+void SoundMixer::playMP3CDTrack(PlayingSoundHandle *handle, File *file, mad_timer_t duration, byte volume, int8 pan, int id) {
// Create the input stream
AudioInputStream *input = makeMP3Stream(file, duration, 0);
- playInputStream(handle, input, true, volume, pan);
+ playInputStream(handle, input, true, volume, pan, id);
}
#endif
#ifdef USE_VORBIS
-void SoundMixer::playVorbis(PlayingSoundHandle *handle, File *file, uint32 size) {
- playSfxSound_Vorbis(this, file, size, handle);
+void SoundMixer::playVorbis(PlayingSoundHandle *handle, File *file, uint32 size, byte volume, int8 pan, int id) {
+ // Create the input stream
+ AudioInputStream *input = makeVorbisStream(file, size);
+ playInputStream(handle, input, false, volume, pan, id);
}
-void SoundMixer::playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track, byte volume, int8 pan) {
+void SoundMixer::playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track, byte volume, int8 pan, int id) {
// Create the input stream
AudioInputStream *input = makeVorbisStream(ov_file, duration);
- playInputStream(handle, input, is_cd_track, volume, pan);
+ playInputStream(handle, input, is_cd_track, volume, pan, id);
}
#endif
-void SoundMixer::playInputStream(PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume, int8 pan) {
+void SoundMixer::playInputStream(PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume, int8 pan, int id) {
Common::StackLock lock(_mutex);
+ if (input == 0) {
+ warning("input stream is 0");
+ return;
+ }
+
+ // Prevent duplicate sounds
+ if (id != -1) {
+ for (int i = 0; i != NUM_CHANNELS; i++)
+ if (_channels[i] != 0 && _channels[i]->getId() == id) {
+ delete input;
+ return;
+ }
+ }
+
// Create the channel
- Channel *chan = new Channel(this, handle, input, isMusic, volume, pan);
+ Channel *chan = new Channel(this, handle, input, isMusic, volume, pan, false, id);
insertChannel(handle, chan);
}