Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6260


Ignore:
Timestamp:
Dec 6, 2009, 9:46:04 PM (14 years ago)
Author:
rgrieder
Message:

Audio sources seem to be very limited resources. If we create more than available sources (usually more than 256), it will not result in a failed assert anymore. Instead, the sound will simply not load and play.

Location:
code/branches/presentation2/src/orxonox/sound
Files:
2 edited

Legend:

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

    r6255 r6260  
    5555        {
    5656            alGenSources(1, &this->audioSource_);
    57             assert(this->audioSource_ != 0);
     57            if (!alIsSource(this->audioSource_))
     58                COUT(1) << "Sound: Source generation failed: " << SoundManager::getALErrorString(alGetError()) << std::endl;
    5859        }
    5960    }
     
    6263    {
    6364        this->setSource("");
    64         if (GameMode::playsSound())
     65        if (GameMode::playsSound() && alIsSource(this->audioSource_))
    6566            alDeleteSources(1, &this->audioSource_);
    6667    }
     
    7778    {
    7879        this->state_ = Playing;
    79         if (GameMode::playsSound() && this->getSourceState() != AL_PLAYING)
     80        if (GameMode::playsSound() && alIsSource(this->audioSource_) && this->getSourceState() != AL_PLAYING)
    8081        {
    8182            alSourcePlay(this->audioSource_);
     
    8990    {
    9091        this->state_ = Stopped;
    91         if (GameMode::playsSound())
     92        if (GameMode::playsSound() && alIsSource(this->audioSource_))
    9293            alSourceStop(this->audioSource_);
    9394    }
     
    9899            return;
    99100        this->state_ = Paused;
    100         if (GameMode::playsSound())
     101        if (GameMode::playsSound() && alIsSource(this->audioSource_))
    101102            alSourcePause(this->audioSource_);
    102103    }
     
    104105    ALint BaseSound::getSourceState() const
    105106    {
    106         if (GameMode::playsSound())
     107        if (GameMode::playsSound() && alIsSource(this->audioSource_))
    107108        {
    108109            ALint state;
     
    145146    {
    146147        this->bLoop_ = val;
    147         if (GameMode::playsSound())
     148        if (GameMode::playsSound() && alIsSource(this->audioSource_))
    148149            alSourcei(this->audioSource_, AL_LOOPING, (val ? AL_TRUE : AL_FALSE));
    149150    }
     
    158159        }       
    159160        this->pitch_ = pitch;
    160         if (GameMode::playsSound())
     161        if (GameMode::playsSound() && alIsSource(this->audioSource_))
    161162        {
    162163            if (int error = alGetError())
     
    176177        if (this->soundBuffer_ != NULL)
    177178        {
    178             alSourceStop(this->audioSource_);
    179             // Unload old sound first
    180             alSourcei(this->audioSource_, AL_BUFFER, 0);
     179            if (alIsSource(this->audioSource_))
     180            {
     181                alSourceStop(this->audioSource_);
     182                // Unload old buffer first
     183                alSourcei(this->audioSource_, AL_BUFFER, 0);
     184            }
    181185            SoundManager::getInstance().releaseSoundBuffer(this->soundBuffer_, this->bPooling_);
    182186            this->soundBuffer_.reset();
     
    184188
    185189        this->source_ = source;
    186         if (source_.empty())
     190        if (source_.empty() || !alIsSource(this->audioSource_))
    187191            return;
    188192
     
    200204
    201205        alSourcei(this->audioSource_, AL_BUFFER, this->soundBuffer_->getBuffer());
    202         if (alGetError() != AL_NO_ERROR)
    203         {
    204             COUT(2) << "Sound: OpenAL: Error loading sample file: " << source << std::endl;
     206        if (ALuint error = alGetError())
     207        {
     208            COUT(1) << "Sound Error: Could not load file \"" << source << "\": " << SoundManager::getALErrorString << std::endl;
    205209            return;
    206210        }
  • code/branches/presentation2/src/orxonox/sound/SoundBuffer.cc

    r6254 r6260  
    8787        delete[] buffer;
    8888
    89         if (this->audioBuffer_ == AL_NONE)
     89        if (!alIsBuffer(this->audioBuffer_))
    9090            ThrowException(General, "Sound Error: Standard file loader failed: " << alutGetErrorString(alutGetError()));
    9191    }
     
    170170        ov_clear(&vf);
    171171
    172         if (this->audioBuffer_ == AL_NONE)
     172        if (!alIsBuffer(this->audioBuffer_))
    173173            ThrowException(General, "Sound: Ogg file loader failed when creating the buffer.");
    174174    }
Note: See TracChangeset for help on using the changeset viewer.