Make streamtitle display work with fmodex
Yes, polling looks ugly, but there doesn't seem to be a callback method for changed metadata anymore and the "updated" member in the FMOD_TAG struct doesn't want to work properly.meow-7.2.2
parent
fb7e3b69ea
commit
3cc0755527
|
|
@ -42,6 +42,12 @@ public:
|
|||
bool stopStream(); // Returns true if the stream was successfully stopped.
|
||||
bool ready();
|
||||
|
||||
// <FS:Ansariel> Streamtitle display
|
||||
bool hasNewMetadata();
|
||||
std::string getCurrentArtist();
|
||||
std::string getCurrentTitle();
|
||||
// </FS:Ansariel>
|
||||
|
||||
const std::string& getURL() { return mInternetStreamURL; }
|
||||
|
||||
FMOD_OPENSTATE getOpenState(unsigned int* percentbuffered=NULL, bool* starving=NULL, bool* diskbusy=NULL);
|
||||
|
|
@ -52,6 +58,11 @@ protected:
|
|||
bool mReady;
|
||||
|
||||
std::string mInternetStreamURL;
|
||||
|
||||
// <FS:Ansariel> Streamtitle display
|
||||
char* mArtist;
|
||||
char* mTitle;
|
||||
// </FS:Ansariel>
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -299,6 +310,38 @@ void LLStreamingAudio_FMODEX::setGain(F32 vol)
|
|||
}
|
||||
}
|
||||
|
||||
// <FS:Ansariel> Streamtitle display
|
||||
bool LLStreamingAudio_FMODEX::hasNewMetadata()
|
||||
{
|
||||
if (mCurrentInternetStreamp)
|
||||
{
|
||||
return mCurrentInternetStreamp->hasNewMetadata();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string LLStreamingAudio_FMODEX::getCurrentTitle()
|
||||
{
|
||||
if (mCurrentInternetStreamp)
|
||||
{
|
||||
return mCurrentInternetStreamp->getCurrentTitle();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string LLStreamingAudio_FMODEX::getCurrentArtist()
|
||||
{
|
||||
if (mCurrentInternetStreamp)
|
||||
{
|
||||
return mCurrentInternetStreamp->getCurrentArtist();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
// </FS:Ansariel>
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// manager of possibly-multiple internet audio streams
|
||||
|
||||
|
|
@ -390,3 +433,47 @@ void LLStreamingAudio_FMODEX::setBufferSizes(U32 streambuffertime, U32 decodebuf
|
|||
settings.defaultDecodeBufferSize = decodebuffertime;//ms
|
||||
mSystem->setAdvancedSettings(&settings);
|
||||
}
|
||||
|
||||
// <FS:Ansariel> Streamtitle display
|
||||
bool LLAudioStreamManagerFMODEX::hasNewMetadata()
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
FMOD_TAG tag;
|
||||
FMOD_RESULT res;
|
||||
|
||||
res = mInternetStream->getTag("TITLE", 0, &tag);
|
||||
if (res == FMOD_OK)
|
||||
{
|
||||
char* new_title = (char*)tag.data;
|
||||
if (new_title != mTitle)
|
||||
{
|
||||
mTitle = new_title;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
res = mInternetStream->getTag("ARTIST", 0, &tag);
|
||||
if (res == FMOD_OK)
|
||||
{
|
||||
char* new_artist = (char*)tag.data;
|
||||
if (new_artist != mArtist)
|
||||
{
|
||||
mArtist = new_artist;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string LLAudioStreamManagerFMODEX::getCurrentTitle()
|
||||
{
|
||||
return std::string(mTitle);
|
||||
}
|
||||
|
||||
std::string LLAudioStreamManagerFMODEX::getCurrentArtist()
|
||||
{
|
||||
return std::string(mArtist);
|
||||
}
|
||||
// </FS:Ansariel>
|
||||
|
|
|
|||
|
|
@ -58,6 +58,13 @@ class LLStreamingAudio_FMODEX : public LLStreamingAudioInterface
|
|||
|
||||
/*virtual*/ bool supportsAdjustableBufferSizes(){return true;}
|
||||
/*virtual*/ void setBufferSizes(U32 streambuffertime, U32 decodebuffertime);
|
||||
|
||||
// <FS:Ansariel> Streamtitle display
|
||||
virtual bool hasNewMetadata();
|
||||
virtual std::string getCurrentArtist();
|
||||
virtual std::string getCurrentTitle();
|
||||
// </FS:Ansariel>
|
||||
|
||||
private:
|
||||
FMOD::System *mSystem;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,19 +52,21 @@ void StreamTitleDisplay::checkMetadata()
|
|||
static LLCachedControl<U32> ShowStreamMetadata(gSavedSettings, "ShowStreamMetadata");
|
||||
static LLCachedControl<bool> StreamMetadataAnnounceToChat(gSavedSettings, "StreamMetadataAnnounceToChat");
|
||||
|
||||
if(!gAudiop)
|
||||
if (!gAudiop)
|
||||
{
|
||||
return;
|
||||
if(gAudiop->getStreamingAudioImpl()->hasNewMetadata() && (ShowStreamMetadata > 0 || StreamMetadataAnnounceToChat))
|
||||
}
|
||||
if ((ShowStreamMetadata > 0 || StreamMetadataAnnounceToChat) && gAudiop->getStreamingAudioImpl()->hasNewMetadata())
|
||||
{
|
||||
std::string chat = "";
|
||||
std::string title = gAudiop->getStreamingAudioImpl()->getCurrentTitle();
|
||||
std::string artist = gAudiop->getStreamingAudioImpl()->getCurrentArtist();
|
||||
|
||||
if(artist.length() > 0)
|
||||
if (artist.length() > 0)
|
||||
{
|
||||
chat = artist;
|
||||
}
|
||||
if(title.length() > 0)
|
||||
if (title.length() > 0)
|
||||
{
|
||||
if (chat.length() > 0)
|
||||
{
|
||||
|
|
@ -88,7 +90,7 @@ void StreamTitleDisplay::checkMetadata()
|
|||
{
|
||||
LLSD args;
|
||||
args["TITLE"] = title;
|
||||
if(artist.length() > 0)
|
||||
if (artist.length() > 0)
|
||||
{
|
||||
args["ARTIST"] = artist;
|
||||
LLNotificationsUtil::add("StreamMetadata", args);
|
||||
|
|
|
|||
Loading…
Reference in New Issue