From c882ef9dabbb69e569bd5861712cf4117794a9ae Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Fri, 7 Sep 2012 14:47:30 -0400 Subject: AUDIO: Make MidiParser_QT::loadMusic() detect the file type --- audio/midiparser_qt.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'audio/midiparser_qt.cpp') diff --git a/audio/midiparser_qt.cpp b/audio/midiparser_qt.cpp index 5500c28e44..d6440508df 100644 --- a/audio/midiparser_qt.cpp +++ b/audio/midiparser_qt.cpp @@ -25,10 +25,19 @@ #include "common/memstream.h" bool MidiParser_QT::loadMusic(byte *data, uint32 size) { - // Assume that this is a Tune and not a QuickTime container + if (size < 8) + return false; + Common::SeekableReadStream *stream = new Common::MemoryReadStream(data, size, DisposeAfterUse::NO); - if (!loadFromTune(stream)) { + // Attempt to detect what format we have + bool result; + if (READ_BE_UINT32(data + 4) == MKTAG('m', 'u', 's', 'i')) + result = loadFromTune(stream); + else + result = loadFromContainerStream(stream); + + if (!result) { delete stream; return false; } -- cgit v1.2.3