Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5954


Ignore:
Timestamp:
Oct 14, 2009, 4:59:47 PM (15 years ago)
Author:
youngk
Message:

Bug Fix: SoundBase. The old sound file is now automatically unloaded upon change of sound file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/sound3/src/orxonox/sound/BaseSound.cc

    r5946 r5954  
    111111    void BaseSound::setSource(const std::string& source)
    112112    {
    113         this->source_ = source;
    114         if (!GameMode::playsSound())
    115             return;
    116 
    117         if (source.empty() && alIsSource(this->audioSource_))
     113        if (!GameMode::playsSound())
     114        {
     115            this->source_ = source;
     116            return;
     117        }
     118       
     119        if (this->source_ != source && alIsSource(this->audioSource_))
    118120        {
    119121            // Unload sound
     
    121123            alDeleteSources(1, &this->audioSource_);
    122124            alDeleteBuffers(1, &this->audioBuffer_);
     125        }
     126
     127        this->source_ = source;
     128
     129        if(source_.empty())
     130        {
    123131            return;
    124132        }
Note: See TracChangeset for help on using the changeset viewer.