Changeset 5779 in orxonox.OLD for trunk/src/lib/sound
- Timestamp:
- Nov 26, 2005, 2:20:58 PM (19 years ago)
- Location:
- trunk/src/lib/sound
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/sound/sound_engine.cc
r5473 r5779 63 63 if(this->sourceList != NULL) 64 64 { 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()); 73 67 } 74 68 … … 76 70 if (this->bufferList != NULL) 77 71 { 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())); 86 74 } 87 75 … … 148 136 { 149 137 // 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); 157 145 } 158 delete sourceIterator;146 } 159 147 } 160 148 … … 195 183 if (likely(this->sourceList != NULL)) 196 184 { 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)) 202 191 { 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); 211 200 } 212 enumSource = (SoundSource*)iterator->nextElement();213 201 } 214 delete iterator;215 202 } 216 203 } … … 221 208 void SoundEngine::flushUnusedBuffers() 222 209 { 223 if(this->sourceList && this->bufferList)210 /* if(this->sourceList && this->bufferList) 224 211 { 225 212 tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator(); … … 241 228 } 242 229 delete bufferIterator; 243 } 230 }*/ /// FIXME 244 231 } 245 232 … … 252 239 if (this->bufferList) 253 240 { 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); 262 243 } 263 244 } … … 270 251 if (this->sourceList) 271 252 { 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(); 280 255 } 281 256 } -
trunk/src/lib/sound/sound_engine.h
r5405 r5779 13 13 #include "sound_source.h" 14 14 15 #include <list> 16 15 17 #define SOUND_DOPPLER_FACTOR 0.001 //!< A factor for the audible doppler effect 16 18 #define SOUND_DOPPLER_VELOCITY 5000000 //!< A factor for the TravelSpeed of sound … … 18 20 // FORWARD DECLARATION 19 21 class PNode; 20 template<class T> class tList;21 22 class IniParser; 22 23 … … 70 71 float effectsVolume; //!< the maximum volume of sound-effects in % (0f,1f] 71 72 PNode* listener; //!< The listener of the Scene 72 tList<BaseObject>*bufferList; //!< A list of buffers73 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. 74 75 75 76 };
Note: See TracChangeset
for help on using the changeset viewer.