Ticket #8254: sky-sound.diff

File sky-sound.diff, 4.1 KB (added by eriktorbjorn, 21 years ago)

Patch against a July 7 CVS snapshot

  • scummvm/sky/sound.cpp

    diff -ur ScummVM+orig/scummvm/sky/sound.cpp ScummVM+hack/scummvm/sky/sound.cpp
    old new  
    3333#pragma START_PACK_STRUCTS
    3434#endif
    3535
     36enum {
     37        SOUND_CH0    = 0,
     38        SOUND_CH1    = 1,
     39        SOUND_BG     = 2,
     40        SOUND_VOICE  = 3,
     41        SOUND_SPEECH = 4
     42};
     43
    3644struct RoomList {
    3745        uint8 room;
    3846        uint8 adlibVolume;
     
    10211029        _bgSoundHandle = 0;
    10221030        _ingameSpeech = 0;
    10231031        _ingameSound0 = _ingameSound1 = 0;
    1024         _spSlot = _slot0 = _slot1 = -1;
    10251032        _saveSounds[0] = _saveSounds[1] = 0xFFFF;
    10261033}
    10271034
     
    10331040
    10341041int SkySound::playVoice(byte *sound, uint32 size) {
    10351042
    1036         return playSound(sound, size, &_voiceHandle);
     1043        _mixer->stopID(SOUND_VOICE);
     1044        return playSound(SOUND_VOICE, sound, size, &_voiceHandle);
    10371045}
    10381046
    10391047
    10401048int SkySound::playBgSound(byte *sound, uint32 size) {
    10411049
    10421050        size -= 512; //Hack to get rid of the annoying pop at the end of some bg sounds
    1043         return playSound(sound, size, &_bgSoundHandle);
     1051        _mixer->stopID(SOUND_BG);
     1052        return playSound(SOUND_BG, sound, size, &_bgSoundHandle);
    10441053}
    10451054
    1046 int SkySound::playSound(byte *sound, uint32 size, PlayingSoundHandle *handle) {
     1055int SkySound::playSound(uint32 id, byte *sound, uint32 size, PlayingSoundHandle *handle) {
    10471056
    10481057        byte flags = 0;
    10491058        flags |= SoundMixer::FLAG_UNSIGNED|SoundMixer::FLAG_AUTOFREE;
    10501059        size -= sizeof(struct dataFileHeader);
    10511060        byte *buffer = (byte *)malloc(size);
    10521061        memcpy(buffer, sound+sizeof(struct dataFileHeader), size);     
    1053        
    1054         return _mixer->playRaw(handle, buffer, size, 11025, flags);
     1062
     1063        _mixer->stopID(id);
     1064        return _mixer->playRaw(handle, buffer, size, 11025, flags, id);
    10551065}
    10561066
    10571067void SkySound::loadSection(uint8 pSection) {
     
    10741084
    10751085void SkySound::playSound(uint16 sound, uint16 volume, uint8 channel) {
    10761086
    1077         if (channel == 0) {
    1078                 if ((_slot0 >= 0) && ((_slot0 != _spSlot) || (!_ingameSpeech))) {
    1079                         _mixer->stop(_slot0);
    1080                         _slot0 = -1;
    1081                 }
    1082         } else {
    1083                 if ((_slot1 >= 0) && ((_slot1 != _spSlot) || (!_ingameSpeech))){
    1084                         _mixer->stop(_slot1);
    1085                         _slot1 = -1;
    1086                 }
    1087         }
     1087        if (channel == 0)
     1088                _mixer->stopID(SOUND_CH0);
     1089        else
     1090                _mixer->stopID(SOUND_CH1);
    10881091
    10891092        if (!_soundData) {
    10901093                warning("SkySound::playSound(%04X, %04X) called with a section having been loaded.\n", sound, volume);
     
    11131116       
    11141117        _mixer->setVolume(volume);
    11151118        if (channel == 0)
    1116                 _slot0 = _mixer->playRaw(&_ingameSound0, _soundData + dataOfs, dataSize, sampleRate, flags);
     1119                _mixer->playRaw(&_ingameSound0, _soundData + dataOfs, dataSize, sampleRate, flags, SOUND_CH0);
    11171120        else
    1118                 _slot1 = _mixer->playRaw(&_ingameSound1, _soundData + dataOfs, dataSize, sampleRate, flags);
     1121                _mixer->playRaw(&_ingameSound1, _soundData + dataOfs, dataSize, sampleRate, flags, SOUND_CH1);
    11191122}
    11201123
    11211124void SkySound::fnStartFx(uint32 sound, uint8 channel) {
     
    12051208}
    12061209
    12071210void SkySound::fnStopFx(void) {
    1208         if (_slot0 >= 0) _mixer->stop(_slot0);
    1209         if (_slot1 >= 0) _mixer->stop(_slot1);
    1210         _slot0 = _slot1 = -1;
     1211        _mixer->stopID(SOUND_CH0);
     1212        _mixer->stopID(SOUND_CH1);
    12111213        _saveSounds[0] = _saveSounds[1] = 0xFFFF;
    12121214}
    12131215
     
    12291231
    12301232        free(speechData);
    12311233
    1232         _spSlot = _mixer->playRaw(&_ingameSpeech, playBuffer, speechSize, 11025, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
     1234        _mixer->stopID(SOUND_SPEECH);
     1235        _mixer->playRaw(&_ingameSpeech, playBuffer, speechSize, 11025, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
    12331236        return true;
    12341237}
  • scummvm/sky/sound.h

    diff -ur ScummVM+orig/scummvm/sky/sound.h ScummVM+hack/scummvm/sky/sound.h
    old new  
    4747
    4848protected:
    4949
    50         int playSound(byte *sound, uint32 size, PlayingSoundHandle *handle);
     50        int playSound(uint32 id, byte *sound, uint32 size, PlayingSoundHandle *handle);
    5151
    5252public:
    5353        SkySound(SoundMixer *mixer, SkyDisk *pDisk);
     
    7272        uint16 _sfxBaseOfs;
    7373        uint8 *_soundData;
    7474        uint8 *_sampleRates, *_sfxInfo;
    75         int _slot0, _slot1, _spSlot;
    7675
    7776        static uint16 _speechConvertTable[8];
    7877        static SfxQueue _sfxQueue[MAX_QUEUED_FX];