tweak stream looping behavior

remotes/1734709060101541481/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->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)
{
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
{
@ -1031,14 +1038,7 @@ static void FAudioGMS_INTERNAL_SoundInstance_AddBuffers(FAudioGMS_SoundInstance
if (sampleCount < defaultRequestedSampleCount)
{
if (instance->loop)
{
stb_vorbis_seek(instance->soundData.streamingSound.fileHandle, instance->playBegin);
}
else
{
instance->soundData.streamingSound.isFinalBuffer = 1;
}
instance->soundData.streamingSound.isFinalBuffer = 1;
}
instance->soundData.streamingSound.nextStreamBufferIndex =