Ticket #8613: imuse-mixer-flags.diff

File imuse-mixer-flags.diff, 5.9 KB (added by eriktorbjorn, 14 years ago)

Patch against current SVN

  • engines/scumm/imuse_digi/dimuse.cpp

     
    7676        free(_audioNames);
    7777}
    7878
     79int32 IMuseDigital::makeMixerFlags(int32 flags) {
     80        int32 mixerFlags = 0;
     81        if (flags & kFlagUnsigned)
     82                mixerFlags |= Audio::Mixer::FLAG_UNSIGNED;
     83        if (flags & kFlag16Bits)
     84                mixerFlags |= Audio::Mixer::FLAG_16BITS;
     85        if (flags & kFlagLittleEndian)
     86                mixerFlags |= Audio::Mixer::FLAG_LITTLE_ENDIAN;
     87        if (flags & kFlagStereo)
     88                mixerFlags |= Audio::Mixer::FLAG_STEREO;
     89        if (flags & kFlagReverseStereo)
     90                mixerFlags |= Audio::Mixer::FLAG_REVERSE_STEREO;
     91        return mixerFlags;
     92}
     93
    7994void IMuseDigital::resetState() {
    8095        _curMusicState = 0;
    8196        _curMusicSeq = 0;
     
    122137                MKLINE(Track, soundType, sleInt32, VER(31)),
    123138                MKLINE(Track, iteration, sleInt32, VER(31)),
    124139                MKLINE(Track, mod, sleInt32, VER(31)),
    125                 MKLINE(Track, mixerFlags, sleInt32, VER(31)),
     140                MKLINE(Track, flags, sleInt32, VER(31)),
    126141                MK_OBSOLETE(Track, mixerVol, sleInt32, VER(31), VER(42)),
    127142                MK_OBSOLETE(Track, mixerPan, sleInt32, VER(31), VER(42)),
    128143                MKLINE(Track, compressed, sleByte, VER(45)),
     
    171186                        int channels = _sound->getChannels(track->soundHandle);
    172187                        int freq = _sound->getFreq(track->soundHandle);
    173188                        track->iteration = freq * channels;
    174                         track->mixerFlags = 0;
     189                        track->flags = 0;
    175190                        if (channels == 2)
    176                                 track->mixerFlags = Audio::Mixer::FLAG_STEREO | Audio::Mixer::FLAG_REVERSE_STEREO;
     191                                track->flags = kFlagStereo | kFlagReverseStereo;
    177192
    178193                        if ((bits == 12) || (bits == 16)) {
    179                                 track->mixerFlags |= Audio::Mixer::FLAG_16BITS;
     194                                track->flags |= kFlag16Bits;
    180195                                track->iteration *= 2;
    181196                        } else if (bits == 8) {
    182                                 track->mixerFlags |= Audio::Mixer::FLAG_UNSIGNED;
     197                                track->flags |= kFlagUnsigned;
    183198                        } else
    184199                                error("IMuseDigital::saveOrLoad(): Can't handle %d bit samples", bits);
    185200
    186201#ifdef SCUMM_LITTLE_ENDIAN
    187202                        if (track->compressed)
    188                                 track->mixerFlags |= Audio::Mixer::FLAG_LITTLE_ENDIAN;
     203                                track->flags |= kFlagLittleEndian;
    189204#endif
    190205
    191206                        track->stream2 = NULL;
    192                         track->stream = Audio::makeAppendableAudioStream(freq, track->mixerFlags);
     207                        track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->flags));
    193208
    194209                        const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
    195210                        const int vol = track->vol / 1000;
  • engines/scumm/imuse_digi/dimuse_track.cpp

     
    103103        track->dataOffset = 0;
    104104        track->regionOffset = 0;
    105105        track->mod = 0;
    106         track->mixerFlags = 0;
     106        track->flags = 0;
    107107        track->toBeRemoved = false;
    108108        track->readyToRemove = false;
    109109        track->soundType = soundType;
     
    143143
    144144                track->iteration = freq * channels;
    145145                if (channels == 2)
    146                         track->mixerFlags = Audio::Mixer::FLAG_STEREO | Audio::Mixer::FLAG_REVERSE_STEREO;
     146                        track->flags = kFlagStereo | kFlagReverseStereo;
    147147
    148148                if ((bits == 12) || (bits == 16)) {
    149                         track->mixerFlags |= Audio::Mixer::FLAG_16BITS;
     149                        track->flags |= kFlag16Bits;
    150150                        track->iteration *= 2;
    151151                } else if (bits == 8) {
    152                         track->mixerFlags |= Audio::Mixer::FLAG_UNSIGNED;
     152                        track->flags |= kFlagUnsigned;
    153153                } else
    154154                        error("IMuseDigital::startSound(): Can't handle %d bit samples", bits);
    155155
    156156#ifdef SCUMM_LITTLE_ENDIAN
    157157                if (track->compressed)
    158                         track->mixerFlags |= Audio::Mixer::FLAG_LITTLE_ENDIAN;
     158                        track->flags |= kFlagLittleEndian;
    159159#endif
    160160        }
    161161
     
    177177
    178178                // setup 1 second stream wrapped buffer
    179179                track->stream2 = NULL;
    180                 track->stream = Audio::makeAppendableAudioStream(freq, track->mixerFlags);
     180                track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->flags));
    181181                _mixer->playInputStream(type, &track->handle, track->stream, -1, vol, pan, false);
    182182                track->started = true;
    183183        }
     
    328328        fadeTrack->curRegion = track->curRegion;
    329329        fadeTrack->curHookId = track->curHookId;
    330330        fadeTrack->iteration = track->iteration;
    331         fadeTrack->mixerFlags = track->mixerFlags;
     331        fadeTrack->flags = track->flags;
    332332        fadeTrack->mod = track->mod;
    333333        fadeTrack->toBeRemoved = track->toBeRemoved;
    334334        fadeTrack->readyToRemove = track->readyToRemove;
     
    355355                type = Audio::Mixer::kMusicSoundType;
    356356
    357357        // setup 1 second stream wrapped buffer
    358         fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundHandle), fadeTrack->mixerFlags);
     358        fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundHandle), makeMixerFlags(fadeTrack->flags));
    359359        _mixer->playInputStream(type, &fadeTrack->handle, fadeTrack->stream, -1, fadeTrack->vol / 1000, fadeTrack->pan, false);
    360360        fadeTrack->started = true;
    361361        fadeTrack->used = true;
  • engines/scumm/imuse_digi/dimuse.h

     
    4444class Serializer;
    4545class ScummEngine_v7;
    4646
     47// These flag bits correspond exactly to the sound mixer flags of March 2007.
     48// We define our own so that savegames won't break, even if the mixer flags
     49// change after this point.
     50
     51enum {
     52        kFlagUnsigned = 1 << 0,
     53        kFlag16Bits = 1 << 1,
     54        kFlagLittleEndian = 1 << 2,
     55        kFlagStereo = 1 << 3,
     56        kFlagReverseStereo = 1 << 4
     57
     58        // kFlagAutoFree = 1 << 5,
     59        // kFlagLoop = 1 << 6
     60};
     61
    4762class IMuseDigital : public MusicEngine {
    4863private:
    4964
     
    7691                int32 soundType;
    7792                int32 iteration;
    7893                int32 mod;
    79                 int32 mixerFlags;
     94                int32 flags;
    8095
    8196                ImuseDigiSndMgr::soundStruct *soundHandle;
    8297                Audio::SoundHandle handle;
     
    104119        int32 _curMusicSeq;
    105120        int32 _curMusicCue;
    106121
     122        int32 makeMixerFlags(int32 flags);
    107123        static void timer_handler(void *refConf);
    108124        void callback();
    109125        void switchToNextRegion(Track *track);