mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
fixed stream seeking bug
--HG-- branch : minor
This commit is contained in:
@@ -444,6 +444,8 @@ float Source::getVolume() const
|
||||
|
||||
void Source::seekAtomic(float offset, void *unit)
|
||||
{
|
||||
float offsetSamples, offsetSeconds;
|
||||
|
||||
switch (*((Source::Unit *) unit))
|
||||
{
|
||||
case Source::UNIT_SAMPLES:
|
||||
@@ -461,7 +463,7 @@ void Source::seekAtomic(float offset, void *unit)
|
||||
{
|
||||
case TYPE_STATIC:
|
||||
alSourcef(source, AL_SAMPLE_OFFSET, offsetSamples);
|
||||
offsetSamples = offsetSeconds = 0;
|
||||
this->offsetSamples = this->offsetSeconds = 0;
|
||||
break;
|
||||
case TYPE_STREAM:
|
||||
{
|
||||
@@ -471,6 +473,8 @@ void Source::seekAtomic(float offset, void *unit)
|
||||
if (valid)
|
||||
stopAtomic();
|
||||
|
||||
this->offsetSamples = offsetSamples;
|
||||
this->offsetSeconds = offsetSeconds;
|
||||
decoder->seek(offsetSeconds);
|
||||
|
||||
if (wasPlaying)
|
||||
@@ -482,7 +486,7 @@ void Source::seekAtomic(float offset, void *unit)
|
||||
if (valid)
|
||||
{
|
||||
alSourcef(source, AL_SAMPLE_OFFSET, offsetSamples);
|
||||
offsetSamples = offsetSeconds = 0;
|
||||
this->offsetSamples = this->offsetSeconds = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -505,6 +509,8 @@ void Source::seekAtomic(float offset, void *unit)
|
||||
if (buffer == AL_NONE)
|
||||
offsetSamples = 0;
|
||||
offsetSeconds = offsetSamples / sampleRate;
|
||||
this->offsetSamples = offsetSamples;
|
||||
this->offsetSeconds = offsetSeconds;
|
||||
}
|
||||
break;
|
||||
case TYPE_MAX_ENUM:
|
||||
@@ -755,6 +761,7 @@ bool Source::queueAtomic(void *data, ALsizei length)
|
||||
unusedBufferQueue(buffer);
|
||||
}
|
||||
bufferedBytes += length;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user