IT import: handle end of file when reading samples

This commit is contained in:
tildearrow 2024-08-17 17:18:14 -05:00
parent 3fce04e77b
commit 3f47979ea7

View file

@ -639,6 +639,8 @@ bool DivEngine::loadIT(unsigned char* file, size_t len) {
logD("seek not needed..."); logD("seek not needed...");
} }
logV("reading sample data (%d)",s->samples);
if (flags&8) { // compressed sample if (flags&8) { // compressed sample
unsigned int ret=0; unsigned int ret=0;
logV("decompression begin... (%d)",s->samples); logV("decompression begin... (%d)",s->samples);
@ -672,6 +674,7 @@ bool DivEngine::loadIT(unsigned char* file, size_t len) {
} }
logV("got: %d",ret); logV("got: %d",ret);
} else { } else {
try {
if (s->depth==DIV_SAMPLE_DEPTH_16BIT) { if (s->depth==DIV_SAMPLE_DEPTH_16BIT) {
if (flags&4) { // downmix stereo if (flags&4) { // downmix stereo
for (unsigned int i=0; i<s->samples; i++) { for (unsigned int i=0; i<s->samples; i++) {
@ -729,6 +732,9 @@ bool DivEngine::loadIT(unsigned char* file, size_t len) {
} }
} }
} }
} catch (EndOfFileException& e) {
logW("premature end of file...");
}
} }
// scale sample if necessary // scale sample if necessary