diff options
Diffstat (limited to 'sound/mixer.cpp')
-rw-r--r-- | sound/mixer.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
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 |