diff options
author | Chris Robinson <[email protected]> | 2013-12-28 10:34:26 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2013-12-28 10:34:26 -0800 |
commit | 0d7996409ea300eab47fff096c2d3c5aea592a29 (patch) | |
tree | debb8617177ef2ef4e011813aa7eae53a66db4ee /Alc | |
parent | fe55cd6de8b316f5e3869b88e9d64846847fb2a7 (diff) |
Ensure the soundfont version is 2.x
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/midi/sf2load.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/Alc/midi/sf2load.c b/Alc/midi/sf2load.c index 7d2a13e0..52ce931c 100644 --- a/Alc/midi/sf2load.c +++ b/Alc/midi/sf2load.c @@ -1001,6 +1001,7 @@ static void processInstrument(InstrumentHeader *inst, IDList *sounds, const Soun ALboolean loadSf2(Reader *stream, ALuint sfid) { + ALuint version = 0; Soundfont sfont; RiffHdr riff; RiffHdr list; @@ -1024,11 +1025,36 @@ ALboolean loadSf2(Reader *stream, ALuint sfid) ERROR_GOTO(error, "Invalid Format, expected LIST (INFO) got '%c%c%c%c'\n", FOURCCARGS(list.mCode)); if(list.mList != FOURCC('I','N','F','O')) ERROR_GOTO(error, "Invalid Format, expected INFO got '%c%c%c%c'\n", FOURCCARGS(list.mList)); - /* FIXME: Check and load info chunks */ - skip(stream, list.mSize); + while(list.mSize > 0 && !READERR(stream)) + { + RiffHdr info; + + RiffHdr_read(&info, stream); + list.mSize -= 8; + if(info.mCode == FOURCC('i','f','i','l')) + { + if(info.mSize != 4) + ERR("Invalid ifil chunk size: %d\n", info.mSize); + else + { + ALushort major = read_le16(stream); + ALushort minor = read_le16(stream); + + info.mSize -= 4; + list.mSize -= 4; + + version = (major<<16) | minor; + } + } + list.mSize -= info.mSize; + skip(stream, info.mSize); + } if(READERR(stream) != 0) ERROR_GOTO(error, "Error reading INFO chunk\n"); + if(version>>16 != 2) + ERROR_GOTO(error, "Unsupported format version: %d.%02d\n", version>>16, version&0xffff); + TRACE("Loading SF2 format version: %d.%02d\n", version>>16, version&0xffff); RiffHdr_read(&list, stream); if(list.mCode != FOURCC('L','I','S','T')) |