Changeset 9686 in orxonox.OLD for branches/new_class_id/src/lib/sound/sound_engine.cc
- Timestamp:
- Aug 22, 2006, 2:36:54 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/sound/sound_engine.cc
r9235 r9686 20 20 21 21 #include "sound_engine.h" 22 23 #include "class_list.h"24 22 25 23 #include "p_node.h" … … 31 29 namespace OrxSound 32 30 { 33 31 NewObjectListDefinition(SoundEngine); 34 32 ////////////////// 35 33 /* SOUND-ENGINE */ … … 40 38 SoundEngine::SoundEngine () 41 39 { 42 this-> setClassID(CL_SOUND_ENGINE, "SoundEngine");40 this->registerObject(this, SoundEngine::_objectList); 43 41 this->setName("SoundEngine"); 44 42 45 43 this->listener = NULL; 46 this->bufferList = NULL;47 this->sourceList = NULL;48 44 49 45 this->device = NULL; … … 69 65 { 70 66 // deleting all the SoundSources 71 if(this->sourceList != NULL) 72 { 73 while (this->sourceList->size() > 0) 74 delete static_cast<SoundSource*>(this->sourceList->front()); 75 } 67 while (!SoundSource::objectList().empty()) 68 delete (SoundSource::objectList().front()); 76 69 77 70 while(!this->ALSources.empty()) … … 89 82 90 83 // deleting all the SoundBuffers 91 if (this->bufferList != NULL) 92 { 93 while(this->bufferList->size() > 0) 94 ResourceManager::getInstance()->unload(static_cast<SoundBuffer*>(this->bufferList->front())); 95 } 84 while(!SoundBuffer::objectList().empty()) 85 ResourceManager::getInstance()->unload(SoundBuffer::objectList().front()); 96 86 97 87 // removing openAL from AudioResource … … 212 202 213 203 // updating all the Sources positions 214 if (likely(this->sourceList != NULL || (this->sourceList = ClassList::getList(CL_SOUND_SOURCE)) != NULL)) 215 { 216 std::list<BaseObject*>::const_iterator sourceIT; 217 SoundSource* source; 218 for (sourceIT = this->sourceList->begin(); sourceIT != this->sourceList->end(); sourceIT++) 204 NewObjectList<SoundSource>::const_iterator sourceIT; 205 for (sourceIT = SoundSource::objectList().begin(); 206 sourceIT != SoundSource::objectList().end(); 207 sourceIT++) 208 { 209 if ((*sourceIT)->isPlaying()) 219 210 { 220 source = static_cast<SoundSource*>(*sourceIT); 221 if (source->isPlaying()) 211 int play = 0x000; 212 alGetSourcei((*sourceIT)->getID(), AL_SOURCE_STATE, &play); 213 if (DEBUG_LEVEL > 2) 214 SoundEngine::checkError("SoundEngine::update() Play", __LINE__); 215 if(play == AL_PLAYING) 222 216 { 223 int play = 0x000; 224 alGetSourcei(source->getID(), AL_SOURCE_STATE, &play); 225 if (DEBUG_LEVEL > 2) 226 SoundEngine::checkError("SoundEngine::update() Play", __LINE__); 227 if(play == AL_PLAYING) 217 if (likely((*sourceIT)->getNode() != NULL)) 228 218 { 229 if (likely(source->getNode() != NULL)) 230 { 231 alSource3f(source->getID(), AL_POSITION, 232 source->getNode()->getAbsCoor().x, 233 source->getNode()->getAbsCoor().y, 234 source->getNode()->getAbsCoor().z); 235 if (DEBUG_LEVEL > 2) 236 SoundEngine::checkError("SoundEngine::update() Set Source Position", __LINE__); 237 alSource3f(source->getID(), AL_VELOCITY, 238 source->getNode()->getVelocity().x, 239 source->getNode()->getVelocity().y, 240 source->getNode()->getVelocity().z); 241 if (DEBUG_LEVEL > 2) 242 SoundEngine::checkError("SoundEngine::update() Set Source Velocity", __LINE__); 243 } 219 alSource3f((*sourceIT)->getID(), AL_POSITION, 220 (*sourceIT)->getNode()->getAbsCoor().x, 221 (*sourceIT)->getNode()->getAbsCoor().y, 222 (*sourceIT)->getNode()->getAbsCoor().z); 223 if (DEBUG_LEVEL > 2) 224 SoundEngine::checkError("SoundEngine::update() Set Source Position", __LINE__); 225 alSource3f((*sourceIT)->getID(), AL_VELOCITY, 226 (*sourceIT)->getNode()->getVelocity().x, 227 (*sourceIT)->getNode()->getVelocity().y, 228 (*sourceIT)->getNode()->getVelocity().z); 229 if (DEBUG_LEVEL > 2) 230 SoundEngine::checkError("SoundEngine::update() Set Source Velocity", __LINE__); 244 231 } 245 else246 {247 source->stop();248 }232 } 233 else 234 { 235 (*sourceIT)->stop(); 249 236 } 250 237 } … … 393 380 default: 394 381 case AL_NO_ERROR: 395 382 return ("AL_NO_ERROR"); 396 383 case AL_INVALID_NAME: 397 384 return ("AL_INVALID_NAME"); 398 385 case AL_INVALID_ENUM: 399 386 return ("AL_INVALID_ENUM"); 400 387 case AL_INVALID_VALUE: 401 388 return ("AL_INVALID_VALUE"); 402 389 case AL_INVALID_OPERATION: 403 390 return ("AL_INVALID_OPERATION"); 404 391 case AL_OUT_OF_MEMORY: 405 392 return ("AL_OUT_OF_MEMORY"); 406 393 }; 407 394 } … … 414 401 default: 415 402 case ALC_NO_ERROR: 416 403 return ("AL_NO_ERROR"); 417 404 case ALC_INVALID_DEVICE: 418 405 return ("ALC_INVALID_DEVICE"); 419 406 case ALC_INVALID_CONTEXT: 420 407 return("ALC_INVALID_CONTEXT"); 421 408 case ALC_INVALID_ENUM: 422 409 return("ALC_INVALID_ENUM"); 423 410 case ALC_INVALID_VALUE: 424 411 return ("ALC_INVALID_VALUE"); 425 412 case ALC_OUT_OF_MEMORY: 426 413 return("ALC_OUT_OF_MEMORY"); 427 414 }; 428 415 }
Note: See TracChangeset
for help on using the changeset viewer.