From d9de58b46ab4c5e248b8dd7b3f79e1672f1f215a Mon Sep 17 00:00:00 2001 From: callum Date: Fri, 19 Apr 2013 16:29:11 -0700 Subject: OPEN-173 FIX FMODEx Music stutters once every few seconds (OSS patch via Latif Khalifa & Siana Gearz) --- autobuild.xml | 12 +++++----- indra/llaudio/llstreamingaudio_fmodex.cpp | 39 +++++++++++++++++++++++-------- indra/llaudio/llstreamingaudio_fmodex.h | 2 -- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/autobuild.xml b/autobuild.xml index ba6b76e7b2..1bf09eab3d 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -498,9 +498,9 @@ archive hash - 89a3df89da75444877cf3197416fed67 + 10352aab979c333a52dbad21b6e6fba9 url - http://s3-proxy.lindenlab.com/private-builds-secondlife-com/hg/repo/3p-fmodex-private/rev/270029/arch/Darwin/installer/fmodex-4.44-darwin-20130205.tar.bz2 + http://s3-proxy.lindenlab.com/private-builds-secondlife-com/hg/repo/3p-fmodex-private/rev/274403/arch/Darwin/installer/fmodex-4.44-darwin-20130419.tar.bz2 name darwin @@ -510,9 +510,9 @@ archive hash - fd787931f49ece9bf99f4d1d1596f04b + 79e45527aa9fb90b813599dff5ce01a7 url - http://s3-proxy.lindenlab.com/private-builds-secondlife-com/hg/repo/3p-fmodex-private/rev/269984/arch/Linux/installer/fmodex-4.44-linux-20130205.tar.bz2 + http://s3-proxy.lindenlab.com/private-builds-secondlife-com/hg/repo/3p-fmodex-private/rev/274378/arch/Linux/installer/fmodex-4.44-linux-20130419.tar.bz2 name linux @@ -522,9 +522,9 @@ archive hash - 9e0f62be63e74af18f670f864cac93da + 81a2f77651e37b704198c7ea72f63040 url - http://s3-proxy.lindenlab.com/private-builds-secondlife-com/hg/repo/3p-fmodex-private/rev/270026/arch/CYGWIN/installer/fmodex-4.44-windows-20130205.tar.bz2 + http://s3-proxy.lindenlab.com/private-builds-secondlife-com/hg/repo/3p-fmodex-private/rev/274401/arch/CYGWIN/installer/fmodex-4.44-windows-20130419.tar.bz2 name windows diff --git a/indra/llaudio/llstreamingaudio_fmodex.cpp b/indra/llaudio/llstreamingaudio_fmodex.cpp index 4a74267650..266fa2f57b 100644 --- a/indra/llaudio/llstreamingaudio_fmodex.cpp +++ b/indra/llaudio/llstreamingaudio_fmodex.cpp @@ -153,7 +153,6 @@ void LLStreamingAudio_FMODEX::update() // Reset volume to previously set volume setGain(getGain()); mFMODInternetStreamChannelp->setPaused(false); - mLastStarved.stop(); } } else if(open_state == FMOD_OPENSTATE_ERROR) @@ -168,21 +167,43 @@ void LLStreamingAudio_FMODEX::update() if(mFMODInternetStreamChannelp->getCurrentSound(&sound) == FMOD_OK && sound) { + FMOD_TAG tag; + S32 tagcount, dirtytagcount; + + if(sound->getNumTags(&tagcount, &dirtytagcount) == FMOD_OK && dirtytagcount) + { + for(S32 i = 0; i < tagcount; ++i) + { + if(sound->getTag(NULL, i, &tag)!=FMOD_OK) + continue; + + if (tag.type == FMOD_TAGTYPE_FMOD) + { + if (!strcmp(tag.name, "Sample Rate Change")) + { + llinfos << "Stream forced changing sample rate to " << *((float *)tag.data) << llendl; + mFMODInternetStreamChannelp->setFrequency(*((float *)tag.data)); + } + continue; + } + } + } + if(starving) { - if(!mLastStarved.getStarted()) + bool paused = false; + mFMODInternetStreamChannelp->getPaused(&paused); + if(!paused) { - llinfos << "Stream starvation detected! Muting stream audio until it clears." << llendl; + llinfos << "Stream starvation detected! Pausing stream until buffer nearly full." << llendl; llinfos << " (diskbusy="<setMute(true); + mFMODInternetStreamChannelp->setPaused(true); } - mLastStarved.start(); } - else if(mLastStarved.getStarted() && mLastStarved.getElapsedTimeF32() > 1.f) + else if(progress > 80) { - mLastStarved.stop(); - mFMODInternetStreamChannelp->setMute(false); + mFMODInternetStreamChannelp->setPaused(false); } } } @@ -190,8 +211,6 @@ void LLStreamingAudio_FMODEX::update() void LLStreamingAudio_FMODEX::stop() { - mLastStarved.stop(); - if (mFMODInternetStreamChannelp) { mFMODInternetStreamChannelp->setPaused(true); diff --git a/indra/llaudio/llstreamingaudio_fmodex.h b/indra/llaudio/llstreamingaudio_fmodex.h index 42b6b3aaa8..1dee18ae7d 100644 --- a/indra/llaudio/llstreamingaudio_fmodex.h +++ b/indra/llaudio/llstreamingaudio_fmodex.h @@ -67,8 +67,6 @@ private: std::string mURL; F32 mGain; - - LLTimer mLastStarved; }; -- cgit v1.2.3