- Timestamp:
- Dec 11, 2009, 2:15:43 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/src/orxonox/sound/SoundManager.cc
r6298 r6322 87 87 COUT(1) << "Sound: Just getting the DLL with the dependencies is not enough for Windows (esp. Windows 7)!" << std::endl; 88 88 #endif 89 ThrowException(InitialisationFailed, "Sound : OpenAL error: Could not open sound device.");89 ThrowException(InitialisationFailed, "Sound Error: Could not open sound device."); 90 90 } 91 91 Loki::ScopeGuard closeDeviceGuard = Loki::MakeGuard(&alcCloseDevice, this->device_); … … 100 100 101 101 GameMode::setPlaysSound(true); 102 Loki::ScopeGuard resetPlaysSoundGuard = Loki::MakeGuard(&GameMode::setPlaysSound, false); 102 103 103 104 // Get some information about the sound … … 110 111 else 111 112 COUT(2) << "Sound Warning: MIME Type retrieval failed: " << alutGetErrorString(alutGetError()) << std::endl; 113 114 this->setVolumeInternal(1.0, SoundType::none); 115 this->setVolumeInternal(1.0, SoundType::ambient); 116 this->setVolumeInternal(1.0, SoundType::effects); 117 118 this->mute_[SoundType::none] = false; 119 this->mute_[SoundType::ambient] = false; 120 this->mute_[SoundType::effects] = false; 121 122 this->setConfigValues(); 123 124 // Try to get at least one source 125 ALuint source; 126 alGenSources(1, &source); 127 if (!alGetError() && alIsSource(source)) 128 this->soundSources_.push_back(source); 129 else 130 ThrowException(InitialisationFailed, "Sound Error: Could not even create a single source"); 131 // Get the rest of the sources 132 alGenSources(1, &source); 133 unsigned int count = 1; 134 while (alIsSource(source) && !alGetError() && count <= this->maxSources_) 135 { 136 this->soundSources_.push_back(source); 137 alGenSources(1, &source); 138 ++count; 139 } 112 140 113 141 // Disarm guards … … 115 143 closeDeviceGuard.Dismiss(); 116 144 desroyContextGuard.Dismiss(); 117 118 this->setVolumeInternal(1.0, SoundType::none); 119 this->setVolumeInternal(1.0, SoundType::ambient); 120 this->setVolumeInternal(1.0, SoundType::effects); 121 122 this->mute_[SoundType::none] = false; 123 this->mute_[SoundType::ambient] = false; 124 this->mute_[SoundType::effects] = false; 125 126 this->setConfigValues(); 145 resetPlaysSoundGuard.Dismiss(); 127 146 128 147 COUT(4) << "Sound: Initialisation complete" << std::endl; … … 164 183 .description("Determines how fast sounds should fade, per second.") 165 184 .callback(this, &SoundManager::checkFadeStepValidity); 166 185 167 186 SetConfigValue(soundVolume_, 1.0f) 168 187 .description("Defines the overall volume.") 169 188 .callback(this, &SoundManager::checkSoundVolumeValidity); 170 189 171 190 SetConfigValue(ambientVolume_, 1.0f) 172 191 .description("Defines the ambient volume.") 173 192 .callback(this, &SoundManager::checkAmbientVolumeValidity); 174 193 175 194 SetConfigValue(effectsVolume_, 1.0f) 176 195 .description("Defines the effects volume.") 177 196 .callback(this, &SoundManager::checkEffectsVolumeValidity); 197 198 SetConfigValue(maxSources_, 1024) 199 .description("Maximum number of sources to be made available"); 178 200 } 179 201 … … 595 617 } 596 618 } 619 620 ALuint SoundManager::getSoundSource() 621 { 622 if (!this->soundSources_.empty()) 623 { 624 ALuint source = this->soundSources_.back(); 625 this->soundSources_.pop_back(); 626 return source; 627 } 628 else 629 { 630 // Return no source ID 631 ALuint source = 123456789; 632 while (alIsSource(++source)); 633 return source; 634 } 635 } 636 637 void SoundManager::releaseSoundSource(ALuint source) 638 { 639 #ifndef NDEBUG 640 for (std::vector<ALuint>::const_iterator it = this->soundSources_.begin(); it != this->soundSources_.end(); ++it) 641 assert((*it) != source); 642 #endif 643 this->soundSources_.push_back(source); 644 } 597 645 }
Note: See TracChangeset
for help on using the changeset viewer.