FIRE-17879: Fix possible crash in sound explorer: Stored audio source pointer might be invalid
parent
b233d552f3
commit
41c8f09e06
|
|
@ -1347,7 +1347,7 @@ LLAudioSource::LLAudioSource(const LLUUID& id, const LLUUID& owner_id, const F32
|
|||
std::map<LLUUID, LLSoundHistoryItem> gSoundHistory;
|
||||
|
||||
// static
|
||||
void LLAudioSource::logSoundPlay(const LLUUID& id, LLAudioSource* audio_source, LLVector3d position, S32 type, const LLUUID& assetid, const LLUUID& ownerid, const LLUUID& sourceid, bool is_trigger, bool is_looped)
|
||||
void LLAudioSource::logSoundPlay(const LLUUID& id, LLVector3d position, S32 type, const LLUUID& assetid, const LLUUID& ownerid, const LLUUID& sourceid, bool is_trigger, bool is_looped)
|
||||
{
|
||||
// <FS:ND> Corrupt asset, do not bother
|
||||
if( gAudiop->isCorruptSound( assetid ) )
|
||||
|
|
@ -1362,7 +1362,6 @@ void LLAudioSource::logSoundPlay(const LLUUID& id, LLAudioSource* audio_source,
|
|||
|
||||
LLSoundHistoryItem item;
|
||||
item.mID = id;
|
||||
item.mAudioSource = audio_source;
|
||||
item.mPosition = position;
|
||||
item.mType = type;
|
||||
item.mAssetID = assetid;
|
||||
|
|
@ -1387,7 +1386,6 @@ void LLAudioSource::logSoundStop(const LLUUID& id)
|
|||
{
|
||||
gSoundHistory[id].mPlaying = false;
|
||||
gSoundHistory[id].mTimeStopped = LLTimer::getElapsedSeconds();
|
||||
gSoundHistory[id].mAudioSource = NULL; // just in case
|
||||
pruneSoundLog();
|
||||
}
|
||||
}
|
||||
|
|
@ -1546,7 +1544,7 @@ bool LLAudioSource::play(const LLUUID &audio_uuid)
|
|||
// NaCl - Sound Explorer
|
||||
if(mType != LLAudioEngine::AUDIO_TYPE_UI) //&& mSourceID.notNull())
|
||||
{
|
||||
logSoundPlay(mLogID, this, mPositionGlobal, mType, audio_uuid, mOwnerID, mSourceID, mIsTrigger, mLoop);
|
||||
logSoundPlay(mLogID, mPositionGlobal, mType, audio_uuid, mOwnerID, mSourceID, mIsTrigger, mLoop);
|
||||
}
|
||||
// NaCl End
|
||||
// Special abuse of play(); don't play a sound, but kill it.
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ protected:
|
|||
void setChannel(LLAudioChannel *channelp);
|
||||
LLAudioChannel *getChannel() const { return mChannelp; }
|
||||
// NaCl - Sound Explorer
|
||||
static void logSoundPlay(const LLUUID& id, LLAudioSource* audio_source, LLVector3d position, S32 type, const LLUUID& assetid, const LLUUID& ownerid, const LLUUID& sourceid, bool is_trigger, bool is_looped);
|
||||
static void logSoundPlay(const LLUUID& id, LLVector3d position, S32 type, const LLUUID& assetid, const LLUUID& ownerid, const LLUUID& sourceid, bool is_trigger, bool is_looped);
|
||||
static void logSoundStop(const LLUUID& id);
|
||||
static void pruneSoundLog();
|
||||
static S32 sSoundHistoryPruneCounter;
|
||||
|
|
@ -556,7 +556,6 @@ struct LLSoundHistoryItem
|
|||
F64 mTimeStopped;
|
||||
bool mReviewed;
|
||||
bool mReviewedCollision;
|
||||
LLAudioSource* mAudioSource;
|
||||
|
||||
LLSoundHistoryItem()
|
||||
: mType(0)
|
||||
|
|
@ -567,7 +566,6 @@ struct LLSoundHistoryItem
|
|||
, mTimeStopped(0.f)
|
||||
, mReviewed(false)
|
||||
, mReviewedCollision(false)
|
||||
, mAudioSource(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -386,23 +386,25 @@ void NACLFloaterExploreSounds::handleLookAt()
|
|||
void NACLFloaterExploreSounds::handleStop()
|
||||
{
|
||||
std::vector<LLScrollListItem*> selection = mHistoryScroller->getAllSelected();
|
||||
std::vector<LLScrollListItem*>::iterator selection_iter = selection.begin();
|
||||
std::vector<LLScrollListItem*>::iterator selection_end = selection.end();
|
||||
for (; selection_iter != selection_end; ++selection_iter)
|
||||
for (const auto& selection_item : selection)
|
||||
{
|
||||
LLSoundHistoryItem item = getItem((*selection_iter)->getValue());
|
||||
LLSoundHistoryItem item = getItem(selection_item->getValue());
|
||||
if (item.mID.notNull() && item.mPlaying)
|
||||
{
|
||||
// Make sure the audio source in question is still in the system to prevent
|
||||
// crashes by using a stale pointer. This can happen when the same UUID is
|
||||
// played twice without stopping it first. -Zi
|
||||
if (!gAudiop->findAudioSource(item.mSourceID))
|
||||
LLAudioSource* audio_source = gAudiop->findAudioSource(item.mSourceID);
|
||||
if (audio_source)
|
||||
{
|
||||
LL_WARNS("SoundExplorer") << "audio source " << item.mAudioSource << " already gone but still marked as playing. Fixing ..." << LL_ENDL;
|
||||
S32 type = item.mType;
|
||||
audio_source->setType(LLAudioEngine::AUDIO_TYPE_UI);
|
||||
audio_source->play(LLUUID::null);
|
||||
audio_source->setType(type);
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_WARNS("SoundExplorer") << "audio source for source ID " << item.mSourceID << " already gone but still marked as playing. Fixing ..." << LL_ENDL;
|
||||
if (gSoundHistory.find(item.mID) != gSoundHistory.end())
|
||||
{
|
||||
gSoundHistory[item.mID].mPlaying = false;
|
||||
gSoundHistory[item.mID].mAudioSource = nullptr;
|
||||
gSoundHistory[item.mID].mTimeStopped = LLTimer::getElapsedSeconds();
|
||||
}
|
||||
else
|
||||
|
|
@ -412,7 +414,6 @@ void NACLFloaterExploreSounds::handleStop()
|
|||
if (histItem.mID == item.mID)
|
||||
{
|
||||
histItem.mPlaying = false;
|
||||
histItem.mAudioSource = nullptr;
|
||||
histItem.mTimeStopped = LLTimer::getElapsedSeconds();
|
||||
break;
|
||||
}
|
||||
|
|
@ -420,14 +421,6 @@ void NACLFloaterExploreSounds::handleStop()
|
|||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.mAudioSource)
|
||||
{
|
||||
S32 type = item.mType;
|
||||
item.mAudioSource->setType(LLAudioEngine::AUDIO_TYPE_UI);
|
||||
item.mAudioSource->play(LLUUID::null);
|
||||
item.mAudioSource->setType(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue