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
This commit is contained in:
sergm
2021-02-11 21:35:37 +02:00
parent 5a44b4dc57
commit 3d94173733
3 changed files with 10 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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:

View File

@@ -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);