From c56c8ea5e618a74000e7bdce09c40eca7f3b01fb Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 29 Jul 2002 16:18:32 +0000 Subject: patch 587769 by Fridvin Logi (supposedly helps with Nexus in The Dig) svn-id: r4678 --- sound/mixer.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'sound/mixer.cpp') diff --git a/sound/mixer.cpp b/sound/mixer.cpp index 06a8c3f99e..7cb75050cf 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -68,27 +68,19 @@ int SoundMixer::insert_at(PlayingSoundHandle *handle, int index, Channel * chan) return index; } -int SoundMixer::insert(PlayingSoundHandle *handle, Channel * chan) +int SoundMixer::play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, + byte flags) { for (int i = 0; i != NUM_CHANNELS; i++) { if (_channels[i] == NULL) { - return insert_at(handle, i, chan); + return insert_at(handle, i, new Channel_RAW(this, sound, size, rate, flags)); } } - warning("SoundMixer::insert out of mixer slots"); - chan->real_destroy(); - + warning("SoundMixer::out of mixer slots"); return -1; } - -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)); -} - int SoundMixer::play_stream(PlayingSoundHandle *handle, int idx, void *sound, uint32 size, uint rate, byte flags) { @@ -98,12 +90,26 @@ int SoundMixer::play_stream(PlayingSoundHandle *handle, int idx, void *sound, ui #ifdef COMPRESSED_SOUND_FILE int SoundMixer::play_mp3(PlayingSoundHandle *handle, void *sound, uint32 size, byte flags) { - return insert(handle, new Channel_MP3(this, sound, size, flags)); + for (int i = 0; i != NUM_CHANNELS; i++) { + if (_channels[i] == NULL) { + return insert_at(handle, i, new Channel_MP3(this, sound, size, flags)); + } + } + + warning("SoundMixer::out of mixer slots"); + return -1; } int SoundMixer::play_mp3_cdtrack(PlayingSoundHandle *handle, FILE * file, mad_timer_t duration) { /* Stop the previously playing CD track (if any) */ - return insert(handle, new Channel_MP3_CDMUSIC(this, file, duration)); + for (int i = 0; i != NUM_CHANNELS; i++) { + if (_channels[i] == NULL) { + return insert_at(handle, i, new Channel_MP3_CDMUSIC(this, file, duration)); + } + } + + warning("SoundMixer::out of mixer slots"); + return -1; } #endif -- cgit v1.2.3