- Timestamp:
- Jan 10, 2016, 1:54:11 PM (9 years ago)
- Location:
- code/branches/cpp11_v3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v3
- Property svn:mergeinfo changed
-
code/branches/cpp11_v3/src/orxonox/sound/SoundManager.cc
r10624 r11054 83 83 ThrowException(InitialisationAborted, "Sound: Not loading at all"); 84 84 #if !defined(ORXONOX_PLATFORM_APPLE) 85 if (!alutInitWithoutContext( NULL, NULL))85 if (!alutInitWithoutContext(nullptr, nullptr)) 86 86 ThrowException(InitialisationFailed, "Sound Error: ALUT initialisation failed: " << alutGetErrorString(alutGetError())); 87 87 Loki::ScopeGuard alutExitGuard = Loki::MakeGuard(&alutExit); … … 90 90 /* 91 91 // Get list of available sound devices and display them 92 const char* devices = alcGetString( NULL, ALC_DEVICE_SPECIFIER);92 const char* devices = alcGetString(nullptr, ALC_DEVICE_SPECIFIER); 93 93 char* device = new char[strlen(devices)+1]; 94 94 strcpy(device, devices); … … 110 110 this->device_ = alcOpenDevice(renderDevice.c_str()); 111 111 */ 112 this->device_ = alcOpenDevice( NULL);113 if (this->device_ == NULL)112 this->device_ = alcOpenDevice(nullptr); 113 if (this->device_ == nullptr) 114 114 ThrowException(InitialisationFailed, "Sound Error: Could not open sound device."); 115 115 Loki::ScopeGuard closeDeviceGuard = Loki::MakeGuard(&alcCloseDevice, this->device_); 116 116 117 117 // Create sound context and make it the currently used one 118 this->context_ = alcCreateContext(this->device_, NULL);119 if (this->context_ == NULL)118 this->context_ = alcCreateContext(this->device_, nullptr); 119 if (this->context_ == nullptr) 120 120 ThrowException(InitialisationFailed, "Sound Error: Could not create ALC context"); 121 121 Loki::ScopeGuard desroyContextGuard = Loki::MakeGuard(&alcDestroyContext, this->context_); … … 189 189 190 190 // Relieve context to destroy it 191 if (!alcMakeContextCurrent( NULL))191 if (!alcMakeContextCurrent(nullptr)) 192 192 orxout(internal_error, context::sound) << "Could not unset ALC context" << endl; 193 193 alcDestroyContext(this->context_); … … 294 294 { 295 295 case SoundType::All: 296 for ( ObjectList<BaseSound>::iterator it = ObjectList<BaseSound>::begin(); it != ObjectList<BaseSound>::end(); ++it)297 (*it)->updateVolume();296 for (BaseSound* sound : ObjectList<BaseSound>()) 297 sound->updateVolume(); 298 298 break; 299 299 case SoundType::Music: 300 for ( ObjectList<AmbientSound>::iterator it = ObjectList<AmbientSound>::begin(); it != ObjectList<AmbientSound>::end(); ++it)301 (*it)->updateVolume();300 for (AmbientSound* sound : ObjectList<AmbientSound>()) 301 sound->updateVolume(); 302 302 break; 303 303 case SoundType::Effects: 304 for ( ObjectList<WorldSound>::iterator it = ObjectList<WorldSound>::begin(); it != ObjectList<WorldSound>::end(); ++it)305 (*it)->updateVolume();304 for (WorldSound* sound : ObjectList<WorldSound>()) 305 sound->updateVolume(); 306 306 break; 307 307 default: … … 350 350 void SoundManager::registerAmbientSound(AmbientSound* newAmbient) 351 351 { 352 if (newAmbient != NULL&& !this->bDestructorCalled_)352 if (newAmbient != nullptr && !this->bDestructorCalled_) 353 353 { 354 354 for (AmbientList::const_iterator it = this->ambientSounds_.begin(); it != this->ambientSounds_.end(); ++it) … … 373 373 void SoundManager::unregisterAmbientSound(AmbientSound* oldAmbient) 374 374 { 375 if (oldAmbient == NULL|| ambientSounds_.empty() || this->bDestructorCalled_)375 if (oldAmbient == nullptr || ambientSounds_.empty() || this->bDestructorCalled_) 376 376 return; 377 377 … … 405 405 void SoundManager::pauseAmbientSound(AmbientSound* ambient) 406 406 { 407 if (ambient != NULL)408 { 409 for ( AmbientList::iterator it = this->ambientSounds_.begin(); it != this->ambientSounds_.end(); ++it)410 { 411 if ( it->first == ambient)407 if (ambient != nullptr) 408 { 409 for (std::pair<AmbientSound*, bool>& pair : this->ambientSounds_) 410 { 411 if (pair.first == ambient) 412 412 { 413 it->second = true;414 this->fadeOut( it->first);413 pair.second = true; 414 this->fadeOut(pair.first); 415 415 return; 416 416 } … … 422 422 { 423 423 // If we're already fading out --> remove that 424 for (std::list<StrongPtr<AmbientSound> 424 for (std::list<StrongPtr<AmbientSound>>::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++) 425 425 { 426 426 if (*it == sound) … … 438 438 { 439 439 // If we're already fading in --> remove that 440 for (std::list<StrongPtr<AmbientSound> 440 for (std::list<StrongPtr<AmbientSound>>::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++) 441 441 { 442 442 if (*it == sound) … … 461 461 462 462 // FADE IN 463 for (std::list<StrongPtr<AmbientSound> 463 for (std::list<StrongPtr<AmbientSound>>::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); ) 464 464 { 465 465 if ((*it)->getVolume() + this->crossFadeStep_*dt > 1.0f) … … 476 476 477 477 // FADE OUT 478 for (std::list<StrongPtr<AmbientSound> 478 for (std::list<StrongPtr<AmbientSound>>::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); ) 479 479 { 480 480 if ((*it)->getVolume() - this->crossFadeStep_*dt < 0.0f) … … 505 505 } 506 506 507 s hared_ptr<SoundBuffer> SoundManager::getSoundBuffer(const std::string& filename)508 { 509 s hared_ptr<SoundBuffer> buffer;507 std::shared_ptr<SoundBuffer> SoundManager::getSoundBuffer(const std::string& filename) 508 { 509 std::shared_ptr<SoundBuffer> buffer; 510 510 // Check active or pooled buffers 511 511 SoundBufferMap::const_iterator it = this->soundBuffers_.find(filename); … … 538 538 } 539 539 540 void SoundManager::releaseSoundBuffer(const s hared_ptr<SoundBuffer>& buffer, bool bPoolBuffer)540 void SoundManager::releaseSoundBuffer(const std::shared_ptr<SoundBuffer>& buffer, bool bPoolBuffer) 541 541 { 542 542 // Check if others are still using the buffer … … 551 551 while (this->effectsPoolSize_ + it->second->getSize() > this->maxEffectsPoolSize_s && !this->effectsPool_.empty()) 552 552 { 553 s hared_ptr<SoundBuffer> bufferDel = this->effectsPool_.back();553 std::shared_ptr<SoundBuffer> bufferDel = this->effectsPool_.back(); 554 554 this->effectsPoolSize_ -= bufferDel->getSize(); 555 555 bufferDel->poolIterator_ = this->effectsPool_.end(); … … 576 576 ALuint source = this->availableSoundSources_.back(); 577 577 this->availableSoundSources_.pop_back(); 578 this->usedSoundSources_. push_back(std::make_pair(source, object));578 this->usedSoundSources_.emplace_back(source, object); 579 579 return source; 580 580 } … … 588 588 if (alIsSource(source) && !alGetError()) 589 589 { 590 this->usedSoundSources_. push_back(std::make_pair(source, object));590 this->usedSoundSources_.emplace_back(source, object); 591 591 return source; 592 592 } … … 606 606 #endif 607 607 this->availableSoundSources_.push_back(source); 608 for (std::vector<std::pair<ALuint, BaseSound*> 608 for (std::vector<std::pair<ALuint, BaseSound*>>::iterator it = this->usedSoundSources_.begin(); 609 609 it != this->usedSoundSources_.end(); ++it) 610 610 {
Note: See TracChangeset
for help on using the changeset viewer.