mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-17 19:19:16 +01:00
MUS Playlists! ARGH!
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@353 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
a1642a84fa
commit
875c0d1eae
@ -96,9 +96,10 @@ META_OBJS=meta/adx_header.o \
|
|||||||
meta/dc_kcey.o \
|
meta/dc_kcey.o \
|
||||||
meta/ps2_rstm.o \
|
meta/ps2_rstm.o \
|
||||||
meta/acm.o \
|
meta/acm.o \
|
||||||
meta/ps2_kces.o \
|
meta/mus_acm.o \
|
||||||
meta/ps2_dxh.o \
|
meta/ps2_kces.o \
|
||||||
meta/ps2_psh.o
|
meta/ps2_dxh.o \
|
||||||
|
meta/ps2_psh.o
|
||||||
|
|
||||||
OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS)
|
OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS)
|
||||||
|
|
||||||
|
@ -12,31 +12,31 @@ void render_vgmstream_mus_acm(sample * buffer, int32_t sample_count, VGMSTREAM *
|
|||||||
int samples_to_do;
|
int samples_to_do;
|
||||||
int samples_this_block = acm->total_values / acm->info.channels;
|
int samples_this_block = acm->total_values / acm->info.channels;
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (vgmstream->loop_flag && vgmstream_do_loop(vgmstream)) {
|
if (vgmstream->loop_flag && vgmstream_do_loop(vgmstream)) {
|
||||||
|
data->current_file = data->loop_start_file;
|
||||||
|
acm_reset(data->files[data->current_file]);
|
||||||
|
vgmstream->samples_into_block = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
samples_to_do = vgmstream_samples_to_do(samples_this_block, 1, vgmstream);
|
samples_to_do = vgmstream_samples_to_do(samples_this_block, 1, vgmstream);
|
||||||
|
|
||||||
|
/*printf("samples_to_do=%d,samples_this_block=%d,samples_written=%d,sample_count=%d\n",samples_to_do,samples_this_block,samples_written,sample_count);*/
|
||||||
|
|
||||||
if (samples_written+samples_to_do > sample_count)
|
if (samples_written+samples_to_do > sample_count)
|
||||||
samples_to_do=sample_count-samples_written;
|
samples_to_do=sample_count-samples_written;
|
||||||
|
|
||||||
if (samples_to_do == 0)
|
if (samples_to_do == 0)
|
||||||
{
|
{
|
||||||
data->current_file++;
|
data->current_file++;
|
||||||
|
/*printf("next %d, %d samples\n",data->current_file,data->files[data->current_file]->total_values/data->files[data->current_file]->info.channels);*/
|
||||||
/* check for loop */
|
/* check for loop */
|
||||||
if (vgmstream->loop_flag) {
|
|
||||||
if (data->current_file == data->loop_end_file)
|
|
||||||
data->current_file = data->loop_start_file;
|
|
||||||
} else {
|
|
||||||
/* */
|
|
||||||
}
|
|
||||||
acm_reset(data->files[data->current_file]);
|
acm_reset(data->files[data->current_file]);
|
||||||
|
vgmstream->samples_into_block = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*printf("decode %d samples file %d\n",samples_to_do,data->current_file);*/
|
||||||
decode_acm(acm,
|
decode_acm(acm,
|
||||||
buffer+samples_written*vgmstream->channels,
|
buffer+samples_written*vgmstream->channels,
|
||||||
samples_to_do, vgmstream->channels);
|
samples_to_do, vgmstream->channels);
|
||||||
|
@ -262,6 +262,10 @@
|
|||||||
RelativePath=".\meta\ivb.c"
|
RelativePath=".\meta\ivb.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\meta\mus_acm.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\meta\musc.c"
|
RelativePath=".\meta\musc.c"
|
||||||
>
|
>
|
||||||
|
@ -75,5 +75,6 @@ libmeta_la_SOURCES += acm.c
|
|||||||
libmeta_la_SOURCES += ps2_kces.c
|
libmeta_la_SOURCES += ps2_kces.c
|
||||||
libmeta_la_SOURCES += ps2_dxh.c
|
libmeta_la_SOURCES += ps2_dxh.c
|
||||||
libmeta_la_SOURCES += ps2_psh.c
|
libmeta_la_SOURCES += ps2_psh.c
|
||||||
|
libmeta_la_SOURCES += mus_acm.c
|
||||||
|
|
||||||
EXTRA_DIST = meta.h
|
EXTRA_DIST = meta.h
|
||||||
|
@ -163,4 +163,6 @@ VGMSTREAM * init_vgmstream_ps2_dxh(STREAMFILE * streamFile);
|
|||||||
|
|
||||||
VGMSTREAM * init_vgmstream_ps2_psh(STREAMFILE * streamFile);
|
VGMSTREAM * init_vgmstream_ps2_psh(STREAMFILE * streamFile);
|
||||||
|
|
||||||
|
VGMSTREAM * init_vgmstream_mus_acm(STREAMFILE * streamFile);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
349
src/meta/mus_acm.c
Normal file
349
src/meta/mus_acm.c
Normal file
@ -0,0 +1,349 @@
|
|||||||
|
#include "../vgmstream.h"
|
||||||
|
#include "meta.h"
|
||||||
|
#include "../util.h"
|
||||||
|
#include "../streamfile.h"
|
||||||
|
#include "../coding/acm_decoder.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define DIRSEP '\\'
|
||||||
|
#else
|
||||||
|
#define DIRSEP '/'
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define NAME_LENGTH 260
|
||||||
|
|
||||||
|
int exists(char *filename, STREAMFILE *streamfile) {
|
||||||
|
STREAMFILE * temp =
|
||||||
|
streamfile->open(streamfile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||||
|
if (!temp) return 0;
|
||||||
|
|
||||||
|
close_streamfile(temp);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* needs the name of a file in the directory to test, as all we can do reliably is attempt to open a file */
|
||||||
|
int find_directory_name(char *name_base, char *dir_name, int subdir_name_size, char *subdir_name, char *name, char *file_name, STREAMFILE *streamfile) {
|
||||||
|
/* find directory name */
|
||||||
|
{
|
||||||
|
char temp_dir_name[NAME_LENGTH];
|
||||||
|
|
||||||
|
subdir_name[0]='\0';
|
||||||
|
concatn(subdir_name_size,subdir_name,name_base);
|
||||||
|
|
||||||
|
if (strlen(subdir_name) >= subdir_name_size-2) goto fail;
|
||||||
|
subdir_name[strlen(subdir_name)+1]='\0';
|
||||||
|
subdir_name[strlen(subdir_name)]=DIRSEP;
|
||||||
|
|
||||||
|
temp_dir_name[0]='\0';
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,dir_name);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,subdir_name);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,name_base);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,name);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,".ACM");
|
||||||
|
|
||||||
|
if (!exists(temp_dir_name,streamfile)) {
|
||||||
|
int i;
|
||||||
|
/* try all lowercase */
|
||||||
|
for (i=strlen(subdir_name)-1;i>=0;i--) {
|
||||||
|
subdir_name[i]=tolower(subdir_name[i]);
|
||||||
|
}
|
||||||
|
temp_dir_name[0]='\0';
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,dir_name);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,subdir_name);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,name_base);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,name);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,".ACM");
|
||||||
|
|
||||||
|
if (!exists(temp_dir_name,streamfile)) {
|
||||||
|
/* try first uppercase */
|
||||||
|
subdir_name[0]=toupper(subdir_name[0]);
|
||||||
|
temp_dir_name[0]='\0';
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,dir_name);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,subdir_name);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,name_base);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,name);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,".ACM");
|
||||||
|
if (!exists(temp_dir_name,streamfile)) {
|
||||||
|
/* try also 3rd uppercase */
|
||||||
|
subdir_name[2]=toupper(subdir_name[2]);
|
||||||
|
temp_dir_name[0]='\0';
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,dir_name);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,subdir_name);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,name_base);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,name);
|
||||||
|
concatn(sizeof(temp_dir_name),temp_dir_name,".ACM");
|
||||||
|
|
||||||
|
if (!exists(temp_dir_name,streamfile)) {
|
||||||
|
/* ah well, disaster has befallen your party */
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* MUS playlist for InterPlay ACM */
|
||||||
|
VGMSTREAM * init_vgmstream_mus_acm(STREAMFILE *streamFile) {
|
||||||
|
VGMSTREAM * vgmstream = NULL;
|
||||||
|
ACMStream *acm_stream = NULL;
|
||||||
|
mus_acm_codec_data *data = NULL;
|
||||||
|
|
||||||
|
char filename[NAME_LENGTH];
|
||||||
|
char line_buffer[NAME_LENGTH];
|
||||||
|
char * end_ptr;
|
||||||
|
char name_base[NAME_LENGTH];
|
||||||
|
char (*names)[NAME_LENGTH] = NULL;
|
||||||
|
char dir_name[NAME_LENGTH];
|
||||||
|
char subdir_name[NAME_LENGTH];
|
||||||
|
|
||||||
|
int i;
|
||||||
|
int loop_flag = 0;
|
||||||
|
int channel_count;
|
||||||
|
int file_count;
|
||||||
|
size_t line_bytes;
|
||||||
|
int whole_line_read = 0;
|
||||||
|
off_t mus_offset = 0;
|
||||||
|
|
||||||
|
int loop_end_index = -1;
|
||||||
|
int loop_start_index = -1;
|
||||||
|
int32_t loop_start_samples = -1;
|
||||||
|
int32_t loop_end_samples = -1;
|
||||||
|
|
||||||
|
int32_t total_samples = 0;
|
||||||
|
|
||||||
|
/* check extension, case insensitive */
|
||||||
|
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||||
|
if (strcasecmp("mus",filename_extension(filename))) goto fail;
|
||||||
|
|
||||||
|
/* read file name base */
|
||||||
|
line_bytes = get_streamfile_dos_line(sizeof(line_buffer),line_buffer,
|
||||||
|
mus_offset, streamFile, &whole_line_read);
|
||||||
|
if (!whole_line_read) goto fail;
|
||||||
|
mus_offset += line_bytes;
|
||||||
|
memcpy(name_base,line_buffer,sizeof(name_base));
|
||||||
|
|
||||||
|
/* uppercase name_base */
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i=0;name_base[i];i++) name_base[i]=toupper(name_base[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*printf("name base: %s\n",name_base);*/
|
||||||
|
|
||||||
|
/* read track entry count */
|
||||||
|
line_bytes = get_streamfile_dos_line(sizeof(line_buffer),line_buffer,
|
||||||
|
mus_offset, streamFile, &whole_line_read);
|
||||||
|
if (!whole_line_read) goto fail;
|
||||||
|
if (line_buffer[0] == '\0') goto fail;
|
||||||
|
mus_offset += line_bytes;
|
||||||
|
file_count = strtol(line_buffer,&end_ptr,10);
|
||||||
|
/* didn't parse whole line as an integer (optional opening whitespace) */
|
||||||
|
if (*end_ptr != '\0') goto fail;
|
||||||
|
|
||||||
|
/*printf("entries: %d\n",file_count);*/
|
||||||
|
|
||||||
|
names = calloc(file_count,sizeof(names[0]));
|
||||||
|
if (!names) goto fail;
|
||||||
|
|
||||||
|
dir_name[0]='\0';
|
||||||
|
concatn(sizeof(dir_name),dir_name,filename);
|
||||||
|
|
||||||
|
{
|
||||||
|
/* find directory name for the directory contianing the MUS */
|
||||||
|
char * last_slash;
|
||||||
|
last_slash = strrchr(dir_name,DIRSEP);
|
||||||
|
if (last_slash != NULL) {
|
||||||
|
/* trim off the file name */
|
||||||
|
last_slash[1]='\0';
|
||||||
|
} else {
|
||||||
|
/* no dir name? annihilate! */
|
||||||
|
dir_name[0] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* can't do this until we have a file name */
|
||||||
|
subdir_name[0]='\0';
|
||||||
|
|
||||||
|
/* parse each entry */
|
||||||
|
{
|
||||||
|
char name[NAME_LENGTH];
|
||||||
|
char loop_name_base_temp[NAME_LENGTH];
|
||||||
|
char loop_name_temp[NAME_LENGTH];
|
||||||
|
char loop_name_base[NAME_LENGTH];
|
||||||
|
char loop_name[NAME_LENGTH];
|
||||||
|
for (i=0;i<file_count;i++)
|
||||||
|
{
|
||||||
|
int fields_matched;
|
||||||
|
line_bytes =
|
||||||
|
get_streamfile_dos_line(sizeof(line_buffer),line_buffer,
|
||||||
|
mus_offset, streamFile, &whole_line_read);
|
||||||
|
if (!whole_line_read) goto fail;
|
||||||
|
mus_offset += line_bytes;
|
||||||
|
|
||||||
|
fields_matched = sscanf(line_buffer,"%s %s %s",name,
|
||||||
|
loop_name_base_temp,loop_name_temp);
|
||||||
|
|
||||||
|
|
||||||
|
if (fields_matched < 1) goto fail;
|
||||||
|
if (fields_matched == 3 && loop_name_base[0] != '@')
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
memcpy(loop_name,loop_name_temp,sizeof(loop_name));
|
||||||
|
memcpy(loop_name_base,loop_name_base_temp,sizeof(loop_name_base));
|
||||||
|
for (j=0;loop_name[j];j++) loop_name[j]=toupper(loop_name[j]);
|
||||||
|
for (j=0;loop_name_base[j];j++) loop_name_base[j]=toupper(loop_name_base[j]);
|
||||||
|
/* loop back entry */
|
||||||
|
loop_end_index = i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* normal entry, ignoring the @TAG for now */
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
/* uppercase */
|
||||||
|
int j;
|
||||||
|
for (j=0;j<strlen(name);j++) name[j]=toupper(name[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* try looking in the common directory */
|
||||||
|
names[i][0] = '\0';
|
||||||
|
concatn(sizeof(names[0]),names[i],dir_name);
|
||||||
|
concatn(sizeof(names[0]),names[i],name);
|
||||||
|
concatn(sizeof(names[0]),names[i],".ACM");
|
||||||
|
|
||||||
|
if (!exists(names[i],streamFile)) {
|
||||||
|
|
||||||
|
/* We can't test for the directory until we have a file name
|
||||||
|
* to look for, so we do it here with the first file that seems to
|
||||||
|
* be in a subdirectory */
|
||||||
|
if (subdir_name[0]=='\0') {
|
||||||
|
if (find_directory_name(name_base, dir_name, sizeof(subdir_name), subdir_name, name, filename, streamFile))
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
names[i][0] = '\0';
|
||||||
|
concatn(sizeof(names[0]),names[i],dir_name);
|
||||||
|
concatn(sizeof(names[0]),names[i],subdir_name);
|
||||||
|
concatn(sizeof(names[0]),names[i],name_base);
|
||||||
|
concatn(sizeof(names[0]),names[i],name);
|
||||||
|
concatn(sizeof(names[0]),names[i],".ACM");
|
||||||
|
|
||||||
|
if (!exists(names[i],streamFile)) goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*printf("%2d %s\n",i,names[i]);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loop_end_index != -1) {
|
||||||
|
/* find the file to loop back to */
|
||||||
|
char target_name[NAME_LENGTH];
|
||||||
|
target_name[0]='\0';
|
||||||
|
concatn(sizeof(target_name),target_name,dir_name);
|
||||||
|
concatn(sizeof(target_name),target_name,subdir_name);
|
||||||
|
concatn(sizeof(target_name),target_name,loop_name_base);
|
||||||
|
concatn(sizeof(target_name),target_name,loop_name);
|
||||||
|
concatn(sizeof(target_name),target_name,".ACM");
|
||||||
|
|
||||||
|
for (i=0;i<file_count;i++) {
|
||||||
|
if (!strcmp(target_name,names[i]))
|
||||||
|
{
|
||||||
|
loop_start_index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loop_start_index != -1) {
|
||||||
|
/*printf("loop from %d to %d\n",loop_end_index,loop_start_index);*/
|
||||||
|
/*if (loop_start_index < file_count-1) loop_start_index++;*/
|
||||||
|
/*loop_end_index++;*/
|
||||||
|
loop_flag = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set up the struct to track the files */
|
||||||
|
data = calloc(1,sizeof(mus_acm_codec_data));
|
||||||
|
if (!data) goto fail;
|
||||||
|
|
||||||
|
data->files = calloc(file_count,sizeof(ACMStream *));
|
||||||
|
if (!data->files) {
|
||||||
|
free(data); data = NULL;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* open each file... */
|
||||||
|
for (i=0;i<file_count;i++) {
|
||||||
|
|
||||||
|
/* gonna do this a little backwards, open and parse the file
|
||||||
|
before creating the vgmstream */
|
||||||
|
|
||||||
|
if (acm_open_decoder(&acm_stream,streamFile,names[i]) != ACM_OK) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
data->files[i]=acm_stream;
|
||||||
|
|
||||||
|
if (i==loop_start_index) loop_start_samples = total_samples;
|
||||||
|
if (i==loop_end_index) loop_end_samples = total_samples;
|
||||||
|
|
||||||
|
total_samples += acm_stream->total_values / acm_stream->info.channels;
|
||||||
|
|
||||||
|
if (i>0) {
|
||||||
|
if (acm_stream->info.channels != data->files[0]->info.channels ||
|
||||||
|
acm_stream->info.rate != data->files[0]->info.rate) goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i==loop_end_index) loop_end_samples = total_samples;
|
||||||
|
|
||||||
|
channel_count = data->files[0]->info.channels;
|
||||||
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||||
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
|
vgmstream->channels = channel_count;
|
||||||
|
vgmstream->sample_rate = data->files[0]->info.rate;
|
||||||
|
vgmstream->coding_type = coding_ACM;
|
||||||
|
vgmstream->num_samples = total_samples;
|
||||||
|
vgmstream->loop_start_sample = loop_start_samples;
|
||||||
|
vgmstream->loop_end_sample = loop_end_samples;
|
||||||
|
vgmstream->layout_type = layout_mus_acm;
|
||||||
|
vgmstream->meta_type = meta_MUS_ACM;
|
||||||
|
|
||||||
|
data->file_count = file_count;
|
||||||
|
data->current_file = 0;
|
||||||
|
data->loop_start_file = loop_start_index;
|
||||||
|
data->loop_end_file = loop_end_index;
|
||||||
|
/*data->end_file = -1;*/
|
||||||
|
|
||||||
|
vgmstream->codec_data = data;
|
||||||
|
|
||||||
|
free(names);
|
||||||
|
|
||||||
|
return vgmstream;
|
||||||
|
|
||||||
|
/* clean up anything we may have opened */
|
||||||
|
fail:
|
||||||
|
if (data) {
|
||||||
|
int i;
|
||||||
|
for (i=0;i<data->file_count;i++) {
|
||||||
|
if (data->files[i]) {
|
||||||
|
acm_close(data->files[i]);
|
||||||
|
data->files[i] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (names) free(names);
|
||||||
|
if (vgmstream) close_vgmstream(vgmstream);
|
||||||
|
return NULL;
|
||||||
|
}
|
@ -202,3 +202,62 @@ STREAMFILE * open_stdio_streamfile_buffer(const char * const filename, size_t bu
|
|||||||
|
|
||||||
return streamFile;
|
return streamFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Read a line into dst. The source files are MS-DOS style,
|
||||||
|
* separated (not terminated) by CRLF. Return 1 if the full line was
|
||||||
|
* retrieved (if it could fit in dst), 0 otherwise. In any case the result
|
||||||
|
* will be properly terminated. The CRLF will be removed if there is one.
|
||||||
|
* Return the number of bytes read (including CRLF line ending). Note that
|
||||||
|
* this is not the length of the string, and could be larger than the buffer.
|
||||||
|
* *line_done_ptr is set to 1 if the complete line was read into dst,
|
||||||
|
* otherwise it is set to 0. line_done_ptr can be NULL if you aren't
|
||||||
|
* interested in this info.
|
||||||
|
*/
|
||||||
|
size_t get_streamfile_dos_line(int dst_length, char * dst, off_t offset,
|
||||||
|
STREAMFILE * infile, int *line_done_ptr)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
off_t file_length = get_streamfile_size(infile);
|
||||||
|
/* how many bytes over those put in the buffer were read */
|
||||||
|
int extra_bytes = 0;
|
||||||
|
|
||||||
|
if (line_done_ptr) *line_done_ptr = 0;
|
||||||
|
|
||||||
|
for (i=0;i<dst_length-1 && offset+i < file_length;i++)
|
||||||
|
{
|
||||||
|
char in_char = read_8bit(offset+i,infile);
|
||||||
|
/* check for end of line */
|
||||||
|
if (in_char == 0x0d &&
|
||||||
|
read_8bit(offset+i+1,infile) == 0x0a)
|
||||||
|
{
|
||||||
|
extra_bytes = 2;
|
||||||
|
if (line_done_ptr) *line_done_ptr = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
dst[i]=in_char;
|
||||||
|
}
|
||||||
|
|
||||||
|
dst[i]='\0';
|
||||||
|
|
||||||
|
/* did we fill the buffer? */
|
||||||
|
if (i==dst_length) {
|
||||||
|
/* did the bytes we missed just happen to be the end of the line? */
|
||||||
|
if (read_8bit(offset+i,infile) == 0x0d &&
|
||||||
|
read_8bit(offset+i+1,infile) == 0x0a)
|
||||||
|
{
|
||||||
|
extra_bytes = 2;
|
||||||
|
/* if so be proud! */
|
||||||
|
if (line_done_ptr) *line_done_ptr = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* did we hit the file end? */
|
||||||
|
if (offset+i == file_length)
|
||||||
|
{
|
||||||
|
/* then we did in fact finish reading the last line */
|
||||||
|
if (line_done_ptr) *line_done_ptr = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i+extra_bytes;
|
||||||
|
}
|
||||||
|
@ -134,4 +134,7 @@ static inline STREAMFILE * open_stdio_streamfile(const char * const filename) {
|
|||||||
return open_stdio_streamfile_buffer(filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
return open_stdio_streamfile_buffer(filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t get_streamfile_dos_line(int dst_length, char * dst, off_t offset,
|
||||||
|
STREAMFILE * infile, int *line_done_ptr);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -94,6 +94,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
|
|||||||
init_vgmstream_kcey,
|
init_vgmstream_kcey,
|
||||||
init_vgmstream_ps2_rstm,
|
init_vgmstream_ps2_rstm,
|
||||||
init_vgmstream_acm,
|
init_vgmstream_acm,
|
||||||
|
init_vgmstream_mus_acm,
|
||||||
init_vgmstream_ps2_kces,
|
init_vgmstream_ps2_kces,
|
||||||
init_vgmstream_ps2_dxh,
|
init_vgmstream_ps2_dxh,
|
||||||
init_vgmstream_ps2_psh,
|
init_vgmstream_ps2_psh,
|
||||||
@ -379,6 +380,7 @@ void render_vgmstream(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstre
|
|||||||
render_vgmstream_interleave_byte(buffer,sample_count,vgmstream);
|
render_vgmstream_interleave_byte(buffer,sample_count,vgmstream);
|
||||||
break;
|
break;
|
||||||
case layout_acm:
|
case layout_acm:
|
||||||
|
case layout_mus_acm:
|
||||||
render_vgmstream_mus_acm(buffer,sample_count,vgmstream);
|
render_vgmstream_mus_acm(buffer,sample_count,vgmstream);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1054,7 +1056,10 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case layout_acm:
|
case layout_acm:
|
||||||
snprintf(temp,TEMPSIZE,"However ACM Does That");
|
snprintf(temp,TEMPSIZE,"ACM blocked");
|
||||||
|
break;
|
||||||
|
case layout_mus_acm:
|
||||||
|
snprintf(temp,TEMPSIZE,"multiple ACM files, ACM blocked");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
snprintf(temp,TEMPSIZE,"INCONCEIVABLE");
|
snprintf(temp,TEMPSIZE,"INCONCEIVABLE");
|
||||||
@ -1368,6 +1373,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
|||||||
break;
|
break;
|
||||||
case meta_ACM:
|
case meta_ACM:
|
||||||
snprintf(temp,TEMPSIZE,"InterPlay ACM Header");
|
snprintf(temp,TEMPSIZE,"InterPlay ACM Header");
|
||||||
|
break;
|
||||||
|
case meta_MUS_ACM:
|
||||||
|
snprintf(temp,TEMPSIZE,"MUS playlist and multiple InterPlay ACM Headered files");
|
||||||
break;
|
break;
|
||||||
case meta_PS2_KCES:
|
case meta_PS2_KCES:
|
||||||
snprintf(temp,TEMPSIZE,"Konami KCES Header");
|
snprintf(temp,TEMPSIZE,"Konami KCES Header");
|
||||||
|
@ -111,6 +111,7 @@ typedef enum {
|
|||||||
layout_mpeg, /* proper MPEG audio stream */
|
layout_mpeg, /* proper MPEG audio stream */
|
||||||
#endif
|
#endif
|
||||||
layout_acm, /* dummy, let libacm handle layout */
|
layout_acm, /* dummy, let libacm handle layout */
|
||||||
|
layout_mus_acm, /* mus has multi-files to deal with */
|
||||||
} layout_t;
|
} layout_t;
|
||||||
|
|
||||||
/* The meta type specifies how we know what we know about the file. We may know because of a header we read, some of it may have been guessed from filenames, etc. */
|
/* The meta type specifies how we know what we know about the file. We may know because of a header we read, some of it may have been guessed from filenames, etc. */
|
||||||
|
@ -89,6 +89,7 @@ gchar *vgmstream_exts [] = {
|
|||||||
"kcey",
|
"kcey",
|
||||||
"rstm",
|
"rstm",
|
||||||
"acm",
|
"acm",
|
||||||
|
"mus",
|
||||||
/* terminator */
|
/* terminator */
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
@ -150,6 +150,7 @@ char * extension_list[] = {
|
|||||||
"kcey\0KCEY Audio File (*.KCEY)\0",
|
"kcey\0KCEY Audio File (*.KCEY)\0",
|
||||||
"rstm\0RSTM Audio File (*.RSTM)\0",
|
"rstm\0RSTM Audio File (*.RSTM)\0",
|
||||||
"acm\0ACM Audio File (*.ACM)\0",
|
"acm\0ACM Audio File (*.ACM)\0",
|
||||||
|
"mus\0MUS Playlist File (*.MUS)\0",
|
||||||
"kces\0KCES Audio File (*.KCES)\0",
|
"kces\0KCES Audio File (*.KCES)\0",
|
||||||
"dxh\0DXH Audio File (*.DXH)\0",
|
"dxh\0DXH Audio File (*.DXH)\0",
|
||||||
"psh\0PSH Audio File (*.PSH)\0",
|
"psh\0PSH Audio File (*.PSH)\0",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user