Pre-emptive fix for an attenuation distance issue in iOS' OpenAL implementation.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2015-02-16 00:10:11 -04:00
parent 606f077e5d
commit 813457aa71
+12 -2
View File
@@ -25,6 +25,7 @@
// STD
#include <iostream>
#include <float.h>
#include <algorithm>
namespace love
{
@@ -33,6 +34,13 @@ namespace audio
namespace openal
{
#ifdef LOVE_IOS
// OpenAL on iOS barfs if the max distance is +inf.
static const float MAX_ATTENUATION_DISTANCE = 1000000.0f;
#else
static const float MAX_ATTENUATION_DISTANCE = FLT_MAX;
#endif
class InvalidFormatException : public love::Exception
{
public:
@@ -81,7 +89,7 @@ Source::Source(Pool *pool, love::sound::SoundData *soundData)
, maxVolume(1.0f)
, referenceDistance(1.0f)
, rolloffFactor(1.0f)
, maxDistance(FLT_MAX)
, maxDistance(MAX_ATTENUATION_DISTANCE)
, cone()
, offsetSamples(0)
, offsetSeconds(0)
@@ -120,7 +128,7 @@ Source::Source(Pool *pool, love::sound::Decoder *decoder)
, maxVolume(1.0f)
, referenceDistance(1.0f)
, rolloffFactor(1.0f)
, maxDistance(FLT_MAX)
, maxDistance(MAX_ATTENUATION_DISTANCE)
, cone()
, offsetSamples(0)
, offsetSeconds(0)
@@ -872,6 +880,8 @@ void Source::setMaxDistance(float distance)
if (channels > 1)
throw SpatialSupportException();
distance = std::min(distance, MAX_ATTENUATION_DISTANCE);
if (valid)
{
alSourcef(source, AL_MAX_DISTANCE, distance);