Merge pull request #739 from NicknineTheEagle/ubi

Ubi DAT: Play silence if external file is not found
This commit is contained in:
NicknineTheEagle 2020-10-29 23:52:44 +03:00 committed by GitHub
commit 6f1f2ce957
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -632,24 +632,20 @@ static VGMSTREAM *init_vgmstream_ubi_dat_main(ubi_sb_header *sb, STREAMFILE *sf_
STREAMFILE *sf_data = NULL;
if (sb->is_external) {
if (strcmp(sb->resource_name, "silence.wav") == 0) {
/* some Rayman 2 banks reference non-existent silence.wav, looks like some kind of hack? */
sb->duration = (float)(sb->stream_size / sb->channels / 2) / (float)sb->sample_rate;
return init_vgmstream_ubi_sb_silence(sb, sf_index, sf);
}
sf_data = open_streamfile_by_filename(sf, sb->resource_name);
if (!sf_data) {
/* play silence if external file is not found since Rayman 2 seems to rely on this behavior */
VGM_LOG("UBI DAT: external stream '%s' not found\n", sb->resource_name);
goto fail;
strncat(sb->readable_name, " (missing)", sizeof(sb->readable_name));
sb->duration = (float)pcm_bytes_to_samples(sb->stream_size, sb->channels, 16) / (float)sb->sample_rate;
return init_vgmstream_ubi_sb_silence(sb, sf_index, sf);
}
}
/* DAT banks don't work with raw audio data, they open full external files and rely almost entirely
* on their metadata, that's why we're handling this here, separately from other types */
switch (sb->stream_type) {
case 0x01:
{
case 0x01: {
if (!sb->is_external) { /* Dreamcast bank */
if (sb->version == 0x00000000) {
uint32_t entry_offset, start_offset, num_samples, codec;
@ -726,7 +722,7 @@ static VGMSTREAM *init_vgmstream_ubi_dat_main(ubi_sb_header *sb, STREAMFILE *sf_
}
break;
}
case 0x04:{ /* standard WAV */
case 0x04: { /* standard WAV */
if (!sb->is_external) {
VGM_LOG("Ubi DAT: Found RAM stream_type 0x04\n");
goto fail;