From 7c3cdf29df95b442722eed978033e153ad2ac48e Mon Sep 17 00:00:00 2001 From: Drake Arconis <lightdrake@gmail.com> Date: Mon, 11 Aug 2014 07:54:03 -0400 Subject: [PATCH] Fix fmod studio build and knock out a few stream issues --- indra/llaudio/llaudioengine_fmodstudio.cpp | 3 +- indra/llaudio/llstreamingaudio_fmodstudio.cpp | 38 +++++++++++++++---- indra/llaudio/llstreamingaudio_fmodstudio.h | 1 + 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/indra/llaudio/llaudioengine_fmodstudio.cpp b/indra/llaudio/llaudioengine_fmodstudio.cpp index bfcc2ea124..9eebe84d71 100644 --- a/indra/llaudio/llaudioengine_fmodstudio.cpp +++ b/indra/llaudio/llaudioengine_fmodstudio.cpp @@ -486,7 +486,6 @@ bool LLAudioChannelFMODSTUDIO::updateBuffer() // If we have a source for the channel, we need to update its gain. if (mCurrentSourcep) { - // SJB: warnings can spam and hurt framerate, disabling //FMOD_RESULT result; mChannelp->setVolume(getSecondaryGain() * mCurrentSourcep->getGain()); @@ -677,7 +676,7 @@ bool LLAudioBufferFMODSTUDIO::loadWAV(const std::string& filename) mSoundp = NULL; } - FMOD_MODE base_mode = FMOD_LOOP_NORMAL | FMOD_SOFTWARE; + FMOD_MODE base_mode = FMOD_LOOP_NORMAL; FMOD_CREATESOUNDEXINFO exinfo; memset(&exinfo,0,sizeof(exinfo)); exinfo.cbsize = sizeof(exinfo); diff --git a/indra/llaudio/llstreamingaudio_fmodstudio.cpp b/indra/llaudio/llstreamingaudio_fmodstudio.cpp index 5110cd3806..d8833e114c 100644 --- a/indra/llaudio/llstreamingaudio_fmodstudio.cpp +++ b/indra/llaudio/llstreamingaudio_fmodstudio.cpp @@ -100,9 +100,17 @@ void LLStreamingAudio_FMODSTUDIO::start(const std::string& url) if (!url.empty()) { - LL_INFOS() << "Starting internet stream: " << url << LL_ENDL; - mCurrentInternetStreamp = new LLAudioStreamManagerFMODSTUDIO(mSystem,url); - mURL = url; + if(mDeadStreams.empty()) + { + LL_INFOS() << "Starting internet stream: " << url << LL_ENDL; + mCurrentInternetStreamp = new LLAudioStreamManagerFMODSTUDIO(mSystem,url); + mURL = url; + } + else + { + LL_INFOS() << "Deferring stream load until buffer release: " << url << LL_ENDL; + mPendingURL = url; + } } else { @@ -131,6 +139,21 @@ void LLStreamingAudio_FMODSTUDIO::update() } } + if(!mDeadStreams.empty()) + { + llassert_always(mCurrentInternetStreamp == NULL); + return; + } + + if(!mPendingURL.empty()) + { + llassert_always(mCurrentInternetStreamp == NULL); + llinfos << "Starting internet stream: " << mPendingURL << LL_ENDL; + mCurrentInternetStreamp = new LLAudioStreamManagerFMODSTUDIO(mSystem,mPendingURL); + mURL = mPendingURL; + mPendingURL.clear(); + } + // Don't do anything if there are no streams playing if (!mCurrentInternetStreamp) { @@ -211,6 +234,8 @@ void LLStreamingAudio_FMODSTUDIO::update() void LLStreamingAudio_FMODSTUDIO::stop() { + mPendingURL.clear(); + if (mFMODInternetStreamChannelp) { mFMODInternetStreamChannelp->setPaused(true); @@ -264,7 +289,7 @@ int LLStreamingAudio_FMODSTUDIO::isPlaying() { return 1; // Active and playing } - else if (!mURL.empty()) + else if (!mURL.empty() || !mPendingURL.empty()) { return 2; // "Paused" } @@ -344,8 +369,6 @@ bool LLAudioStreamManagerFMODSTUDIO::stopStream() { if (mInternetStream) { - - bool close = true; switch (getOpenState()) { @@ -356,9 +379,8 @@ bool LLAudioStreamManagerFMODSTUDIO::stopStream() close = true; } - if (close) + if (close && mInternetStream->release() == FMOD_OK) { - mInternetStream->release(); mStreamChannel = NULL; mInternetStream = NULL; return true; diff --git a/indra/llaudio/llstreamingaudio_fmodstudio.h b/indra/llaudio/llstreamingaudio_fmodstudio.h index 4ed797c742..5e1a6a373c 100644 --- a/indra/llaudio/llstreamingaudio_fmodstudio.h +++ b/indra/llaudio/llstreamingaudio_fmodstudio.h @@ -66,6 +66,7 @@ private: std::list<LLAudioStreamManagerFMODSTUDIO *> mDeadStreams; std::string mURL; + std::string mPendingURL; F32 mGain; }; -- GitLab