2008-07-20 07:41:41 +02:00
|
|
|
#include "meta.h"
|
2018-03-16 15:42:01 +01:00
|
|
|
#include "../coding/coding.h"
|
2008-07-20 07:41:41 +02:00
|
|
|
#include "../coding/acm_decoder.h"
|
|
|
|
|
2018-03-16 15:42:01 +01:00
|
|
|
/* ACM - InterPlay infinity engine games [Planescape: Torment (PC), Baldur's Gate (PC)] */
|
2008-07-20 07:41:41 +02:00
|
|
|
VGMSTREAM * init_vgmstream_acm(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2018-03-16 13:03:39 +01:00
|
|
|
int loop_flag = 0, channel_count, sample_rate, num_samples;
|
|
|
|
mus_acm_codec_data *data = NULL;
|
2008-07-20 07:41:41 +02:00
|
|
|
|
|
|
|
|
2018-03-16 13:03:39 +01:00
|
|
|
/* checks */
|
|
|
|
if (!check_extensions(streamFile, "acm"))
|
|
|
|
goto fail;
|
|
|
|
if (read_32bitBE(0x0,streamFile) != 0x97280301) /* header id */
|
|
|
|
goto fail;
|
2008-07-20 07:41:41 +02:00
|
|
|
|
|
|
|
|
2018-03-16 13:03:39 +01:00
|
|
|
/* init decoder */
|
2018-03-16 15:42:01 +01:00
|
|
|
data = init_acm(1);
|
|
|
|
if (!data) goto fail;
|
2008-07-20 07:41:41 +02:00
|
|
|
|
2018-03-16 13:03:39 +01:00
|
|
|
/* open and parse the file before creating the vgmstream */
|
|
|
|
{
|
|
|
|
ACMStream *acm_stream = NULL;
|
|
|
|
char filename[PATH_LIMIT];
|
2008-07-20 07:41:41 +02:00
|
|
|
|
2018-03-16 13:03:39 +01:00
|
|
|
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;
|
2008-07-20 07:41:41 +02:00
|
|
|
}
|
|
|
|
|
2018-03-16 13:03:39 +01:00
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
2008-07-20 07:41:41 +02:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2018-03-16 13:03:39 +01:00
|
|
|
vgmstream->sample_rate = sample_rate;
|
|
|
|
vgmstream->num_samples = num_samples;
|
2008-07-20 07:41:41 +02:00
|
|
|
|
2018-03-16 13:03:39 +01:00
|
|
|
vgmstream->meta_type = meta_ACM;
|
|
|
|
vgmstream->coding_type = coding_ACM;
|
|
|
|
vgmstream->layout_type = layout_none;
|
2008-07-20 07:41:41 +02:00
|
|
|
|
|
|
|
vgmstream->codec_data = data;
|
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2018-03-16 15:42:01 +01:00
|
|
|
free_acm(data);
|
2018-03-16 13:03:39 +01:00
|
|
|
close_vgmstream(vgmstream);
|
2008-07-20 07:41:41 +02:00
|
|
|
return NULL;
|
|
|
|
}
|