]> git.jsancho.org Git - lugaru.git/commitdiff
Cleaned a bit OPENAL_SetFrequency, fixing some clang warnings
authorCôme Chilliet <come@chilliet.eu>
Tue, 29 Nov 2016 10:15:23 +0000 (17:15 +0700)
committerCôme Chilliet <come@chilliet.eu>
Tue, 29 Nov 2016 10:15:23 +0000 (17:15 +0700)
It would be best to check if calls to OPENAL_SetFrequency are really needed

Source/GameTick.cpp
Source/openal_wrapper.cpp
Source/openal_wrapper.h

index d935138b0a41ceeabe07eb896a9a6cca189b2def..177cfe930241ff3360bf35bd531eb90873a2a065 100644 (file)
@@ -5307,7 +5307,7 @@ void MenuTick()
         }
     }
 
-    OPENAL_SetFrequency(channels[stream_menutheme], 22050);
+    OPENAL_SetFrequency(channels[stream_menutheme]);
 
     if (entername) {
         inputText(displaytext[0], &displayselected);
@@ -5421,7 +5421,7 @@ void Game::Tick()
             fireSound();
             flash();
             if (musictoggle) {
-                OPENAL_SetFrequency(OPENAL_ALL, 0.001);
+                OPENAL_SetFrequency(OPENAL_ALL);
                 emit_stream_np(stream_menutheme);
                 pause_sound(leveltheme);
             }
@@ -5438,7 +5438,7 @@ void Game::Tick()
             }
             //play menu theme
             if (musictoggle && (mainmenu == 1 || mainmenu == 2)) {
-                OPENAL_SetFrequency(OPENAL_ALL, 0.001);
+                OPENAL_SetFrequency(OPENAL_ALL);
                 emit_stream_np(stream_menutheme);
                 pause_sound(leveltheme);
             }
@@ -5492,14 +5492,14 @@ void Game::Tick()
         if (Input::isKeyPressed(SDL_SCANCODE_V) && debugmode) {
             freeze = !freeze;
             if (freeze) {
-                OPENAL_SetFrequency(OPENAL_ALL, 0.001);
+                OPENAL_SetFrequency(OPENAL_ALL);
             }
         }
 
         if (Input::isKeyPressed(consolekey) && debugmode) {
             console = !console;
             if (console) {
-                OPENAL_SetFrequency(OPENAL_ALL, 0.001);
+                OPENAL_SetFrequency(OPENAL_ALL);
             } else {
                 freeze = 0;
                 waiting = false;
@@ -5530,7 +5530,7 @@ void Game::Tick()
 
         static int oldwinfreeze;
         if (winfreeze && !oldwinfreeze) {
-            OPENAL_SetFrequency(OPENAL_ALL, 0.001);
+            OPENAL_SetFrequency(OPENAL_ALL);
             emit_sound_np(consolesuccesssound);
         }
         if (winfreeze == 0)
@@ -6840,10 +6840,7 @@ void Game::Tick()
                     envsound[j] = envsound[numenvsounds];
                 }
             }
-            if (slomo)
-                OPENAL_SetFrequency(OPENAL_ALL, slomofreq);
-            else
-                OPENAL_SetFrequency(OPENAL_ALL, 22050);
+            OPENAL_SetFrequency(OPENAL_ALL, slomo);
 
             if (tutoriallevel == 1) {
                 XYZ temp;
@@ -6865,7 +6862,7 @@ void Game::Tick()
                 if (tutorialstage >= 51)
                     if (distsq(&temp, &Person::players[0]->coords) >= distsq(&temp, &temp2) - 1 || distsq(&temp3, &Person::players[0]->coords) < 4) {
                         OPENAL_StopSound(OPENAL_ALL);  // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
-                        OPENAL_SetFrequency(OPENAL_ALL, 0.001);
+                        OPENAL_SetFrequency(OPENAL_ALL);
 
                         emit_stream_np(stream_menutheme);
 
index b59706581288660a97125d563f30e6a35c13a47a..4331c69f33ff075d450336a0dadefc2e5d966959 100644 (file)
@@ -27,6 +27,8 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 #include "Sounds.h"
 #include "Game.h"
 
+extern float slomofreq;
+
 // NOTE:
 // FMOD uses a Left Handed Coordinate system, OpenAL uses a Right Handed
 //  one...so we just need to flip the sign on the Z axis when appropriate.
@@ -430,21 +432,20 @@ static signed char OPENAL_Sample_SetMode(OPENAL_SAMPLE *sptr, unsigned int mode)
     return true;
 }
 
-AL_API signed char OPENAL_SetFrequency(int channel, int freq)
+AL_API signed char OPENAL_SetFrequency(int channel, bool slomo)
 {
     if (!initialized)
         return false;
     if (channel == OPENAL_ALL) {
         for (int i = 0; i < num_channels; i++)
-            OPENAL_SetFrequency(i, freq);
+            OPENAL_SetFrequency(i, slomo);
         return true;
     }
 
     if ((channel < 0) || (channel >= num_channels))
         return false;
-    if (freq == 8012)
-        // hack
-        alSourcef(impl_channels[channel].sid, AL_PITCH, 8012.0f / 44100.0f);
+    if (slomo)
+        alSourcef(impl_channels[channel].sid, AL_PITCH, ((ALfloat) slomofreq) / 44100.0f);
     else
         alSourcef(impl_channels[channel].sid, AL_PITCH, 1.0f);
     return true;
index 51a9f5ca9aa17b67eb4ccc384d9ea50f5619ba48..16d4f674c94db8ed0754ea79610fcdf528c6d241 100644 (file)
@@ -94,7 +94,7 @@ extern "C" {
     AL_API void OPENAL_Close();
     AL_API OPENAL_SAMPLE *OPENAL_Sample_Load(int index, const char *name_or_data, unsigned int mode, int offset, int length);
     AL_API void OPENAL_Sample_Free(OPENAL_SAMPLE *sptr);
-    AL_API signed char OPENAL_SetFrequency(int channel, int freq);
+    AL_API signed char OPENAL_SetFrequency(int channel, bool slomo = false);
     AL_API signed char OPENAL_SetVolume(int channel, int vol);
     AL_API signed char OPENAL_SetPaused(int channel, signed char paused);
     AL_API void OPENAL_SetSFXMasterVolume(int volume);