diff --git a/src/sound/backend/i_sound.cpp b/src/sound/backend/i_sound.cpp index 0ba595ac7..3c6585a44 100644 --- a/src/sound/backend/i_sound.cpp +++ b/src/sound/backend/i_sound.cpp @@ -409,7 +409,7 @@ std::pair SoundRenderer::LoadSoundVoc(uint8_t *sfxdata, int le if (codec == 0) bits = 8; else if (codec == 4) - bits = -16; + bits = 16; else okay = false; len += blocksize - 2; } @@ -460,7 +460,7 @@ std::pair SoundRenderer::LoadSoundVoc(uint8_t *sfxdata, int le if (codec == 0) bits = 8; else if (codec == 4) - bits = -16; + bits = 16; else okay = false; len += blocksize - 12; } else okay = false; diff --git a/src/sound/backend/i_soundinternal.h b/src/sound/backend/i_soundinternal.h index 8ee722086..aac498b00 100644 --- a/src/sound/backend/i_soundinternal.h +++ b/src/sound/backend/i_soundinternal.h @@ -2,6 +2,7 @@ #define __SNDINT_H #include +#include #include "vectors.h" #include "tarray.h" diff --git a/src/sound/backend/oalsound.cpp b/src/sound/backend/oalsound.cpp index b2357fc36..8a3a5f13b 100644 --- a/src/sound/backend/oalsound.cpp +++ b/src/sound/backend/oalsound.cpp @@ -576,7 +576,7 @@ OpenALSoundRenderer::OpenALSoundRenderer() // Make sure one source is capable of stereo output with the rest doing // mono, without running out of voices attribs.Push(ALC_MONO_SOURCES); - attribs.Push(MAX(*snd_channels, 2) - 1); + attribs.Push(std::max(snd_channels, 2) - 1); attribs.Push(ALC_STEREO_SOURCES); attribs.Push(1); if(ALC.SOFT_HRTF) @@ -686,7 +686,7 @@ OpenALSoundRenderer::OpenALSoundRenderer() // At least Apple's OpenAL implementation returns zeroes, // although it can generate reasonable number of sources. - const int numChannels = MAX(*snd_channels, 2); + const int numChannels = std::max(snd_channels, 2); int numSources = numMono + numStereo; if (0 == numSources) @@ -694,7 +694,7 @@ OpenALSoundRenderer::OpenALSoundRenderer() numSources = numChannels; } - Sources.Resize(MIN(numChannels, numSources)); + Sources.Resize(std::min(numChannels, numSources)); for(unsigned i = 0;i < Sources.Size();i++) { alGenSources(1, &Sources[i]); @@ -917,6 +917,7 @@ void OpenALSoundRenderer::SetSfxVolume(float volume) { SfxVolume = volume; + if (!soundEngine) return; FSoundChan *schan = soundEngine->GetChannels(); while(schan) { @@ -1523,7 +1524,7 @@ FISoundChannel *OpenALSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener * distance that corresponds to the area radius. */ alSourcef(source, AL_SOURCE_RADIUS, (chanflags&SNDF_AREA) ? // Clamp in case the max distance is <= the area radius - 1.f/MAX(GetRolloff(rolloff, AREA_SOUND_RADIUS), 0.00001f) : 0.f + 1.f/std::max(GetRolloff(rolloff, AREA_SOUND_RADIUS), 0.00001f) : 0.f ); } else if((chanflags&SNDF_AREA) && dist_sqr < AREA_SOUND_RADIUS*AREA_SOUND_RADIUS) @@ -1670,9 +1671,9 @@ void OpenALSoundRenderer::ChannelPitch(FISoundChannel *chan, float pitch) ALuint source = GET_PTRID(chan->SysChannel); if (WasInWater && !(chan->ChanFlags & CHANF_UI)) - alSourcef(source, AL_PITCH, MAX(pitch, 0.0001f)*PITCH_MULT); + alSourcef(source, AL_PITCH, std::max(pitch, 0.0001f)*PITCH_MULT); else - alSourcef(source, AL_PITCH, MAX(pitch, 0.0001f)); + alSourcef(source, AL_PITCH, std::max(pitch, 0.0001f)); } void OpenALSoundRenderer::FreeSource(ALuint source) diff --git a/src/sound/s_sound.cpp b/src/sound/s_sound.cpp index bcb84d18b..51bfdb773 100644 --- a/src/sound/s_sound.cpp +++ b/src/sound/s_sound.cpp @@ -804,7 +804,7 @@ void SoundEngine::LoadSound3D(sfxinfo_t *sfx, FSoundLoadBuffer *pBuffer) { snd = GSnd->LoadSoundBuffered(pBuffer, true); } - else + else if (sfx->lumpnum >= 0) { auto sfxdata = ReadSound(sfx->lumpnum); int size = sfxdata.Size();