This commit is contained in:
bnnm 2019-10-07 00:17:12 +02:00
parent 122622252a
commit 15aa8652c6
3 changed files with 7 additions and 4 deletions

View File

@ -509,6 +509,7 @@ static int play_compressed_file(const char *filename, struct params *par, const
if (!mkdtemp(temp_dir)) { if (!mkdtemp(temp_dir)) {
fprintf(stderr, "%s: error creating temp dir for decompression\n", temp_dir); fprintf(stderr, "%s: error creating temp dir for decompression\n", temp_dir);
ret = -1;
goto fail; goto fail;
} }
@ -567,8 +568,7 @@ static int play_compressed_file(const char *filename, struct params *par, const
remove(temp_file); remove(temp_file);
remove(temp_dir); remove(temp_dir);
fail: fail:
free(cmd); free(cmd);
free(temp_file); free(temp_file);

View File

@ -1124,11 +1124,14 @@ size_t ms_ima_bytes_to_samples(size_t bytes, int block_align, int channels) {
} }
size_t xbox_ima_bytes_to_samples(size_t bytes, int channels) { size_t xbox_ima_bytes_to_samples(size_t bytes, int channels) {
int mod;
int block_align = 0x24 * channels; int block_align = 0x24 * channels;
if (channels <= 0) return 0; if (channels <= 0) return 0;
mod = bytes % block_align;
/* XBOX IMA blocks have a 4 byte header per channel; 2 samples per byte (2 nibbles) */ /* XBOX IMA blocks have a 4 byte header per channel; 2 samples per byte (2 nibbles) */
return (bytes / block_align) * (block_align - 4 * channels) * 2 / channels return (bytes / block_align) * (block_align - 4 * channels) * 2 / channels
+ ((bytes % block_align) ? ((bytes % block_align) - 4 * channels) * 2 / channels : 0); /* unlikely (encoder aligns) */ + ((mod > 0 && mod > 0x04*channels) ? (mod - 0x04*channels) * 2 / channels : 0); /* unlikely (encoder aligns) */
} }
size_t dat4_ima_bytes_to_samples(size_t bytes, int channels) { size_t dat4_ima_bytes_to_samples(size_t bytes, int channels) {

View File

@ -902,7 +902,7 @@ static void add_extension(int length, char * dst, const char * ext) {
/* copy new extension + double null terminate */ /* copy new extension + double null terminate */
/* ex: "vgmstream\0vgmstream Audio File (*.VGMSTREAM)\0" */ /* ex: "vgmstream\0vgmstream Audio File (*.VGMSTREAM)\0" */
written = sprintf(buf, "%s%c%s Audio File (*.%s)%c", ext,'\0',ext_upp,ext_upp,'\0'); written = snprintf(buf,sizeof(buf)-1, "%s%c%s Audio File (*.%s)%c", ext,'\0',ext_upp,ext_upp,'\0');
for (j = 0; j < written; i++,j++) for (j = 0; j < written; i++,j++)
dst[i] = buf[j]; dst[i] = buf[j];
dst[i] = '\0'; dst[i] = '\0';