From 3d9417373354703b41c4a37bec308f96ede54706 Mon Sep 17 00:00:00 2001 From: sergm Date: Thu, 11 Feb 2021 21:35:37 +0200 Subject: [PATCH] Further extended ROMImage API (#44) - Added method ROMImage::isFileUserProvided to make memory cleanup easier wrt. freeing the File of a ROMImage which may not be created internally as with ROMImages merged from partial ones - Minor formatting fix in ROMImage - Mentioned that full ROMImages are required in description of Synth::open --- mt32emu/src/ROMInfo.cpp | 6 +++++- mt32emu/src/ROMInfo.h | 4 ++++ mt32emu/src/Synth.h | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mt32emu/src/ROMInfo.cpp b/mt32emu/src/ROMInfo.cpp index 9a5e26c..6c7fa70 100644 --- a/mt32emu/src/ROMInfo.cpp +++ b/mt32emu/src/ROMInfo.cpp @@ -197,7 +197,7 @@ const ROMImage *ROMImage::makeROMImage(File *file, const ROMInfo * const *romInf const ROMImage *ROMImage::makeROMImage(File *file1, File *file2) { static const ROMInfo * const *partialROMInfos = ROMInfo::getROMInfoList( 1 << ROMInfo::Control | 1 << ROMInfo::PCM | 1 << ROMInfo::Reverb, - 1 << ROMInfo::FirstHalf | 1 << ROMInfo::SecondHalf| 1 << ROMInfo::Mux0 | 1 << ROMInfo::Mux1 + 1 << ROMInfo::FirstHalf | 1 << ROMInfo::SecondHalf | 1 << ROMInfo::Mux0 | 1 << ROMInfo::Mux1 ); const ROMImage *image1 = makeROMImage(file1, partialROMInfos); @@ -237,6 +237,10 @@ File *ROMImage::getFile() const { return file; } +bool ROMImage::isFileUserProvided() const { + return !ownFile; +} + const ROMInfo *ROMImage::getROMInfo() const { return romInfo; } diff --git a/mt32emu/src/ROMInfo.h b/mt32emu/src/ROMInfo.h index 9eeeedf..9c8ed0b 100644 --- a/mt32emu/src/ROMInfo.h +++ b/mt32emu/src/ROMInfo.h @@ -101,6 +101,10 @@ public: MT32EMU_EXPORT_V(2.5) static const ROMImage *mergeROMImages(const ROMImage *romImage1, const ROMImage *romImage2); MT32EMU_EXPORT File *getFile() const; + + // Returns true in case this ROMImage is built with a user provided File that has to be deallocated separately. + // For a ROMImage created via merging two partial ROMImages, this method returns false. + MT32EMU_EXPORT_V(2.5) bool isFileUserProvided() const; MT32EMU_EXPORT const ROMInfo *getROMInfo() const; private: diff --git a/mt32emu/src/Synth.h b/mt32emu/src/Synth.h index fc58ef3..b167bf0 100644 --- a/mt32emu/src/Synth.h +++ b/mt32emu/src/Synth.h @@ -292,7 +292,7 @@ public: // Used to initialise the MT-32. Must be called before any other function. // Returns true if initialization was sucessful, otherwise returns false. - // controlROMImage and pcmROMImage represent Control and PCM ROM images for use by synth. + // controlROMImage and pcmROMImage represent full Control and PCM ROM images for use by synth. // usePartialCount sets the maximum number of partials playing simultaneously for this session (optional). // analogOutputMode sets the mode for emulation of analogue circuitry of the hardware units (optional). MT32EMU_EXPORT bool open(const ROMImage &controlROMImage, const ROMImage &pcmROMImage, Bit32u usePartialCount = DEFAULT_MAX_PARTIALS, AnalogOutputMode analogOutputMode = AnalogOutputMode_COARSE);