diff options
author | Chris Xiong <chirs241097@gmail.com> | 2020-01-16 23:46:05 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2020-01-16 23:46:05 +0800 |
commit | 63224bf7ac365b428e5115fc6ef6339a0b40c9fa (patch) | |
tree | 45d72410a3f19200945b304d4c20f03fc6cdc0f9 /core | |
parent | f7f2e9039cfd6c3d07a28137e321fa96b0267084 (diff) | |
download | QMidiPlayer-63224bf7ac365b428e5115fc6ef6339a0b40c9fa.tar.xz |
Seeking while paused no longer breaks playback completely.
"main.seek" callbacks are now invoked after the player has done seeking,
fixing incorrect channel info in simple visualization after seeking.
Use QT_STRINGIFY.
Diffstat (limited to 'core')
-rw-r--r-- | core/qmpmidiplay.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/core/qmpmidiplay.cpp b/core/qmpmidiplay.cpp index 4cb5430..2fed6a8 100644 --- a/core/qmpmidiplay.cpp +++ b/core/qmpmidiplay.cpp @@ -186,8 +186,15 @@ void CMidiPlayer::playEvents() ttick=getEvent(0)->time;ttime=std::chrono::high_resolution_clock::now(); for(ct=getEvent(0)->time;tceptr<ecnt;) { - while(tcpaused)std::this_thread::sleep_for(std::chrono::milliseconds(100)); using namespace std::chrono; + while(tcpaused)std::this_thread::sleep_for(milliseconds(100)); + if(resumed){ + resumed=false; + ct=getEvent(tceptr)->time; + ttick=getTick(); + ttime=high_resolution_clock::now(); + continue; + } high_resolution_clock::time_point b=high_resolution_clock::now(); if(getTick()-_lrtick>divs){ _lrtick=getTick(); @@ -209,14 +216,11 @@ void CMidiPlayer::playEvents() if(tcstop||!midiReaders||tceptr>=ecnt)break; high_resolution_clock::time_point a=high_resolution_clock::now(); auto sendtime=a-b; - if(resumed){resumed=false; - ttick=getTick();ttime=high_resolution_clock::now(); - } - else if(sendtime.count()<(getEvent(tceptr)->time-ct)*dpt) { double ns_sleep=(getEvent(tceptr)->time-ct)*dpt-sendtime.count(); double correction=(getTick()-ttick)*dpt-(b-ttime).count(); + if(correction>0)correction=0; #ifdef _WIN32 w32usleep((uint64_t)(((getEvent(tceptr)->time-ct)*dpt-sendtime.count())/1000)); #else |