[Orxonox-commit 1352] r6070 - code/branches/sound3/src/orxonox/sound
rgrieder at orxonox.net
rgrieder at orxonox.net
Sun Nov 15 15:53:12 CET 2009
Author: rgrieder
Date: 2009-11-15 15:53:12 +0100 (Sun, 15 Nov 2009)
New Revision: 6070
Modified:
code/branches/sound3/src/orxonox/sound/BaseSound.cc
Log:
OpenAL sources should be linked to the lifetime of a BaseSound.
Modified: code/branches/sound3/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/branches/sound3/src/orxonox/sound/BaseSound.cc 2009-11-15 14:43:06 UTC (rev 6069)
+++ code/branches/sound3/src/orxonox/sound/BaseSound.cc 2009-11-15 14:53:12 UTC (rev 6070)
@@ -45,11 +45,16 @@
, bLoop_(false)
{
RegisterRootObject(BaseSound);
+
+ if (GameMode::playsSound())
+ alGenSources(1, &this->audioSource_);
}
BaseSound::~BaseSound()
{
this->setSource("");
+ if (this->audioSource_)
+ alDeleteSources(1, &this->audioSource_);
}
void BaseSound::play()
@@ -123,13 +128,11 @@
return;
}
- if (alIsSource(this->audioSource_))
+ if (alIsSource(this->audioBuffer_))
{
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;
}
@@ -171,7 +174,6 @@
}
}
- alGenSources(1, &this->audioSource_);
alSourcei(this->audioSource_, AL_BUFFER, this->audioBuffer_);
if (alGetError() != AL_NO_ERROR)
{
More information about the Orxonox-commit
mailing list