diff options
author | Martin Kiewitz | 2015-07-04 12:55:49 +0200 |
---|---|---|
committer | Martin Kiewitz | 2015-07-04 12:55:49 +0200 |
commit | 96005c7da9229f4801ac73b4200c54e38dcd7e32 (patch) | |
tree | 1cd8886792976f6d156fd39bf0d9d48c5aabb5ff /engines/agos | |
parent | fba886a21f784da5bd48accb0dd5aaf133dd0b29 (diff) | |
download | scummvm-rg350-96005c7da9229f4801ac73b4200c54e38dcd7e32.tar.gz scummvm-rg350-96005c7da9229f4801ac73b4200c54e38dcd7e32.tar.bz2 scummvm-rg350-96005c7da9229f4801ac73b4200c54e38dcd7e32.zip |
AUDIO: Miles Audio AdLib instrument stream support
- not using byte pointer + size and instead now a
SeekableReadStream for factory
- adjusted ACCESS + AGOS engines accordingly
Diffstat (limited to 'engines/agos')
-rw-r--r-- | engines/agos/midi.cpp | 29 | ||||
-rw-r--r-- | engines/agos/midi.h | 2 |
2 files changed, 9 insertions, 22 deletions
diff --git a/engines/agos/midi.cpp b/engines/agos/midi.cpp index f81721297d..9563d7d329 100644 --- a/engines/agos/midi.cpp +++ b/engines/agos/midi.cpp @@ -191,16 +191,15 @@ int MidiPlayer::open(int gameType, bool isDemo) { // if there is no file called MIDPAK.AD, try to extract it from the file SETUP.SHR // if we didn't do this, the user would be forced to "install" the game instead of simply // copying all files from CD-ROM. - const byte *instrumentRawData = NULL; - uint32 instrumentRawDataSize = 0; - instrumentRawData = simon2SetupExtractFile("MIDPAK.AD", instrumentRawDataSize); - if (!instrumentRawData) + Common::SeekableReadStream *midpakAdLibStream; + midpakAdLibStream = simon2SetupExtractFile("MIDPAK.AD"); + if (!midpakAdLibStream) error("MidiPlayer: could not extract MIDPAK.AD from SETUP.SHR"); // Pass this extracted data to the driver warning("SIMON 2: using MIDPAK.AD extracted from SETUP.SHR"); - _driver = Audio::MidiDriver_Miles_AdLib_create("", "", instrumentRawData, instrumentRawDataSize); - delete[] instrumentRawData; + _driver = Audio::MidiDriver_Miles_AdLib_create("", "", midpakAdLibStream); + delete midpakAdLibStream; } // TODO: not sure what's going wrong with AdLib // it doesn't seem to matter if we use the regular XMIDI tracks or the 2nd set meant for MT32 @@ -818,7 +817,7 @@ void MidiPlayer::loadS1D(Common::File *in, bool sfx) { // [bundle file header] // [compressed file header] [compressed file data] // * compressed file count -const byte *MidiPlayer::simon2SetupExtractFile(const Common::String &requestedFileName, uint32 &extractedDataSize) { +Common::SeekableReadStream *MidiPlayer::simon2SetupExtractFile(const Common::String &requestedFileName) { Common::File *setupBundleStream = new Common::File(); uint32 bundleSize = 0; uint32 bundleBytesLeft = 0; @@ -830,9 +829,8 @@ const byte *MidiPlayer::simon2SetupExtractFile(const Common::String &requestedFi Common::String fileName; uint32 fileCompressedSize = 0; byte *fileCompressedDataPtr = nullptr; - byte *extractedDataPtr = nullptr; - extractedDataSize = 0; + Common::SeekableReadStream *extractedStream = nullptr; if (!setupBundleStream->open("setup.shr")) error("MidiPlayer: could not open setup.shr"); @@ -885,22 +883,11 @@ const byte *MidiPlayer::simon2SetupExtractFile(const Common::String &requestedFi error("MidiPlayer: setup.shr read error"); Common::MemoryReadStream *compressedStream = nullptr; - Common::SeekableReadStream *extractedStream = nullptr; compressedStream = new Common::MemoryReadStream(fileCompressedDataPtr, fileCompressedSize); // we don't know the unpacked size, let decompressor figure it out extractedStream = Common::decompressDCL(compressedStream); delete compressedStream; - - if (extractedStream) { - // Successfully extracted the data - // TODO: clean up required, but this also requires Miles Audio drivers to use streams - extractedDataPtr = new byte[extractedStream->size()]; - extractedStream->seek(0); - extractedStream->read(extractedDataPtr, extractedStream->size()); - extractedDataSize = extractedStream->size(); - delete extractedStream; - } break; } @@ -913,7 +900,7 @@ const byte *MidiPlayer::simon2SetupExtractFile(const Common::String &requestedFi setupBundleStream->close(); delete setupBundleStream; - return extractedDataPtr; + return extractedStream; } } // End of namespace AGOS diff --git a/engines/agos/midi.h b/engines/agos/midi.h index fff87e63c6..d0a7d77971 100644 --- a/engines/agos/midi.h +++ b/engines/agos/midi.h @@ -129,7 +129,7 @@ private: kMusicMode _musicMode; private: - const byte *simon2SetupExtractFile(const Common::String &requestedFileName, uint32 &extractedDataSize); + Common::SeekableReadStream *simon2SetupExtractFile(const Common::String &requestedFileName); }; } // End of namespace AGOS |