mirror of
https://github.com/love2d/love.git
synced 2026-08-17 02:58:31 +02:00
Build type information on first use (load-time), instead of using a hardcoded list
--HG-- branch : dynamiccore2
This commit is contained in:
@@ -178,7 +178,7 @@ Source::Source(Pool *pool, int sampleRate, int bitDepth, int channels)
|
||||
}
|
||||
|
||||
Source::Source(const Source &s)
|
||||
: love::audio::Source(s.type)
|
||||
: love::audio::Source(s.sourceType)
|
||||
, pool(s.pool)
|
||||
, valid(false)
|
||||
, staticBuffer(s.staticBuffer)
|
||||
@@ -199,14 +199,14 @@ Source::Source(const Source &s)
|
||||
, bitDepth(s.bitDepth)
|
||||
, decoder(nullptr)
|
||||
, toLoop(0)
|
||||
, unusedBufferTop(s.type == TYPE_STREAM ? MAX_BUFFERS - 1 : -1)
|
||||
, unusedBufferTop(s.sourceType == TYPE_STREAM ? MAX_BUFFERS - 1 : -1)
|
||||
{
|
||||
if (type == TYPE_STREAM)
|
||||
if (sourceType == TYPE_STREAM)
|
||||
{
|
||||
if (s.decoder.get())
|
||||
decoder.set(s.decoder->clone(), Acquire::NORETAIN);
|
||||
}
|
||||
if (type != TYPE_STATIC)
|
||||
if (sourceType != TYPE_STATIC)
|
||||
{
|
||||
alGenBuffers(MAX_BUFFERS, streamBuffers);
|
||||
for (unsigned int i = 0; i < MAX_BUFFERS; i++)
|
||||
@@ -223,7 +223,7 @@ Source::~Source()
|
||||
if (valid)
|
||||
pool->stop(this);
|
||||
|
||||
if (type != TYPE_STATIC)
|
||||
if (sourceType != TYPE_STATIC)
|
||||
alDeleteBuffers(MAX_BUFFERS, streamBuffers);
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ bool Source::isFinished() const
|
||||
if (!valid)
|
||||
return false;
|
||||
|
||||
if (type == TYPE_STREAM && (isLooping() || !decoder->isFinished()))
|
||||
if (sourceType == TYPE_STREAM && (isLooping() || !decoder->isFinished()))
|
||||
return false;
|
||||
|
||||
ALenum state;
|
||||
@@ -277,7 +277,7 @@ bool Source::update()
|
||||
if (!valid)
|
||||
return false;
|
||||
|
||||
switch (type)
|
||||
switch (sourceType)
|
||||
{
|
||||
case TYPE_STATIC:
|
||||
// Looping mode could have changed.
|
||||
@@ -401,7 +401,7 @@ void Source::seekAtomic(float offset, void *unit)
|
||||
break;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
switch (sourceType)
|
||||
{
|
||||
case TYPE_STATIC:
|
||||
alSourcef(source, AL_SAMPLE_OFFSET, offsetSamples);
|
||||
@@ -494,7 +494,7 @@ double Source::getDurationAtomic(void *vunit)
|
||||
{
|
||||
Unit unit = *(Unit *) vunit;
|
||||
|
||||
switch (type)
|
||||
switch (sourceType)
|
||||
{
|
||||
case TYPE_STATIC:
|
||||
{
|
||||
@@ -649,10 +649,10 @@ bool Source::isRelative() const
|
||||
|
||||
void Source::setLooping(bool enable)
|
||||
{
|
||||
if (type == TYPE_QUEUE)
|
||||
if (sourceType == TYPE_QUEUE)
|
||||
throw QueueLoopingException();
|
||||
|
||||
if (valid && type == TYPE_STATIC)
|
||||
if (valid && sourceType == TYPE_STATIC)
|
||||
alSourcei(source, AL_LOOPING, enable ? AL_TRUE : AL_FALSE);
|
||||
|
||||
looping = enable;
|
||||
@@ -665,7 +665,7 @@ bool Source::isLooping() const
|
||||
|
||||
bool Source::queue(void *data, size_t length, int dataSampleRate, int dataBitDepth, int dataChannels)
|
||||
{
|
||||
if (type != TYPE_QUEUE)
|
||||
if (sourceType != TYPE_QUEUE)
|
||||
throw QueueTypeMismatchException();
|
||||
|
||||
if (dataSampleRate != sampleRate || dataBitDepth != bitDepth || dataChannels != channels )
|
||||
@@ -709,7 +709,7 @@ bool Source::queueAtomic(void *data, ALsizei length)
|
||||
|
||||
int Source::getFreeBufferCount() const
|
||||
{
|
||||
switch (type) //why not :^)
|
||||
switch (sourceType) //why not :^)
|
||||
{
|
||||
case TYPE_STATIC:
|
||||
return 0;
|
||||
@@ -730,7 +730,7 @@ void Source::prepareAtomic()
|
||||
// of the new one.
|
||||
reset();
|
||||
|
||||
switch (type)
|
||||
switch (sourceType)
|
||||
{
|
||||
case TYPE_STATIC:
|
||||
alSourcei(source, AL_BUFFER, staticBuffer->getBuffer());
|
||||
@@ -771,7 +771,7 @@ void Source::prepareAtomic()
|
||||
|
||||
void Source::teardownAtomic()
|
||||
{
|
||||
switch (type)
|
||||
switch (sourceType)
|
||||
{
|
||||
case TYPE_STATIC:
|
||||
alSourcef(source, AL_SAMPLE_OFFSET, 0);
|
||||
@@ -839,7 +839,7 @@ bool Source::playAtomic(ALuint source)
|
||||
valid = true; //if it fails it will be set to false again
|
||||
//but this prevents a horrible, horrible bug
|
||||
|
||||
if (type != TYPE_STREAM)
|
||||
if (sourceType != TYPE_STREAM)
|
||||
offsetSamples = offsetSeconds = 0;
|
||||
|
||||
return success;
|
||||
@@ -891,7 +891,7 @@ bool Source::playAtomic(const std::vector<love::audio::Source*> &sources, const
|
||||
Source *source = (Source*) _source;
|
||||
source->valid = source->valid || success;
|
||||
|
||||
if (success && source->type != TYPE_STREAM)
|
||||
if (success && source->sourceType != TYPE_STREAM)
|
||||
source->offsetSamples = source->offsetSeconds = 0;
|
||||
}
|
||||
|
||||
@@ -952,7 +952,7 @@ void Source::reset()
|
||||
alSourcef(source, AL_REFERENCE_DISTANCE, referenceDistance);
|
||||
alSourcef(source, AL_ROLLOFF_FACTOR, rolloffFactor);
|
||||
alSourcef(source, AL_MAX_DISTANCE, maxDistance);
|
||||
alSourcei(source, AL_LOOPING, (type == TYPE_STATIC) && isLooping() ? AL_TRUE : AL_FALSE);
|
||||
alSourcei(source, AL_LOOPING, (sourceType == TYPE_STATIC) && isLooping() ? AL_TRUE : AL_FALSE);
|
||||
alSourcei(source, AL_SOURCE_RELATIVE, relative ? AL_TRUE : AL_FALSE);
|
||||
alSourcei(source, AL_CONE_INNER_ANGLE, cone.innerAngle);
|
||||
alSourcei(source, AL_CONE_OUTER_ANGLE, cone.outerAngle);
|
||||
|
||||
Reference in New Issue
Block a user