Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5779 in orxonox.OLD for trunk/src/lib/sound


Ignore:
Timestamp:
Nov 26, 2005, 2:20:58 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: ClassList is now in std::list style
ShellCommand is now in std::list style

Location:
trunk/src/lib/sound
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/sound/sound_engine.cc

    r5473 r5779  
    6363  if(this->sourceList != NULL)
    6464  {
    65     tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();
    66     SoundSource* enumSource = (SoundSource*)sourceIterator->firstElement();
    67     while (enumSource)
    68     {
    69         delete enumSource;
    70         enumSource = (SoundSource*)sourceIterator->nextElement();
    71     }
    72     delete sourceIterator;
     65    while (this->sourceList->size() > 0)
     66      delete dynamic_cast<SoundSource*>(this->sourceList->front());
    7367  }
    7468
     
    7670  if (this->bufferList != NULL)
    7771  {
    78     tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
    79     SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->firstElement();
    80     while (enumBuffer)
    81     {
    82       ResourceManager::getInstance()->unload(enumBuffer);
    83       enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
    84     }
    85     delete bufferIterator;
     72    while(this->bufferList->size() > 0)
     73      ResourceManager::getInstance()->unload(dynamic_cast<SoundBuffer*>(this->bufferList->front()));
    8674  }
    8775
     
    148136{
    149137  // look if there are any sources that have the buffer still loaded
    150   tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();
    151   SoundSource* enumSource = (SoundSource*)sourceIterator->firstElement();
    152   while (enumSource)
    153     {
    154       if (buffer == enumSource->getBuffer())
    155         delete enumSource;
    156       enumSource = (SoundSource*)sourceIterator->nextElement();
     138  if (this->sourceList != NULL)
     139  {
     140    list<BaseObject*>::iterator source;
     141    for (source = this->sourceList->begin(); source != this->sourceList->end(); source++)
     142    {
     143      if (buffer == static_cast<SoundSource*>(*source)->getBuffer())
     144        delete (*source);
    157145    }
    158   delete sourceIterator;
     146  }
    159147}
    160148
     
    195183  if (likely(this->sourceList != NULL))
    196184  {
    197     tIterator<BaseObject>* iterator = this->sourceList->getIterator();
    198     SoundSource* enumSource = (SoundSource*)iterator->firstElement();
    199     while (enumSource)
    200     {
    201       if (likely(enumSource->getNode() != NULL))
     185    list<BaseObject*>::iterator sourceIT;
     186    SoundSource* source;
     187    for (sourceIT = this->sourceList->begin(); sourceIT != this->sourceList->end(); sourceIT++)
     188    {
     189      source = static_cast<SoundSource*>(*sourceIT);
     190      if (likely(source->getNode() != NULL))
    202191      {
    203         alSource3f(enumSource->getID(), AL_POSITION,
    204                    enumSource->getNode()->getAbsCoor().x,
    205                    enumSource->getNode()->getAbsCoor().y,
    206                    enumSource->getNode()->getAbsCoor().z);
    207         alSource3f(enumSource->getID(), AL_VELOCITY,
    208                    enumSource->getNode()->getVelocity().x,
    209                    enumSource->getNode()->getVelocity().y,
    210                    enumSource->getNode()->getVelocity().z);
     192        alSource3f(source->getID(), AL_POSITION,
     193                   source->getNode()->getAbsCoor().x,
     194                   source->getNode()->getAbsCoor().y,
     195                   source->getNode()->getAbsCoor().z);
     196        alSource3f(source->getID(), AL_VELOCITY,
     197                   source->getNode()->getVelocity().x,
     198                   source->getNode()->getVelocity().y,
     199                   source->getNode()->getVelocity().z);
    211200      }
    212       enumSource = (SoundSource*)iterator->nextElement();
    213201    }
    214     delete iterator;
    215202  }
    216203}
     
    221208void SoundEngine::flushUnusedBuffers()
    222209{
    223   if(this->sourceList && this->bufferList)
     210/*  if(this->sourceList && this->bufferList)
    224211  {
    225212    tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
     
    241228    }
    242229    delete bufferIterator;
    243   }
     230}*/ /// FIXME
    244231}
    245232
     
    252239  if (this->bufferList)
    253240  {
    254     tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
    255     SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->firstElement();
    256     while (enumBuffer)
    257     {
    258       ResourceManager::getInstance()->unload(enumBuffer, RP_LEVEL);
    259       enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
    260     }
    261     delete bufferIterator;
     241    while (this->bufferList->size() > 0)
     242      ResourceManager::getInstance()->unload(static_cast<SoundBuffer*>(this->bufferList->front()), RP_LEVEL);
    262243  }
    263244}
     
    270251  if (this->sourceList)
    271252  {
    272     tIterator<BaseObject>* Iterator = this->sourceList->getIterator();
    273     SoundSource* enumSource = (SoundSource*)Iterator->firstElement();
    274     while (enumSource)
    275     {
    276       delete enumSource;
    277       enumSource = (SoundSource*)Iterator->nextElement();
    278     }
    279     delete Iterator;
     253    while(this->sourceList->size() > 0)
     254      delete this->sourceList->front();
    280255  }
    281256}
  • trunk/src/lib/sound/sound_engine.h

    r5405 r5779  
    1313#include "sound_source.h"
    1414
     15#include <list>
     16
    1517#define SOUND_DOPPLER_FACTOR       0.001          //!< A factor for the audible doppler effect
    1618#define SOUND_DOPPLER_VELOCITY     5000000        //!< A factor for the TravelSpeed of sound
     
    1820// FORWARD DECLARATION
    1921class PNode;
    20 template<class T> class tList;
    2122class IniParser;
    2223
     
    7071    float                    effectsVolume;            //!< the maximum volume of sound-effects in % (0f,1f]
    7172    PNode*                   listener;                 //!< The listener of the Scene
    72     tList<BaseObject>*       bufferList;               //!< A list of buffers
    73     tList<BaseObject>*       sourceList;               //!< A list for all the sources in the scene.
     73    std::list<BaseObject*>*  bufferList;               //!< A list of buffers
     74    std::list<BaseObject*>*  sourceList;               //!< A list for all the sources in the scene.
    7475
    7576};
Note: See TracChangeset for help on using the changeset viewer.