Fix some loop install issues with layers

This commit is contained in:
bnnm 2020-09-06 19:24:56 +02:00
parent 77173e4ac8
commit 627fbe2f4e
2 changed files with 10 additions and 0 deletions

View File

@ -95,6 +95,10 @@ void loop_layout_layered(VGMSTREAM* vgmstream, int32_t loop_sample) {
data->layers[layer]->current_sample = data->layers[layer]->loop_end_sample; /* forces do loop */
vgmstream_do_loop(data->layers[layer]); /* guaranteed to work should loop_layout be called */
}
else {
/* needed when mixing non-looping layers and installing loop externally */
seek_vgmstream(data->layers[layer], loop_sample);
}
}
}

View File

@ -796,6 +796,12 @@ void close_vgmstream(VGMSTREAM* vgmstream) {
void vgmstream_force_loop(VGMSTREAM* vgmstream, int loop_flag, int loop_start_sample, int loop_end_sample) {
if (!vgmstream) return;
/* ignore bad values (may happen with layers + TXTP loop install) */
if (loop_flag && (loop_start_sample < 0 ||
loop_start_sample > loop_end_sample ||
loop_end_sample > vgmstream->num_samples))
return;
/* this requires a bit more messing with the VGMSTREAM than I'm comfortable with... */
if (loop_flag && !vgmstream->loop_flag && !vgmstream->loop_ch) {
vgmstream->loop_ch = calloc(vgmstream->channels, sizeof(VGMSTREAMCHANNEL));