diff options
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | src/adlmidi.cpp | 9 |
2 files changed, 13 insertions, 1 deletions
@@ -60,6 +60,11 @@ To build that example you will need to have installed SDL2 library. to play any MIDI via this library. # Changelog +## 1.0.3 2016-08-06 + * Added handling of 111'th controller as "loopStart" (which used by RPG-Maker) + * Fixed infinite loop caused by blank MIDI-files (add extra second of waiting if over 10000 0-waiting loops are been detected) + * Fixed damaged playing of IMF files (cased by wrong implementation of getc() function where return type must be int, not unsigned char) + ## 1.0.2 2016-03-16 * Fixed infinite loop causes swapped loopEnd and loopStart (when loopEnd goes before loopStart) * Fixed sielent volume tracks (when initial voule is zero, tracks wouldn't be playd even after applying fading in volume events) diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp index 7eca21c..8553cef 100644 --- a/src/adlmidi.cpp +++ b/src/adlmidi.cpp @@ -873,12 +873,19 @@ public: double Tick(double s, double granularity) { if(CurrentPosition.began) CurrentPosition.wait -= s; - while(CurrentPosition.wait <= granularity * 0.5) + int AntiFreezeCounter = 10000;//Limit 10000 loops to avoid freezing + while( (CurrentPosition.wait <= granularity * 0.5) && (AntiFreezeCounter>0) ) { //std::fprintf(stderr, "wait = %g...\n", CurrentPosition.wait); ProcessEvents(); + if(CurrentPosition.wait <= 0.0) + AntiFreezeCounter--; } + if(AntiFreezeCounter <= 0) + CurrentPosition.wait += 1.0;/* Add extra 1 second when over 10000 events + with zero delay are been detected */ + for(unsigned c = 0; c < opl.NumChannels; ++c) ch[c].AddAge(s * 1000); |