aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWohlstand <admin@wohlnet.ru>2016-08-06 20:15:34 +0300
committerWohlstand <admin@wohlnet.ru>2016-08-06 20:15:34 +0300
commit5c95f7a249771f53cf1bfe3ff919bcae16b33f3b (patch)
tree10bac84bb495ff1d9775a8535f8a37082421190e
parent2452400e793d70f4d9d11867d20b87ab967a6916 (diff)
downloadlibADLMIDI-5c95f7a249771f53cf1bfe3ff919bcae16b33f3b.tar.gz
libADLMIDI-5c95f7a249771f53cf1bfe3ff919bcae16b33f3b.tar.bz2
libADLMIDI-5c95f7a249771f53cf1bfe3ff919bcae16b33f3b.zip
Fixed infinite loop caused by attempt to play blank MIDI-file
-rw-r--r--README.md5
-rw-r--r--src/adlmidi.cpp9
2 files changed, 13 insertions, 1 deletions
diff --git a/README.md b/README.md
index 7588000..655eb4d 100644
--- a/README.md
+++ b/README.md
@@ -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);