summaryrefslogtreecommitdiff
path: root/indra/llaudio/llaudioengine_fmod.cpp
diff options
context:
space:
mode:
authorTofu Linden <tofu.linden@lindenlab.com>2010-06-08 20:48:57 +0100
committerTofu Linden <tofu.linden@lindenlab.com>2010-06-08 20:48:57 +0100
commitf5ae54f8c3fe954a08faa9b2de695c0326f2aeac (patch)
tree4c019dd25b0999d3136c5918b89385c365176856 /indra/llaudio/llaudioengine_fmod.cpp
parent9fd216e874b3937ae53bdd827d8120b42558a06f (diff)
DEV-11516 FIXED VWR-5308: Current wind noise generation is CPU intensive.
Minor optimizations to wind generation. Patch by gigs and aimee, reviewed by merov.
Diffstat (limited to 'indra/llaudio/llaudioengine_fmod.cpp')
-rw-r--r--indra/llaudio/llaudioengine_fmod.cpp92
1 files changed, 55 insertions, 37 deletions
diff --git a/indra/llaudio/llaudioengine_fmod.cpp b/indra/llaudio/llaudioengine_fmod.cpp
index d7f58defca..7a8a04afa1 100644
--- a/indra/llaudio/llaudioengine_fmod.cpp
+++ b/indra/llaudio/llaudioengine_fmod.cpp
@@ -54,13 +54,12 @@ extern "C" {
void * F_CALLBACKAPI windCallback(void *originalbuffer, void *newbuffer, int length, void* userdata);
}
-FSOUND_DSPUNIT *gWindDSP = NULL;
-
LLAudioEngine_FMOD::LLAudioEngine_FMOD()
{
mInited = false;
mWindGen = NULL;
+ mWindDSP = NULL;
}
@@ -258,10 +257,10 @@ void LLAudioEngine_FMOD::allocateListener(void)
void LLAudioEngine_FMOD::shutdown()
{
- if (gWindDSP)
+ if (mWindDSP)
{
- FSOUND_DSP_SetActive(gWindDSP,false);
- FSOUND_DSP_Free(gWindDSP);
+ FSOUND_DSP_SetActive(mWindDSP,false);
+ FSOUND_DSP_Free(mWindDSP);
}
stopInternetStream();
@@ -289,29 +288,66 @@ LLAudioChannel * LLAudioEngine_FMOD::createChannel()
}
-void LLAudioEngine_FMOD::initWind()
+bool LLAudioEngine_FMOD::initWind()
{
- mWindGen = new LLWindGen<MIXBUFFERFORMAT>;
+ if (!mWindGen)
+ {
+ bool enable;
+
+ switch (FSOUND_GetMixer())
+ {
+ case FSOUND_MIXER_MMXP5:
+ case FSOUND_MIXER_MMXP6:
+ case FSOUND_MIXER_QUALITY_MMXP5:
+ case FSOUND_MIXER_QUALITY_MMXP6:
+ enable = (typeid(MIXBUFFERFORMAT) == typeid(S16));
+ break;
+ case FSOUND_MIXER_BLENDMODE:
+ enable = (typeid(MIXBUFFERFORMAT) == typeid(S32));
+ break;
+ case FSOUND_MIXER_QUALITY_FPU:
+ enable = (typeid(MIXBUFFERFORMAT) == typeid(F32));
+ break;
+ default:
+ // FSOUND_GetMixer() does not return a valid mixer type on Darwin
+ LL_INFOS("AppInit") << "Unknown FMOD mixer type, assuming default" << LL_ENDL;
+ enable = true;
+ break;
+ }
+
+ if (enable)
+ {
+ mWindGen = new LLWindGen<MIXBUFFERFORMAT>(FSOUND_GetOutputRate());
+ }
+ else
+ {
+ LL_WARNS("AppInit") << "Incompatible FMOD mixer type, wind noise disabled" << LL_ENDL;
+ }
+ }
+
+ mNextWindUpdate = 0.0;
- if (!gWindDSP)
+ if (mWindGen && !mWindDSP)
{
- gWindDSP = FSOUND_DSP_Create(&windCallback, FSOUND_DSP_DEFAULTPRIORITY_CLEARUNIT + 20, mWindGen);
+ mWindDSP = FSOUND_DSP_Create(&windCallback, FSOUND_DSP_DEFAULTPRIORITY_CLEARUNIT + 20, mWindGen);
}
- if (gWindDSP)
+ if (mWindDSP)
{
- FSOUND_DSP_SetActive(gWindDSP, true);
+ FSOUND_DSP_SetActive(mWindDSP, true);
+ return true;
}
- mNextWindUpdate = 0.0;
+
+ return false;
}
void LLAudioEngine_FMOD::cleanupWind()
{
- if (gWindDSP)
+ if (mWindDSP)
{
- FSOUND_DSP_SetActive(gWindDSP, false);
- FSOUND_DSP_Free(gWindDSP);
- gWindDSP = NULL;
+ FSOUND_DSP_SetActive(mWindDSP, false);
+ FSOUND_DSP_Free(mWindDSP);
+ mWindDSP = NULL;
}
delete mWindGen;
@@ -740,30 +776,12 @@ void * F_CALLBACKAPI windCallback(void *originalbuffer, void *newbuffer, int len
// originalbuffer = fmod's original mixbuffer.
// newbuffer = the buffer passed from the previous DSP unit.
// length = length in samples at this mix time.
- // param = user parameter passed through in FSOUND_DSP_Create.
- //
- // modify the buffer in some fashion
+ // userdata = user parameter passed through in FSOUND_DSP_Create.
LLWindGen<LLAudioEngine_FMOD::MIXBUFFERFORMAT> *windgen =
(LLWindGen<LLAudioEngine_FMOD::MIXBUFFERFORMAT> *)userdata;
- U8 stride;
-
-#if LL_DARWIN
- stride = sizeof(LLAudioEngine_FMOD::MIXBUFFERFORMAT);
-#else
- int mixertype = FSOUND_GetMixer();
- if (mixertype == FSOUND_MIXER_BLENDMODE ||
- mixertype == FSOUND_MIXER_QUALITY_FPU)
- {
- stride = 4;
- }
- else
- {
- stride = 2;
- }
-#endif
-
- newbuffer = windgen->windGenerate((LLAudioEngine_FMOD::MIXBUFFERFORMAT *)newbuffer, length, stride);
+
+ newbuffer = windgen->windGenerate((LLAudioEngine_FMOD::MIXBUFFERFORMAT *)newbuffer, length);
return newbuffer;
}