Changeset 6260 for code/branches/presentation2/src/orxonox
- Timestamp:
- Dec 6, 2009, 9:46:04 PM (15 years ago)
- Location:
- code/branches/presentation2/src/orxonox/sound
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/src/orxonox/sound/BaseSound.cc
r6255 r6260 55 55 { 56 56 alGenSources(1, &this->audioSource_); 57 assert(this->audioSource_ != 0); 57 if (!alIsSource(this->audioSource_)) 58 COUT(1) << "Sound: Source generation failed: " << SoundManager::getALErrorString(alGetError()) << std::endl; 58 59 } 59 60 } … … 62 63 { 63 64 this->setSource(""); 64 if (GameMode::playsSound() )65 if (GameMode::playsSound() && alIsSource(this->audioSource_)) 65 66 alDeleteSources(1, &this->audioSource_); 66 67 } … … 77 78 { 78 79 this->state_ = Playing; 79 if (GameMode::playsSound() && this->getSourceState() != AL_PLAYING)80 if (GameMode::playsSound() && alIsSource(this->audioSource_) && this->getSourceState() != AL_PLAYING) 80 81 { 81 82 alSourcePlay(this->audioSource_); … … 89 90 { 90 91 this->state_ = Stopped; 91 if (GameMode::playsSound() )92 if (GameMode::playsSound() && alIsSource(this->audioSource_)) 92 93 alSourceStop(this->audioSource_); 93 94 } … … 98 99 return; 99 100 this->state_ = Paused; 100 if (GameMode::playsSound() )101 if (GameMode::playsSound() && alIsSource(this->audioSource_)) 101 102 alSourcePause(this->audioSource_); 102 103 } … … 104 105 ALint BaseSound::getSourceState() const 105 106 { 106 if (GameMode::playsSound() )107 if (GameMode::playsSound() && alIsSource(this->audioSource_)) 107 108 { 108 109 ALint state; … … 145 146 { 146 147 this->bLoop_ = val; 147 if (GameMode::playsSound() )148 if (GameMode::playsSound() && alIsSource(this->audioSource_)) 148 149 alSourcei(this->audioSource_, AL_LOOPING, (val ? AL_TRUE : AL_FALSE)); 149 150 } … … 158 159 } 159 160 this->pitch_ = pitch; 160 if (GameMode::playsSound() )161 if (GameMode::playsSound() && alIsSource(this->audioSource_)) 161 162 { 162 163 if (int error = alGetError()) … … 176 177 if (this->soundBuffer_ != NULL) 177 178 { 178 alSourceStop(this->audioSource_); 179 // Unload old sound first 180 alSourcei(this->audioSource_, AL_BUFFER, 0); 179 if (alIsSource(this->audioSource_)) 180 { 181 alSourceStop(this->audioSource_); 182 // Unload old buffer first 183 alSourcei(this->audioSource_, AL_BUFFER, 0); 184 } 181 185 SoundManager::getInstance().releaseSoundBuffer(this->soundBuffer_, this->bPooling_); 182 186 this->soundBuffer_.reset(); … … 184 188 185 189 this->source_ = source; 186 if (source_.empty() )190 if (source_.empty() || !alIsSource(this->audioSource_)) 187 191 return; 188 192 … … 200 204 201 205 alSourcei(this->audioSource_, AL_BUFFER, this->soundBuffer_->getBuffer()); 202 if ( alGetError() != AL_NO_ERROR)203 { 204 COUT( 2) << "Sound: OpenAL: Error loading sample file: " << source<< std::endl;206 if (ALuint error = alGetError()) 207 { 208 COUT(1) << "Sound Error: Could not load file \"" << source << "\": " << SoundManager::getALErrorString << std::endl; 205 209 return; 206 210 } -
code/branches/presentation2/src/orxonox/sound/SoundBuffer.cc
r6254 r6260 87 87 delete[] buffer; 88 88 89 if ( this->audioBuffer_ == AL_NONE)89 if (!alIsBuffer(this->audioBuffer_)) 90 90 ThrowException(General, "Sound Error: Standard file loader failed: " << alutGetErrorString(alutGetError())); 91 91 } … … 170 170 ov_clear(&vf); 171 171 172 if ( this->audioBuffer_ == AL_NONE)172 if (!alIsBuffer(this->audioBuffer_)) 173 173 ThrowException(General, "Sound: Ogg file loader failed when creating the buffer."); 174 174 }
Note: See TracChangeset
for help on using the changeset viewer.