mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-17 23:36:41 +01:00
Simplify mus_acm_codec_data into acm_codec_data
This commit is contained in:
parent
98aa30a38e
commit
05dc3df6e0
@ -822,20 +822,19 @@ void acm_reset(ACMStream *acm)
|
||||
* interface to vgmstream
|
||||
***********************************************/
|
||||
|
||||
mus_acm_codec_data *init_acm(int files) {
|
||||
mus_acm_codec_data* data = NULL;
|
||||
acm_codec_data *init_acm(STREAMFILE *streamFile) {
|
||||
acm_codec_data* data = NULL;
|
||||
ACMStream *acm_stream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
|
||||
if (files == 0)
|
||||
goto fail;
|
||||
|
||||
data = calloc(1,sizeof(mus_acm_codec_data));
|
||||
data = calloc(1,sizeof(acm_codec_data));
|
||||
if (!data) goto fail;
|
||||
|
||||
data->files = calloc(files,sizeof(ACMStream *));
|
||||
if (!data->files) goto fail;
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (acm_open_decoder(&acm_stream,streamFile,filename) != ACM_OK)
|
||||
goto fail;
|
||||
|
||||
data->file_count = files;
|
||||
data->current_file = 0;
|
||||
data->file = acm_stream;
|
||||
|
||||
return data;
|
||||
|
||||
@ -844,8 +843,10 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void decode_acm(ACMStream * acm, sample * outbuf, int32_t samples_to_do, int channelspacing) {
|
||||
void decode_acm(acm_codec_data *data, sample * outbuf, int32_t samples_to_do, int channelspacing) {
|
||||
ACMStream * acm = data->file;
|
||||
int32_t samples_read = 0;
|
||||
|
||||
while (samples_read < samples_to_do) {
|
||||
int32_t bytes_read_just_now = acm_read(
|
||||
acm,
|
||||
@ -862,30 +863,18 @@ void decode_acm(ACMStream * acm, sample * outbuf, int32_t samples_to_do, int cha
|
||||
}
|
||||
|
||||
void reset_acm(VGMSTREAM *vgmstream) {
|
||||
mus_acm_codec_data *data = vgmstream->codec_data;
|
||||
int i;
|
||||
if (data) {
|
||||
data->current_file = 0;
|
||||
for (i=0;i<data->file_count;i++) {
|
||||
acm_reset(data->files[i]);
|
||||
}
|
||||
acm_codec_data *data = vgmstream->codec_data;
|
||||
|
||||
if (data && data->file) {
|
||||
acm_reset(data->file);
|
||||
}
|
||||
}
|
||||
|
||||
void free_acm(mus_acm_codec_data *data) {
|
||||
void free_acm(acm_codec_data *data) {
|
||||
if (data) {
|
||||
if (data->files) {
|
||||
int i;
|
||||
for (i = 0; i < data->file_count; i++) {
|
||||
/* shouldn't be duplicates */
|
||||
if (data->files[i]) {
|
||||
acm_close(data->files[i]);
|
||||
}
|
||||
|
||||
}
|
||||
free(data->files);
|
||||
if (data->file) {
|
||||
acm_close(data->file);
|
||||
}
|
||||
|
||||
free(data);
|
||||
}
|
||||
}
|
||||
|
@ -102,10 +102,10 @@ void decode_cbd2_int(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspac
|
||||
void decode_ws(VGMSTREAM * vgmstream, int channel, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
|
||||
|
||||
/* acm_decoder */
|
||||
mus_acm_codec_data *init_acm(int files);
|
||||
void decode_acm(ACMStream * acm, sample * outbuf, int32_t samples_to_do, int channelspacing);
|
||||
acm_codec_data *init_acm();
|
||||
void decode_acm(acm_codec_data *data, sample * outbuf, int32_t samples_to_do, int channelspacing);
|
||||
void reset_acm(VGMSTREAM *vgmstream);
|
||||
void free_acm(mus_acm_codec_data *data);
|
||||
void free_acm(acm_codec_data *data);
|
||||
|
||||
/* nwa_decoder */
|
||||
void decode_nwa(NWAData *nwa, sample *outbuf, int32_t samples_to_do);
|
||||
|
@ -6,7 +6,7 @@
|
||||
VGMSTREAM * init_vgmstream_acm(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
int loop_flag = 0, channel_count, sample_rate, num_samples;
|
||||
mus_acm_codec_data *data = NULL;
|
||||
acm_codec_data *data = NULL;
|
||||
|
||||
|
||||
/* checks */
|
||||
@ -17,23 +17,13 @@ VGMSTREAM * init_vgmstream_acm(STREAMFILE *streamFile) {
|
||||
|
||||
|
||||
/* init decoder */
|
||||
data = init_acm(1);
|
||||
if (!data) goto fail;
|
||||
|
||||
/* open and parse the file before creating the vgmstream */
|
||||
{
|
||||
ACMStream *acm_stream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
data = init_acm(streamFile);
|
||||
if (!data) 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 = data->file->info.channels;
|
||||
sample_rate = data->file->info.rate;
|
||||
num_samples = data->file->total_values / data->file->info.channels;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1791,16 +1791,11 @@ void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to
|
||||
vgmstream->channels);
|
||||
break;
|
||||
#endif
|
||||
case coding_ACM: { //single ACM
|
||||
mus_acm_codec_data *data = vgmstream->codec_data;
|
||||
ACMStream *acm;
|
||||
|
||||
acm = data->files[data->current_file];
|
||||
decode_acm(acm,
|
||||
case coding_ACM:
|
||||
decode_acm(vgmstream->codec_data,
|
||||
buffer+samples_written*vgmstream->channels,
|
||||
samples_to_do, vgmstream->channels);
|
||||
break;
|
||||
}
|
||||
case coding_NWA0:
|
||||
case coding_NWA1:
|
||||
case coding_NWA2:
|
||||
|
@ -1041,20 +1041,10 @@ typedef struct {
|
||||
} atrac9_codec_data;
|
||||
#endif
|
||||
|
||||
/* with one file this is also used for just ACM */
|
||||
/* libacm interface */
|
||||
typedef struct {
|
||||
int file_count;
|
||||
int current_file;
|
||||
/* the index we return to upon loop completion */
|
||||
int loop_start_file;
|
||||
/* one after the index of the last file, typically
|
||||
* will be equal to file_count */
|
||||
int loop_end_file;
|
||||
/* Upon exit from a loop, which file to play. */
|
||||
/* -1 if there is no such file */
|
||||
/*int end_file;*/
|
||||
ACMStream **files;
|
||||
} mus_acm_codec_data;
|
||||
ACMStream *file;
|
||||
} acm_codec_data;
|
||||
|
||||
#define AIX_BUFFER_SIZE 0x1000
|
||||
/* AIXery */
|
||||
|
Loading…
x
Reference in New Issue
Block a user