From 63224bf7ac365b428e5115fc6ef6339a0b40c9fa Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Thu, 16 Jan 2020 23:46:05 +0800 Subject: 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. --- core/qmpmidiplay.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'core') 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;tceptrtime; + 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 -- cgit v1.2.3