- Timestamp:
- Mar 1, 2011, 5:10:29 AM (13 years ago)
- Location:
- code/branches/usability
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/usability
- Property svn:mergeinfo changed
/code/branches/sound4 (added) merged: 6435,6476,6504 /code/branches/sound5 (added) merged: 6505-6511,6562,6674,6726,6729-6730,6733,6767,6769,6931,6962,7720
- Property svn:mergeinfo changed
-
code/branches/usability/src/orxonox/sound/SoundManager.cc
r7858 r8005 22 22 * Author: 23 23 * Erwin 'vaiursch' Herrsche 24 * 25 * Co-authors: 24 26 * Kevin Young 25 27 * Reto Grieder 26 * Co-authors:27 * ...28 28 * 29 29 */ … … 52 52 ManageScopedSingleton(SoundManager, ScopeID::Graphics, true); 53 53 54 std::string SoundManager::getALErrorString(ALenum code) 54 // From SoundPrereqs.h 55 std::string getALErrorString(ALenum code) 55 56 { 56 57 switch (code) … … 80 81 81 82 if (!alutInitWithoutContext(NULL, NULL)) 82 ThrowException(InitialisationFailed, "Sound Error: ALUT initialisation failed: " << alutGetErrorString(alutGetError()));83 ThrowException(InitialisationFailed, "Sound: Error: ALUT initialisation failed: " << alutGetErrorString(alutGetError())); 83 84 Loki::ScopeGuard alutExitGuard = Loki::MakeGuard(&alutExit); 84 85 … … 112 113 COUT(1) << "Sound: Just getting the DLL with the dependencies is not enough for Windows (esp. Windows 7)!" << std::endl; 113 114 #endif 114 ThrowException(InitialisationFailed, "Sound Error: Could not open sound device.");115 ThrowException(InitialisationFailed, "Sound: Error: Could not open sound device."); 115 116 } 116 117 Loki::ScopeGuard closeDeviceGuard = Loki::MakeGuard(&alcCloseDevice, this->device_); 117 118 118 119 // Create sound context and make it the currently used one 119 this->context_ = alcCreateContext(this->device_, NULL); 120 const ALint contattr[] = {ALC_SYNC, 1, 0}; 121 this->context_ = alcCreateContext(this->device_, contattr); 120 122 if (this->context_ == NULL) 121 ThrowException(InitialisationFailed, "Sound Error: Could not create ALC context");123 ThrowException(InitialisationFailed, "Sound: Error: Could not create ALC context"); 122 124 Loki::ScopeGuard desroyContextGuard = Loki::MakeGuard(&alcDestroyContext, this->context_); 123 125 if (!alcMakeContextCurrent(this->context_)) 124 ThrowException(InitialisationFailed, "Sound Error: Could not use ALC context");126 ThrowException(InitialisationFailed, "Sound: Error: Could not use ALC context"); 125 127 126 128 GameMode::setPlaysSound(true); … … 135 137 COUT(4) << "Sound: --- Supported MIME Types: " << types << std::endl; 136 138 else 137 COUT(2) << "Sound Warning: MIME Type retrieval failed: " << alutGetErrorString(alutGetError()) << std::endl;139 COUT(2) << "Sound: Warning: MIME Type retrieval failed: " << alutGetErrorString(alutGetError()) << std::endl; 138 140 139 141 this->mute_[SoundType::All] = 1.0f; … … 149 151 this->availableSoundSources_.push_back(source); 150 152 else 151 ThrowException(InitialisationFailed, "Sound Error: Could not create even a single source");153 ThrowException(InitialisationFailed, "Sound: Error: Could not create even a single source"); 152 154 // Create a few initial sources 153 155 this->createSoundSources(this->minSources_ - 1); … … 171 173 // If there are still used buffers around, well, that's just very bad... 172 174 if (this->soundBuffers_.size() != this->effectsPool_.size()) 173 COUT(1) << "Sound Error: Some sound buffers are still in use but OpenAL is about to shut down. Fix this!" << std::endl;175 COUT(1) << "Sound: Error: Some sound buffers are still in use but OpenAL is about to shut down. Fix this!" << std::endl; 174 176 // Empty buffer pool and buffer list 175 177 this->effectsPool_.clear(); … … 178 180 // There should not be any sources in use anymore 179 181 if (!this->usedSoundSources_.empty()) 180 COUT(1) << "Sound Error: Some sound sources are still in use but OpenAL is about to shut down. Fix this!" << std::endl;182 COUT(1) << "Sound: Error: Some sound sources are still in use but OpenAL is about to shut down. Fix this!" << std::endl; 181 183 while (!this->availableSoundSources_.empty()) 182 184 { … … 189 191 // Relieve context to destroy it 190 192 if (!alcMakeContextCurrent(NULL)) 191 COUT(1) << "Sound Error: Could not unset ALC context" << std::endl;193 COUT(1) << "Sound: Error: Could not unset ALC context" << std::endl; 192 194 alcDestroyContext(this->context_); 193 195 if (ALCenum error = alcGetError(this->device_)) 194 196 { 195 197 if (error == AL_INVALID_OPERATION) 196 COUT(1) << "Sound Error: Could not destroy ALC context because it is the current one" << std::endl;198 COUT(1) << "Sound: Error: Could not destroy ALC context because it is the current one" << std::endl; 197 199 else 198 COUT(1) << "Sound Error: Could not destroy ALC context because it is invalid" << std::endl;200 COUT(1) << "Sound: Error: Could not destroy ALC context because it is invalid" << std::endl; 199 201 } 200 202 #ifdef AL_VERSION_1_1 201 203 if (!alcCloseDevice(this->device_)) 202 COUT(1) << "Sound Error: Could not destroy ALC device. This might be because there are still buffers in use!" << std::endl;204 COUT(1) << "Sound: Error: Could not destroy ALC device. This might be because there are still buffers in use!" << std::endl; 203 205 #else 204 206 alcCloseDevice(this->device_); 205 207 #endif 206 208 if (!alutExit()) 207 COUT(1) << "Sound Error: Closing ALUT failed: " << alutGetErrorString(alutGetError()) << std::endl;209 COUT(1) << "Sound: Error: Closing ALUT failed: " << alutGetErrorString(alutGetError()) << std::endl; 208 210 } 209 211 … … 251 253 if (crossFadeStep_ <= 0.0 || crossFadeStep_ >= 1.0 ) 252 254 { 253 COUT(2) << "Sound warning: fade step out of range, ignoring change." << std::endl;255 COUT(2) << "Sound: Warning: fade step out of range, ignoring change." << std::endl; 254 256 ResetConfigValue(crossFadeStep_); 255 257 } … … 260 262 float clampedVolume = clamp(this->volume_[type], 0.0f, 1.0f); 261 263 if (clampedVolume != this->volume_[type]) 262 COUT(2) << "Sound warning: Volume setting (" << type << ") out of range, clamping." << std::endl;264 COUT(2) << "Sound: Warning: Volume setting (" << type << ") out of range, clamping." << std::endl; 263 265 this->updateVolume(type); 264 266 } … … 352 354 if (it->first == newAmbient) 353 355 { 354 COUT(2) << "Sound warning: Will not play an AmbientSound twice." << std::endl;356 COUT(2) << "Sound: Warning: Will not play an AmbientSound twice." << std::endl; 355 357 return; 356 358 } … … 620 622 alDeleteSources(1, &this->availableSoundSources_.back()); 621 623 if (alGetError()) 622 COUT(1) << "Sound Error: Failed to delete a source --> lost forever" << std::endl;624 COUT(1) << "Sound: Error: Failed to delete a source --> lost forever" << std::endl; 623 625 this->availableSoundSources_.pop_back(); 624 626 }
Note: See TracChangeset
for help on using the changeset viewer.