aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llaudio
diff options
context:
space:
mode:
authorMcCabe Maxsted2011-06-24 17:53:33 -0700
committerMcCabe Maxsted2011-06-24 17:53:33 -0700
commit5cf5dc73eadaa6ba1ebc92aa67c622e600926f24 (patch)
tree7bc764727445099e77c0044caaabd2169daba2d1 /linden/indra/llaudio
parentCreated new window for inworld dice rolling in advanced > UI. Todo: add butto... (diff)
downloadmeta-impy-5cf5dc73eadaa6ba1ebc92aa67c622e600926f24.zip
meta-impy-5cf5dc73eadaa6ba1ebc92aa67c622e600926f24.tar.gz
meta-impy-5cf5dc73eadaa6ba1ebc92aa67c622e600926f24.tar.bz2
meta-impy-5cf5dc73eadaa6ba1ebc92aa67c622e600926f24.tar.xz
Tiny bit of coding standards changes for llaudioengine_openal and moved audio engine cleanup later during shutdown to prevent conflicts
Diffstat (limited to 'linden/indra/llaudio')
-rw-r--r--linden/indra/llaudio/llaudioengine_openal.cpp43
-rw-r--r--linden/indra/llaudio/llaudioengine_openal.h6
2 files changed, 29 insertions, 20 deletions
diff --git a/linden/indra/llaudio/llaudioengine_openal.cpp b/linden/indra/llaudio/llaudioengine_openal.cpp
index 08ec464..90dffc6 100644
--- a/linden/indra/llaudio/llaudioengine_openal.cpp
+++ b/linden/indra/llaudio/llaudioengine_openal.cpp
@@ -38,7 +38,7 @@
38#include "lllistener_openal.h" 38#include "lllistener_openal.h"
39 39
40 40
41static const float WIND_BUFFER_SIZE_SEC = 0.05f; // 1/20th sec 41static const F32 WIND_BUFFER_SIZE_SEC = 0.05f; // 1/20th sec
42 42
43std::string convertALErrorToString(ALenum error) 43std::string convertALErrorToString(ALenum error)
44{ 44{
@@ -94,7 +94,7 @@ bool LLAudioEngine_OpenAL::init(const S32 num_channels, void* userdata)
94 mWindGen = NULL; 94 mWindGen = NULL;
95 LLAudioEngine::init(num_channels, userdata); 95 LLAudioEngine::init(num_channels, userdata);
96 96
97 if(!alutInit(NULL, NULL)) 97 if (!alutInit(NULL, NULL))
98 { 98 {
99 llwarns << "LLAudioEngine_OpenAL::init() ALUT initialization failed: " << alutGetErrorString (alutGetError ()) << llendl; 99 llwarns << "LLAudioEngine_OpenAL::init() ALUT initialization failed: " << alutGetErrorString (alutGetError ()) << llendl;
100 return false; 100 return false;
@@ -230,7 +230,7 @@ std::string LLAudioEngine_OpenAL::getDriverName(bool verbose)
230void LLAudioEngine_OpenAL::allocateListener() 230void LLAudioEngine_OpenAL::allocateListener()
231{ 231{
232 mListenerp = (LLListener *) new LLListener_OpenAL(); 232 mListenerp = (LLListener *) new LLListener_OpenAL();
233 if(!mListenerp) 233 if (!mListenerp)
234 { 234 {
235 llwarns << "LLAudioEngine_OpenAL::allocateListener() Listener creation failed" << llendl; 235 llwarns << "LLAudioEngine_OpenAL::allocateListener() Listener creation failed" << llendl;
236 } 236 }
@@ -239,18 +239,19 @@ void LLAudioEngine_OpenAL::allocateListener()
239// virtual 239// virtual
240void LLAudioEngine_OpenAL::shutdown() 240void LLAudioEngine_OpenAL::shutdown()
241{ 241{
242 llinfos << "About to LLAudioEngine::shutdown()" << llendl; 242 llinfos << "Entering LLAudioEngine::shutdown()" << llendl;
243 243
244 LLAudioEngine::shutdown(); 244 LLAudioEngine::shutdown();
245 245
246 llinfos << "About to alutExit()" << llendl; 246 llinfos << "Entering alutExit()" << llendl;
247 if(!alutExit()) 247 if (!alutExit())
248 { 248 {
249 llwarns << "Nuts." << llendl;
250 llwarns << "LLAudioEngine_OpenAL::shutdown() ALUT shutdown failed: " << alutGetErrorString(alutGetError()) << llendl; 249 llwarns << "LLAudioEngine_OpenAL::shutdown() ALUT shutdown failed: " << alutGetErrorString(alutGetError()) << llendl;
251 } 250 }
252 251 else
253 llinfos << "LLAudioEngine_OpenAL::shutdown() OpenAL successfully shut down" << llendl; 252 {
253 llinfos << "LLAudioEngine_OpenAL::shutdown() OpenAL successfully shut down" << llendl;
254 }
254 255
255 delete mListenerp; 256 delete mListenerp;
256 mListenerp = NULL; 257 mListenerp = NULL;
@@ -270,6 +271,10 @@ void LLAudioEngine_OpenAL::shutdown()
270 { 271 {
271 llinfos << "AL error: " << convertALErrorToString(error) << ". Could not destroy context!" << llendl; 272 llinfos << "AL error: " << convertALErrorToString(error) << ". Could not destroy context!" << llendl;
272 } 273 }
274 else
275 {
276 mContext = NULL;
277 }
273 278
274 alcCloseDevice(mDevice); 279 alcCloseDevice(mDevice);
275 error = alGetError(); 280 error = alGetError();
@@ -277,6 +282,10 @@ void LLAudioEngine_OpenAL::shutdown()
277 { 282 {
278 llinfos << "AL error: " << convertALErrorToString(error) << ". Could not close device!" << llendl; 283 llinfos << "AL error: " << convertALErrorToString(error) << ". Could not close device!" << llendl;
279 } 284 }
285 else
286 {
287 mDevice = NULL;
288 }
280} 289}
281 290
282LLAudioBuffer *LLAudioEngine_OpenAL::createBuffer() 291LLAudioBuffer *LLAudioEngine_OpenAL::createBuffer()
@@ -306,7 +315,7 @@ LLAudioChannelOpenAL::LLAudioChannelOpenAL()
306LLAudioChannelOpenAL::~LLAudioChannelOpenAL() 315LLAudioChannelOpenAL::~LLAudioChannelOpenAL()
307{ 316{
308 cleanup(); 317 cleanup();
309 if (mALSource != AL_NONE) //MC 318 if (mALSource != AL_NONE)
310 { 319 {
311 alDeleteSources(1, &mALSource); 320 alDeleteSources(1, &mALSource);
312 mALSource = AL_NONE; 321 mALSource = AL_NONE;
@@ -327,7 +336,7 @@ void LLAudioChannelOpenAL::play()
327 return; 336 return;
328 } 337 }
329 338
330 if(!isPlaying()) 339 if (!isPlaying())
331 { 340 {
332 alSourcePlay(mALSource); 341 alSourcePlay(mALSource);
333 getSource()->setPlayedOnce(true); 342 getSource()->setPlayedOnce(true);
@@ -453,7 +462,7 @@ LLAudioBufferOpenAL::~LLAudioBufferOpenAL()
453 462
454void LLAudioBufferOpenAL::cleanup() 463void LLAudioBufferOpenAL::cleanup()
455{ 464{
456 if(mALBuffer != AL_NONE) 465 if (mALBuffer != AL_NONE)
457 { 466 {
458 alDeleteBuffers(1, &mALBuffer); 467 alDeleteBuffers(1, &mALBuffer);
459 mALBuffer = AL_NONE; 468 mALBuffer = AL_NONE;
@@ -464,7 +473,7 @@ bool LLAudioBufferOpenAL::loadWAV(const std::string& filename)
464{ 473{
465 cleanup(); 474 cleanup();
466 mALBuffer = alutCreateBufferFromFile(filename.c_str()); 475 mALBuffer = alutCreateBufferFromFile(filename.c_str());
467 if(mALBuffer == AL_NONE) 476 if (mALBuffer == AL_NONE)
468 { 477 {
469 ALenum error = alutGetError(); 478 ALenum error = alutGetError();
470 if (gDirUtilp->fileExists(filename)) 479 if (gDirUtilp->fileExists(filename))
@@ -492,7 +501,7 @@ bool LLAudioBufferOpenAL::loadWAV(const std::string& filename)
492 501
493U32 LLAudioBufferOpenAL::getLength() 502U32 LLAudioBufferOpenAL::getLength()
494{ 503{
495 if(mALBuffer == AL_NONE) 504 if (mALBuffer == AL_NONE)
496 { 505 {
497 return 0; 506 return 0;
498 } 507 }
@@ -514,7 +523,7 @@ void LLAudioEngine_OpenAL::initWind()
514 523
515 alGenSources(1,&mWindSource); 524 alGenSources(1,&mWindSource);
516 525
517 if((error=alGetError()) != AL_NO_ERROR) 526 if ((error=alGetError()) != AL_NO_ERROR)
518 { 527 {
519 llwarns << "LLAudioEngine_OpenAL::initWind() Error creating wind sources: " << convertALErrorToString(error) << llendl; 528 llwarns << "LLAudioEngine_OpenAL::initWind() Error creating wind sources: " << convertALErrorToString(error) << llendl;
520 } 529 }
@@ -527,7 +536,7 @@ void LLAudioEngine_OpenAL::initWind()
527 536
528 mWindBuf = new WIND_SAMPLE_T [mWindBufSamples * 2 /*stereo*/]; 537 mWindBuf = new WIND_SAMPLE_T [mWindBufSamples * 2 /*stereo*/];
529 538
530 if(mWindBuf==NULL) 539 if (mWindBuf == NULL)
531 { 540 {
532 llerrs << "LLAudioEngine_OpenAL::initWind() Error creating wind memory buffer" << llendl; 541 llerrs << "LLAudioEngine_OpenAL::initWind() Error creating wind memory buffer" << llendl;
533 mEnableWind=false; 542 mEnableWind=false;
@@ -576,7 +585,7 @@ void LLAudioEngine_OpenAL::updateWind(LLVector3 wind_vec, F32 camera_altitude)
576 if (!mEnableWind) 585 if (!mEnableWind)
577 return; 586 return;
578 587
579 if(!mWindBuf) 588 if (!mWindBuf)
580 return; 589 return;
581 590
582 if (mWindUpdateTimer.checkExpirationAndReset(LL_WIND_UPDATE_INTERVAL)) 591 if (mWindUpdateTimer.checkExpirationAndReset(LL_WIND_UPDATE_INTERVAL))
diff --git a/linden/indra/llaudio/llaudioengine_openal.h b/linden/indra/llaudio/llaudioengine_openal.h
index df32e13..47748c3 100644
--- a/linden/indra/llaudio/llaudioengine_openal.h
+++ b/linden/indra/llaudio/llaudioengine_openal.h
@@ -70,9 +70,9 @@ class LLAudioEngine_OpenAL : public LLAudioEngine
70 U32 mWindBufSamples; 70 U32 mWindBufSamples;
71 U32 mWindBufBytes; 71 U32 mWindBufBytes;
72 ALuint mWindSource; 72 ALuint mWindSource;
73 int mNumEmptyWindALBuffers; 73 S32 mNumEmptyWindALBuffers;
74 74
75 static const int MAX_NUM_WIND_BUFFERS = 80; 75 static const S32 MAX_NUM_WIND_BUFFERS = 80;
76 76
77 ALCcontext* mContext; 77 ALCcontext* mContext;
78 ALCdevice* mDevice; 78 ALCdevice* mDevice;
@@ -109,7 +109,7 @@ class LLAudioBufferOpenAL : public LLAudioBuffer
109 friend class LLAudioChannelOpenAL; 109 friend class LLAudioChannelOpenAL;
110 protected: 110 protected:
111 void cleanup(); 111 void cleanup();
112 ALuint getBuffer() {return mALBuffer;} 112 ALuint getBuffer() { return mALBuffer; }
113 113
114 ALuint mALBuffer; 114 ALuint mALBuffer;
115}; 115};