2008-05-06 05:35:37 +02:00
|
|
|
#include "layout.h"
|
2008-03-04 08:15:25 +01:00
|
|
|
#include "../vgmstream.h"
|
|
|
|
|
|
|
|
void render_vgmstream_blocked(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
|
|
|
|
int samples_written=0;
|
|
|
|
|
|
|
|
int frame_size = get_vgmstream_frame_size(vgmstream);
|
|
|
|
int samples_per_frame = get_vgmstream_samples_per_frame(vgmstream);
|
|
|
|
int samples_this_block;
|
|
|
|
|
2008-07-03 04:20:52 +02:00
|
|
|
if (frame_size == 0) {
|
|
|
|
/* assume 4 bit */
|
|
|
|
/* TODO: get_vgmstream_frame_size() really should return bits... */
|
|
|
|
samples_this_block = vgmstream->current_block_size * 2 * samples_per_frame;
|
|
|
|
} else {
|
|
|
|
samples_this_block = vgmstream->current_block_size / frame_size * samples_per_frame;
|
|
|
|
}
|
2008-03-04 08:15:25 +01:00
|
|
|
|
|
|
|
while (samples_written<sample_count) {
|
|
|
|
int samples_to_do;
|
|
|
|
|
|
|
|
if (vgmstream->loop_flag && vgmstream_do_loop(vgmstream)) {
|
2008-07-03 04:20:52 +02:00
|
|
|
if (frame_size == 0) {
|
|
|
|
samples_this_block = vgmstream->current_block_size * 2 * samples_per_frame;
|
|
|
|
} else {
|
|
|
|
samples_this_block = vgmstream->current_block_size / frame_size * samples_per_frame;
|
|
|
|
}
|
2008-03-04 08:15:25 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
samples_to_do = vgmstream_samples_to_do(samples_this_block, samples_per_frame, vgmstream);
|
|
|
|
|
|
|
|
if (samples_written+samples_to_do > sample_count)
|
|
|
|
samples_to_do=sample_count-samples_written;
|
|
|
|
|
|
|
|
if (vgmstream->current_block_offset>=0)
|
|
|
|
decode_vgmstream(vgmstream, samples_written, samples_to_do, buffer);
|
|
|
|
else {
|
|
|
|
int i;
|
|
|
|
/* we've run off the end! */
|
|
|
|
for (i=samples_written*vgmstream->channels;
|
|
|
|
i<(samples_written+samples_to_do)*vgmstream->channels;i++)
|
|
|
|
buffer[i]=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
samples_written += samples_to_do;
|
|
|
|
vgmstream->current_sample += samples_to_do;
|
|
|
|
vgmstream->samples_into_block+=samples_to_do;
|
|
|
|
|
|
|
|
if (vgmstream->samples_into_block==samples_this_block) {
|
|
|
|
switch (vgmstream->layout_type) {
|
|
|
|
case layout_ast_blocked:
|
|
|
|
ast_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
2009-09-02 14:18:23 +02:00
|
|
|
case layout_mxch_blocked:
|
|
|
|
mxch_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
2008-03-04 08:15:25 +01:00
|
|
|
case layout_halpst_blocked:
|
|
|
|
if (vgmstream->next_block_offset>=0)
|
|
|
|
halpst_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
else
|
|
|
|
vgmstream->current_block_offset=-1;
|
|
|
|
break;
|
2008-05-10 21:59:29 +02:00
|
|
|
case layout_xa_blocked:
|
|
|
|
xa_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
2008-06-02 19:58:08 +02:00
|
|
|
case layout_ea_blocked:
|
|
|
|
ea_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
2008-07-14 21:21:45 +02:00
|
|
|
case layout_eacs_blocked:
|
|
|
|
eacs_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
2008-06-03 20:41:26 +02:00
|
|
|
case layout_caf_blocked:
|
|
|
|
caf_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
2008-06-29 03:30:13 +02:00
|
|
|
case layout_wsi_blocked:
|
|
|
|
wsi_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
2008-07-02 15:39:51 +02:00
|
|
|
case layout_str_snds_blocked:
|
|
|
|
str_snds_block_update(vgmstream->next_block_offset,vgmstream);
|
2008-07-02 05:57:21 +02:00
|
|
|
break;
|
2008-07-03 04:20:52 +02:00
|
|
|
case layout_ws_aud_blocked:
|
|
|
|
ws_aud_block_update(vgmstream->next_block_offset,vgmstream);
|
2008-08-10 22:08:03 +02:00
|
|
|
break;
|
|
|
|
case layout_matx_blocked:
|
|
|
|
matx_block_update(vgmstream->next_block_offset,vgmstream);
|
2008-08-11 09:19:44 +02:00
|
|
|
break;
|
|
|
|
case layout_de2_blocked:
|
|
|
|
de2_block_update(vgmstream->next_block_offset,vgmstream);
|
2008-12-04 21:11:45 +01:00
|
|
|
break;
|
2008-12-15 05:37:43 +01:00
|
|
|
case layout_emff_ps2_blocked:
|
|
|
|
emff_ps2_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
|
|
|
case layout_emff_ngc_blocked:
|
|
|
|
emff_ngc_block_update(vgmstream->next_block_offset,vgmstream);
|
2008-12-09 19:16:51 +01:00
|
|
|
break;
|
2008-12-16 16:48:21 +01:00
|
|
|
case layout_gsb_blocked:
|
|
|
|
gsb_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
2008-12-04 21:11:45 +01:00
|
|
|
case layout_vs_blocked:
|
|
|
|
vs_block_update(vgmstream->next_block_offset,vgmstream);
|
2008-07-03 04:20:52 +02:00
|
|
|
break;
|
2008-08-19 13:34:16 +02:00
|
|
|
case layout_xvas_blocked:
|
|
|
|
xvas_block_update(vgmstream->next_block_offset,vgmstream);
|
2008-11-28 17:25:52 +01:00
|
|
|
break;
|
2008-12-12 00:16:09 +01:00
|
|
|
case layout_thp_blocked:
|
|
|
|
thp_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
2008-12-18 07:51:26 +01:00
|
|
|
case layout_filp_blocked:
|
|
|
|
filp_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
2009-03-19 20:43:06 +01:00
|
|
|
case layout_ivaud_blocked:
|
|
|
|
ivaud_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
2010-12-03 23:48:51 +01:00
|
|
|
case layout_psx_mgav_blocked:
|
2010-04-20 22:26:10 +02:00
|
|
|
psx_mgav_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
2010-12-03 23:48:51 +01:00
|
|
|
case layout_ps2_adm_blocked:
|
|
|
|
ps2_adm_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
|
|
|
case layout_dsp_bdsp_blocked:
|
|
|
|
dsp_bdsp_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
|
|
|
case layout_tra_blocked:
|
|
|
|
tra_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
2010-12-06 23:22:06 +01:00
|
|
|
case layout_ps2_iab_blocked:
|
|
|
|
ps2_iab_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
2010-12-29 13:33:33 +01:00
|
|
|
case layout_ps2_strlr_blocked:
|
|
|
|
ps2_strlr_block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
break;
|
2008-07-14 21:21:45 +02:00
|
|
|
default:
|
2008-03-04 08:15:25 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-07-03 23:21:01 +02:00
|
|
|
/* for VBR these may change */
|
|
|
|
frame_size = get_vgmstream_frame_size(vgmstream);
|
|
|
|
samples_per_frame = get_vgmstream_samples_per_frame(vgmstream);
|
|
|
|
|
2008-07-03 04:20:52 +02:00
|
|
|
if (frame_size == 0) {
|
|
|
|
samples_this_block = vgmstream->current_block_size * 2 * samples_per_frame;
|
|
|
|
} else {
|
|
|
|
samples_this_block = vgmstream->current_block_size / frame_size * samples_per_frame;
|
|
|
|
}
|
2008-03-04 08:15:25 +01:00
|
|
|
vgmstream->samples_into_block=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|