shithub: choc

Download patch

ref: 8c7e10c96855a31fe94a77c23e6977aea0b4b279
parent: e7b1f3015bdae2519a5f040b52a37feaa9502e3e
author: Jonathan Dowland <[email protected]>
date: Fri Jun 26 03:52:17 EDT 2015

Introduce pitch to allocated_sound_t

Rework GetAllocatedSoundBySfxInfo to search by sfxinfo_t and pitch,
with all callers looking for NORM_PITCH.

--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -52,6 +52,7 @@
     sfxinfo_t *sfxinfo;
     Mix_Chunk chunk;
     int use_count;
+    int pitch;
     allocated_sound_t *prev, *next;
 };
 
@@ -227,6 +228,7 @@
     snd->chunk.alen = len;
     snd->chunk.allocated = 1;
     snd->chunk.volume = MIX_MAX_VOLUME;
+    snd->pitch = NORM_PITCH;
 
     snd->sfxinfo = sfxinfo;
     snd->use_count = 0;
@@ -272,15 +274,15 @@
 }
 
 // Search through the list of allocated sounds and return the one that matches
-// the supplied sfxinfo entry.
+// the supplied sfxinfo entry and pitch level.
 
-static allocated_sound_t * GetAllocatedSoundBySfxInfo(sfxinfo_t *sfxinfo)
+static allocated_sound_t * GetAllocatedSoundBySfxInfoAndPitch(sfxinfo_t *sfxinfo, int pitch)
 {
     allocated_sound_t * p = allocated_sounds_head;
 
     while(p != NULL)
     {
-        if(p->sfxinfo == sfxinfo)
+        if(p->sfxinfo == sfxinfo && p->pitch == pitch)
         {
             return p;
         }
@@ -802,7 +804,7 @@
 static boolean LockSound(sfxinfo_t *sfxinfo)
 {
     // If the sound isn't loaded, load it now
-    if (GetAllocatedSoundBySfxInfo(sfxinfo) == NULL)
+    if (GetAllocatedSoundBySfxInfoAndPitch(sfxinfo, NORM_PITCH) == NULL)
     {
         if (!CacheSFX(sfxinfo))
         {
@@ -810,7 +812,7 @@
         }
     }
 
-    LockAllocatedSound(GetAllocatedSoundBySfxInfo(sfxinfo));
+    LockAllocatedSound(GetAllocatedSoundBySfxInfoAndPitch(sfxinfo, NORM_PITCH));
 
     return true;
 }
@@ -893,7 +895,7 @@
         return -1;
     }
 
-    snd = GetAllocatedSoundBySfxInfo(sfxinfo);
+    snd = GetAllocatedSoundBySfxInfoAndPitch(sfxinfo, NORM_PITCH);
 
     // play sound