|
@@ -24,7 +24,6 @@
|
|
|
|
|
|
// STD
|
|
// STD
|
|
#include <iostream>
|
|
#include <iostream>
|
|
-#include <float.h>
|
|
|
|
#include <algorithm>
|
|
#include <algorithm>
|
|
|
|
|
|
namespace love
|
|
namespace love
|
|
@@ -34,13 +33,6 @@ 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:
|
|
@@ -123,25 +115,9 @@ StaticDataBuffer::~StaticDataBuffer()
|
|
Source::Source(Pool *pool, love::sound::SoundData *soundData)
|
|
Source::Source(Pool *pool, love::sound::SoundData *soundData)
|
|
: love::audio::Source(Source::TYPE_STATIC)
|
|
: love::audio::Source(Source::TYPE_STATIC)
|
|
, pool(pool)
|
|
, pool(pool)
|
|
- , valid(false)
|
|
|
|
- , staticBuffer(nullptr)
|
|
|
|
- , pitch(1.0f)
|
|
|
|
- , volume(1.0f)
|
|
|
|
- , relative(false)
|
|
|
|
- , looping(false)
|
|
|
|
- , minVolume(0.0f)
|
|
|
|
- , maxVolume(1.0f)
|
|
|
|
- , referenceDistance(1.0f)
|
|
|
|
- , rolloffFactor(1.0f)
|
|
|
|
- , maxDistance(MAX_ATTENUATION_DISTANCE)
|
|
|
|
- , cone()
|
|
|
|
- , offsetSamples(0)
|
|
|
|
- , offsetSeconds(0)
|
|
|
|
, sampleRate(soundData->getSampleRate())
|
|
, sampleRate(soundData->getSampleRate())
|
|
, channels(soundData->getChannels())
|
|
, channels(soundData->getChannels())
|
|
, bitDepth(soundData->getBitDepth())
|
|
, bitDepth(soundData->getBitDepth())
|
|
- , decoder(nullptr)
|
|
|
|
- , toLoop(0)
|
|
|
|
{
|
|
{
|
|
ALenum fmt = getFormat(soundData->getChannels(), soundData->getBitDepth());
|
|
ALenum fmt = getFormat(soundData->getChannels(), soundData->getBitDepth());
|
|
if (fmt == 0)
|
|
if (fmt == 0)
|
|
@@ -159,25 +135,10 @@ Source::Source(Pool *pool, love::sound::SoundData *soundData)
|
|
Source::Source(Pool *pool, love::sound::Decoder *decoder)
|
|
Source::Source(Pool *pool, love::sound::Decoder *decoder)
|
|
: love::audio::Source(Source::TYPE_STREAM)
|
|
: love::audio::Source(Source::TYPE_STREAM)
|
|
, pool(pool)
|
|
, pool(pool)
|
|
- , valid(false)
|
|
|
|
- , staticBuffer(nullptr)
|
|
|
|
- , pitch(1.0f)
|
|
|
|
- , volume(1.0f)
|
|
|
|
- , relative(false)
|
|
|
|
- , looping(false)
|
|
|
|
- , minVolume(0.0f)
|
|
|
|
- , maxVolume(1.0f)
|
|
|
|
- , referenceDistance(1.0f)
|
|
|
|
- , rolloffFactor(1.0f)
|
|
|
|
- , maxDistance(MAX_ATTENUATION_DISTANCE)
|
|
|
|
- , cone()
|
|
|
|
- , offsetSamples(0)
|
|
|
|
- , offsetSeconds(0)
|
|
|
|
, sampleRate(decoder->getSampleRate())
|
|
, sampleRate(decoder->getSampleRate())
|
|
, channels(decoder->getChannels())
|
|
, channels(decoder->getChannels())
|
|
, bitDepth(decoder->getBitDepth())
|
|
, bitDepth(decoder->getBitDepth())
|
|
, decoder(decoder)
|
|
, decoder(decoder)
|
|
- , toLoop(0)
|
|
|
|
, unusedBufferTop(MAX_BUFFERS - 1)
|
|
, unusedBufferTop(MAX_BUFFERS - 1)
|
|
{
|
|
{
|
|
if (getFormat(decoder->getChannels(), decoder->getBitDepth()) == 0)
|
|
if (getFormat(decoder->getChannels(), decoder->getBitDepth()) == 0)
|
|
@@ -197,27 +158,9 @@ Source::Source(Pool *pool, love::sound::Decoder *decoder)
|
|
Source::Source(Pool *pool, int sampleRate, int bitDepth, int channels)
|
|
Source::Source(Pool *pool, int sampleRate, int bitDepth, int channels)
|
|
: love::audio::Source(Source::TYPE_QUEUE)
|
|
: love::audio::Source(Source::TYPE_QUEUE)
|
|
, pool(pool)
|
|
, pool(pool)
|
|
- , valid(false)
|
|
|
|
- , staticBuffer(nullptr)
|
|
|
|
- , pitch(1.0f)
|
|
|
|
- , volume(1.0f)
|
|
|
|
- , relative(false)
|
|
|
|
- , looping(false)
|
|
|
|
- , minVolume(0.0f)
|
|
|
|
- , maxVolume(1.0f)
|
|
|
|
- , referenceDistance(1.0f)
|
|
|
|
- , rolloffFactor(1.0f)
|
|
|
|
- , maxDistance(MAX_ATTENUATION_DISTANCE)
|
|
|
|
- , cone()
|
|
|
|
- , offsetSamples(0)
|
|
|
|
- , offsetSeconds(0)
|
|
|
|
, sampleRate(sampleRate)
|
|
, sampleRate(sampleRate)
|
|
, channels(channels)
|
|
, channels(channels)
|
|
, bitDepth(bitDepth)
|
|
, bitDepth(bitDepth)
|
|
- , decoder(nullptr)
|
|
|
|
- , toLoop(0)
|
|
|
|
- , unusedBufferTop(-1)
|
|
|
|
- , bufferedBytes(0)
|
|
|
|
{
|
|
{
|
|
ALenum fmt = getFormat(channels, bitDepth);
|
|
ALenum fmt = getFormat(channels, bitDepth);
|
|
if (fmt == 0)
|
|
if (fmt == 0)
|
|
@@ -256,7 +199,7 @@ Source::Source(const Source &s)
|
|
, bitDepth(s.bitDepth)
|
|
, bitDepth(s.bitDepth)
|
|
, decoder(nullptr)
|
|
, decoder(nullptr)
|
|
, toLoop(0)
|
|
, toLoop(0)
|
|
- , unusedBufferTop(-1)
|
|
|
|
|
|
+ , unusedBufferTop(s.type == TYPE_STREAM ? MAX_BUFFERS - 1 : -1)
|
|
{
|
|
{
|
|
if (type == TYPE_STREAM)
|
|
if (type == TYPE_STREAM)
|
|
{
|
|
{
|