- apparently, freeing data->samples from free_ongakukan_adp (ongakukan_adp_decoder.c) causes heap corruption everywhere because it was already freed to begin with!
-- removing the offending line of code will no longer crash VS2022 builds of vgmstream.
significant improvements include:
- char flags in ongakukan_adp_lib.c have all, with one exception, been made to bools.
-- ATM, sample_mode will remain a char.
-- several other variables have been removed. they did not affect decoding in any significant way.
-- init_ongakukan_adpcm now accepts at least one bool as an argument for a total of four arguments.
-- many function from lib renamed to follow external lib function naming standard.
- simplified ongakukan_adp_decoder.c
-- decode_ongakukan_adp in particular benefited from this code simpification; loop is now re-done so all samples are copied to outbuf when they're made available.
-- as a consequence of this, at least one var was removed entirely, while others have been redefined into different purposes; samples_filled is now a bool var that flags whether or not all available samples were decoded.
-- init_ongakukan_adp has four arguments as well, and accepts at least one bool as an argument of its own.
-- streamfile is now close there as well instead of in the external decoder lib.
- adp_ongakukan.c saw much simpified code as well; meta checks have been relaxed significantly, which meant the removal of several var and at least three vars repurposed into bools.
-- supposed_size is introduced as an entirely new var; it now calculates the supposed file size of an ADP file with several 32-bit fields from the first byte as a base.
-- consequently, file_size checks are now made against supposed_size.
- as a consequence of all of the above, riff.c has now lost an additional RIFF size check; initially if RIFF chunk reported a big-enough size than RIFF file realistically has, it would be enough for vgmstream to stop working with said file.
till now, Ongakukan ADPCM decoder worked by "samples filled" and "samples consumed" var from ongakukan_adp_decoder.c ("decoder code" henceforth) get values from ongakukan-adp_lib.c ("decoder lib code" henceforth). samples done was also not initialized to 0 in decoder code, which led to "stuttery" playback with ADP files when decoded sound data from those same files would endlessly repeat by about half-a-second till it reached duration.
this commit fixes this; ADP files are now decoded from beginning-to-end, and you'll be getting no "repeating" sounds literally every second. instead you'll be getting the sound data the way you'd listen to them in-game.