forked from MoonsideGames/FAudioGMS
tweak stream looping behavior
parent
e17d7e0da8
commit
e12914177f
BIN
gamemaker/extensions/FAudioGMS/FAudioGMS.dll (Stored with Git LFS)
BIN
gamemaker/extensions/FAudioGMS/FAudioGMS.dll (Stored with Git LFS)
Binary file not shown.
|
@ -356,14 +356,21 @@ 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)
|
||||||
|
{
|
||||||
|
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);
|
FAudioGMS_INTERNAL_SoundInstance_Stop(instance);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FAudioGMS_INTERNAL_SoundInstance_AddBuffers(instance);
|
FAudioGMS_INTERNAL_SoundInstance_AddBuffers(instance);
|
||||||
|
@ -1030,16 +1037,9 @@ static void FAudioGMS_INTERNAL_SoundInstance_AddBuffers(FAudioGMS_SoundInstance
|
||||||
instance->soundData.streamingSound.isFinalBuffer = 0;
|
instance->soundData.streamingSound.isFinalBuffer = 0;
|
||||||
|
|
||||||
if (sampleCount < defaultRequestedSampleCount)
|
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 =
|
instance->soundData.streamingSound.nextStreamBufferIndex =
|
||||||
(instance->soundData.streamingSound.nextStreamBufferIndex + 1) % STREAMING_BUFFER_COUNT;
|
(instance->soundData.streamingSound.nextStreamBufferIndex + 1) % STREAMING_BUFFER_COUNT;
|
||||||
|
|
Loading…
Reference in New Issue