commit ac31afbe7610df77b6658b84afaaef4e01c7028d
Author: Simon Howard <fraggle@soulsphere.org>
AuthorDate: Wed Jul 8 21:37:45 2015 -0400
Commit: Simon Howard <fraggle@soulsphere.org>
CommitDate: Wed Jul 8 21:37:45 2015 -0400
Fix formatting issues introduced in last merge.
Also fixes a minor bug that would cause the pitch shift configuration
to be reset each time the sound configuration window was opened.
---
src/doom/s_sound.c | 2 +-
src/heretic/s_sound.c | 2 +-
src/hexen/s_sound.c | 2 +-
src/i_sdlsound.c | 21 +++++++++++----------
src/setup/sound.c | 12 ++++--------
5 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/src/doom/s_sound.c b/src/doom/s_sound.c
index a29509d9..4263e631 100644
--- a/src/doom/s_sound.c
+++ b/src/doom/s_sound.c
@@ -143,7 +143,7 @@ void S_Init(int sfxVolume, int musicVolume)
}
// Doom defaults to pitch-shifting off.
- if(snd_pitchshift == -1)
+ if (snd_pitchshift == -1)
{
snd_pitchshift = 0;
}
diff --git a/src/heretic/s_sound.c b/src/heretic/s_sound.c
index 850dd016..b4a026c0 100644
--- a/src/heretic/s_sound.c
+++ b/src/heretic/s_sound.c
@@ -525,7 +525,7 @@ void S_Init(void)
I_AtExit(S_ShutDown, true);
// Heretic defaults to pitch-shifting on
- if(snd_pitchshift == -1)
+ if (snd_pitchshift == -1)
{
snd_pitchshift = 1;
}
diff --git a/src/hexen/s_sound.c b/src/hexen/s_sound.c
index 56262f46..947b3bfd 100644
--- a/src/hexen/s_sound.c
+++ b/src/hexen/s_sound.c
@@ -800,7 +800,7 @@ void S_Init(void)
I_AtExit(S_ShutDown, true);
// Hexen defaults to pitch-shifting on
- if(snd_pitchshift == -1)
+ if (snd_pitchshift == -1)
{
snd_pitchshift = 1;
}
diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c
index 12476b4f..6896330d 100644
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -280,14 +280,15 @@ static allocated_sound_t * GetAllocatedSoundBySfxInfoAndPitch(sfxinfo_t *sfxinfo
{
allocated_sound_t * p = allocated_sounds_head;
- while(p != NULL)
+ while (p != NULL)
{
- if(p->sfxinfo == sfxinfo && p->pitch == pitch)
+ if (p->sfxinfo == sfxinfo && p->pitch == pitch)
{
return p;
}
p = p->next;
}
+
return NULL;
}
@@ -309,14 +310,14 @@ static allocated_sound_t * PitchShift(allocated_sound_t *insnd, int pitch)
dstlen = (int)((1 + (1 - (float)pitch / NORM_PITCH)) * srclen);
// ensure that the new buffer is an even length
- if( (dstlen % 2) == 0)
+ if ((dstlen % 2) == 0)
{
dstlen++;
}
outsnd = AllocateSound(insnd->sfxinfo, dstlen);
- if(!outsnd)
+ if (!outsnd)
{
return NULL;
}
@@ -325,7 +326,7 @@ static allocated_sound_t * PitchShift(allocated_sound_t *insnd, int pitch)
dstbuf = (Sint16 *)outsnd->chunk.abuf;
// loop over output buffer. find corresponding input cell, copy over
- for(outp = dstbuf; outp < dstbuf + dstlen/2; ++outp)
+ for (outp = dstbuf; outp < dstbuf + dstlen/2; ++outp)
{
inp = srcbuf + (int)((float)(outp - dstbuf) / dstlen * srclen);
*outp = *inp;
@@ -353,7 +354,7 @@ static void ReleaseSoundOnChannel(int channel)
// if the sound is a pitch-shift and it's not in use, immediately
// free it
- if(snd->pitch != NORM_PITCH && snd->use_count <= 0)
+ if (snd->pitch != NORM_PITCH && snd->use_count <= 0)
{
FreeAllocatedSound(snd);
}
@@ -947,22 +948,22 @@ static int I_SDL_StartSound(sfxinfo_t *sfxinfo, int channel, int vol, int sep, i
snd = GetAllocatedSoundBySfxInfoAndPitch(sfxinfo, pitch);
- if(snd == NULL)
+ if (snd == NULL)
{
allocated_sound_t *newsnd;
// fetch the base sound effect, un-pitch-shifted
snd = GetAllocatedSoundBySfxInfoAndPitch(sfxinfo, NORM_PITCH);
- if(!snd)
+ if (snd == NULL)
{
return -1;
}
- if(snd_pitchshift)
+ if (snd_pitchshift)
{
newsnd = PitchShift(snd, pitch);
- if(newsnd)
+ if (newsnd)
{
LockAllocatedSound(newsnd);
UnlockAllocatedSound(snd);
diff --git a/src/setup/sound.c b/src/setup/sound.c
index 3a47d674..7af323c2 100644
--- a/src/setup/sound.c
+++ b/src/setup/sound.c
@@ -294,14 +294,6 @@ void ConfigSound(void)
num_music_modes = NUM_MUSICMODES - 1;
}
- // All versions of Heretic and Hexen did pitch-shifting.
- // Most versions of Doom did not and Strife never did.
-
- if(gamemission == heretic || gamemission == hexen)
- {
- snd_pitchshift = 1;
- }
-
// Build the window
window = TXT_NewWindow("Sound configuration");
@@ -412,6 +404,10 @@ void BindSoundVariables(void)
timidity_cfg_path = M_StringDuplicate("");
gus_patch_path = M_StringDuplicate("");
+ // All versions of Heretic and Hexen did pitch-shifting.
+ // Most versions of Doom did not and Strife never did.
+ snd_pitchshift = gamemission == heretic || gamemission == hexen;
+
// Default sound volumes - different games use different values.
switch (gamemission)