Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 11, 2011, 4:05:55 PM (14 years ago)
Author:
landauf
Message:

fixed (?) an endless loop in SoundManager::preUpdate if a non-looping ambient sound faded out. maybe solved the problem by returning a bool from stop() depending on whether or not the sound source was destroyed.

someone who knows more about the sound system should probably have a look at this.

Location:
code/trunk/src/orxonox/sound
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/sound/AmbientSound.cc

    r7854 r7856  
    5757    }
    5858
    59     void AmbientSound::stop()
     59    bool AmbientSound::stop()
    6060    {
    6161        if (GameMode::playsSound())
    6262            SoundManager::getInstance().unregisterAmbientSound(this);
     63        return false; // sound source not (yet) destroyed - return false
    6364    }
    6465
  • code/trunk/src/orxonox/sound/AmbientSound.h

    r7854 r7856  
    5151
    5252        void play();
    53         void stop();
     53        bool stop();
    5454        void pause();
    5555
  • code/trunk/src/orxonox/sound/BaseSound.cc

    r7163 r7856  
    9696    }
    9797
    98     void BaseSound::doStop()
     98    bool BaseSound::doStop()
    9999    {
    100100        this->state_ = Stopped;
     
    109109            this->audioSource_ += 123455;
    110110            while (alIsSource(++this->audioSource_));
    111         }
     111           
     112            return true; // sound source destroyed - return true
     113        }
     114        return false; // nothing done - return false
    112115    }
    113116
  • code/trunk/src/orxonox/sound/BaseSound.h

    r7854 r7856  
    5151
    5252        virtual void play()  { this->doPlay(); }
    53         virtual void stop()  { this->doStop(); }
     53        virtual bool stop()  { return this->doStop(); } // returns true if the sound source was destroyed
    5454        virtual void pause() { this->doPause(); }
    5555
     
    8686
    8787        void doPlay();
    88         void doStop();
     88        bool doStop(); // returns true if the sound source was destroyed
    8989        void doPause();
    9090
  • code/trunk/src/orxonox/sound/SoundManager.cc

    r7855 r7856  
    241241            if (state == AL_STOPPED)
    242242            {
    243                 this->usedSoundSources_[i].second->stop();
    244                 --i;
     243                if (this->usedSoundSources_[i].second->stop()) // if stop() returns true, the sound source was removed, thus decrement the array index
     244                    --i;
    245245            }
    246246        }
Note: See TracChangeset for help on using the changeset viewer.