Fix looping bug

This commit is contained in:
Zachary Hall 2024-04-11 10:46:39 -07:00
parent 6746f8caf0
commit b80f203561

View file

@ -94,14 +94,14 @@ void PlaybackInstance::SDLCallbackInner(Uint8 *stream, int len) {
size_t new_samples = render_vgmstream((sample_t*)(buf), (int)samples, this->stream); size_t new_samples = render_vgmstream((sample_t*)(buf), (int)samples, this->stream);
#else #else
size_t new_samples = render_vgmstream((sample_t*)(buf), (int)samples, this->stream); size_t new_samples = render_vgmstream((sample_t*)(buf), (int)samples, this->stream);
samples = new_samples; vgmstream_spec.samples = new_samples;
vgmstream_spec.samples = samples; SDL_AudioStreamPut(sdl_stream, buf, new_samples * sizeof(sample_t) * this->stream->channels);
SDL_AudioStreamPut(sdl_stream, buf, samples * sizeof(sample_t) * this->stream->channels);
new_bufsize = SDL_AudioStreamGet(sdl_stream, buf, bufsize); new_bufsize = SDL_AudioStreamGet(sdl_stream, buf, bufsize);
#endif #endif
if (samples > new_samples) { if (samples > new_samples) {
reset_vgmstream(this->stream); reset_vgmstream(this->stream);
} }
samples = new_samples;
for (int i = 0; i < new_bufsize / sizeof(SAMPLETYPE); i++) { for (int i = 0; i < new_bufsize / sizeof(SAMPLETYPE); i++) {
((SAMPLETYPE*)new_buf)[i] *= real_volume; ((SAMPLETYPE*)new_buf)[i] *= real_volume;
} }