Allow ACM to play as regular (single file) layout and remove layout_acm

This commit is contained in:
bnnm 2018-03-16 13:03:39 +01:00
parent 95d9a7f566
commit 8d4974033c
4 changed files with 57 additions and 42 deletions

View File

@ -581,7 +581,6 @@ static const layout_info layout_info_list[] = {
{layout_blocked_rws, "blocked (RWS)"},
{layout_blocked_hwas, "blocked (HWAS)"},
{layout_tra_blocked, "TRA blocked"},
{layout_acm, "ACM blocked"},
{layout_mus_acm, "multiple ACM files, ACM blocked"},
{layout_aix, "AIX interleave, internally 18-byte interleaved"},
{layout_segmented, "segmented"},

View File

@ -7,60 +7,71 @@
/* The real work is done by libacm */
VGMSTREAM * init_vgmstream_acm(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
ACMStream *acm_stream = NULL;
mus_acm_codec_data *data;
int loop_flag = 0, channel_count, sample_rate, num_samples;
mus_acm_codec_data *data = NULL;
char filename[PATH_LIMIT];
int loop_flag = 0;
int channel_count;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("acm",filename_extension(filename))) goto fail;
/* check header */
if (read_32bitBE(0x0,streamFile) != 0x97280301)
goto fail;
data = calloc(1,sizeof(mus_acm_codec_data));
if (!data) goto fail;
data->files = calloc(1,sizeof(ACMStream *));
if (!data->files) {
free(data); data = NULL;
/* checks */
if (!check_extensions(streamFile, "acm"))
goto fail;
if (read_32bitBE(0x0,streamFile) != 0x97280301) /* header id */
goto fail;
/* init decoder */
{
data = calloc(1,sizeof(mus_acm_codec_data));
if (!data) goto fail;
data->current_file = 0;
data->file_count = 1;
data->files = calloc(data->file_count,sizeof(ACMStream *));
if (!data->files) goto fail;
}
/* gonna do this a little backwards, open and parse the file
before creating the vgmstream */
/* open and parse the file before creating the vgmstream */
{
ACMStream *acm_stream = NULL;
char filename[PATH_LIMIT];
if (acm_open_decoder(&acm_stream,streamFile,filename) != ACM_OK) {
goto fail;
streamFile->get_name(streamFile,filename,sizeof(filename));
if (acm_open_decoder(&acm_stream,streamFile,filename) != ACM_OK)
goto fail;
data->files[0] = acm_stream;
channel_count = acm_stream->info.channels;
sample_rate = acm_stream->info.rate;
num_samples = acm_stream->total_values / acm_stream->info.channels;
}
channel_count = acm_stream->info.channels;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->channels = channel_count;
vgmstream->sample_rate = acm_stream->info.rate;
vgmstream->coding_type = coding_ACM;
vgmstream->num_samples = acm_stream->total_values / acm_stream->info.channels;
vgmstream->layout_type = layout_acm;
vgmstream->meta_type = meta_ACM;
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = num_samples;
data->file_count = 1;
data->current_file = 0;
data->files[0] = acm_stream;
/*data->end_file = -1;*/
vgmstream->meta_type = meta_ACM;
vgmstream->coding_type = coding_ACM;
vgmstream->layout_type = layout_none;
vgmstream->codec_data = data;
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
if (data && (!vgmstream || !vgmstream->codec_data)) {
if (data) {
int i;
for (i = 0; i < data->file_count; i++) {
acm_close(data->files[i]);
}
free(data->files);
free(data);
}
}
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -967,7 +967,6 @@ void render_vgmstream(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstre
case layout_blocked_xvag_subsong:
render_vgmstream_blocked(buffer,sample_count,vgmstream);
break;
case layout_acm:
case layout_mus_acm:
render_vgmstream_mus_acm(buffer,sample_count,vgmstream);
break;
@ -1819,9 +1818,16 @@ void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to
vgmstream->channels);
break;
#endif
case coding_ACM:
/* handled in its own layout, here to quiet compiler */
case coding_ACM: {
mus_acm_codec_data *data = vgmstream->codec_data;
ACMStream *acm;
acm = data->files[data->current_file];
decode_acm(acm,
buffer+samples_written*vgmstream->channels,
samples_to_do, vgmstream->channels);
break;
}
case coding_NWA0:
case coding_NWA1:
case coding_NWA2:

View File

@ -255,7 +255,6 @@ typedef enum {
layout_blocked_xvag_subsong, /* XVAG subsongs [God of War III (PS4)] */
/* otherwise odd */
layout_acm, /* libacm layout */
layout_mus_acm, /* mus has multi-files to deal with */
layout_aix, /* CRI AIX's wheels within wheels */
layout_segmented, /* song divided in segments, each a complete VGMSTREAM */