mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
Query the Decoder instead of the current OpenAL buffer when getting the sample rate for calculations in streaming audio Sources.
Some OpenAL implementations return 0 for alGetSourcei(source, AL_BUFFER) if the source isn't static, which eventually results in returning 0 when querying the buffer's sample rate.
This commit is contained in:
@@ -255,10 +255,7 @@ bool Source::update()
|
|||||||
|
|
||||||
alGetSourcef(source, AL_SAMPLE_OFFSET, &curOffsetSamples);
|
alGetSourcef(source, AL_SAMPLE_OFFSET, &curOffsetSamples);
|
||||||
|
|
||||||
ALint b;
|
int freq = decoder->getSampleRate();
|
||||||
alGetSourcei(source, AL_BUFFER, &b);
|
|
||||||
int freq;
|
|
||||||
alGetBufferi(b, AL_FREQUENCY, &freq);
|
|
||||||
curOffsetSecs = curOffsetSamples / freq;
|
curOffsetSecs = curOffsetSamples / freq;
|
||||||
|
|
||||||
// Get a free buffer.
|
// Get a free buffer.
|
||||||
@@ -334,11 +331,7 @@ void Source::seekAtomic(float offset, void *unit)
|
|||||||
if (type == TYPE_STREAM)
|
if (type == TYPE_STREAM)
|
||||||
{
|
{
|
||||||
offsetSamples = offset;
|
offsetSamples = offset;
|
||||||
ALint buffer;
|
offset /= decoder->getSampleRate();
|
||||||
alGetSourcei(source, AL_BUFFER, &buffer);
|
|
||||||
int freq;
|
|
||||||
alGetBufferi(buffer, AL_FREQUENCY, &freq);
|
|
||||||
offset /= freq;
|
|
||||||
offsetSeconds = offset;
|
offsetSeconds = offset;
|
||||||
decoder->seek(offset);
|
decoder->seek(offset);
|
||||||
}
|
}
|
||||||
@@ -353,11 +346,7 @@ void Source::seekAtomic(float offset, void *unit)
|
|||||||
{
|
{
|
||||||
offsetSeconds = offset;
|
offsetSeconds = offset;
|
||||||
decoder->seek(offset);
|
decoder->seek(offset);
|
||||||
ALint buffer;
|
offsetSamples = offset * decoder->getSampleRate();
|
||||||
alGetSourcei(source, AL_BUFFER, &buffer);
|
|
||||||
int freq;
|
|
||||||
alGetBufferi(buffer, AL_FREQUENCY, &freq);
|
|
||||||
offsetSamples = offset*freq;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -399,11 +388,7 @@ float Source::tellAtomic(void *unit) const
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
alGetSourcef(source, AL_SAMPLE_OFFSET, &offset);
|
alGetSourcef(source, AL_SAMPLE_OFFSET, &offset);
|
||||||
ALint buffer;
|
offset /= decoder->getSampleRate();
|
||||||
alGetSourcei(source, AL_BUFFER, &buffer);
|
|
||||||
int freq;
|
|
||||||
alGetBufferi(buffer, AL_FREQUENCY, &freq);
|
|
||||||
offset /= freq;
|
|
||||||
if (type == TYPE_STREAM) offset += offsetSeconds;
|
if (type == TYPE_STREAM) offset += offsetSeconds;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user