diff options
author | Wohlstand <admin@wohlnet.ru> | 2017-10-18 02:22:01 +0300 |
---|---|---|
committer | Wohlstand <admin@wohlnet.ru> | 2017-10-18 02:22:01 +0300 |
commit | 380d08e1a234efb17cf15a6b6c2d00c52e4fc648 (patch) | |
tree | 563567a5615623db8e9e3acdffa3be8f44cb84ba /src/adlmidi_load.cpp | |
parent | d7b33b8d4fc3efe90d8e388d451966fa4baefba6 (diff) | |
download | libADLMIDI-380d08e1a234efb17cf15a6b6c2d00c52e4fc648.tar.gz libADLMIDI-380d08e1a234efb17cf15a6b6c2d00c52e4fc648.tar.bz2 libADLMIDI-380d08e1a234efb17cf15a6b6c2d00c52e4fc648.zip |
Smooth finalizing, rewinding, and a bit more crash safety
* Smooth finalizing of song when loop is disabled (old ugly hack has been removed :wink:)
* Added an ability to reset song position to begin (very helpful when song reaches the end)
* Avoided possible crashes on attempt to fetch sample data without opening of MIDI file
Diffstat (limited to 'src/adlmidi_load.cpp')
-rw-r--r-- | src/adlmidi_load.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/adlmidi_load.cpp b/src/adlmidi_load.cpp index 5258dc9..a1242d7 100644 --- a/src/adlmidi_load.cpp +++ b/src/adlmidi_load.cpp @@ -200,9 +200,8 @@ static bool readInstrument(MIDIplay::fileReader &file, WOPL_Inst &ins, bool isPe bool MIDIplay::LoadBank(MIDIplay::fileReader &fr) { -#define qqq(x) (void)x size_t fsize; - qqq(fsize); + ADL_UNUSED(fsize); if(!fr.isValid()) { ADLMIDI_ErrorString = "Custom bank: Invalid data stream!"; @@ -296,6 +295,7 @@ bool MIDIplay::LoadBank(MIDIplay::fileReader &fr) } } + opl.AdlBank = opl._parent->AdlBank; opl.dynamic_metainstruments.clear(); opl.dynamic_instruments.clear(); @@ -351,10 +351,7 @@ bool MIDIplay::LoadMIDI(const std::string &filename) file.openFile(filename.c_str()); if(!LoadMIDI(file)) - { - std::perror(filename.c_str()); return false; - } return true; } @@ -368,16 +365,23 @@ bool MIDIplay::LoadMIDI(void *data, unsigned long size) bool MIDIplay::LoadMIDI(MIDIplay::fileReader &fr) { -#define qqq(x) (void)x size_t fsize; - qqq(fsize); + ADL_UNUSED(fsize); //! Temp buffer for conversion AdlMIDI_CPtr<uint8_t> cvt_buf; - //std::FILE* fr = std::fopen(filename.c_str(), "rb"); + #ifdef DISABLE_EMBEDDED_BANKS + if((opl.AdlBank != ~0u) || (opl.dynamic_metainstruments.size() < 256)) + { + ADLMIDI_ErrorString = "Bank is not set! Please load any instruments bank by using of adl_openBankFile() or adl_openBankData() functions!"; + return false; + } + #endif + if(!fr.isValid()) { - ADLMIDI_ErrorString = "Invalid data stream!"; + ADLMIDI_ErrorString = "Invalid data stream!\n"; + ADLMIDI_ErrorString += std::strerror(errno); return false; } @@ -429,6 +433,7 @@ bool MIDIplay::LoadMIDI(MIDIplay::fileReader &fr) opl.Reset(); trackStart = true; + atEnd = false; loopStart = true; loopStart_passed = false; invalidLoop = false; |