diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp index 6be8a8042..99e151f12 100644 --- a/indra/llaudio/llaudioengine.cpp +++ b/indra/llaudio/llaudioengine.cpp @@ -174,6 +174,9 @@ void LLAudioEngine::shutdown() delete mBuffers[i]; mBuffers[i] = NULL; } + + delete mStreamingAudioImpl; + mStreamingAudioImpl = NULL; } diff --git a/indra/llaudio/llaudioengine_fmodex.cpp b/indra/llaudio/llaudioengine_fmodex.cpp index c3e067c59..6417a901d 100644 --- a/indra/llaudio/llaudioengine_fmodex.cpp +++ b/indra/llaudio/llaudioengine_fmodex.cpp @@ -513,8 +513,6 @@ void LLAudioEngine_FMODEX::allocateListener(void) void LLAudioEngine_FMODEX::shutdown() { - stopInternetStream(); - LL_INFOS("AudioImpl") << "About to LLAudioEngine::shutdown()" << LL_ENDL; LLAudioEngine::shutdown(); diff --git a/indra/llaudio/llaudioengine_fmodstudio.cpp b/indra/llaudio/llaudioengine_fmodstudio.cpp index 3ff461a58..09bc4531d 100644 --- a/indra/llaudio/llaudioengine_fmodstudio.cpp +++ b/indra/llaudio/llaudioengine_fmodstudio.cpp @@ -509,8 +509,6 @@ void LLAudioEngine_FMODSTUDIO::allocateListener(void) void LLAudioEngine_FMODSTUDIO::shutdown() { - stopInternetStream(); - LL_INFOS("AudioImpl") << "About to LLAudioEngine::shutdown()" << LL_ENDL; LLAudioEngine::shutdown(); diff --git a/indra/llaudio/llstreamingaudio_fmodex.cpp b/indra/llaudio/llstreamingaudio_fmodex.cpp index 2cfae5128..154b1fc34 100644 --- a/indra/llaudio/llstreamingaudio_fmodex.cpp +++ b/indra/llaudio/llstreamingaudio_fmodex.cpp @@ -90,7 +90,13 @@ LLStreamingAudio_FMODEX::LLStreamingAudio_FMODEX(FMOD::System *system) : LLStreamingAudio_FMODEX::~LLStreamingAudio_FMODEX() { - // nothing interesting/safe to do. + stop(); + for (U32 i = 0; i < 100; ++i) + { + if (releaseDeadStreams()) + break; + ms_sleep(10); + } } @@ -169,24 +175,7 @@ std::string utf16input_to_utf8(char* input, U32 len, utf_endian_type_t type) void LLStreamingAudio_FMODEX::update() { - // Kill dead internet streams, if possible - std::list::iterator iter; - for (iter = mDeadStreams.begin(); iter != mDeadStreams.end();) - { - LLAudioStreamManagerFMODEX *streamp = *iter; - if (streamp->stopStream()) - { - llinfos << "Closed dead stream" << llendl; - delete streamp; - mDeadStreams.erase(iter++); - } - else - { - iter++; - } - } - - if(!mDeadStreams.empty()) + if (!releaseDeadStreams()) { llassert_always(mCurrentInternetStreamp == NULL); return; @@ -570,3 +559,25 @@ void LLStreamingAudio_FMODEX::setBufferSizes(U32 streambuffertime, U32 decodebuf settings.defaultDecodeBufferSize = decodebuffertime;//ms mSystem->setAdvancedSettings(&settings); } + +bool LLStreamingAudio_FMODEX::releaseDeadStreams() +{ + // Kill dead internet streams, if possible + std::list::iterator iter; + for (iter = mDeadStreams.begin(); iter != mDeadStreams.end();) + { + LLAudioStreamManagerFMODSTUDIO *streamp = *iter; + if (streamp->stopStream()) + { + llinfos << "Closed dead stream" << llendl; + delete streamp; + mDeadStreams.erase(iter++); + } + else + { + iter++; + } + } + + return mDeadStreams.empty(); +} \ No newline at end of file diff --git a/indra/llaudio/llstreamingaudio_fmodex.h b/indra/llaudio/llstreamingaudio_fmodex.h index 8e8bb2da6..15a4af931 100644 --- a/indra/llaudio/llstreamingaudio_fmodex.h +++ b/indra/llaudio/llstreamingaudio_fmodex.h @@ -70,6 +70,8 @@ class LLStreamingAudio_FMODEX : public LLStreamingAudioInterface /*virtual*/ bool supportsAdjustableBufferSizes(){return true;} /*virtual*/ void setBufferSizes(U32 streambuffertime, U32 decodebuffertime); private: + bool releaseDeadStreams(); + FMOD::System *mSystem; LLAudioStreamManagerFMODEX *mCurrentInternetStreamp; diff --git a/indra/llaudio/llstreamingaudio_fmodstudio.cpp b/indra/llaudio/llstreamingaudio_fmodstudio.cpp index 0c7b3d2c4..cfe8c05c3 100644 --- a/indra/llaudio/llstreamingaudio_fmodstudio.cpp +++ b/indra/llaudio/llstreamingaudio_fmodstudio.cpp @@ -160,6 +160,13 @@ LLStreamingAudio_FMODSTUDIO::LLStreamingAudio_FMODSTUDIO(FMOD::System *system) : LLStreamingAudio_FMODSTUDIO::~LLStreamingAudio_FMODSTUDIO() { + stop(); + for (U32 i = 0; i < 100; ++i) + { + if (releaseDeadStreams()) + break; + ms_sleep(10); + } if (mStreamGroup) { @@ -169,7 +176,6 @@ LLStreamingAudio_FMODSTUDIO::~LLStreamingAudio_FMODSTUDIO() } if (mStreamDSP) mStreamDSP->release(); - // nothing interesting/safe to do. } @@ -248,24 +254,7 @@ std::string utf16input_to_utf8(char* input, U32 len, utf_endian_type_t type) void LLStreamingAudio_FMODSTUDIO::update() { - // Kill dead internet streams, if possible - std::list::iterator iter; - for (iter = mDeadStreams.begin(); iter != mDeadStreams.end();) - { - LLAudioStreamManagerFMODSTUDIO *streamp = *iter; - if (streamp->stopStream()) - { - llinfos << "Closed dead stream" << llendl; - delete streamp; - mDeadStreams.erase(iter++); - } - else - { - iter++; - } - } - - if(!mDeadStreams.empty()) + if (!releaseDeadStreams()) { llassert_always(mCurrentInternetStreamp == NULL); return; @@ -653,3 +642,25 @@ void LLStreamingAudio_FMODSTUDIO::setBufferSizes(U32 streambuffertime, U32 decod settings.defaultDecodeBufferSize = decodebuffertime;//ms mSystem->setAdvancedSettings(&settings); } + +bool LLStreamingAudio_FMODSTUDIO::releaseDeadStreams() +{ + // Kill dead internet streams, if possible + std::list::iterator iter; + for (iter = mDeadStreams.begin(); iter != mDeadStreams.end();) + { + LLAudioStreamManagerFMODSTUDIO *streamp = *iter; + if (streamp->stopStream()) + { + llinfos << "Closed dead stream" << llendl; + delete streamp; + mDeadStreams.erase(iter++); + } + else + { + iter++; + } + } + + return mDeadStreams.empty(); +} \ No newline at end of file diff --git a/indra/llaudio/llstreamingaudio_fmodstudio.h b/indra/llaudio/llstreamingaudio_fmodstudio.h index a71a88eba..831e2407e 100644 --- a/indra/llaudio/llstreamingaudio_fmodstudio.h +++ b/indra/llaudio/llstreamingaudio_fmodstudio.h @@ -74,6 +74,8 @@ class LLStreamingAudio_FMODSTUDIO : public LLStreamingAudioInterface /*virtual*/ void setBufferSizes(U32 streambuffertime, U32 decodebuffertime); private: + bool releaseDeadStreams(); + FMOD::System *mSystem; LLAudioStreamManagerFMODSTUDIO *mCurrentInternetStreamp; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index e35d5ab27..3ed202986 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -4479,12 +4479,6 @@ void LLAppViewer::shutdownAudio() { if (gAudiop) { - // shut down the streaming audio sub-subsystem first, in case it relies on not outliving the general audio subsystem. - - LLStreamingAudioInterface *sai = gAudiop->getStreamingAudioImpl(); - delete sai; - gAudiop->setStreamingAudioImpl(NULL); - // shut down the audio subsystem bool want_longname = false;