mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +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)
|
void Source::seekAtomic(float offset, void *unit)
|
||||||
{
|
{
|
||||||
|
float offsetSamples, offsetSeconds;
|
||||||
|
|
||||||
switch (*((Source::Unit *) unit))
|
switch (*((Source::Unit *) unit))
|
||||||
{
|
{
|
||||||
case Source::UNIT_SAMPLES:
|
case Source::UNIT_SAMPLES:
|
||||||
@@ -461,7 +463,7 @@ void Source::seekAtomic(float offset, void *unit)
|
|||||||
{
|
{
|
||||||
case TYPE_STATIC:
|
case TYPE_STATIC:
|
||||||
alSourcef(source, AL_SAMPLE_OFFSET, offsetSamples);
|
alSourcef(source, AL_SAMPLE_OFFSET, offsetSamples);
|
||||||
offsetSamples = offsetSeconds = 0;
|
this->offsetSamples = this->offsetSeconds = 0;
|
||||||
break;
|
break;
|
||||||
case TYPE_STREAM:
|
case TYPE_STREAM:
|
||||||
{
|
{
|
||||||
@@ -471,6 +473,8 @@ void Source::seekAtomic(float offset, void *unit)
|
|||||||
if (valid)
|
if (valid)
|
||||||
stopAtomic();
|
stopAtomic();
|
||||||
|
|
||||||
|
this->offsetSamples = offsetSamples;
|
||||||
|
this->offsetSeconds = offsetSeconds;
|
||||||
decoder->seek(offsetSeconds);
|
decoder->seek(offsetSeconds);
|
||||||
|
|
||||||
if (wasPlaying)
|
if (wasPlaying)
|
||||||
@@ -482,7 +486,7 @@ void Source::seekAtomic(float offset, void *unit)
|
|||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
alSourcef(source, AL_SAMPLE_OFFSET, offsetSamples);
|
alSourcef(source, AL_SAMPLE_OFFSET, offsetSamples);
|
||||||
offsetSamples = offsetSeconds = 0;
|
this->offsetSamples = this->offsetSeconds = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -505,6 +509,8 @@ void Source::seekAtomic(float offset, void *unit)
|
|||||||
if (buffer == AL_NONE)
|
if (buffer == AL_NONE)
|
||||||
offsetSamples = 0;
|
offsetSamples = 0;
|
||||||
offsetSeconds = offsetSamples / sampleRate;
|
offsetSeconds = offsetSamples / sampleRate;
|
||||||
|
this->offsetSamples = offsetSamples;
|
||||||
|
this->offsetSeconds = offsetSeconds;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TYPE_MAX_ENUM:
|
case TYPE_MAX_ENUM:
|
||||||
@@ -755,6 +761,7 @@ bool Source::queueAtomic(void *data, ALsizei length)
|
|||||||
unusedBufferQueue(buffer);
|
unusedBufferQueue(buffer);
|
||||||
}
|
}
|
||||||
bufferedBytes += length;
|
bufferedBytes += length;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user