diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp index 8be13d7834..397b7355f1 100644 --- a/indra/llaudio/llaudioengine.cpp +++ b/indra/llaudio/llaudioengine.cpp @@ -1347,7 +1347,7 @@ LLAudioSource::LLAudioSource(const LLUUID& id, const LLUUID& owner_id, const F32 std::map 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) { // 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. diff --git a/indra/llaudio/llaudioengine.h b/indra/llaudio/llaudioengine.h index 44ed31520f..2263d12343 100644 --- a/indra/llaudio/llaudioengine.h +++ b/indra/llaudio/llaudioengine.h @@ -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) { } }; diff --git a/indra/newview/NACLfloaterexploresounds.cpp b/indra/newview/NACLfloaterexploresounds.cpp index ad65c34b5c..f28f675b4e 100644 --- a/indra/newview/NACLfloaterexploresounds.cpp +++ b/indra/newview/NACLfloaterexploresounds.cpp @@ -386,23 +386,25 @@ void NACLFloaterExploreSounds::handleLookAt() void NACLFloaterExploreSounds::handleStop() { std::vector selection = mHistoryScroller->getAllSelected(); - std::vector::iterator selection_iter = selection.begin(); - std::vector::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); - } } } }