Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5962


Ignore:
Timestamp:
Oct 16, 2009, 7:10:03 PM (15 years ago)
Author:
rgrieder
Message:

Fixed sound reloading problem. The solution was in fact to first stop the playback (how trivial and yet unexpected…)

File:
1 edited

Legend:

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

    r5957 r5962  
    111111    void BaseSound::setSource(const std::string& source)
    112112    {
    113         if (!GameMode::playsSound())
     113        if (!GameMode::playsSound() || source == this->source_)
    114114        {
    115115            this->source_ = source;
     
    117117        }
    118118       
    119         if (this->source_ != source && alIsSource(this->audioSource_))
    120         {
    121             // Unload sound
     119        if (alIsSource(this->audioSource_))
     120        {
     121            this->stop();
     122            // Unload old sound first
    122123            alSourcei(this->audioSource_, AL_BUFFER, 0);
    123124            alDeleteSources(1, &this->audioSource_);
     125            this->audioSource_ = 0;
    124126            alDeleteBuffers(1, &this->audioBuffer_);
     127            this->audioBuffer_ = 0;
    125128        }
    126129
    127130        this->source_ = source;
    128 
    129         if(source_.empty())
    130         {
    131             return;
    132         }
     131        if (source_.empty())
     132            return;
    133133
    134134        COUT(3) << "Sound: OpenAL ALUT: loading file " << source << std::endl;
Note: See TracChangeset for help on using the changeset viewer.