[Orxonox-commit 1786] r6504 - code/branches/sound4/src/orxonox/sound
erwin at orxonox.net
erwin at orxonox.net
Thu Mar 11 15:12:37 CET 2010
Author: erwin
Date: 2010-03-11 15:12:37 +0100 (Thu, 11 Mar 2010)
New Revision: 6504
Modified:
code/branches/sound4/src/orxonox/sound/AmbientSound.cc
code/branches/sound4/src/orxonox/sound/AmbientSound.h
code/branches/sound4/src/orxonox/sound/BaseSound.cc
code/branches/sound4/src/orxonox/sound/SoundManager.cc
Log:
Commit before rebase, attempt to fix everything ;-)
Modified: code/branches/sound4/src/orxonox/sound/AmbientSound.cc
===================================================================
--- code/branches/sound4/src/orxonox/sound/AmbientSound.cc 2010-03-11 10:44:51 UTC (rev 6503)
+++ code/branches/sound4/src/orxonox/sound/AmbientSound.cc 2010-03-11 14:12:37 UTC (rev 6504)
@@ -171,5 +171,12 @@
DataStreamPtr dataStream = Resource::open(fileInfo);
this->soundstreamthread_ = boost::thread(SoundStreamer(), this->audioSource_, dataStream);
+ this->initialiseSource();
}
+
+ void AmbientSound::doStop()
+ {
+ SUPER(AmbientSound, doStop);
+ this->soundstreamthread_.interrupt();
+ }
}
Modified: code/branches/sound4/src/orxonox/sound/AmbientSound.h
===================================================================
--- code/branches/sound4/src/orxonox/sound/AmbientSound.h 2010-03-11 10:44:51 UTC (rev 6503)
+++ code/branches/sound4/src/orxonox/sound/AmbientSound.h 2010-03-11 14:12:37 UTC (rev 6504)
@@ -72,6 +72,9 @@
protected:
~AmbientSound() { }
+ void doPlay();
+ void doStop();
+
private:
void preDestroy();
void registerVariables();
Modified: code/branches/sound4/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/branches/sound4/src/orxonox/sound/BaseSound.cc 2010-03-11 10:44:51 UTC (rev 6503)
+++ code/branches/sound4/src/orxonox/sound/BaseSound.cc 2010-03-11 14:12:37 UTC (rev 6504)
@@ -140,18 +140,18 @@
alSource3f(this->audioSource_, AL_VELOCITY, 0, 0, 0);
alSource3f(this->audioSource_, AL_DIRECTION, 0, 0, 0);
if (ALint error = alGetError())
- COUT(2) << "Sound Warning: Setting source parameters to 0 failed: " << getALErrorString(error) << std::endl;
+ COUT(2) << "Sound: Warning: Setting source parameters to 0 failed: " << getALErrorString(error) << std::endl;
assert(this->soundBuffer_ != NULL);
alSourcei(this->audioSource_, AL_BUFFER, this->soundBuffer_->getBuffer());
if (ALuint error = alGetError())
- COUT(1) << "Sound Error: Could not set buffer \"" << this->source_ << "\": " << getALErrorString(error) << std::endl;
+ COUT(1) << "Sound: Error: Could not set buffer \"" << this->source_ << "\": " << getALErrorString(error) << std::endl;
}
void BaseSound::setVolume(float vol)
{
this->volume_ = clamp(vol, 0.0f, 1.0f);
if (this->volume_ != vol)
- COUT(2) << "Sound warning: volume out of range, clamping value." << std::endl;
+ COUT(2) << "Sound: Warning: volume out of range, clamping value." << std::endl;
this->updateVolume();
}
@@ -177,7 +177,7 @@
{
if (pitch > 2 || pitch < 0.5)
{
- COUT(2) << "Sound warning: pitch out of range, cropping value." << std::endl;
+ COUT(2) << "Sound: Warning: pitch out of range, cropping value." << std::endl;
pitch = pitch > 2 ? 2 : pitch;
pitch = pitch < 0.5 ? 0.5 : pitch;
}
@@ -231,7 +231,7 @@
alSourcei(this->audioSource_, AL_BUFFER, this->soundBuffer_->getBuffer());
if (ALuint error = alGetError())
{
- COUT(1) << "Sound Error: Could not set buffer \"" << source << "\": " << getALErrorString(error) << std::endl;
+ COUT(1) << "Sound: Error: Could not set buffer \"" << source << "\": " << getALErrorString(error) << std::endl;
return;
}
Modified: code/branches/sound4/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/branches/sound4/src/orxonox/sound/SoundManager.cc 2010-03-11 10:44:51 UTC (rev 6503)
+++ code/branches/sound4/src/orxonox/sound/SoundManager.cc 2010-03-11 14:12:37 UTC (rev 6504)
@@ -42,7 +42,7 @@
#include "core/GameMode.h"
#include "core/ScopedSingletonManager.h"
#include "core/Resource.h"
-#include "SoundBuffer.h"
+#include "SoundBuffer.h":
#include "BaseSound.h"
#include "AmbientSound.h"
#include "WorldSound.h"
@@ -78,7 +78,7 @@
ThrowException(InitialisationAborted, "Sound: Not loading at all");
if (!alutInitWithoutContext(NULL, NULL))
- ThrowException(InitialisationFailed, "Sound Error: ALUT initialisation failed: " << alutGetErrorString(alutGetError()));
+ ThrowException(InitialisationFailed, "Sound: Error: ALUT initialisation failed: " << alutGetErrorString(alutGetError()));
Loki::ScopeGuard alutExitGuard = Loki::MakeGuard(&alutExit);
/*
@@ -110,17 +110,17 @@
#ifdef ORXONOX_PLATFORM_WINDOWS
COUT(1) << "Sound: Just getting the DLL with the dependencies is not enough for Windows (esp. Windows 7)!" << std::endl;
#endif
- ThrowException(InitialisationFailed, "Sound Error: Could not open sound device.");
+ ThrowException(InitialisationFailed, "Sound: Error: Could not open sound device.");
}
Loki::ScopeGuard closeDeviceGuard = Loki::MakeGuard(&alcCloseDevice, this->device_);
// Create sound context and make it the currently used one
this->context_ = alcCreateContext(this->device_, NULL);
if (this->context_ == NULL)
- ThrowException(InitialisationFailed, "Sound Error: Could not create ALC context");
+ ThrowException(InitialisationFailed, "Sound: Error: Could not create ALC context");
Loki::ScopeGuard desroyContextGuard = Loki::MakeGuard(&alcDestroyContext, this->context_);
if (!alcMakeContextCurrent(this->context_))
- ThrowException(InitialisationFailed, "Sound Error: Could not use ALC context");
+ ThrowException(InitialisationFailed, "Sound: Error: Could not use ALC context");
GameMode::setPlaysSound(true);
Loki::ScopeGuard resetPlaysSoundGuard = Loki::MakeGuard(&GameMode::setPlaysSound, false);
@@ -133,7 +133,7 @@
if (const char* types = alutGetMIMETypes(ALUT_LOADER_BUFFER))
COUT(4) << "Sound: --- Supported MIME Types: " << types << std::endl;
else
- COUT(2) << "Sound Warning: MIME Type retrieval failed: " << alutGetErrorString(alutGetError()) << std::endl;
+ COUT(2) << "Sound: Warning: MIME Type retrieval failed: " << alutGetErrorString(alutGetError()) << std::endl;
this->mute_[SoundType::All] = 1.0f;
this->mute_[SoundType::Music] = 1.0f;
@@ -147,7 +147,7 @@
if (!alGetError() && alIsSource(source))
this->availableSoundSources_.push_back(source);
else
- ThrowException(InitialisationFailed, "Sound Error: Could not create even a single source");
+ ThrowException(InitialisationFailed, "Sound: Error: Could not create even a single source");
// Create a few initial sources
this->createSoundSources(this->minSources_ - 1);
@@ -168,14 +168,14 @@
// If there are still used buffers around, well, that's just very bad...
if (this->soundBuffers_.size() != this->effectsPool_.size())
- COUT(1) << "Sound Error: Some sound buffers are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
+ COUT(1) << "Sound: Error: Some sound buffers are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
// Empty buffer pool and buffer list
this->effectsPool_.clear();
this->soundBuffers_.clear();
// There should not be any sources in use anymore
if (!this->usedSoundSources_.empty())
- COUT(1) << "Sound Error: Some sound sources are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
+ COUT(1) << "Sound: Error: Some sound sources are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
while (!this->availableSoundSources_.empty())
{
alDeleteSources(1, &this->availableSoundSources_.back());
@@ -186,23 +186,23 @@
// Relieve context to destroy it
if (!alcMakeContextCurrent(NULL))
- COUT(1) << "Sound Error: Could not unset ALC context" << std::endl;
+ COUT(1) << "Sound: Error: Could not unset ALC context" << std::endl;
alcDestroyContext(this->context_);
if (ALCenum error = alcGetError(this->device_))
{
if (error == AL_INVALID_OPERATION)
- COUT(1) << "Sound Error: Could not destroy ALC context because it is the current one" << std::endl;
+ COUT(1) << "Sound: Error: Could not destroy ALC context because it is the current one" << std::endl;
else
- COUT(1) << "Sound Error: Could not destroy ALC context because it is invalid" << std::endl;
+ COUT(1) << "Sound: Error: Could not destroy ALC context because it is invalid" << std::endl;
}
#ifdef AL_VERSION_1_1
if (!alcCloseDevice(this->device_))
- COUT(1) << "Sound Error: Could not destroy ALC device. This might be because there are still buffers in use!" << std::endl;
+ COUT(1) << "Sound: Error: Could not destroy ALC device. This might be because there are still buffers in use!" << std::endl;
#else
alcCloseDevice(this->device_);
#endif
if (!alutExit())
- COUT(1) << "Sound Error: Closing ALUT failed: " << alutGetErrorString(alutGetError()) << std::endl;
+ COUT(1) << "Sound: Error: Closing ALUT failed: " << alutGetErrorString(alutGetError()) << std::endl;
}
void SoundManager::setConfigValues()
@@ -248,7 +248,7 @@
{
if (crossFadeStep_ <= 0.0 || crossFadeStep_ >= 1.0 )
{
- COUT(2) << "Sound warning: fade step out of range, ignoring change." << std::endl;
+ COUT(2) << "Sound: Warning: fade step out of range, ignoring change." << std::endl;
ResetConfigValue(crossFadeStep_);
}
}
@@ -257,7 +257,7 @@
{
float clampedVolume = clamp(this->volume_[type], 0.0f, 1.0f);
if (clampedVolume != this->volume_[type])
- COUT(2) << "Sound warning: Volume setting (" << type << ") out of range, clamping." << std::endl;
+ COUT(2) << "Sound: Warning: Volume setting (" << type << ") out of range, clamping." << std::endl;
this->updateVolume(type);
}
@@ -349,7 +349,7 @@
{
if (it->first == newAmbient)
{
- COUT(2) << "Sound warning: Will not play an AmbientSound twice." << std::endl;
+ COUT(2) << "Sound: Warning: Will not play an AmbientSound twice." << std::endl;
return;
}
}
@@ -617,7 +617,7 @@
{
alDeleteSources(1, &this->availableSoundSources_.back());
if (alGetError())
- COUT(1) << "Sound Error: Failed to delete a source --> lost forever" << std::endl;
+ COUT(1) << "Sound: Error: Failed to delete a source --> lost forever" << std::endl;
this->availableSoundSources_.pop_back();
}
}
More information about the Orxonox-commit
mailing list