From 2d648c1da0a95b54c877a4aac6835181b1c069e5 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Sat, 14 May 2011 23:43:19 +0200 Subject: [PATCH 1/3] Workaround for windows compiler bug. Visual C++ compiler doesn't like to take a pointer to a variable in the argument list of that variable when it is being declared. --- indra/llcommon/aithreadsafe.h | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/indra/llcommon/aithreadsafe.h b/indra/llcommon/aithreadsafe.h index 810aa8c2f..486b3b24f 100644 --- a/indra/llcommon/aithreadsafe.h +++ b/indra/llcommon/aithreadsafe.h @@ -51,6 +51,14 @@ template struct AIReadAccess; template struct AIWriteAccess; template struct AIAccess; +#if LL_WINDOWS +template class AIThreadSafeBits; +template +struct AIThreadSafeWindowsHack { + AIThreadSafeWindowsHack(AIThreadSafeBits& var, T* object); +}; +#endif + template class AIThreadSafeBits { @@ -73,6 +81,9 @@ public: void* memory() const { return const_cast(&mMemory[0]); } protected: +#if LL_WINDOWS + template friend struct AIThreadSafeWindowsHack; +#endif // Accessors. T const* ptr() const { return reinterpret_cast(mMemory); } T* ptr() { return reinterpret_cast(mMemory); } @@ -168,7 +179,12 @@ protected: public: // Only for use by AITHREADSAFE, see below. - AIThreadSafe(T* object) { llassert(object == AIThreadSafeBits::ptr()); } + AIThreadSafe(T* object) + { +#if !LL_WINDOWS + llassert(object == AIThreadSafeBits::ptr()); +#endif + } }; /** @@ -191,7 +207,18 @@ public: * Note: This macro does not allow to allocate such object on the heap. * If that is needed, have a look at AIThreadSafeDC. */ +#if LL_WINDOWS +template +AIThreadSafeWindowsHack::AIThreadSafeWindowsHack(AIThreadSafeBits& var, T* object) +{ + llassert(object == var.ptr()); +} +#define AITHREADSAFE(type, var, paramlist) \ + AIThreadSafe var(NULL); \ + AIThreadSafeWindowsHack dummy_##var(var, new (var.memory()) type paramlist) +#else #define AITHREADSAFE(type, var, paramlist) AIThreadSafe var(new (var.memory()) type paramlist) +#endif /** * @brief A wrapper class for objects that need to be accessed by more than one thread. From 697f0ad05473d31efa5a27ccf4e9c8930fec722f Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Sun, 15 May 2011 02:23:13 +0200 Subject: [PATCH 2/3] Old VWR-14914 spin-off sound beacon patch. This makes sound beacons green when playing at full volume, yellow when playing at a lower volume and red when they are muted (aka, in another parcel that you can't hear the sounds of). Originally this was a debug patch as muted sound sources used to be implemented by setting the volume to zero, which happens to use like three times more CPU: so, having a lot of muted sound source caused the audio thread to never release a mutex anymore (cause it was never idle anymore), causing the main loop to hang, waiting on that mutex - dropping the FPS drastically. Hence it was necessary to see which sound sources were muted for debugging purposes. (Since VWR-14914, muted source source are not played at all anymore, so they do not take extra CPU). It's still fun to see this extra information though, now the patch exists anyway. --- indra/llaudio/llaudioengine.h | 8 +++++++- indra/newview/llviewerobjectlist.cpp | 2 ++ indra/newview/llviewerwindow.cpp | 2 +- indra/newview/pipeline.cpp | 28 ++++++++++++++++++++++++++-- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/indra/llaudio/llaudioengine.h b/indra/llaudio/llaudioengine.h index 4d5d919e1..07e97b0be 100644 --- a/indra/llaudio/llaudioengine.h +++ b/indra/llaudio/llaudioengine.h @@ -337,6 +337,7 @@ public: friend class LLAudioChannel; protected: void setChannel(LLAudioChannel *channelp); +public: LLAudioChannel *getChannel() const { return mChannelp; } protected: @@ -430,17 +431,22 @@ public: friend class LLAudioEngine; friend class LLAudioSource; + protected: virtual void play() = 0; virtual void playSynced(LLAudioChannel *channelp) = 0; virtual void cleanup() = 0; + void setWaiting(bool waiting) { mWaiting = waiting; } + +public: virtual bool isPlaying() = 0; - void setWaiting(const bool waiting) { mWaiting = waiting; } bool isWaiting() const { return mWaiting; } +protected: virtual bool updateBuffer(); // Check to see if the buffer associated with the source changed, and update if necessary. virtual void update3DPosition() = 0; virtual void updateLoop() = 0; // Update your loop/completion status, for use by queueing/syncing. + protected: LLAudioSource *mCurrentSourcep; LLAudioBuffer *mCurrentBufferp; diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 5e62531d1..332c090fc 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -980,6 +980,7 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer) // No dead objects, don't need to scan object list. return; } + llwarns << "ENTERING LLViewerObjectList::cleanDeadObjects" << llendl; S32 num_removed = 0; LLViewerObject *objectp; @@ -1008,6 +1009,7 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer) // before blowing away the dead list. mDeadObjects.clear(); mNumDeadObjects = 0; + llwarns << "LEAVING LLViewerObjectList::cleanDeadObjects" << llendl; } void LLViewerObjectList::updateActive(LLViewerObject *objectp) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 2e256db6b..5075d1a86 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -553,7 +553,7 @@ public: } if (LLPipeline::getRenderSoundBeacons(NULL)) { - addText(xpos, ypos, "Viewing sound beacons (yellow)"); + addText(xpos, ypos, "Viewing sound beacons (blue/cyan/green/yellow/red)"); ypos += y_inc; } } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 3562733ea..ac8e8e2db 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2548,8 +2548,32 @@ void LLPipeline::postSort(LLCamera& camera) LLVector3 pos = gAgent.getPosAgentFromGlobal(pos_global); if (gPipeline.sRenderBeacons) { - //pos += LLVector3(0.f, 0.f, 0.2f); - gObjectList.addDebugBeacon(pos, "", LLColor4(1.f, 1.f, 0.f, 0.5f), LLColor4(1.f, 1.f, 1.f, 0.5f), gSavedSettings.getS32("DebugBeaconLineWidth")); + LLAudioChannel* channel = sourcep->getChannel(); + bool const is_playing = channel && channel->isPlaying(); + S32 width = 2; + LLColor4 color = LLColor4(0.f, 0.f, 1.f, 0.5f); + if (is_playing) + { + llassert(!sourcep->isMuted()); + F32 gain = sourcep->getGain() * channel->getSecondaryGain(); + if (gain == 0.f) + { + color = LLColor4(1.f, 0.f, 0.f, 0.5f); + } + else if (gain == 1.f) + { + color = LLColor4(0.f, 1.f, 0.f, 0.5f); + width = gSavedSettings.getS32("DebugBeaconLineWidth"); + } + else + { + color = LLColor4(1.f, 1.f, 0.f, 0.5f); + width = 1 + gain * (gSavedSettings.getS32("DebugBeaconLineWidth") - 1); + } + } + else if (sourcep->isMuted()) + color = LLColor4(0.f, 1.f, 1.f, 0.5f); + gObjectList.addDebugBeacon(pos, "", color, LLColor4(1.f, 1.f, 1.f, 0.5f), width); } } // now deal with highlights for all those seeable sound sources From 4e68f5878a4460b5cea44e245537b204acb83028 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Sun, 15 May 2011 05:03:34 +0200 Subject: [PATCH 3/3] Add missing AIReadAccessConst initialization of mIsCopyConstructed --- indra/llcommon/aithreadsafe.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/indra/llcommon/aithreadsafe.h b/indra/llcommon/aithreadsafe.h index 486b3b24f..3963281cb 100644 --- a/indra/llcommon/aithreadsafe.h +++ b/indra/llcommon/aithreadsafe.h @@ -305,7 +305,11 @@ struct AIReadAccessConst protected: //! Constructor used by AIReadAccess. AIReadAccessConst(AIThreadSafe& wrapper, state_type state) - : mWrapper(wrapper), mState(state) { } + : mWrapper(wrapper), mState(state) +#if AI_NEED_ACCESS_CC + , mIsCopyConstructed(false) +#endif + { } AIThreadSafe& mWrapper; //!< Reference to the object that we provide access to. state_type const mState; //!< The lock state that mWrapper is in.