mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Pre-emptive fix for an attenuation distance issue in iOS' OpenAL implementation.
--HG-- branch : minor
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
// STD
|
// STD
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace love
|
namespace love
|
||||||
{
|
{
|
||||||
@@ -33,6 +34,13 @@ namespace audio
|
|||||||
namespace openal
|
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
|
class InvalidFormatException : public love::Exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -81,7 +89,7 @@ Source::Source(Pool *pool, love::sound::SoundData *soundData)
|
|||||||
, maxVolume(1.0f)
|
, maxVolume(1.0f)
|
||||||
, referenceDistance(1.0f)
|
, referenceDistance(1.0f)
|
||||||
, rolloffFactor(1.0f)
|
, rolloffFactor(1.0f)
|
||||||
, maxDistance(FLT_MAX)
|
, maxDistance(MAX_ATTENUATION_DISTANCE)
|
||||||
, cone()
|
, cone()
|
||||||
, offsetSamples(0)
|
, offsetSamples(0)
|
||||||
, offsetSeconds(0)
|
, offsetSeconds(0)
|
||||||
@@ -120,7 +128,7 @@ Source::Source(Pool *pool, love::sound::Decoder *decoder)
|
|||||||
, maxVolume(1.0f)
|
, maxVolume(1.0f)
|
||||||
, referenceDistance(1.0f)
|
, referenceDistance(1.0f)
|
||||||
, rolloffFactor(1.0f)
|
, rolloffFactor(1.0f)
|
||||||
, maxDistance(FLT_MAX)
|
, maxDistance(MAX_ATTENUATION_DISTANCE)
|
||||||
, cone()
|
, cone()
|
||||||
, offsetSamples(0)
|
, offsetSamples(0)
|
||||||
, offsetSeconds(0)
|
, offsetSeconds(0)
|
||||||
@@ -872,6 +880,8 @@ void Source::setMaxDistance(float distance)
|
|||||||
if (channels > 1)
|
if (channels > 1)
|
||||||
throw SpatialSupportException();
|
throw SpatialSupportException();
|
||||||
|
|
||||||
|
distance = std::min(distance, MAX_ATTENUATION_DISTANCE);
|
||||||
|
|
||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
alSourcef(source, AL_MAX_DISTANCE, distance);
|
alSourcef(source, AL_MAX_DISTANCE, distance);
|
||||||
|
|||||||
Reference in New Issue
Block a user