Add looping support to .diva

This commit is contained in:
M&M 2020-04-15 13:20:37 -07:00
parent 8135607bfe
commit df94b272b3

View File

@ -5,7 +5,9 @@
VGMSTREAM * init_vgmstream_diva(STREAMFILE *streamFile) { VGMSTREAM * init_vgmstream_diva(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM * vgmstream = NULL;
off_t start_offset; off_t start_offset;
int channel_count, loop_flag = 0; int channel_count;
int loop_end;
int loop_flag = (loop_end != 0);
/* checks */ /* checks */
if (!check_extensions(streamFile, "diva")) if (!check_extensions(streamFile, "diva"))
@ -16,16 +18,19 @@ VGMSTREAM * init_vgmstream_diva(STREAMFILE *streamFile) {
start_offset = 0x40; start_offset = 0x40;
channel_count = read_8bit(0x1C, streamFile); channel_count = read_8bit(0x1C, streamFile);
loop_end = read_32bitLE(0x18, streamFile);
/* build the VGMSTREAM */ /* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count, loop_flag); vgmstream = allocate_vgmstream(channel_count, loop_flag);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
vgmstream->sample_rate = read_32bitLE(0x0C, streamFile); vgmstream->sample_rate = read_32bitLE(0x0C, streamFile);
vgmstream->num_samples = read_32bitLE(0x10, streamFile); vgmstream->num_samples = read_32bitLE(0x10, streamFile);
vgmstream->meta_type = meta_DIVA; vgmstream->loop_start_sample = read_32bitLE(0x14, streamFile);
vgmstream->layout_type = layout_none; vgmstream->loop_end_sample = loop_end;
vgmstream->coding_type = coding_DVI_IMA; vgmstream->meta_type = meta_DIVA;
vgmstream->layout_type = layout_none;
vgmstream->coding_type = coding_DVI_IMA;
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset)) if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
goto fail; goto fail;