tweak stream looping behavior

main
cosmonaut 2021-11-18 12:35:31 -08:00
parent e17d7e0da8
commit e12914177f
2 changed files with 14 additions and 14 deletions

Binary file not shown.

View File

@ -356,13 +356,20 @@ static void FAudioGMS_INTERNAL_OnBufferEndCallback(
instance->soundData.streamingSound.streamBufferSize / instance->soundData.streamingSound.streamBufferSize /
(instance->format.nChannels * sizeof(float)); (instance->format.nChannels * sizeof(float));
instance->soundData.streamingSound.mostRecentSampleOffset = SDL_min( instance->soundData.streamingSound.mostRecentSampleOffset %= instance->playLength;
instance->soundData.streamingSound.mostRecentSampleOffset,
instance->playLength);
if (instance->soundData.streamingSound.isFinalBuffer) if (instance->soundData.streamingSound.isFinalBuffer)
{ {
FAudioGMS_INTERNAL_SoundInstance_Stop(instance); if (instance->loop)
{
stb_vorbis_seek(instance->soundData.streamingSound.fileHandle, instance->playBegin);
instance->soundData.streamingSound.mostRecentSampleOffset = instance->playBegin;
FAudioGMS_INTERNAL_SoundInstance_AddBuffers(instance);
}
else
{
FAudioGMS_INTERNAL_SoundInstance_Stop(instance);
}
} }
else else
{ {
@ -1031,14 +1038,7 @@ static void FAudioGMS_INTERNAL_SoundInstance_AddBuffers(FAudioGMS_SoundInstance
if (sampleCount < defaultRequestedSampleCount) if (sampleCount < defaultRequestedSampleCount)
{ {
if (instance->loop) instance->soundData.streamingSound.isFinalBuffer = 1;
{
stb_vorbis_seek(instance->soundData.streamingSound.fileHandle, instance->playBegin);
}
else
{
instance->soundData.streamingSound.isFinalBuffer = 1;
}
} }
instance->soundData.streamingSound.nextStreamBufferIndex = instance->soundData.streamingSound.nextStreamBufferIndex =