Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4207 in orxonox.OLD for orxonox/branches/openAL/src/lib


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

Location:
orxonox/branches/openAL/src/lib/sound
Files:
2 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*/
  • orxonox/branches/openAL/src/lib/sound/sound_engine.h

    r4206 r4207  
    5151
    5252  // development functions
    53   /** \returns The ID of the Source */
    54   inline ALuint getID(void) { return this->sourceID; }
     53  /** \returns The ID of this Source */
     54  inline ALuint getID(void) const { return this->sourceID; }
     55  /** \returns the SoundBuffer of this Source */
     56  inline SoundBuffer* getBuffer(void) const { return this->buffer; }
    5557  /** \returns the SourceNode of this Source */
    56   inline PNode* getNode(void) { return this->sourceNode;}
     58  inline PNode* getNode(void) const { return this->sourceNode;}
    5759
    5860  void setRolloffFactor(ALfloat rolloffFactor);
     
    8284  void removeSource(SoundSource* source);
    8385
    84 
    8586  void update(void);
    8687
     88  void flushUnusedBuffers(void);
    8789
    8890  // error handling:
Note: See TracChangeset for help on using the changeset viewer.