diff --git a/src/coding/coding.h b/src/coding/coding.h index 79b3b816..aa9d0827 100644 --- a/src/coding/coding.h +++ b/src/coding/coding.h @@ -354,6 +354,6 @@ int w_bits(vgm_bitstream * ob, int num_bits, uint32_t value); /* helper to pass a wrapped, clamped, fake extension-ed, SF to another meta */ -STREAMFILE* setup_subfile_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, char* extension); +STREAMFILE* setup_subfile_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* extension); #endif /*_CODING_H*/ diff --git a/src/coding/coding_utils.c b/src/coding/coding_utils.c index b63e65d6..158c5e4e 100644 --- a/src/coding/coding_utils.c +++ b/src/coding/coding_utils.c @@ -1085,7 +1085,7 @@ int w_bits(vgm_bitstream * ob, int num_bits, uint32_t value) { /* CUSTOM STREAMFILES */ /* ******************************************** */ -STREAMFILE* setup_subfile_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, char* extension) { +STREAMFILE* setup_subfile_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* extension) { STREAMFILE *temp_streamFile = NULL, *new_streamFile = NULL; new_streamFile = open_wrap_streamfile(streamFile); diff --git a/src/meta/aax.c b/src/meta/aax.c index 1ad4dbaa..3418620e 100644 --- a/src/meta/aax.c +++ b/src/meta/aax.c @@ -3,8 +3,6 @@ #include "../coding/coding.h" #include "aax_utf.h" -static STREAMFILE* setup_aax_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* fake_ext); - #define MAX_SEGMENTS 2 /* usually segment0=intro, segment1=loop/main */ @@ -77,7 +75,7 @@ VGMSTREAM * init_vgmstream_aax(STREAMFILE *streamFile) { /* open each segment subfile */ for (i = 0; i < segment_count; i++) { - STREAMFILE* temp_streamFile = setup_aax_streamfile(streamFile, segment_offset[i],segment_size[i], (is_hca ? "hca" : "adx")); + STREAMFILE* temp_streamFile = setup_subfile_streamfile(streamFile, segment_offset[i],segment_size[i], (is_hca ? "hca" : "adx")); if (!temp_streamFile) goto fail; data->segments[i] = is_hca ? @@ -138,29 +136,6 @@ fail: return NULL; } -static STREAMFILE* setup_aax_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* fake_ext) { - STREAMFILE *temp_streamFile = NULL, *new_streamFile = NULL; - - /* setup subfile */ - new_streamFile = open_wrap_streamfile(streamFile); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - new_streamFile = open_clamp_streamfile(temp_streamFile, subfile_offset,subfile_size); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - new_streamFile = open_fakename_streamfile(temp_streamFile, NULL,fake_ext); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - return temp_streamFile; - -fail: - close_streamfile(temp_streamFile); - return NULL; -} - /* CRI's UTF wrapper around DSP [Sonic Colors sfx (Wii), NiGHTS: Journey of Dreams sfx (Wii)] */ VGMSTREAM * init_vgmstream_utf_dsp(STREAMFILE *streamFile) { diff --git a/src/meta/atsl.c b/src/meta/atsl.c index 7ec19024..b469c2da 100644 --- a/src/meta/atsl.c +++ b/src/meta/atsl.c @@ -1,7 +1,6 @@ #include "meta.h" #include "../coding/coding.h" -static STREAMFILE* setup_atsl_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* fake_ext); typedef enum { ATRAC3, ATRAC9, KOVS, KTSS } atsl_codec; /* .ATSL - Koei Tecmo audio container [One Piece Pirate Warriors (PS3), Warriors All-Stars (PC)] */ @@ -110,7 +109,7 @@ VGMSTREAM * init_vgmstream_atsl(STREAMFILE *streamFile) { /* some kind of seek/switch table may follow (optional, found in .atsl3) */ - temp_streamFile = setup_atsl_streamfile(streamFile, subfile_offset,subfile_size, fake_ext); + temp_streamFile = setup_subfile_streamfile(streamFile, subfile_offset,subfile_size, fake_ext); if (!temp_streamFile) goto fail; /* init the VGMSTREAM */ @@ -144,27 +143,3 @@ fail: close_vgmstream(vgmstream); return NULL; } - - -static STREAMFILE* setup_atsl_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* fake_ext) { - STREAMFILE *temp_streamFile = NULL, *new_streamFile = NULL; - - /* setup subfile */ - new_streamFile = open_wrap_streamfile(streamFile); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - new_streamFile = open_clamp_streamfile(temp_streamFile, subfile_offset,subfile_size); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - new_streamFile = open_fakename_streamfile(temp_streamFile, NULL,fake_ext); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - return temp_streamFile; - -fail: - close_streamfile(temp_streamFile); - return NULL; -} diff --git a/src/meta/nus3bank.c b/src/meta/nus3bank.c index f47919ae..48b749d7 100644 --- a/src/meta/nus3bank.c +++ b/src/meta/nus3bank.c @@ -1,7 +1,6 @@ #include "meta.h" #include "../coding/coding.h" -static STREAMFILE* setup_nus3bank_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* fake_ext); typedef enum { /*XMA_RAW, ATRAC3,*/ IDSP, ATRAC9, OPUS, BNSF, /*PCM, XMA_RIFF*/ } nus3bank_codec; /* .nus3bank - Namco's newest audio container [Super Smash Bros (Wii U), idolmaster (PS4))] */ @@ -144,7 +143,7 @@ VGMSTREAM * init_vgmstream_nus3bank(STREAMFILE *streamFile) { //;VGM_LOG("NUS3BANK: subfile=%lx, size=%x\n", subfile_offset, subfile_size); - temp_streamFile = setup_nus3bank_streamfile(streamFile, subfile_offset,subfile_size, fake_ext); + temp_streamFile = setup_subfile_streamfile(streamFile, subfile_offset,subfile_size, fake_ext); if (!temp_streamFile) goto fail; /* init the VGMSTREAM */ @@ -182,27 +181,3 @@ fail: close_vgmstream(vgmstream); return NULL; } - - -static STREAMFILE* setup_nus3bank_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* fake_ext) { - STREAMFILE *temp_streamFile = NULL, *new_streamFile = NULL; - - /* setup subfile */ - new_streamFile = open_wrap_streamfile(streamFile); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - new_streamFile = open_clamp_streamfile(temp_streamFile, subfile_offset,subfile_size); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - new_streamFile = open_fakename_streamfile(temp_streamFile, NULL,fake_ext); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - return temp_streamFile; - -fail: - close_streamfile(temp_streamFile); - return NULL; -} diff --git a/src/meta/opus_ppp.c b/src/meta/opus_ppp.c index 2adc0c4e..0ff9a26a 100644 --- a/src/meta/opus_ppp.c +++ b/src/meta/opus_ppp.c @@ -2,8 +2,6 @@ #include "../coding/coding.h" #include "../layout/layout.h" -static STREAMFILE* setup_opus_ppp_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* fake_ext); - /* Nippon Ichi SPS wrapper (segmented) [Penny-Punching Princess (Switch)] */ VGMSTREAM * init_vgmstream_opus_sps_n1_segmented(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; @@ -43,7 +41,7 @@ VGMSTREAM * init_vgmstream_opus_sps_n1_segmented(STREAMFILE *streamFile) { if (!segment_size) goto fail; - temp_streamFile = setup_opus_ppp_streamfile(streamFile, segment_offset,segment_size, "opus"); + temp_streamFile = setup_subfile_streamfile(streamFile, segment_offset,segment_size, "opus"); if (!temp_streamFile) goto fail; data->segments[i] = init_vgmstream_opus_std(temp_streamFile); @@ -93,26 +91,3 @@ fail: free_layout_segmented(data); return NULL; } - -static STREAMFILE* setup_opus_ppp_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* fake_ext) { - STREAMFILE *temp_streamFile = NULL, *new_streamFile = NULL; - - /* setup subfile */ - new_streamFile = open_wrap_streamfile(streamFile); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - new_streamFile = open_clamp_streamfile(temp_streamFile, subfile_offset,subfile_size); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - new_streamFile = open_fakename_streamfile(temp_streamFile, NULL,fake_ext); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - return temp_streamFile; - -fail: - close_streamfile(temp_streamFile); - return NULL; -} diff --git a/src/meta/ps2_ads.c b/src/meta/ps2_ads.c index 4b280dd5..b72fb885 100644 --- a/src/meta/ps2_ads.c +++ b/src/meta/ps2_ads.c @@ -313,8 +313,6 @@ fail: /* ****************************************************************************** */ -static STREAMFILE* setup_subfile_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* fake_ext); - /* ADS in containers */ VGMSTREAM * init_vgmstream_ps2_ads_container(STREAMFILE *streamFile) { VGMSTREAM *vgmstream = NULL; @@ -356,28 +354,3 @@ fail: close_vgmstream(vgmstream); return NULL; } - -static STREAMFILE* setup_subfile_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* fake_ext) { - STREAMFILE *temp_streamFile = NULL, *new_streamFile = NULL; - - /* setup subfile */ - new_streamFile = open_wrap_streamfile(streamFile); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - new_streamFile = open_clamp_streamfile(temp_streamFile, subfile_offset,subfile_size); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - if (fake_ext) { - new_streamFile = open_fakename_streamfile(temp_streamFile, NULL,fake_ext); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - } - - return temp_streamFile; - -fail: - close_streamfile(temp_streamFile); - return NULL; -} diff --git a/src/meta/sps_n1.c b/src/meta/sps_n1.c index f6857797..d75101ba 100644 --- a/src/meta/sps_n1.c +++ b/src/meta/sps_n1.c @@ -1,8 +1,6 @@ #include "meta.h" #include "../coding/coding.h" -static STREAMFILE* setup_sps_streamfile(STREAMFILE *streamfile, off_t subfile_offset, size_t subfile_size, char* extension); - /* .SPS - Nippon Ichi wrapper [ClaDun (PSP)] */ VGMSTREAM * init_vgmstream_sps_n1(STREAMFILE *streamFile) { VGMSTREAM *vgmstream = NULL; @@ -26,7 +24,7 @@ VGMSTREAM * init_vgmstream_sps_n1(STREAMFILE *streamFile) { /* init the VGMSTREAM */ switch(type) { case 1: /* .vag */ - temp_streamFile = setup_sps_streamfile(streamFile, subfile_offset, subfile_size, "vag"); + temp_streamFile = setup_subfile_streamfile(streamFile, subfile_offset, subfile_size, "vag"); if (!temp_streamFile) goto fail; vgmstream = init_vgmstream_vag(temp_streamFile); @@ -34,7 +32,7 @@ VGMSTREAM * init_vgmstream_sps_n1(STREAMFILE *streamFile) { break; case 2: /* .at3 */ - temp_streamFile = setup_sps_streamfile(streamFile, subfile_offset, subfile_size, "at3"); + temp_streamFile = setup_subfile_streamfile(streamFile, subfile_offset, subfile_size, "at3"); if (!temp_streamFile) goto fail; vgmstream = init_vgmstream_riff(temp_streamFile); @@ -54,26 +52,3 @@ fail: close_vgmstream(vgmstream); return NULL; } - -static STREAMFILE* setup_sps_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, char* extension) { - STREAMFILE *temp_streamFile = NULL, *new_streamFile = NULL; - - /* setup subfile */ - new_streamFile = open_wrap_streamfile(streamFile); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - new_streamFile = open_clamp_streamfile(temp_streamFile, subfile_offset,subfile_size); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - new_streamFile = open_fakename_streamfile(temp_streamFile, NULL,extension); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - return temp_streamFile; - -fail: - close_streamfile(temp_streamFile); - return NULL; -} diff --git a/src/meta/ubi_jade.c b/src/meta/ubi_jade.c index a3b48435..054c8714 100644 --- a/src/meta/ubi_jade.c +++ b/src/meta/ubi_jade.c @@ -1,7 +1,6 @@ #include "meta.h" #include "../coding/coding.h" -static STREAMFILE* setup_jade_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* fake_ext); static int get_loop_points(STREAMFILE *streamFile, int *out_loop_start, int *out_loop_end); /* Jade RIFF - from Ubisoft Jade engine games [Beyond Good & Evil (multi), Rayman Raving Rabbids 1/2 (multi)] */ @@ -231,7 +230,7 @@ VGMSTREAM * init_vgmstream_ubi_jade(STREAMFILE *streamFile) { if (read_32bitBE(start_offset, streamFile) != 0x4D534643) /* "MSF\43" */ goto fail; - temp_streamFile = setup_jade_streamfile(streamFile, start_offset, data_size, "msf"); + temp_streamFile = setup_subfile_streamfile(streamFile, start_offset, data_size, "msf"); if (!temp_streamFile) goto fail; temp_vgmstream = init_vgmstream_ps3_msf(temp_streamFile); @@ -362,7 +361,7 @@ VGMSTREAM * init_vgmstream_ubi_jade_container(STREAMFILE *streamFile) { subfile_size = read_32bitLE(subfile_offset+0x04,streamFile) + 0x04+0x04; - temp_streamFile = setup_jade_streamfile(streamFile, subfile_offset,subfile_size, NULL); + temp_streamFile = setup_subfile_streamfile(streamFile, subfile_offset,subfile_size, NULL); if (!temp_streamFile) goto fail; if (check_extensions(streamFile,"xma")) { @@ -379,28 +378,3 @@ fail: close_vgmstream(vgmstream); return NULL; } - -static STREAMFILE* setup_jade_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* fake_ext) { - STREAMFILE *temp_streamFile = NULL, *new_streamFile = NULL; - - /* setup subfile */ - new_streamFile = open_wrap_streamfile(streamFile); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - new_streamFile = open_clamp_streamfile(temp_streamFile, subfile_offset,subfile_size); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - if (fake_ext) { - new_streamFile = open_fakename_streamfile(temp_streamFile, NULL,fake_ext); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - } - - return temp_streamFile; - -fail: - close_streamfile(temp_streamFile); - return NULL; -} diff --git a/src/meta/xwb.c b/src/meta/xwb.c index d7cf3340..339a03e1 100644 --- a/src/meta/xwb.c +++ b/src/meta/xwb.c @@ -72,7 +72,6 @@ typedef struct { } xwb_header; static void get_name(char * buf, size_t maxsize, int target_subsong, xwb_header * xwb, STREAMFILE *streamFile); -static STREAMFILE* setup_subfile_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* fake_ext); /* XWB - XACT Wave Bank (Microsoft SDK format for XBOX/XBOX360/Windows) */ @@ -600,31 +599,6 @@ fail: /* ****************************************************************************** */ -static STREAMFILE* setup_subfile_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* fake_ext) { - STREAMFILE *temp_streamFile = NULL, *new_streamFile = NULL; - - /* setup subfile */ - new_streamFile = open_wrap_streamfile(streamFile); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - new_streamFile = open_clamp_streamfile(temp_streamFile, subfile_offset,subfile_size); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - new_streamFile = open_fakename_streamfile(temp_streamFile, NULL,fake_ext); - if (!new_streamFile) goto fail; - temp_streamFile = new_streamFile; - - return temp_streamFile; - -fail: - close_streamfile(temp_streamFile); - return NULL; -} - -/* ****************************************************************************** */ - /* try to get the stream name in the .xwb, though they are very rarely included */ static int get_xwb_name(char * buf, size_t maxsize, int target_subsong, xwb_header * xwb, STREAMFILE *streamFile) { size_t read;