diff options
author | Filippos Karapetis | 2012-12-27 16:34:23 +0200 |
---|---|---|
committer | Filippos Karapetis | 2012-12-27 17:12:26 +0200 |
commit | bf62205c737fe3904577d5e314b58cadba0c2789 (patch) | |
tree | d6301a681595d84463e93824dc394c6fbc41c51e | |
parent | 5b09c1c8e3dd4ed927e1c6ee670defe83e4382c9 (diff) | |
download | scummvm-rg350-bf62205c737fe3904577d5e314b58cadba0c2789.tar.gz scummvm-rg350-bf62205c737fe3904577d5e314b58cadba0c2789.tar.bz2 scummvm-rg350-bf62205c737fe3904577d5e314b58cadba0c2789.zip |
MT32: Move the ROM file deletion code to the ScummVM MT32 driver
This removes the custom ScummVM file deletion code in the munt code
-rw-r--r-- | audio/softsynth/mt32.cpp | 44 | ||||
-rw-r--r-- | audio/softsynth/mt32/ROMInfo.cpp | 1 |
2 files changed, 28 insertions, 17 deletions
diff --git a/audio/softsynth/mt32.cpp b/audio/softsynth/mt32.cpp index 3e87963113..e2f1f36f2c 100644 --- a/audio/softsynth/mt32.cpp +++ b/audio/softsynth/mt32.cpp @@ -110,8 +110,9 @@ private: uint16 _channelMask; MT32Emu::Synth *_synth; MT32Emu::ReportHandlerScummVM *_reportHandler; - const MT32Emu::ROMImage *_controlROM; - const MT32Emu::ROMImage *_pcmROM; + const MT32Emu::ROMImage *_controlROM, *_pcmROM; + Common::File *_controlFile, *_pcmFile; + void deleteMuntStructures(); int _outputRate; @@ -198,10 +199,26 @@ MidiDriver_MT32::MidiDriver_MT32(Audio::Mixer *mixer) : MidiDriver_Emulated(mixe } MidiDriver_MT32::~MidiDriver_MT32() { + deleteMuntStructures(); +} + +void MidiDriver_MT32::deleteMuntStructures() { delete _synth; + _synth = NULL; delete _reportHandler; - MT32Emu::ROMImage::freeROMImage(_controlROM); - MT32Emu::ROMImage::freeROMImage(_pcmROM); + _reportHandler = NULL; + + if (_controlROM) + MT32Emu::ROMImage::freeROMImage(_controlROM); + _controlROM = NULL; + if (_pcmROM) + MT32Emu::ROMImage::freeROMImage(_pcmROM); + _pcmROM = NULL; + + delete _controlFile; + _controlFile = NULL; + delete _pcmFile; + _pcmFile = NULL; } int MidiDriver_MT32::open() { @@ -226,14 +243,14 @@ int MidiDriver_MT32::open() { _initializing = true; drawMessage(-1, _s("Initializing MT-32 Emulator")); - Common::File *controlFile = new Common::File(); - if (!controlFile->open("MT32_CONTROL.ROM")) + _controlFile = new Common::File(); + if (!_controlFile->open("MT32_CONTROL.ROM")) error("Error opening MT32_CONTROL.ROM"); - Common::File *pcmFile = new Common::File(); - if (!pcmFile->open("MT32_PCM.ROM")) + _pcmFile = new Common::File(); + if (!_pcmFile->open("MT32_PCM.ROM")) error("Error opening MT32_PCM.ROM"); - _controlROM = MT32Emu::ROMImage::makeROMImage(controlFile); - _pcmROM = MT32Emu::ROMImage::makeROMImage(pcmFile); + _controlROM = MT32Emu::ROMImage::makeROMImage(_controlFile); + _pcmROM = MT32Emu::ROMImage::makeROMImage(_pcmFile); if (!_synth->open(*_controlROM, *_pcmROM)) return MERR_DEVICE_NOT_AVAILABLE; @@ -295,12 +312,7 @@ void MidiDriver_MT32::close() { _mixer->stopHandle(_mixerSoundHandle); _synth->close(); - delete _synth; - _synth = NULL; - delete _reportHandler; - _reportHandler = NULL; - MT32Emu::ROMImage::freeROMImage(_controlROM); - MT32Emu::ROMImage::freeROMImage(_pcmROM); + deleteMuntStructures(); } void MidiDriver_MT32::generateSamples(int16 *data, int len) { diff --git a/audio/softsynth/mt32/ROMInfo.cpp b/audio/softsynth/mt32/ROMInfo.cpp index 5735409655..514bc23496 100644 --- a/audio/softsynth/mt32/ROMInfo.cpp +++ b/audio/softsynth/mt32/ROMInfo.cpp @@ -96,7 +96,6 @@ const ROMImage* ROMImage::makeROMImage(Common::File *file) { void ROMImage::freeROMImage(const ROMImage *romImage) { ROMInfo::freeROMInfo(romImage->romInfo); - delete (romImage->file); delete romImage; } |