aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden
diff options
context:
space:
mode:
Diffstat (limited to 'linden')
-rw-r--r--linden/indra/llaudio/llaudioengine_openal.cpp43
-rw-r--r--linden/indra/llaudio/llaudioengine_openal.h6
-rw-r--r--linden/indra/newview/llappviewer.cpp59
3 files changed, 59 insertions, 49 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};
diff --git a/linden/indra/newview/llappviewer.cpp b/linden/indra/newview/llappviewer.cpp
index aeb52a2..c9ab291 100644
--- a/linden/indra/newview/llappviewer.cpp
+++ b/linden/indra/newview/llappviewer.cpp
@@ -1284,35 +1284,6 @@ bool LLAppViewer::cleanup()
1284 1284
1285 llinfos << "Global stuff deleted" << llendflush; 1285 llinfos << "Global stuff deleted" << llendflush;
1286 1286
1287 if (gAudioStream)
1288 {
1289 // shut down the streaming audio sub-subsystem first, in case it relies on not outliving the general audio subsystem.
1290
1291 delete gAudioStream;
1292 gAudioStream = NULL;
1293 }
1294
1295 if (gAudiop)
1296 {
1297 // shut down the audio subsystem
1298
1299 bool want_longname = false;
1300 if (gAudiop->getDriverName(want_longname) == "FMOD")
1301 {
1302 // This hack exists because fmod likes to occasionally
1303 // crash or hang forever when shutting down, for no
1304 // apparent reason.
1305 llwarns << "Hack, skipping FMOD audio engine cleanup" << llendflush;
1306 }
1307 else
1308 {
1309 gAudiop->shutdown();
1310 }
1311
1312 delete gAudiop;
1313 gAudiop = NULL;
1314 }
1315
1316 // Note: this is where LLFeatureManager::getInstance()-> used to be deleted. 1287 // Note: this is where LLFeatureManager::getInstance()-> used to be deleted.
1317 1288
1318 // Patch up settings for next time 1289 // Patch up settings for next time
@@ -1548,6 +1519,36 @@ bool LLAppViewer::cleanup()
1548 end_messaging_system(); 1519 end_messaging_system();
1549 llinfos << "Message system deleted." << llendflush; 1520 llinfos << "Message system deleted." << llendflush;
1550 1521
1522 if (gAudioStream)
1523 {
1524 // shut down the streaming audio sub-subsystem first, in case it relies on not outliving the general audio subsystem.
1525
1526 delete gAudioStream;
1527 gAudioStream = NULL;
1528 }
1529
1530 if (gAudiop)
1531 {
1532 // shut down the audio subsystem
1533
1534 bool want_longname = false;
1535 if (gAudiop->getDriverName(want_longname) == "FMOD")
1536 {
1537 // This hack exists because fmod likes to occasionally
1538 // crash or hang forever when shutting down, for no
1539 // apparent reason.
1540 llwarns << "Hack, skipping FMOD audio engine cleanup" << llendflush;
1541 }
1542 else
1543 {
1544 gAudiop->shutdown();
1545 }
1546
1547 delete gAudiop;
1548 gAudiop = NULL;
1549 }
1550 llinfos << "Audio system deleted" << llendl;
1551
1551 // *NOTE:Mani - The following call is not thread safe. 1552 // *NOTE:Mani - The following call is not thread safe.
1552 LLCurl::cleanupClass(); 1553 LLCurl::cleanupClass();
1553 llinfos << "LLCurl cleaned up." << llendflush; 1554 llinfos << "LLCurl cleaned up." << llendflush;