Changeset 6383 for code/branches/presentation2/src
- Timestamp:
- Dec 19, 2009, 10:14:08 PM (15 years ago)
- Location:
- code/branches/presentation2/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc
r6381 r6383 115 115 { 116 116 if (GameMode::isMaster() && this->player_) 117 {118 117 this->player_->stopTemporaryControl(); 119 } 118 120 119 if ( this->defSndWpnEngine_ ) 121 {122 if ( this->defSndWpnEngine_->isPlaying() )123 this->defSndWpnEngine_->stop();124 120 this->defSndWpnEngine_->destroy(); 125 } 121 126 122 if ( this->defSndWpnLaunch_ ) 127 {128 if ( this->defSndWpnLaunch_->isPlaying())129 this->defSndWpnLaunch_->stop();130 123 this->defSndWpnLaunch_->destroy(); 131 }132 124 } 133 125 } -
code/branches/presentation2/src/orxonox/sound/BaseSound.cc
r6382 r6383 77 77 if (!alIsSource(this->audioSource_)) 78 78 { 79 this->audioSource_ = SoundManager::getInstance().getSoundSource( );79 this->audioSource_ = SoundManager::getInstance().getSoundSource(this); 80 80 if (!alIsSource(this->audioSource_)) 81 81 return; -
code/branches/presentation2/src/orxonox/sound/SoundManager.cc
r6378 r6383 145 145 alGenSources(1, &source); 146 146 if (!alGetError() && alIsSource(source)) 147 this-> soundSources_.push_back(source);147 this->availableSoundSources_.push_back(source); 148 148 else 149 149 ThrowException(InitialisationFailed, "Sound Error: Could not even create a single source"); … … 153 153 while (alIsSource(source) && !alGetError() && count <= this->maxSources_) 154 154 { 155 this-> soundSources_.push_back(source);155 this->availableSoundSources_.push_back(source); 156 156 alGenSources(1, &source); 157 157 ++count; … … 195 195 { 196 196 this->processCrossFading(time.getDeltaTime()); 197 198 // Check whether a sound object has stopped playing 199 for (unsigned int i = 0; i < this->usedSoundSources_.size(); ++i) 200 { 201 ALint state; 202 alGetSourcei(this->usedSoundSources_[i].first, AL_SOURCE_STATE, &state); 203 if (state == AL_STOPPED) 204 { 205 this->usedSoundSources_[i].second->stop(); 206 --i; 207 } 208 } 197 209 } 198 210 … … 536 548 } 537 549 538 ALuint SoundManager::getSoundSource() 539 { 540 if (!this->soundSources_.empty()) 541 { 542 ALuint source = this->soundSources_.back(); 543 this->soundSources_.pop_back(); 550 ALuint SoundManager::getSoundSource(BaseSound* object) 551 { 552 if (!this->availableSoundSources_.empty()) 553 { 554 ALuint source = this->availableSoundSources_.back(); 555 this->availableSoundSources_.pop_back(); 556 this->usedSoundSources_.push_back(std::make_pair(source, object)); 544 557 return source; 545 558 } … … 556 569 { 557 570 #ifndef NDEBUG 558 for (std::vector<ALuint>::const_iterator it = this-> soundSources_.begin(); it != this->soundSources_.end(); ++it)571 for (std::vector<ALuint>::const_iterator it = this->availableSoundSources_.begin(); it != this->availableSoundSources_.end(); ++it) 559 572 assert((*it) != source); 560 573 #endif 561 this->soundSources_.push_back(source); 574 this->availableSoundSources_.push_back(source); 575 for (std::vector<std::pair<ALuint, BaseSound*> >::iterator it = this->usedSoundSources_.begin(); 576 it != this->usedSoundSources_.end(); ++it) 577 { 578 if (it->first == source) 579 { 580 this->usedSoundSources_.erase(it); 581 break; 582 } 583 } 562 584 } 563 585 } -
code/branches/presentation2/src/orxonox/sound/SoundManager.h
r6370 r6383 102 102 void releaseSoundBuffer(const shared_ptr<SoundBuffer>& buffer, bool bPoolBuffer); 103 103 104 ALuint getSoundSource( );104 ALuint getSoundSource(BaseSound* object); 105 105 void releaseSoundSource(ALuint source); 106 106 … … 147 147 // Sound source related 148 148 unsigned int maxSources_; 149 std::vector<ALuint> soundSources_; 149 std::vector<ALuint> availableSoundSources_; 150 std::vector<std::pair<ALuint, BaseSound*> > usedSoundSources_; 150 151 151 152 static SoundManager* singletonPtr_s;
Note: See TracChangeset
for help on using the changeset viewer.