From dce063bb9622aa149781029479901115f3ca92f3 Mon Sep 17 00:00:00 2001 From: bnnm Date: Tue, 3 Jan 2017 13:34:20 +0100 Subject: [PATCH] Add a single, unified format list; plugins build their own using it To simplify adding new formats, for now it's a simple list and could improve later. Some missing formats were indirectly added: - Winamp: aifcl - foobar: aifcl, b1s, bdsp, ffw, iadp, wb, xag - XMPlay: many --- BUILD.md | 5 +- fb2k/in_vgmstream.cpp | 306 ++----------------------- src/Makefile | 2 +- src/Makefile.unix.am | 2 +- src/formats.c | 329 +++++++++++++++++++++++++++ src/formats.h | 15 ++ src/libvgmstream.vcproj | 8 + src/libvgmstream.vcxproj | 2 + src/libvgmstream.vcxproj.filters | 6 + winamp/in_vgmstream.c | 379 ++++++------------------------- xmp-vgmstream/DllMain.c | 69 +++++- 11 files changed, 512 insertions(+), 611 deletions(-) create mode 100644 src/formats.c create mode 100644 src/formats.h diff --git a/BUILD.md b/BUILD.md index 319f5a5c..41f8d4d3 100644 --- a/BUILD.md +++ b/BUILD.md @@ -93,9 +93,8 @@ For new simple formats, assuming existing layout/coding: - *src/meta/meta.h*: register parser's init - *src/vgmstream.h*: register new meta - *src/vgmstream.c*: add parser init to search list, add meta description -- *winamp/in_vgmstream.c* - *fb2k/in_vgmstream.cpp* - *xml-vgmstream/DllMain.c*: add new extension to the format list +- *src/formats.c*: add new extension to the format list + *fb2k/in_vgmstream.cpp*: add new extension to the file associations list - *src/Makefile* *src/meta/Makefile.unix.am* *src/libvgmstream.vcproj/vcxproj/filters*: to compile new (format-name).c parser diff --git a/fb2k/in_vgmstream.cpp b/fb2k/in_vgmstream.cpp index 523d6d4a..0154fb0a 100644 --- a/fb2k/in_vgmstream.cpp +++ b/fb2k/in_vgmstream.cpp @@ -19,8 +19,8 @@ #include extern "C" { +#include "../src/formats.h" #include "../src/vgmstream.h" -#include "../src/util.h" } #include "foo_vgmstream.h" #include "version.h" @@ -336,298 +336,19 @@ void input_vgmstream::retag(const file_info & p_info,abort_callback & p_abort) { bool input_vgmstream::g_is_our_content_type(const char * p_content_type) {return false;} bool input_vgmstream::g_is_our_path(const char * p_path,const char * p_extension) { - if(!stricmp_utf8(p_extension,"2dx9")) return 1; - if(!stricmp_utf8(p_extension,"2pfs")) return 1; + const char ** ext_list; + int ext_list_len; + int i; - if(!stricmp_utf8(p_extension,"aaap")) return 1; - if(!stricmp_utf8(p_extension,"aax")) return 1; - if(!stricmp_utf8(p_extension,"acm")) return 1; - if(!stricmp_utf8(p_extension,"adpcm")) return 1; - if(!stricmp_utf8(p_extension,"adm")) return 1; - if(!stricmp_utf8(p_extension,"adp")) return 1; - if(!stricmp_utf8(p_extension,"ads")) return 1; - if(!stricmp_utf8(p_extension,"adx")) return 1; - if(!stricmp_utf8(p_extension,"afc")) return 1; - if(!stricmp_utf8(p_extension,"agsc")) return 1; - if(!stricmp_utf8(p_extension,"ahx")) return 1; - if(!stricmp_utf8(p_extension,"aic")) return 1; - if(!stricmp_utf8(p_extension,"aix")) return 1; - if(!stricmp_utf8(p_extension,"akb")) return 1; - if(!stricmp_utf8(p_extension,"amts")) return 1; - if(!stricmp_utf8(p_extension,"as4")) return 1; - if(!stricmp_utf8(p_extension,"asd")) return 1; - if(!stricmp_utf8(p_extension,"asf")) return 1; - if(!stricmp_utf8(p_extension,"ast")) return 1; - if(!stricmp_utf8(p_extension,"asr")) return 1; - if(!stricmp_utf8(p_extension,"ass")) return 1; - if(!stricmp_utf8(p_extension,"at3")) return 1; - if(!stricmp_utf8(p_extension,"aud")) return 1; - if(!stricmp_utf8(p_extension,"aus")) return 1; + ext_list = vgmstream_get_formats(); + ext_list_len = vgmstream_get_formats_length(); - if(!stricmp_utf8(p_extension,"baka")) return 1; - if(!stricmp_utf8(p_extension,"baf")) return 1; - if(!stricmp_utf8(p_extension,"bar")) return 1; - if(!stricmp_utf8(p_extension,"bcstm")) return 1; - if(!stricmp_utf8(p_extension,"bcwav")) return 1; - if(!stricmp_utf8(p_extension,"bfstm")) return 1; - if(!stricmp_utf8(p_extension,"bfwav")) return 1; - if(!stricmp_utf8(p_extension,"bfwavnsmbu")) return 1; - if(!stricmp_utf8(p_extension,"bg00")) return 1; - if(!stricmp_utf8(p_extension,"bgw")) return 1; - if(!stricmp_utf8(p_extension,"bh2pcm")) return 1; - if(!stricmp_utf8(p_extension,"bmdx")) return 1; - if(!stricmp_utf8(p_extension,"bms")) return 1; - if(!stricmp_utf8(p_extension,"bnk")) return 1; - if(!stricmp_utf8(p_extension,"bns")) return 1; - if(!stricmp_utf8(p_extension,"bnsf")) return 1; - if(!stricmp_utf8(p_extension,"bo2")) return 1; - if(!stricmp_utf8(p_extension,"brstmspm")) return 1; - if(!stricmp_utf8(p_extension,"brstm")) return 1; - if(!stricmp_utf8(p_extension,"btsnd")) return 1; - if(!stricmp_utf8(p_extension,"bvg")) return 1; + for (i=0; i < ext_list_len; i++) { + if (!stricmp_utf8(p_extension, ext_list[i])) + return 1; + } - if(!stricmp_utf8(p_extension,"caf")) return 1; - if(!stricmp_utf8(p_extension,"capdsp")) return 1; - if(!stricmp_utf8(p_extension,"cbd2")) return 1; - if(!stricmp_utf8(p_extension,"ccc")) return 1; - if(!stricmp_utf8(p_extension,"cfn")) return 1; - if(!stricmp_utf8(p_extension,"ckd")) return 1; - if(!stricmp_utf8(p_extension,"cnk")) return 1; - if(!stricmp_utf8(p_extension,"cps")) return 1; - - if(!stricmp_utf8(p_extension,"dcs")) return 1; - if(!stricmp_utf8(p_extension,"de2")) return 1; - if(!stricmp_utf8(p_extension,"ddsp")) return 1; - if(!stricmp_utf8(p_extension,"dmsg")) return 1; - if(!stricmp_utf8(p_extension,"dsp")) return 1; - if(!stricmp_utf8(p_extension,"dspw")) return 1; - if(!stricmp_utf8(p_extension,"dtk")) return 1; - if(!stricmp_utf8(p_extension,"dvi")) return 1; - if(!stricmp_utf8(p_extension,"dxh")) return 1; - - if(!stricmp_utf8(p_extension,"eam")) return 1; - if(!stricmp_utf8(p_extension,"emff")) return 1; - if(!stricmp_utf8(p_extension,"enth")) return 1; - - if(!stricmp_utf8(p_extension,"fag")) return 1; - if(!stricmp_utf8(p_extension,"filp")) return 1; - if(!stricmp_utf8(p_extension,"fsb")) return 1; - if(!stricmp_utf8(p_extension,"fwav")) return 1; - - if(!stricmp_utf8(p_extension,"g1l")) return 1; - if(!stricmp_utf8(p_extension,"gbts")) return 1; - if(!stricmp_utf8(p_extension,"gca")) return 1; - if(!stricmp_utf8(p_extension,"gcm")) return 1; - if(!stricmp_utf8(p_extension,"gcub")) return 1; - if(!stricmp_utf8(p_extension,"gcw")) return 1; - if(!stricmp_utf8(p_extension,"genh")) return 1; - if(!stricmp_utf8(p_extension,"gms")) return 1; - if(!stricmp_utf8(p_extension,"gsb")) return 1; - - if(!stricmp_utf8(p_extension, "hca")) return 1; - if(!stricmp_utf8(p_extension,"hgc1")) return 1; - if(!stricmp_utf8(p_extension,"his")) return 1; - if(!stricmp_utf8(p_extension,"hlwav")) return 1; - if(!stricmp_utf8(p_extension,"hps")) return 1; - if(!stricmp_utf8(p_extension,"hsf")) return 1; - if(!stricmp_utf8(p_extension,"hwas")) return 1; - - if(!stricmp_utf8(p_extension,"iab")) return 1; - if(!stricmp_utf8(p_extension,"idsp")) return 1; - if(!stricmp_utf8(p_extension,"idvi")) return 1; - if(!stricmp_utf8(p_extension,"ikm")) return 1; - if(!stricmp_utf8(p_extension,"ild")) return 1; - if(!stricmp_utf8(p_extension,"int")) return 1; - if(!stricmp_utf8(p_extension,"isd")) return 1; - if(!stricmp_utf8(p_extension,"isws")) return 1; - if(!stricmp_utf8(p_extension,"ivaud")) return 1; - if(!stricmp_utf8(p_extension,"ivag")) return 1; - if(!stricmp_utf8(p_extension,"ivb")) return 1; - - if(!stricmp_utf8(p_extension,"joe")) return 1; - if(!stricmp_utf8(p_extension,"jstm")) return 1; - - if(!stricmp_utf8(p_extension,"kces")) return 1; - if(!stricmp_utf8(p_extension,"kcey")) return 1; - if(!stricmp_utf8(p_extension,"khv")) return 1; - if(!stricmp_utf8(p_extension,"kovs")) return 1; - if(!stricmp_utf8(p_extension,"kraw")) return 1; - - if(!stricmp_utf8(p_extension,"leg")) return 1; - if(!stricmp_utf8(p_extension,"logg")) return 1; - if(!stricmp_utf8(p_extension,"lpcm")) return 1; - if(!stricmp_utf8(p_extension,"lps")) return 1; - if(!stricmp_utf8(p_extension,"lsf")) return 1; - if(!stricmp_utf8(p_extension,"lwav")) return 1; - - if(!stricmp_utf8(p_extension,"matx")) return 1; - if(!stricmp_utf8(p_extension,"mca")) return 1; - if(!stricmp_utf8(p_extension,"mcg")) return 1; - if(!stricmp_utf8(p_extension,"mi4")) return 1; - if(!stricmp_utf8(p_extension,"mib")) return 1; - if(!stricmp_utf8(p_extension,"mic")) return 1; - if(!stricmp_utf8(p_extension,"mihb")) return 1; - if(!stricmp_utf8(p_extension,"mnstr")) return 1; - if(!stricmp_utf8(p_extension,"mpdsp")) return 1; - if(!stricmp_utf8(p_extension,"mpds")) return 1; - if(!stricmp_utf8(p_extension,"msa")) return 1; - if(!stricmp_utf8(p_extension,"msf")) return 1; - if(!stricmp_utf8(p_extension,"mss")) return 1; - if(!stricmp_utf8(p_extension,"msvp")) return 1; - if(!stricmp_utf8(p_extension,"mtaf")) return 1; - if(!stricmp_utf8(p_extension,"mus")) return 1; - if(!stricmp_utf8(p_extension,"musc")) return 1; - if(!stricmp_utf8(p_extension,"musx")) return 1; - if(!stricmp_utf8(p_extension,"mwv")) return 1; - if(!stricmp_utf8(p_extension,"mxst")) return 1; - if(!stricmp_utf8(p_extension,"myspd")) return 1; - - if(!stricmp_utf8(p_extension,"ndp")) return 1; - if(!stricmp_utf8(p_extension,"ngca")) return 1; - if(!stricmp_utf8(p_extension,"npsf")) return 1; - if(!stricmp_utf8(p_extension,"nus3bank")) return 1; - if(!stricmp_utf8(p_extension,"nwa")) return 1; - - if(!stricmp_utf8(p_extension,"omu")) return 1; - if(!stricmp_utf8(p_extension,"otm")) return 1; - - if(!stricmp_utf8(p_extension,"p2bt")) return 1; - if(!stricmp_utf8(p_extension,"p3d")) return 1; - if(!stricmp_utf8(p_extension,"past")) return 1; - if(!stricmp_utf8(p_extension,"pcm")) return 1; - if(!stricmp_utf8(p_extension,"pdt")) return 1; - if(!stricmp_utf8(p_extension,"pnb")) return 1; - if(!stricmp_utf8(p_extension,"pona")) return 1; - if(!stricmp_utf8(p_extension,"pos")) return 1; - if(!stricmp_utf8(p_extension,"ps2stm")) return 1; - if(!stricmp_utf8(p_extension,"psh")) return 1; - if(!stricmp_utf8(p_extension,"psnd")) return 1; - if(!stricmp_utf8(p_extension,"psw")) return 1; - - if(!stricmp_utf8(p_extension,"ras")) return 1; - if(!stricmp_utf8(p_extension,"raw")) return 1; - if(!stricmp_utf8(p_extension,"rkv")) return 1; - if(!stricmp_utf8(p_extension,"rnd")) return 1; - if(!stricmp_utf8(p_extension,"rrds")) return 1; - if(!stricmp_utf8(p_extension,"rsd")) return 1; - if(!stricmp_utf8(p_extension,"rsf")) return 1; - if(!stricmp_utf8(p_extension,"rstm")) return 1; - if(!stricmp_utf8(p_extension,"rvws")) return 1; - if(!stricmp_utf8(p_extension,"rwar")) return 1; - if(!stricmp_utf8(p_extension,"rwav")) return 1; - if(!stricmp_utf8(p_extension,"rws")) return 1; - if(!stricmp_utf8(p_extension,"rwsd")) return 1; - if(!stricmp_utf8(p_extension,"rwx")) return 1; - if(!stricmp_utf8(p_extension,"rxw")) return 1; - - if(!stricmp_utf8(p_extension,"s14")) return 1; - if(!stricmp_utf8(p_extension,"sab")) return 1; - if(!stricmp_utf8(p_extension,"sad")) return 1; - if(!stricmp_utf8(p_extension,"sap")) return 1; - if(!stricmp_utf8(p_extension,"sc")) return 1; - if(!stricmp_utf8(p_extension,"scd")) return 1; - if(!stricmp_utf8(p_extension,"sck")) return 1; - if(!stricmp_utf8(p_extension,"sd9")) return 1; - if(!stricmp_utf8(p_extension,"sdt")) return 1; - if(!stricmp_utf8(p_extension,"seg")) return 1; - if(!stricmp_utf8(p_extension,"sf0")) return 1; - if(!stricmp_utf8(p_extension,"sfl")) return 1; - if(!stricmp_utf8(p_extension,"sfs")) return 1; - if(!stricmp_utf8(p_extension,"sfx")) return 1; - if(!stricmp_utf8(p_extension,"sgb")) return 1; - if(!stricmp_utf8(p_extension,"sgd")) return 1; - if(!stricmp_utf8(p_extension,"sgx")) return 1; - if(!stricmp_utf8(p_extension,"sl3")) return 1; - if(!stricmp_utf8(p_extension,"sli")) return 1; - if(!stricmp_utf8(p_extension,"smp")) return 1; - if(!stricmp_utf8(p_extension,"smpl")) return 1; - if(!stricmp_utf8(p_extension,"snd")) return 1; - if(!stricmp_utf8(p_extension,"snds")) return 1; - if(!stricmp_utf8(p_extension,"sng")) return 1; - if(!stricmp_utf8(p_extension,"sns")) return 1; - if(!stricmp_utf8(p_extension,"spd")) return 1; - if(!stricmp_utf8(p_extension,"spm")) return 1; - if(!stricmp_utf8(p_extension,"sps")) return 1; - if(!stricmp_utf8(p_extension,"spsd")) return 1; - if(!stricmp_utf8(p_extension,"spw")) return 1; - if(!stricmp_utf8(p_extension,"ss2")) return 1; - if(!stricmp_utf8(p_extension,"ss3")) return 1; - if(!stricmp_utf8(p_extension,"ss7")) return 1; - if(!stricmp_utf8(p_extension,"ssm")) return 1; - if(!stricmp_utf8(p_extension,"sss")) return 1; - if(!stricmp_utf8(p_extension,"ster")) return 1; - if(!stricmp_utf8(p_extension,"stma")) return 1; - if(!stricmp_utf8(p_extension,"str")) return 1; - if(!stricmp_utf8(p_extension,"strm")) return 1; - if(!stricmp_utf8(p_extension,"sts")) return 1; - if(!stricmp_utf8(p_extension,"stx")) return 1; - if(!stricmp_utf8(p_extension,"svag")) return 1; - if(!stricmp_utf8(p_extension,"svs")) return 1; - if(!stricmp_utf8(p_extension,"swav")) return 1; - if(!stricmp_utf8(p_extension,"swd")) return 1; - - if(!stricmp_utf8(p_extension,"tec")) return 1; - if(!stricmp_utf8(p_extension,"thp")) return 1; - if(!stricmp_utf8(p_extension,"tk1")) return 1; - if(!stricmp_utf8(p_extension,"tk5")) return 1; - if(!stricmp_utf8(p_extension,"tra")) return 1; - if(!stricmp_utf8(p_extension,"tun")) return 1; - if(!stricmp_utf8(p_extension,"tydsp")) return 1; - - if(!stricmp_utf8(p_extension,"um3")) return 1; - - if(!stricmp_utf8(p_extension,"vag")) return 1; - if(!stricmp_utf8(p_extension,"vas")) return 1; - if(!stricmp_utf8(p_extension,"vawx")) return 1; - if(!stricmp_utf8(p_extension,"vb")) return 1; - if(!stricmp_utf8(p_extension,"vbk")) return 1; - if(!stricmp_utf8(p_extension,"vgs")) return 1; - if(!stricmp_utf8(p_extension,"vgv")) return 1; - if(!stricmp_utf8(p_extension,"vig")) return 1; - if(!stricmp_utf8(p_extension,"vms")) return 1; - if(!stricmp_utf8(p_extension,"voi")) return 1; - if(!stricmp_utf8(p_extension,"vpk")) return 1; - if(!stricmp_utf8(p_extension,"vs")) return 1; - if(!stricmp_utf8(p_extension,"vsf")) return 1; - - if(!stricmp_utf8(p_extension,"waa")) return 1; - if(!stricmp_utf8(p_extension,"wac")) return 1; - if(!stricmp_utf8(p_extension,"wad")) return 1; - if(!stricmp_utf8(p_extension,"wam")) return 1; - if(!stricmp_utf8(p_extension,"wavm")) return 1; - if(!stricmp_utf8(p_extension,"was")) return 1; - if(!stricmp_utf8(p_extension,"wii")) return 1; - if(!stricmp_utf8(p_extension,"wmus")) return 1; - if(!stricmp_utf8(p_extension,"wp2")) return 1; - if(!stricmp_utf8(p_extension,"wpd")) return 1; - if(!stricmp_utf8(p_extension,"wsd")) return 1; - if(!stricmp_utf8(p_extension,"wsi")) return 1; - if(!stricmp_utf8(p_extension,"wvs")) return 1; - - if(!stricmp_utf8(p_extension,"xa")) return 1; - if(!stricmp_utf8(p_extension,"xa2")) return 1; - if(!stricmp_utf8(p_extension,"xa30")) return 1; - if(!stricmp_utf8(p_extension,"xau")) return 1; - if(!stricmp_utf8(p_extension,"xma")) return 1; - if(!stricmp_utf8(p_extension,"xma2")) return 1; - if(!stricmp_utf8(p_extension,"xmu")) return 1; - if(!stricmp_utf8(p_extension,"xnb")) return 1; - if(!stricmp_utf8(p_extension,"xsf")) return 1; - if(!stricmp_utf8(p_extension,"xss")) return 1; - if(!stricmp_utf8(p_extension,"xvag")) return 1; - if(!stricmp_utf8(p_extension,"xvas")) return 1; - if(!stricmp_utf8(p_extension,"xwav")) return 1; - if(!stricmp_utf8(p_extension,"xwb")) return 1; - if(!stricmp_utf8(p_extension,"xwm")) return 1; - - if(!stricmp_utf8(p_extension,"ydsp")) return 1; - if(!stricmp_utf8(p_extension,"ymf")) return 1; - - if(!stricmp_utf8(p_extension,"zsd")) return 1; - if(!stricmp_utf8(p_extension,"zwdsp")) return 1; - - if(!stricmp_utf8(p_extension,"vgmstream")) return 1; - return 0; + return 0; } @@ -676,7 +397,10 @@ static input_singletrack_factory_t g_input_vgmstream_factory; DECLARE_COMPONENT_VERSION(APP_NAME,PLUGIN_VERSION,PLUGIN_DESCRIPTION); VALIDATE_COMPONENT_FILENAME("foo_input_vgmstream.dll"); -// File types go down here (and in the large chunk of IFs above +// Registered file types, to associate an extension with foobar2000 in Windows. +// Accepted types go in input_vgmstream::g_is_our_path; both lists don't need to match. +// todo do we really want to associate every single vgmstream format? +// // these are declared statically, and if anyone has a better idea i'd like to hear it - josh. DECLARE_MULTIPLE_FILE_TYPE("2DX9 Audio File (*.2DX9)", 2dx9); DECLARE_MULTIPLE_FILE_TYPE("2PFS Audio File (*.2PFS)", 2pfs); diff --git a/src/Makefile b/src/Makefile index 0168a93d..c30191a2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -311,7 +311,7 @@ META_OBJS=meta/adx_header.o \ EXT_LIBS = ../ext_libs/clHCA.o -OBJECTS=vgmstream.o streamfile.o util.o header.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS) $(EXT_LIBS) +OBJECTS=vgmstream.o streamfile.o util.o header.o formats.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS) $(EXT_LIBS) libvgmstream.a: $(OBJECTS) $(AR) crs libvgmstream.a $(OBJECTS) diff --git a/src/Makefile.unix.am b/src/Makefile.unix.am index bb1f9164..a2b3f58e 100644 --- a/src/Makefile.unix.am +++ b/src/Makefile.unix.am @@ -4,7 +4,7 @@ AM_CFLAGS = -Wall @CFLAGS@ -I$(top_builddir) -I$(top_srcdir) AM_MAKEFLAGS=-f Makefile.unix libvgmstream_la_LDFLAGS = coding/libcoding.la layout/liblayout.la meta/libmeta.la -libvgmstream_la_SOURCES = vgmstream.c util.c streamfile.c header.c ../ext_libs/clHCA.c +libvgmstream_la_SOURCES = vgmstream.c util.c streamfile.c header.c formats.c ../ext_libs/clHCA.c SUBDIRS = coding layout meta diff --git a/src/formats.c b/src/formats.c new file mode 100644 index 00000000..82ff657a --- /dev/null +++ b/src/formats.c @@ -0,0 +1,329 @@ +#include "formats.h" + +//#define VGM_REGISTER_TYPE(extension) ... +//#define VGM_REGISTER_TYPE_COMMON(extension) ... /* for common extensions like aiff */ + + +/* some extensions could be #ifdef but no really needed */ +/* some formats marked as "not parsed" mean they'll go through FFmpeg, the header/extension is not parsed */ + +static const char* extension_list[] = { + "2dx9", + "2pfs", + + "aaap", + "aax", + "acm", + "adm", + "adp", + "adpcm", + "ads", + "adx", + "afc", + "agsc", + "ahx", + "aifc", + "aifcl", + //"aiff", //common + "aix", + "akb", //AAC + "amts", + "as4", + "asd", + "asf", + "asr", + "ass", + "ast", + "at3", + "aud", + "aus", + + "b1s", + "baf", + "baka", + "bar", + "bcstm", + "bcwav", + "bdsp", + "bfstm", + "bfwav", + "bfwavnsmbu", + "bg00", + "bgw", + "bh2pcm", + "bmdx", + "bms", + "bnk", + "bns", + "bnsf", + "bo2", + "brstm", + "brstmspm", + "btsnd", + "bvg", + + "caf", + "capdsp", + "cbd2", + "ccc", + "cfn", + "ckd", + "cnk", + "cps", + + "dcs", + "ddsp", + "de2", + "dmsg", + "dsp", + "dspw", + "dtk", + "dvi", + "dxh", + + "eam", + "emff", + "enth", + + "fag", + "ffw", + "filp", + "fsb", + "fwav", + + "g1l", + "gbts", + "gca", + "gcm", + "gcub", + "gcw", + "genh", + "gms", + "gsb", + + "hca", + "hgc1", + "his", + "hlwav", + "hps", + "hsf", + "hwas", + + "iab", + "iadp", + "idsp", + "idvi", + "ikm", + "ild", + "int", + "isd", + "isws", + "ivaud", + "ivag", + "ivb", + + "joe", + "jstm", + + "kces", + "kcey", + "khv", + "kovs", + "kraw", + + "leg", + "logg", + "lpcm", + "lps", + "lsf", + "lwav", + + "matx", + "mca", + "mcg", + "mi4", + "mib", + "mic", + "mihb", + "mnstr", + "mpdsp", + "mpds", + "msa", + "msf", + "mss", + "msvp", + "mtaf", + "mus", + "musc", + "musx", + "mwv", + "mxst", + "myspd", + + "ndp", + "ngca", + "npsf", + "nus3bank", //todo not existing? + "nwa", + + "omu", + "otm", + + "p2bt", + "p3d", + "past", + "pcm", + "pdt", + "pnb", + "pona", + "pos", + "ps2stm", + "psh", + "psnd", + "psw", + + "ras", + "raw", + "rkv", + "rnd", + "rrds", + "rsd", + "rsf", + "rstm", + "rvws", + "rwar", + "rwav", + "rws", + "rwsd", + "rwx", + "rxw", + + "s14", + "sab", + "sad", + "sap", + "sc", + "scd", + "sck", + "sd9", + "sdt", + "seg", + "sf0", + "sfl", + "sfs", + "sfx", + "sgb", + "sgd", + "sgx", + "sl3", + "sli", + "smp", + "smpl", + "snd", + "snds", + "sng", + "sns", + "spd", + "spm", + "sps", + "spsd", + "spw", + "ss2", + "ss3", + "ss7", + "ssm", + "sss", + "ster", + "sth", + //"stm", //common + "stma", + "str", + "strm", + "sts", + "stx", + "svag", + "svs", + "swav", + "swd", + + "tec", + "thp", + "tk1", + "tk5", + "tra", + "tun", + "tydsp", + + "um3", + + "vag", + "vas", + "vawx", + "vb", + "vbk", + "vgs", + "vgv", + "vig", + + "vms", + "voi", + "vpk", + "vs", + "vsf", + + "waa", + "wac", + "wad", + "wam", + "was", + "wavm", + "wb", + "wii", + "wmus", + "wp2", + "wpd", + "wsd", + "wsi", + "wvs", + + "xa", + "xa2", + "xa30", + "xag", + "xau", + "xma", + "xma2", + "xmu", + "xnb", + "xsf", + "xss", + "xvag", + "xvas", + "xwav", + "xwb", + "xwm", //FFmpeg, not parsed (XWMA) + + "ydsp", + "ymf", + + "zsd", + "zwdsp", + + "vgmstream" +}; + +/** + * List of supported formats. + * + * For plugins that need to know (test.exe doesn't use it) + */ +const char ** vgmstream_get_formats() { + return extension_list; +} + +/** + * Number of elements in the list. + */ +int vgmstream_get_formats_length() { + return sizeof(extension_list) / sizeof(char*); +} diff --git a/src/formats.h b/src/formats.h new file mode 100644 index 00000000..447cfca8 --- /dev/null +++ b/src/formats.h @@ -0,0 +1,15 @@ +/* + * formats.h - utils to parse supported formats + */ +#ifndef _FORMATS_H_ +#define _FORMATS_H_ + + +/* rough number of chars counting all extensions (actually <1500 and extra space) */ +#define VGM_EXTENSION_LIST_CHAR_SIZE 2000 + +const char ** vgmstream_get_formats(); +int vgmstream_get_formats_length(); + + +#endif /* _FORMATS_H_ */ diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index 85463f6a..563fe21d 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -147,6 +147,10 @@ Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > + + @@ -173,6 +177,10 @@ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + diff --git a/src/libvgmstream.vcxproj b/src/libvgmstream.vcxproj index 3216a50a..d75303fa 100644 --- a/src/libvgmstream.vcxproj +++ b/src/libvgmstream.vcxproj @@ -82,6 +82,7 @@ + @@ -139,6 +140,7 @@ + diff --git a/src/libvgmstream.vcxproj.filters b/src/libvgmstream.vcxproj.filters index 5ff7d1cd..ed9bbb58 100644 --- a/src/libvgmstream.vcxproj.filters +++ b/src/libvgmstream.vcxproj.filters @@ -47,6 +47,9 @@ + + Header Files + Header Files @@ -85,6 +88,9 @@ + + Source Files + Source Files diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index 5e16b312..9870d7db 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -13,9 +13,11 @@ #include #include #include +#include +#include +#include "../src/formats.h" #include "../src/vgmstream.h" -#include "../src/util.h" #include "in2.h" #include "wa_ipc.h" #include "resource.h" @@ -71,308 +73,14 @@ int decode_pos_samples = 0; int stream_length_samples = 0; int fade_samples = 0; -#define EXTENSION_LIST_SIZE 10240 +/* Winamp Play extension list, needed to accept/play and associate extensions in Windows */ +#define EXTENSION_LIST_SIZE VGM_EXTENSION_LIST_CHAR_SIZE * 6 char working_extension_list[EXTENSION_LIST_SIZE] = {0}; -char * extension_list[] = { +#define EXT_BUFFER_SIZE 200 - "2dx9\0""2DX9 Audio File (*.2DX9)\0", - "2pfs\0""2PFS Audio File (*.2PFS)\0", +static void add_extension(int length, char * dst, const char * src); +static void build_extension_list(); - "aax\0AAX Audio File (*.AAX)\0", - "aaap\0AAAP Audio File (*.AAAP)\0", - "aax\0AAX Audio File (*.AAX)\0", - "acm\0ACM Audio File (*.ACM)\0", - "adm\0ADM Audio File (*.ADM)\0", - "adpcm\0ADPCM Audio File (*.ADPCM)\0", - "adp\0ADP Audio File (*.ADP)\0", - "ads\0PS2 ADS Audio File (*.ADS)\0", - "adx\0ADX Audio File (*.ADX)\0", - "afc\0AFC Audio File (*.AFC)\0", - "agsc\0AGSC Audio File (*.AGSC)\0", - "ahx\0AHX Audio File (*.AHX)\0", - "aifc\0AIFC Audio File (*.AIFC)\0", - "aix\0AIX Audio File (*.AIX)\0", - "amts\0AMTS Audio File (*.AMTS)\0", - "as4\0AS4 Audio File (*.AS4)\0", - "asd\0ASD Audio File (*.ASD)\0", - "asf\0ASF Audio File (*.ASF)\0", - "ast\0AST Audio File (*.AST)\0", - "asr\0ASR Audio File (*.ASR)\0", - "ass\0ASS Audio File (*.ASS)\0", - "at3\0AT3 Audio File (*.AT3)\0", - "aud\0AUD Audio File (*.AUD)\0", - "aus\0AUS Audio File (*.AUS)\0", - - "b1s\0B1S Audio File (*.B1S)\0", - "baka\0BAKA Audio File (*.BAKA)\0", - "baf\0BAF Audio File (*.BAF)\0", - "bar\0BAR Audio File (*.BAR)\0", - "bcstm\0BCSTM Audio File (*.BCSTM)\0", - "bcwav\0BCWAV (*.BCWAV)\0", - "bdsp\0BDSP Audio File (*.BDSP)\0", - "bfstm\0BFSTM Audio File (*.BFSTM)\0", - "bfwav;bfwavnsmbu;fwav\0BFWAV Audio File (*.BFWAV)\0", - "bg00\0BG00 Audio File (*.BG00)\0", - "bgw\0BGW Audio File (*.BGW)\0", - "bh2pcm\0BH2PCM Audio File (*.BH2PCM)\0", - "bmdx\0BMDX Audio File (*.BMDX)\0", - "bms\0BMS (*.BMS)\0", - "bnk\0BNK Audio File (*.BNK)\0", - "bns\0BNS Audio File (*.BNS)\0", - "bnsf\0BNSF Audio File (*.BNSF)\0", - "bo2\0BO2 Audio File (*.BO2)\0", - "brstm;brstmspm\0BRSTM Audio File (*.BRSTM)\0", - "btsnd\0BTSND Audio File (*.BTSND)\0", - "bvg\0BVG Audio File (*.BVG)\0", - - "caf\0CAF Audio File (*.CAF)\0", - "capdsp\0CAPDSP Audio File (*.CAPDSP)\0", /* Capcom custom coefs */ - "cbd2\0CBD2 Audio File (*.CBD2)\0", - "ccc\0CCC Audio File (*.CCC)\0", - "cfn\0CFN Audio File (*.CFN)\0", - "ckd\0CKD Audio File (*.CKD)\0", - "cnk\0CNK Audio File (*.CNK)\0", - "cps\0CPS Audio File (*.CPS)\0", - - "dcs\0DCS Audio File (*.DCS)\0", - "de2\0DE2 Audio File (*.DE2)\0", - "ddsp\0DDSP Audio File (*.DDSP)\0", - "dmsg\0DMSG Audio File (*.DMSG)\0", - "dsp\0DSP Audio File (*.DSP)\0", - "dspw\0DSPW Audio File (*.DSPW)\0", - "dtk\0DTK Audio File (*.DTK)\0", - "dvi\0DVI Audio File (*.DVI)\0", - "dxh\0DXH Audio File (*.DXH)\0", - - "eam\0EAM Audio File (*.EAM)\0", - "emff\0EMFF Audio File (*.EMFF)\0", - "enth\0ENTH Audio File (*.ENTH)\0", - - "fag\0FAG Audio File (*.FAG)\0", - "ffw\0FFW Audio File (*.FFW)\0", - "filp\0FILP Audio File (*.FILP)\0", - "fsb\0FSB Audio File (*.FSB)\0", - - "g1l\0G1L Audio File (*.G1L)\0", - "gbts\0GBTS Audio File (*.GBTS)\0", - "gca\0GCA Audio File (*.GCA)\0", - "gcm\0GCM Audio File (*.GCM)\0", - "gcub\0GCUB Audio File (*.GCUB)\0", - "gcw\0GCW Audio File (*.GCW)\0", - "genh\0GENH Audio File (*.GENH)\0", - "gms\0GMS Audio File (*.GMS)\0", - "gsb\0GSB Audio File (*.GSB)\0", - - "hca\0HCA Audio File (*.HCA)\0", - - "hgc1\0HGC1 Audio File (*.HGC1)\0", - "his\0HIS Audio File (*.HIS)\0", - "hlwav\0HLWAV Audio File (*.HLWAV)\0", - "hps\0HALPST Audio File (*.HPS)\0", - "hsf\0HSF Audio File (*.HSF)\0", - "hwas\0HWAS Audio File (*.HWAS)\0", - - "iab\0IAB Audio File (*.IAB)\0", - "iadp\0IADP Audio File (*.IADP)\0", - "idsp\0IDSP Audio File (*.IDSP)\0", - "idvi\0IDVI Audio File (*.IDVI)\0", - "ikm\0IKM Audio File (*.IKM)\0", - "ild\0ILD Audio File (*.ILD)\0", - "int\0PS2 RAW Interleaved PCM (*.INT)\0", - "isd\0ISD Audio File (*.ISD)\0", - "isws\0ISWS Audio File (*.ISWS)\0", - "ivaud\0IVAUD Audio File (*.IVAUD)\0", - "ivag\0IVAG Audio File (*.IVAG)\0", - "ivb\0IVB Audio File (*.IVB)\0", - - "joe\0JOE Audio File (*.JOE)\0", - "jstm\0JSTM Audio File (*.JSTM)\0", - - "kces\0KCES Audio File (*.KCES)\0", - "kcey\0KCEY Audio File (*.KCEY)\0", - "khv\0KHV Audio File (*.KHV)\0", - "kovs\0KOVS Audio File (*.KOVS)\0", - "kraw\0KRAW Audio File (*.KRAW)\0", - - "leg\0LEG Audio File (*.LEG)\0", - "logg\0LOGG Audio File (*.LOGG)\0", - "lpcm\0LPCM Audio File (*.LPCM)\0", - "lps\0LPS Audio File (*.LPS)\0", - "lsf\0LSF Audio File (*.LSF)\0", - "lwav\0LWAV Audio File (*.LWAV)\0", - - "matx\0MATX Audio File (*.MATX)\0", - "mca\0MCA Audio File (*.MCA)\0", - "mcg\0MCG Audio File (*.MCG)\0", - "mi2\0PS2 MI2 Audio File (*.MI2)\0", - "mi4\0PS2 MI4 Audio File (*.MI4)\0", - "mib\0PS2 MIB Audio File (*.MIB)\0", - "mic\0PS2 MIC Audio File (*.MIC)\0", - "mihb\0MIHB Audio File (*.MIHB)\0", - "mnstr\0MNSTR Audio File (*.MNSTR)\0", - "mpdsp\0MPDSP Audio File (*.MPDSP)\0", - "mpds\0MPDS Audio File (*.MPDS)\0", - "msa\0MSA Audio File (*.MSA)\0", - "msf\0MSF Audio File (*.MSF)\0", - "mss\0MSS Audio File (*.MSS)\0", - "msvp\0MSVP Audio File (*.MSVP)\0", - "mtaf\0MTAF Audio File (*.MTAF)\0", - "mus\0MUS Playlist File (*.MUS)\0", - "musc\0MUSC Audio File (*.MUSC)\0", - "musx\0MUSX Audio File (*.MUSX)\0", - "mwv\0MWV Audio File (*.MWV)\0", - "mxst\0MxSt Audio File (*.MxSt)\0", - "myspd\0MYSPD Audio File (*.MYSPD)\0", - - "ndp\0NDP Audio File (*.NDP)\0", - "ngca\0NGCA Audio File (*.NGCA)\0", - "npsf\0PS2 NPSF Audio File (*.NPSF)\0", - "nus3bank\0NUS3BANK Audio File (*.NUS3BANK)\0", - "nwa\0NWA Audio File (*.NWA)\0", - - "omu\0OMU Audio File (*.OMU)\0", - "otm\0OTM Audio File (*.OTM)\0", - - "p2bt\0P2BT Audio File (*.P2BT)\0", - "p3d\0P3D Audio File (*.P3D)\0", - "past\0PAST Audio File (*.PAST)\0", - "pcm\0PCM Audio File (*.PCM)\0", - "pdt\0PDT Audio File (*.PDT)\0", - "pnb\0PNB Audio File (*.PNB)\0", - "pona\0PONA Audio File (*.PONA)\0", - "pos\0POS Audio File (*.POS)\0", - "ps2stm\0PS2STM Audio File (*.PS2STM)\0", - "psh\0PSH Audio File (*.PSH)\0", - "psnd\0PSND Audio File (*.PSND)\0", - "psw\0PSW Audio File (*.PSW)\0", - - "ras\0RAS Audio File (*.RAS)\0", - "raw\0RAW Audio File (*.RAW)\0", - "rkv\0RKV Audio File (*.RKV)\0", - "rnd\0RND Audio File (*.RND)\0", - "rrds\0RRDS Audio File (*.RRDS)\0", - "rsd\0RSD Audio File (*.RSD)\0", - "rsf\0RSF Audio File (*.RSF)\0", - "rstm\0RSTM Audio File (*.RSTM)\0", - "rvws\0RVWS Audio File (*.RVWS)\0", - "rwar\0RWAR Audio File (*.RWSD)\0", - "rwav\0RWAV Audio File (*.RWAV)\0", - "rws\0RWS Audio File (*.RWS)\0", - "rwsd\0RWSD Audio File (*.RWSD)\0", - "rwx\0RWX Audio File (*.RWX)\0", - "rxw\0PS2 RXWS File (*.RXW)\0", - - "s14\0S14 Audio File (*.S14)\0", - "sab\0SAB Audio File (*.SAB)\0", - "sad\0SAD Audio File (*.SAD)\0", - "sap\0SAP Audio File (*.SAP)\0", - "sc\0SC Audio File (*.SC)\0", - "scd\0SCD Audio File (*.SCD)\0", - "sck\0SCK Audio File (*.SCK)\0", - "sd9\0SD9 Audio File (*.SD9)\0", - "sdt\0SDT Audio File (*.SDT)\0", - "seg\0SEG Audio File (*.SEG)\0", - "sf0\0SF0 Audio File (*.SF0)\0", - "sfl\0SFL Audio File (*.SFL)\0", - "sfs\0SFS Audio File (*.SFS)\0", - "sfx\0SFX Audio File (*.SFX)\0", - "sgb\0SGB Audio File (*.SGB)\0", - "sgd\0SGD Audio File (*.SGD)\0", - "sgx\0SGX Audio File (*.SGX)\0", - "sl3\0SL3 Audio File (*.SL3)\0", - "sli\0SLI Audio File (*.SLI)\0", - "smp\0SMP Audio File (*.SMP)\0", - "smpl\0SMPL Audio File (*.SMPL)\0", - "snd\0SND Audio File (*.SND)\0", - "snds\0SNDS Audio File (*.SNDS)\0", - "sng\0SNG Audio File (*.SNG)\0", - "sns\0SNS Audio File (*.SNS)\0", - "spd\0SPD Audio File (*.SPD)\0", - "spm\0SPM Audio File (*.SPM)\0", - "sps\0SPS Audio File (*.SPS)\0", - "spsd\0SPSD Audio File (*.SPSD)\0", - "spw\0SPW Audio File (*.SPW)\0", - "ss2\0PS2 SS2 Audio File (*.SS2)\0", - "ss3\0SS3 Audio File (*.SS3)\0", - "ss7\0SS7 Audio File (*.SS7)\0", - "ssm\0SSM Audio File (*.SSM)\0", - "sss\0SSS Audio File (*.SSS)\0", - "ster\0STER Audio File (*.STER)\0", - "sth\0STH Audio File (*.STH)\0", - "stma\0STMA Audio File (*.STMA)\0", - "str\0STR Audio File (*.STR)\0", - "strm\0STRM Audio File (*.STRM)\0", - "sts\0PS2 EXST Audio File (*.STS)\0", - "stx\0STX Audio File (*.STX)\0", - "svag\0PS2 SVAG Audio File (*.SVAG)\0", - "svs\0SVS Audio File (*.SVS)\0", - "swav\0SWAV Audio File (*.SWAV)\0", - "swd\0SWD Audio File (*.SWD)\0", - - "tec\0TEC Audio File (*.TEC)\0", - "thp\0THP Audio File (*.THP)\0", - "tk1\0TK1 Audio File (*.TK1)\0", - "tk5\0TK5 Audio File (*.TK5)\0", - "tra\0TRA Audio File (*.TRA)\0", - "tun\0TUN Audio File (*.TUN)\0", - "tydsp\0TYDSP Audio File (*.TYDSP)\0", - - "um3\0UM3 Audio File (*.UM3)\0", - - "vag\0VAG Audio File (*.VAG)\0", - "vas\0VAS Audio File (*.VAS)\0", - "vawx\0VAWX Audio File (*.VAWX)\0", - "vb\0VB Audio File (*.VB)\0", - "vbk\0VBK Audio File (*.VBK)\0", - "vgs\0VGS Audio File (*.VGS)\0", - "vig\0VIG Audio File (*.VIG)\0", - "vms\0VMS Audio File (*.VMS)\0", - "vpk\0VPK Audio File (*.VPK)\0", - "vs\0VS Audio File (*.VS)\0", - "vsf\0VSF Audio File (*.VSF)\0", - "vgv\0VGV Audio File (*.VGV)\0", - "voi\0VOI Audio File (*.VOI)\0", - - "waa\0WAA Audio File (*.WAA)\0", - "wac\0WAC Audio File (*.WAC)\0", - "wad\0WAD Audio File (*.WAD)\0", - "wam\0WAM Audio File (*.WAM)\0", - "wavm\0WAVM Audio File (*.WAVM)\0", - "was\0WAS Audio File (*.WAS)\0", - "wb\0WB Audio File (*.WB)\0", - "wii\0WII Audio File (*.WII)\0", - "wmus\0WMUS Audio File (*.WMUS)\0", - "wp2\0WP2 Audio File (*.WP2)\0", - "wpd\0WPD Audio File (*.WPD)\0", - "wsd\0WSD Audio File (*.WSD)\0", - "wsi\0WSI Audio File (*.WSI)\0", - "wvs\0WVS Audio File (*.WVS)\0", - - "xa\0PSX CD-XA File (*.XA)\0", - "xa2\0XA2 Audio File (*.XA2)\0", - "xa30\0XA30 Audio File (*.XA30)\0", - "xau\0XAU Audio File (*.XAU)\0", - "xma\0XMA Audio File (*.XMA)\0", - "xma2\0XMA2 Audio File (*.XMA2)\0", - "xmu\0XMU Audio File (*.XMU)\0", - "xnb\0XNB Audio File (*.XNB)\0", - "xsf\0XSF Audio File (*.XSF)\0", - "xss\0XSS Audio File (*.XSS)\0", - "xvag\0XVAG Audio File (*.XVAG)\0", - "xvas\0XVAS Audio File (*.XVAS)\0", - "xwav\0XWAV Audio File (*.XWAV)\0", - "xwb\0XWB Audio File (*.XWB)\0", - "xwm\0XWM Audio File (*.XWM)\0", - "xag\0XAG Audio File (*.XAG)\0", - - "ydsp\0YDSP Audio File (*.YDSP)\0", - "ymf\0YMF Audio File (*.YMF)\0", - - "zsd\0ZSD Audio File (*.ZSD)\0", - "zwdsp\0ZWDSP Audio File (*.ZWDSP)\0", - - "vgmstream\0vgmstream Audio File (*.VGMSTREAM)\0", -}; void about(HWND hwndParent) { MessageBox(hwndParent, @@ -383,17 +91,6 @@ void about(HWND hwndParent) { } void quit() {} -void build_extension_list() { - int i; - working_extension_list[0]='\0'; - working_extension_list[1]='\0'; - - for (i=0;i length-2 || ext_len * 3 + 20+2 > EXT_BUFFER_SIZE) { + dst[i]='\0'; + dst[i+1]='\0'; + return; + } + + if (i > 0) + i++; + + /* uppercase ext */ + for (j=0; j < ext_len; j++) + ext_upp[j] = toupper(ext[j]); + ext_upp[j] = '\0'; + + /* copy new extension + double null terminate */ + written = sprintf(buf, "%s%c%s Audio File (*.%s)%c", ext,'\0',ext_upp,ext_upp,'\0'); /*ex: "vgmstream\0vgmstream Audio File (*.VGMSTREAM)\0" */ + for (j=0; j < written; i++,j++) + dst[i] = buf[j]; + dst[i]='\0'; + dst[i+1]='\0'; +} diff --git a/xmp-vgmstream/DllMain.c b/xmp-vgmstream/DllMain.c index cdee23a5..3a62b6c9 100644 --- a/xmp-vgmstream/DllMain.c +++ b/xmp-vgmstream/DllMain.c @@ -10,9 +10,11 @@ #include #include #include +#include +#include -#include ".\src\vgmstream.h" -#include ".\src\util.h" +#include "../src/formats.h" +#include "../src/vgmstream.h" #include "xmpin.h" #include "version.h" @@ -329,10 +331,20 @@ void __stdcall GetAdditionalFields(char* blerp) { sprintf(blerp,"oh god how did this get here I am not good with computers\n"); } + +/* XMPlay extension list, only needed to associate extensions in Windows */ +/* todo: as of v3.8.2.17, any more than 1024 will crash XMplay's file list screen (but not using the non-native Winamp plugin...) */ +#define EXTENSION_LIST_SIZE 1024 /*VGM_EXTENSION_LIST_CHAR_SIZE * 2*/ +char working_extension_list[EXTENSION_LIST_SIZE] = {0}; + +static int add_extension(int length, char * dst, const char * src); +static void build_extension_list(); + + XMPIN vgmstream_intf = { XMPIN_FLAG_CANSTREAM, "vgmstream for XMPlay", - "vgmstream files\0""2dx9/aaap/aax/acm/adp/adpcm/ads/adx/afc/agsc/ahx/aifc/aiff/aix/amts/as4/asd/asf/asr/ass/ast/aud/aus/baf/baka/bar/bcstm/bcwav/bfstm/bfwav/bfwavnsmbu/bg00/bgw/bh2pcm/bmdx/bns/bnsf/bo2/brstm/caf/capdsp/ccc/cfn/cnk/dcs/dcsw/ddsp/de2/dmsg/dsp/dvi/dxh/eam/emff/enth/fag/filp/fsb/fwav/gca/gcm/gcsw/gcw/genh/gms/gsp/hca/hgc1/his/hps/hwas/idsp/idvi/ikm/ild/int/isd/ish/ivaud/ivb/joe/kces/kcey/khv/kraw/leg/logg/lps/lsf/lwav/matx/mcg/mi4/mib/mic/mihb/mpdsp/mca/msa/mss/msvp/mus/musc/musx/mwv/myspd/ndp/npsf/nus3bank/nwa/omu/otm/p3d/pcm/pdt/pnb/pos/psh/psw/raw/rkv/rnd/rrds/rsd/rsf/rstm/rwar/rwav/rws/rwsd/rwx/rxw/s14/sab/sad/sap/sc/scd/sd9/sdt/seg/sfl/sfs/sl3/sli/smp/smpl/snd/sng/sns/spd/sps/spsd/spt/spw/ss2/ss7/ssm/sss/ster/sth/stm/stma/str/strm/sts/stx/svag/svs/swav/swd/tec/thp/tk5/tydsp/um3/vag/vas/vgs/vig/vjdsp/voi/vpk/vs/vsf/waa/wac/wad/wam/was/wavm/wb/wii/wp2/wsd/wsi/wvs/xa/xa2/xa30/xma/xma2/xmu/xss/xvas/xwav/xwb/xwm/ydsp/ymf/zsd/zwdsp/vgmstream", + working_extension_list, XMPAbout, NULL, XMP_CheckFile, @@ -386,5 +398,54 @@ __declspec(dllexport) XMPIN* __stdcall XMPIN_GetInterface(UINT32 face, Interface xmpfmisc = (XMPFUNC_MISC*)faceproc(XMPFUNC_MISC_FACE); xmpffile = (XMPFUNC_FILE*)faceproc(XMPFUNC_FILE_FACE); - return &vgmstream_intf; + build_extension_list(); + + return &vgmstream_intf; +} + + +/** + * Creates XMPlay's extension list, a single string with 2 nulls. + * Extensions must be in this format: "Description\0extension1/.../extensionN" + */ +static void build_extension_list() { + const char ** ext_list; + int ext_list_len; + int i, written; + + written = sprintf(working_extension_list, "%s%c", "vgmstream files",'\0'); + + ext_list = vgmstream_get_formats(); + ext_list_len = vgmstream_get_formats_length(); + + for (i=0; i < ext_list_len; i++) { + written += add_extension(EXTENSION_LIST_SIZE-written, working_extension_list + written, ext_list[i]); + } + working_extension_list[written-1] = '\0'; /* remove last "/" */ +} + +/** + * Adds ext to XMPlay's extension list. + */ +static int add_extension(int length, char * dst, const char * ext) { + int ext_len; + int i; + + if (length <= 1) + return 0; + + ext_len = strlen(ext); + + /* check if end reached or not enough room to add */ + if (ext_len+2 > length-2) { + dst[0]='\0'; + return 0; + } + + /* copy new extension + null terminate */ + for (i=0; i < ext_len; i++) + dst[i] = ext[i]; + dst[i]='/'; + dst[i+1]='\0'; + return i+1; }