aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2020-01-16 23:46:05 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2020-01-16 23:46:05 +0800
commit63224bf7ac365b428e5115fc6ef6339a0b40c9fa (patch)
tree45d72410a3f19200945b304d4c20f03fc6cdc0f9
parentf7f2e9039cfd6c3d07a28137e321fa96b0267084 (diff)
downloadQMidiPlayer-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.
-rw-r--r--core/qmpmidiplay.cpp14
-rw-r--r--qmidiplayer-desktop/qmphelpwindow.cpp3
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.cpp2
-rw-r--r--qmidiplayer-desktop/qmpplugin.cpp4
4 files changed, 12 insertions, 11 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
diff --git a/qmidiplayer-desktop/qmphelpwindow.cpp b/qmidiplayer-desktop/qmphelpwindow.cpp
index 325fc57..4579e2c 100644
--- a/qmidiplayer-desktop/qmphelpwindow.cpp
+++ b/qmidiplayer-desktop/qmphelpwindow.cpp
@@ -1,7 +1,6 @@
#include <fluidsynth.h>
#include "qmphelpwindow.hpp"
#include "ui_qmphelpwindow.h"
-#define strify(s) #s
static const char *months="JanFebMarAprMayJunJulAugSepOctNovDec";
std::string parseDate(const char *date)
@@ -39,7 +38,7 @@ void qmpHelpWindow::on_textBrowser_sourceChanged(const QUrl &src)
s.replace("RT_FLUIDSYNTH_VERSION",fluid_version_str());
s.replace("APP_VERSION",APP_VERSION);
s.replace("BUILD_DATE",parseDate(__DATE__).c_str());
- s.replace("BUILD_MACHINE",strify(BUILD_MACHINE));
+ s.replace("BUILD_MACHINE",QT_STRINGIFY(BUILD_MACHINE));
ui->textBrowser->setHtml(s);
}
}
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp
index 1df2d8e..94185c7 100644
--- a/qmidiplayer-desktop/qmpmainwindow.cpp
+++ b/qmidiplayer-desktop/qmpmainwindow.cpp
@@ -413,7 +413,6 @@ void qmpMainWindow::on_hsTimer_sliderPressed()
void qmpMainWindow::on_hsTimer_sliderReleased()
{
dragging=false;
- invokeCallback("main.seek",nullptr);
if(playing)
{
if(ui->hsTimer->value()==100){on_pbNext_clicked();return;}
@@ -431,6 +430,7 @@ void qmpMainWindow::on_hsTimer_sliderReleased()
sprintf(ts,"%02d:%02d",(int)(offset)/60,(int)(offset)%60);
ui->lbCurTime->setText(ts);
}
+ invokeCallback("main.seek",nullptr);
}
uint32_t qmpMainWindow::getPlaybackPercentage(){return ui->hsTimer->value();}
diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp
index 19d14b5..08959cb 100644
--- a/qmidiplayer-desktop/qmpplugin.cpp
+++ b/qmidiplayer-desktop/qmpplugin.cpp
@@ -56,9 +56,7 @@ void qmpPluginManager::scanPlugins(const std::vector<std::string> &pp)
QDirIterator *dir;
std::vector<std::string> cpluginpaths(pp);
#ifdef NON_PORTABLE
-#define strify(s) #s
- QString pdir=QString(strify(INSTALL_PREFIX))+"/lib/qmidiplayer/";
-#undef strify
+ QString pdir=QString(QT_STRINGIFY(INSTALL_PREFIX))+"/lib/qmidiplayer/";
dir=new QDirIterator(pdir);
while(dir->hasNext())
{