[Orxonox-commit 1613] r6331 - code/branches/sound3/src/orxonox/sound
erwin at orxonox.net
erwin at orxonox.net
Sat Dec 12 20:36:02 CET 2009
Author: erwin
Date: 2009-12-12 20:36:02 +0100 (Sat, 12 Dec 2009)
New Revision: 6331
Modified:
code/branches/sound3/src/orxonox/sound/BaseSound.cc
Log:
Attempt to improve sound loading performance
Modified: code/branches/sound3/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/branches/sound3/src/orxonox/sound/BaseSound.cc 2009-12-12 19:02:18 UTC (rev 6330)
+++ code/branches/sound3/src/orxonox/sound/BaseSound.cc 2009-12-12 19:36:02 UTC (rev 6331)
@@ -148,30 +148,33 @@
return;
}
dataStream_ = Resource::open(source);
- // Read everything into a temporary buffer
- char* buffer = new char[fileInfo->size];
- dataStream_->read(buffer, fileInfo->size);
- dataStream_->seek(0);
- this->audioBuffer_ = alutCreateBufferFromFileImage(buffer, fileInfo->size);
- delete[] buffer;
-
- if (this->audioBuffer_ == AL_NONE)
+ if (source.find("ogg", 0) != std::string::npos)
{
- COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;
- if (source.find("ogg", 0) != std::string::npos)
+ COUT(2) << "Sound: Ogg file found, trying ogg loader" << std::endl;
+ this->audioBuffer_ = this->loadOggFile();
+ if(this->audioBuffer_ == AL_NONE)
{
- COUT(2) << "Sound: Trying fallback ogg loader" << std::endl;
- this->audioBuffer_ = this->loadOggFile();
+ COUT(2) << "Sound: Ogg loader failed" << std::endl;
+ dataStream_->seek(0);
}
+ }
- if (this->audioBuffer_ == AL_NONE)
- {
- COUT(2) << "Sound: fallback ogg loader failed: " << alutGetErrorString(alutGetError()) << std::endl;
- return;
- }
+ if (this->audioBuffer_ == AL_NONE)
+ {
+ // Read everything into a temporary buffer
+ char* buffer = new char[fileInfo->size];
+ dataStream_->read(buffer, fileInfo->size);
+
+ this->audioBuffer_ = alutCreateBufferFromFileImage(buffer, fileInfo->size);
+ delete[] buffer;
}
+ if (this->audioBuffer_ == AL_NONE)
+ {
+ COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;
+ }
+
alSourcei(this->audioSource_, AL_BUFFER, this->audioBuffer_);
if (alGetError() != AL_NO_ERROR)
{
More information about the Orxonox-commit
mailing list