[Orxonox-commit 1244] r5962 - code/branches/sound3/src/orxonox/sound
rgrieder at orxonox.net
rgrieder at orxonox.net
Fri Oct 16 19:10:03 CEST 2009
Author: rgrieder
Date: 2009-10-16 19:10:03 +0200 (Fri, 16 Oct 2009)
New Revision: 5962
Modified:
code/branches/sound3/src/orxonox/sound/BaseSound.cc
Log:
Fixed sound reloading problem. The solution was in fact to first stop the playback (how trivial and yet unexpected...)
Modified: code/branches/sound3/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/branches/sound3/src/orxonox/sound/BaseSound.cc 2009-10-16 13:38:48 UTC (rev 5961)
+++ code/branches/sound3/src/orxonox/sound/BaseSound.cc 2009-10-16 17:10:03 UTC (rev 5962)
@@ -110,26 +110,26 @@
void BaseSound::setSource(const std::string& source)
{
- if (!GameMode::playsSound())
+ if (!GameMode::playsSound() || source == this->source_)
{
this->source_ = source;
return;
}
- if (this->source_ != source && alIsSource(this->audioSource_))
+ if (alIsSource(this->audioSource_))
{
- // Unload sound
+ this->stop();
+ // Unload old sound first
alSourcei(this->audioSource_, AL_BUFFER, 0);
alDeleteSources(1, &this->audioSource_);
+ this->audioSource_ = 0;
alDeleteBuffers(1, &this->audioBuffer_);
+ this->audioBuffer_ = 0;
}
this->source_ = source;
-
- if(source_.empty())
- {
+ if (source_.empty())
return;
- }
COUT(3) << "Sound: OpenAL ALUT: loading file " << source << std::endl;
// Get DataStream from the resources
More information about the Orxonox-commit
mailing list