aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2021-01-07 14:06:30 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2021-01-07 14:06:30 +0800
commit327526848c930c5cca7fafbde36d60ea45b786db (patch)
tree719a0525658557c6924a975bd966fdd6559c78a8
parent51d627aa7a879d1840142fb53bc3dfbbf1696411 (diff)
downloadQMidiPlayer-327526848c930c5cca7fafbde36d60ea45b786db.tar.xz
Fix another freezing issue on Windows.
insert bad pun here
-rw-r--r--core/qmpmidiplay.cpp9
-rw-r--r--core/qmpmidiplay.hpp2
2 files changed, 8 insertions, 3 deletions
diff --git a/core/qmpmidiplay.cpp b/core/qmpmidiplay.cpp
index 6a24024..e8e83a2 100644
--- a/core/qmpmidiplay.cpp
+++ b/core/qmpmidiplay.cpp
@@ -242,6 +242,12 @@ void CMidiPlayer::playEvents()
double correction = (getTick() - ttick) * dpt - (b - ttime).count();
if (correction > 0)
correction = 0;
+ else if (ns_sleep + correction < 0)
+ {
+ ttick = getTick();
+ ttime = high_resolution_clock::now();
+ ns_sleep = correction = 0;
+ }
if (ns_sleep + correction > 2.5e8)
{
high_resolution_clock::time_point t = high_resolution_clock::now();
@@ -266,7 +272,7 @@ void CMidiPlayer::playEvents()
}
else if (tts < 0)
{
- fputs("ur operating system (or toolchain) suck!!\n", stderr);
+ // this shouldn't happen... but ok
}
}
else
@@ -354,7 +360,6 @@ CMidiPlayer::CMidiPlayer()
midiReaders = new CMidiFileReaderCollection();
resumed = false;
midiFile = nullptr;
- waitvoice = true;
event_handlers_id = event_read_handlers_id = file_read_finish_hooks_id = 0;
memset(eventHandlerCB, 0, sizeof(eventHandlerCB));
memset(eventHandlerCBuserdata, 0, sizeof(eventHandlerCBuserdata));
diff --git a/core/qmpmidiplay.hpp b/core/qmpmidiplay.hpp
index a4245ae..ddbb63b 100644
--- a/core/qmpmidiplay.hpp
+++ b/core/qmpmidiplay.hpp
@@ -65,7 +65,7 @@ private:
int32_t rpnid[16], rpnval[16];
uint16_t mute, solo;
double ftime;
- bool sendSysEx, waitvoice;
+ bool sendSysEx;
uint8_t chstatus[16][130];//0..127: cc 128: pc
uint32_t ctempo, ctsn, ctsd, divs, cks;
double dpt;//time per tick