Stream frequency change support and new anti-starvation strategy

This commit is contained in:
Siana Gearz
2013-02-26 23:13:39 +01:00
parent 6ee8cc5798
commit c9ab38d449
3 changed files with 16 additions and 13 deletions

View File

@@ -161,7 +161,6 @@ void LLStreamingAudio_FMODEX::update()
// Reset volume to previously set volume // Reset volume to previously set volume
setGain(getGain()); setGain(getGain());
mFMODInternetStreamChannelp->setPaused(false); mFMODInternetStreamChannelp->setPaused(false);
mLastStarved.stop();
} }
} }
else if(open_state == FMOD_OPENSTATE_ERROR) else if(open_state == FMOD_OPENSTATE_ERROR)
@@ -200,6 +199,13 @@ void LLStreamingAudio_FMODEX::update()
if(name == "Title") name = "TITLE"; if(name == "Title") name = "TITLE";
else if(name == "WM/AlbumArtist") name = "ARTIST"; else if(name == "WM/AlbumArtist") name = "ARTIST";
break; break;
case(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;
default: default:
break; break;
} }
@@ -243,19 +249,19 @@ void LLStreamingAudio_FMODEX::update()
} }
if(starving) 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="<<diskbusy<<")" << llendl; llinfos << " (diskbusy="<<diskbusy<<")" << llendl;
llinfos << " (progress="<<progress<<")" << llendl; llinfos << " (progress="<<progress<<")" << llendl;
mFMODInternetStreamChannelp->setMute(true); mFMODInternetStreamChannelp->setPaused(true);
} }
mLastStarved.start();
} }
else if(mLastStarved.getStarted() && mLastStarved.getElapsedTimeF32() > 1.f) else if(progress > 80)
{ {
mLastStarved.stop(); mFMODInternetStreamChannelp->setPaused(false);
mFMODInternetStreamChannelp->setMute(false);
} }
} }
} }
@@ -263,7 +269,6 @@ void LLStreamingAudio_FMODEX::update()
void LLStreamingAudio_FMODEX::stop() void LLStreamingAudio_FMODEX::stop()
{ {
mLastStarved.stop();
if(mMetaData) if(mMetaData)
{ {
delete mMetaData; delete mMetaData;

View File

@@ -79,8 +79,6 @@ private:
std::string mURL; std::string mURL;
F32 mGain; F32 mGain;
LLTimer mLastStarved;
LLSD *mMetaData; LLSD *mMetaData;
}; };

View File

@@ -50,7 +50,7 @@
<key>Type</key> <key>Type</key>
<string>U32</string> <string>U32</string>
<key>Value</key> <key>Value</key>
<integer>7000</integer> <integer>15000</integer>
</map> </map>
<key>SHFMODExDecodeBufferSize</key> <key>SHFMODExDecodeBufferSize</key>
<map> <map>
@@ -61,7 +61,7 @@
<key>Type</key> <key>Type</key>
<string>U32</string> <string>U32</string>
<key>Value</key> <key>Value</key>
<integer>1000</integer> <integer>2000</integer>
</map> </map>
<key>SHAllowScriptCommands</key> <key>SHAllowScriptCommands</key>
<map> <map>