Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 17, 2005, 3:22:37 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/openAL: added flush-function i talked of in the Wiki

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/openAL/src/lib/sound/sound_engine.cc

    r4206 r4207  
    190190  SoundEngine::singletonRef = NULL;
    191191
    192   // deleting all the Resources
     192  // deleting all the SoundSources
    193193  tIterator<SoundSource>* sourceIterator = this->sourceList->getIterator();
    194194  SoundSource* enumSource = sourceIterator->nextElement();
     
    200200  delete sourceIterator;
    201201
     202  // deleting all the SoundBuffers
    202203  tIterator<SoundBuffer>* bufferIterator = this->bufferList->getIterator();
    203204  SoundBuffer* enumBuffer = bufferIterator->nextElement();
     
    315316
    316317/**
     318   \brief Removes all the Buffers that are not anymore needed by any Sources
     319*/
     320void SoundEngine::flushUnusedBuffers(void)
     321{
     322  tIterator<SoundBuffer>* bufferIterator = this->bufferList->getIterator();
     323  SoundBuffer* enumBuffer = bufferIterator->nextElement();
     324  while (enumBuffer)
     325    {
     326      tIterator<SoundSource>* sourceIterator = this->sourceList->getIterator();
     327      SoundSource* enumSource = sourceIterator->nextElement();
     328      while (enumSource)
     329        {
     330          if (enumBuffer == enumSource->getBuffer())
     331            break;
     332          enumSource = sourceIterator->nextElement();
     333        }
     334      delete sourceIterator;
     335      if (enumSource == NULL)
     336        ResourceManager::getInstance()->unload(enumBuffer);
     337      enumBuffer = bufferIterator->nextElement();
     338    }
     339  delete bufferIterator;
     340}
     341
     342/**
    317343   \brief initializes Audio in general
    318344*/
Note: See TracChangeset for help on using the changeset viewer.