From e12914177fff151f25e66ded3cb4ab30ae2514e8 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Thu, 18 Nov 2021 12:35:31 -0800 Subject: [PATCH] tweak stream looping behavior --- gamemaker/extensions/FAudioGMS/FAudioGMS.dll | 4 ++-- src/FAudioGMS.c | 24 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gamemaker/extensions/FAudioGMS/FAudioGMS.dll b/gamemaker/extensions/FAudioGMS/FAudioGMS.dll index 5f2b371..e5fec6a 100644 --- a/gamemaker/extensions/FAudioGMS/FAudioGMS.dll +++ b/gamemaker/extensions/FAudioGMS/FAudioGMS.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cbdb1bd861a1efab3a9071392f2c7d837e6e663ae9b39447f3fbb7fe42aed689 -size 1521664 +oid sha256:d4f989c39a281394849cf09760ca1fde979ce87e00bb0c764cee46b6c5389cee +size 1521152 diff --git a/src/FAudioGMS.c b/src/FAudioGMS.c index 6a88b41..5333cc1 100644 --- a/src/FAudioGMS.c +++ b/src/FAudioGMS.c @@ -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 =