[Orxonox-commit 1486] r6204 - code/branches/presentation2/src/orxonox/sound
rgrieder at orxonox.net
rgrieder at orxonox.net
Wed Dec 2 17:06:57 CET 2009
Author: rgrieder
Date: 2009-12-02 17:06:57 +0100 (Wed, 02 Dec 2009)
New Revision: 6204
Modified:
code/branches/presentation2/src/orxonox/sound/BaseSound.cc
code/branches/presentation2/src/orxonox/sound/WorldSound.cc
Log:
Better error handling for sound.
Modified: code/branches/presentation2/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/BaseSound.cc 2009-12-02 15:57:24 UTC (rev 6203)
+++ code/branches/presentation2/src/orxonox/sound/BaseSound.cc 2009-12-02 16:06:57 UTC (rev 6204)
@@ -123,7 +123,11 @@
void BaseSound::updateVolume(void)
{
if (alIsSource(this->audioSource_))
+ {
alSourcef(this->audioSource_, AL_GAIN, this->volume_*this->getVolumeGain());
+ if (int error = alGetError())
+ COUT(2) << "Sound: Error setting volume: " << error << std::endl;
+ }
}
void BaseSound::setLooping(bool val)
@@ -143,7 +147,11 @@
}
this->pitch_ = pitch;
if (GameMode::playsSound())
+ {
+ if (int error = alGetError())
+ COUT(2) << "Sound: Error setting pitch: " << error << std::endl;
alSourcei(this->audioSource_, AL_PITCH, pitch);
+ }
}
void BaseSound::setSource(const std::string& source)
@@ -188,13 +196,10 @@
alSource3f(this->audioSource_, AL_POSITION, 0, 0, 0);
this->updateVolume();
this->setPitch(this->getPitch());
- alSourcei (this->audioSource_, AL_LOOPING, (this->bLoop_ ? AL_TRUE : AL_FALSE));
+ this->setLooping(getLooping());
if (this->isPlaying() || this->isPaused())
- alSourcePlay(this->audioSource_);
+ BaseSound::play();
if (this->isPaused())
- alSourcePause(this->audioSource_);
-
- if (int error = alGetError())
- COUT(2) << "Sound: OpenAL: Error playing sound: " << error << std::endl;
+ BaseSound::pause();
}
}
Modified: code/branches/presentation2/src/orxonox/sound/WorldSound.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/WorldSound.cc 2009-12-02 15:57:24 UTC (rev 6203)
+++ code/branches/presentation2/src/orxonox/sound/WorldSound.cc 2009-12-02 16:06:57 UTC (rev 6204)
@@ -95,7 +95,7 @@
else
this->stop();
}
-
+
float WorldSound::getVolumeGain()
{
return SoundManager::getInstance().getVolume(SoundType::effects);
More information about the Orxonox-commit
mailing list