From 4cec3133197cd39efd607b82169a85f56c77aa68 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Tue, 6 Feb 2024 01:26:53 +0200
Subject: SL-19585 Switch OpenAL's wind to float

Fixes wind being odly distorted
---
 indra/llaudio/llaudioengine_openal.cpp | 2 +-
 indra/llaudio/llaudioengine_openal.h   | 4 ++--
 indra/llaudio/lllistener_openal.h      | 1 +
 indra/newview/llvieweraudio.cpp        | 9 +++++++--
 4 files changed, 11 insertions(+), 5 deletions(-)

(limited to 'indra')

diff --git a/indra/llaudio/llaudioengine_openal.cpp b/indra/llaudio/llaudioengine_openal.cpp
index 0a79614424..40d7988309 100644
--- a/indra/llaudio/llaudioengine_openal.cpp
+++ b/indra/llaudio/llaudioengine_openal.cpp
@@ -518,7 +518,7 @@ void LLAudioEngine_OpenAL::updateWind(LLVector3 wind_vec, F32 camera_altitude)
 		}
 
 		alBufferData(buffer,
-			     AL_FORMAT_STEREO16,
+                 AL_FORMAT_STEREO_FLOAT32,
 			     mWindGen->windGenerate(mWindBuf,
 						    mWindBufSamples),
 			     mWindBufBytes,
diff --git a/indra/llaudio/llaudioengine_openal.h b/indra/llaudio/llaudioengine_openal.h
index 562c96c794..c2dfad6a56 100644
--- a/indra/llaudio/llaudioengine_openal.h
+++ b/indra/llaudio/llaudioengine_openal.h
@@ -57,9 +57,9 @@ class LLAudioEngine_OpenAL : public LLAudioEngine
 		/*virtual*/ void updateWind(LLVector3 direction, F32 camera_altitude);
 
 	private:
-        typedef S16 WIND_SAMPLE_T;
+        typedef F32 WIND_SAMPLE_T;
     	LLWindGen<WIND_SAMPLE_T> *mWindGen;
-    	S16 *mWindBuf;
+    	F32 *mWindBuf;
     	U32 mWindBufFreq;
     	U32 mWindBufSamples;
     	U32 mWindBufBytes;
diff --git a/indra/llaudio/lllistener_openal.h b/indra/llaudio/lllistener_openal.h
index cb163b11a5..5ed99b0471 100644
--- a/indra/llaudio/lllistener_openal.h
+++ b/indra/llaudio/lllistener_openal.h
@@ -32,6 +32,7 @@
 
 #include "AL/al.h"
 #include "AL/alut.h"
+#include "AL/alext.h"
 
 class LLListener_OpenAL  : public LLListener
 {
diff --git a/indra/newview/llvieweraudio.cpp b/indra/newview/llvieweraudio.cpp
index 6a0edbecb1..949cafb3d3 100644
--- a/indra/newview/llvieweraudio.cpp
+++ b/indra/newview/llvieweraudio.cpp
@@ -545,8 +545,13 @@ void audio_update_wind(bool force_update)
 		// don't use the setter setMaxWindGain() because we don't
 		// want to screw up the fade-in on startup by setting actual source gain
 		// outside the fade-in.
-		F32 master_volume  = gSavedSettings.getBOOL("MuteAudio") ? 0.f : gSavedSettings.getF32("AudioLevelMaster");
-		F32 ambient_volume = gSavedSettings.getBOOL("MuteAmbient") ? 0.f : gSavedSettings.getF32("AudioLevelAmbient");
+        static LLCachedControl<bool> mute_audio(gSavedSettings, "MuteAudio");
+        static LLCachedControl<bool> mute_ambient(gSavedSettings, "MuteAmbient");
+        static LLCachedControl<F32> level_master(gSavedSettings, "AudioLevelMaster");
+        static LLCachedControl<F32> level_ambient(gSavedSettings, "AudioLevelAmbient");
+
+		F32 master_volume  = mute_audio() ? 0.f : level_master();
+		F32 ambient_volume = mute_ambient() ? 0.f : level_ambient();
 		F32 max_wind_volume = master_volume * ambient_volume;
 
 		const F32 WIND_SOUND_TRANSITION_TIME = 2.f;
-- 
cgit v1.2.3