Fix looping and length getting of non-loop metadata holding files

This commit is contained in:
Zachary Hall 2024-04-10 18:16:52 -07:00
parent 91b2c5a56d
commit 21ad4f5759

View file

@ -91,9 +91,13 @@ void PlaybackInstance::SDLCallbackInner(Uint8 *stream, int len) {
if (this->stream != nullptr) { if (this->stream != nullptr) {
size_t samples = (int)bytes_per_iter / sizeof(SAMPLETYPE) / this->stream->channels; size_t samples = (int)bytes_per_iter / sizeof(SAMPLETYPE) / this->stream->channels;
#ifdef SOUNDTOUCH_INTEGER_SAMPLES #ifdef SOUNDTOUCH_INTEGER_SAMPLES
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
samples = render_vgmstream((sample_t*)(buf), (int)samples, this->stream); size_t new_samples = render_vgmstream((sample_t*)(buf), (int)samples, this->stream);
if (samples > new_samples) {
reset_vgmstream(this->stream);
}
samples = new_samples;
vgmstream_spec.samples = samples; vgmstream_spec.samples = samples;
SDL_AudioStreamPut(sdl_stream, buf, 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);
@ -178,14 +182,12 @@ VGMSTREAM *PlaybackInstance::Load2(const char *file) {
vgmstream_cfg_t cfg = {0}; vgmstream_cfg_t cfg = {0};
cfg.allow_play_forever = 1; cfg.allow_play_forever = 1;
cfg.play_forever = 1; cfg.play_forever = 1;
cfg.force_loop = 1; //cfg.disable_config_override = 1;
cfg.really_force_loop = 1;
cfg.disable_config_override = 1;
vgmstream_apply_config(output, &cfg); vgmstream_apply_config(output, &cfg);
vgmstream_spec.channels = output->channels; vgmstream_spec.channels = output->channels;
vgmstream_spec.freq = output->sample_rate; vgmstream_spec.freq = output->sample_rate;
length = (double)output->loop_end_sample / (double)output->sample_rate; length = (double)output->num_samples / (double)output->sample_rate;
update.store(true); update.store(true);
current_file_mutex.lock(); current_file_mutex.lock();
current_file = std::string(file); current_file = std::string(file);