Ticket #1643: dimuse-idea.diff

File dimuse-idea.diff, 3.1 KB (added by eriktorbjorn, 20 years ago)

Patch against a June 17 CVS snapshot

  • scumm/imuse_digi/dimuse.h

    diff -ur ScummVM-cvs20040617/scumm/imuse_digi/dimuse.h ScummVM-cvs20040617+hack/scumm/imuse_digi/dimuse.h
    old new  
    159159        void refreshScripts();
    160160        void flushTracks();
    161161        int getSoundStatus(int sound) const;
     162        bool isSoundInUse(int sound) const;
    162163        int32 getCurMusicPosInMs();
    163164        int32 getCurVoiceLipSyncWidth();
    164165        int32 getCurVoiceLipSyncHeight();
  • scumm/imuse_digi/dimuse_script.cpp

    diff -ur ScummVM-cvs20040617/scumm/imuse_digi/dimuse_script.cpp ScummVM-cvs20040617+hack/scumm/imuse_digi/dimuse_script.cpp
    old new  
    274274        return 0;
    275275}
    276276
     277bool IMuseDigital::isSoundInUse(int sound) const {
     278        Common::StackLock lock(_mutex, "IMuseDigital::isSoundInUse()");
     279
     280        for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
     281                Track *track = _track[l];
     282                if (track->soundId == sound)
     283                        return true;
     284        }
     285        return false;
     286}
     287
    277288void IMuseDigital::stopSound(int soundId) {
    278289        debug(5, "IMuseDigital::stopSound(%d)", soundId);
    279290        for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
  • scumm/imuse_digi/dimuse_sndmgr.cpp

    diff -ur ScummVM-cvs20040617/scumm/imuse_digi/dimuse_sndmgr.cpp ScummVM-cvs20040617+hack/scumm/imuse_digi/dimuse_sndmgr.cpp
    old new  
    302302                _sounds[slot].name[0] = 0;
    303303                if ((soundType == IMUSE_RESOURCE)) {
    304304                        _vm->ensureResourceLoaded(rtSound, soundId);
    305                         _vm->lock(rtSound, soundId);
    306305                        ptr = _vm->getResourceAddress(rtSound, soundId);
    307306                        if (ptr == NULL) {
    308307                                closeSound(&_sounds[slot]);
     
    371370void ImuseDigiSndMgr::closeSound(soundStruct *soundHandle) {
    372371        assert(soundHandle && checkForProperHandle(soundHandle));
    373372
    374         if (soundHandle->resPtr)
    375                 _vm->unlock(rtSound, soundHandle->soundId);
    376 
    377373        delete soundHandle->bundle;
    378374        for (int r = 0; r < soundHandle->numSyncs; r++)
    379375                free(soundHandle->sync[r].ptr);
  • scumm/sound.cpp

    diff -ur ScummVM-cvs20040617/scumm/sound.cpp ScummVM-cvs20040617+hack/scumm/sound.cpp
    old new  
    679679 * are being faded out: get_sound_active() returns true even when the
    680680 * sound is being faded out, while getSoundStatus() returns false in
    681681 * that case.
     682 * In addition, it calls isSoundInUse() instead of getSoundStatus() in
     683 * IMuseDigital. The difference between these two is that the isSoundInUse()
     684 * doesn't require that the mixer is playing the sound at the moment.
    682685 */
    683686bool Sound::isSoundInUse(int sound) const {
    684687
    685688        if (_vm->_imuseDigital)
    686                 return (_vm->_imuseDigital->getSoundStatus(sound) != 0);
     689                return _vm->_imuseDigital->isSoundInUse(sound);
    687690
    688691        if (sound == _currentCDSound)
    689692                return pollCD() != 0;