Ticket #7994: scummvm-mixer.patch

File scummvm-mixer.patch, 2.4 KB (added by SF/phillip_j_fry, 22 years ago)

mixer channel patch

  • sound/mixer.cpp

    diff -r -u scummvm/sound/mixer.cpp scummvm-mod/sound/mixer.cpp
    old new  
    6868        return index;
    6969}
    7070
    71 int SoundMixer::insert(PlayingSoundHandle *handle, Channel * chan)
     71int SoundMixer::play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate,
     72                                                                                                 byte flags)
    7273{
    7374        for (int i = 0; i != NUM_CHANNELS; i++) {
    7475                if (_channels[i] == NULL) {
    75                         return insert_at(handle, i, chan);
     76                        return insert_at(handle, i, new Channel_RAW(this, sound, size, rate, flags));
    7677                }
    7778        }
    7879
    79         warning("SoundMixer::insert out of mixer slots");
    80         chan->real_destroy();
    81 
     80        warning("SoundMixer::out of mixer slots");
    8281        return -1;
    8382}
    8483
    85 
    86 int SoundMixer::play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate,
    87                                                                                                  byte flags)
    88 {
    89         return insert(handle, new Channel_RAW(this, sound, size, rate, flags));
    90 }
    91 
    9284int SoundMixer::play_stream(PlayingSoundHandle *handle, int idx, void *sound, uint32 size,
    9385                                                                                                                uint rate, byte flags)
    9486{
     
    9890#ifdef COMPRESSED_SOUND_FILE
    9991int SoundMixer::play_mp3(PlayingSoundHandle *handle, void *sound, uint32 size, byte flags)
    10092{
    101         return insert(handle, new Channel_MP3(this, sound, size, flags));
     93        for (int i = 0; i != NUM_CHANNELS; i++) {
     94                if (_channels[i] == NULL) {
     95                        return insert_at(handle, i, new Channel_MP3(this, sound, size, flags));
     96                }
     97        }
     98
     99        warning("SoundMixer::out of mixer slots");
     100        return -1;
    102101}
    103102int SoundMixer::play_mp3_cdtrack(PlayingSoundHandle *handle, FILE * file, mad_timer_t duration)
    104103{
    105104        /* Stop the previously playing CD track (if any) */
    106         return insert(handle, new Channel_MP3_CDMUSIC(this, file, duration));
     105        for (int i = 0; i != NUM_CHANNELS; i++) {
     106                if (_channels[i] == NULL) {
     107                        return insert_at(handle, i, new Channel_MP3_CDMUSIC(this, file, duration));
     108                }
     109        }
     110
     111        warning("SoundMixer::out of mixer slots");
     112        return -1;
    107113}
    108114#endif
    109115
  • sound/mixer.h

    diff -r -u scummvm/sound/mixer.h scummvm-mod/sound/mixer.h
    old new  
    145145        Channel *_channels[NUM_CHANNELS];
    146146        PlayingSoundHandle *_handles[NUM_CHANNELS];
    147147
    148         int insert(PlayingSoundHandle *handle, Channel * chan);
    149148        int insert_at(PlayingSoundHandle *handle, int index, Channel * chan);
    150149        void append(void *data, uint32 len);
    151150        void uninsert(Channel * chan);