diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | qmpmainwindow.cpp | 18 | ||||
-rw-r--r-- | qmpmidiplay.cpp | 11 | ||||
-rw-r--r-- | qmpmidiread.cpp | 1 |
4 files changed, 35 insertions, 4 deletions
@@ -1,3 +1,12 @@ +2016-04-05 0.7.0 beta +Raise player thread priority in Windows. +I've been so tired with the timing bug... +Remove several printf's. + +2016-03-23 0.7.0 beta +Fix drag&drop behavior in Windows. +Use winmm functions to ensure timing precision. + 2016-03-19 0.7.0 beta Minor changes on w32usleep... Sync with the Windows build. diff --git a/qmpmainwindow.cpp b/qmpmainwindow.cpp index 3220c13..aad0161 100644 --- a/qmpmainwindow.cpp +++ b/qmpmainwindow.cpp @@ -6,6 +6,9 @@ #include "qmpmainwindow.hpp" #include "ui_qmpmainwindow.h" #include "qmpmidiplay.hpp" +#ifdef _WIN32 +#include <Windows.h> +#endif qmpMainWindow* qmpMainWindow::ref=NULL; @@ -181,6 +184,9 @@ void qmpMainWindow::updateWidgets() player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange(); player->setWaitVoice(qmpSettingsWindow::getSettingsIntf()->value("Midi/WaitVoice",1).toInt()); playerTh=new std::thread(&CMidiPlayer::playerThread,player); +#ifdef _WIN32 + SetThreadPriority(playerTh->native_handle(),THREAD_PRIORITY_TIME_CRITICAL); +#endif st=std::chrono::steady_clock::now();offset=0; timer->start(100); } @@ -271,6 +277,9 @@ void qmpMainWindow::on_pbPlayPause_clicked() player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange(); player->setWaitVoice(qmpSettingsWindow::getSettingsIntf()->value("Midi/WaitVoice",1).toInt()); playerTh=new std::thread(&CMidiPlayer::playerThread,player); +#ifdef _WIN32 + SetThreadPriority(playerTh->native_handle(),THREAD_PRIORITY_TIME_CRITICAL); +#endif st=std::chrono::steady_clock::now();offset=0; timer->start(100); stopped=false; @@ -392,6 +401,9 @@ void qmpMainWindow::on_pbPrev_clicked() player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange(); player->setWaitVoice(qmpSettingsWindow::getSettingsIntf()->value("Midi/WaitVoice",1).toInt()); playerTh=new std::thread(&CMidiPlayer::playerThread,player); +#ifdef _WIN32 + SetThreadPriority(playerTh->native_handle(),THREAD_PRIORITY_TIME_CRITICAL); +#endif st=std::chrono::steady_clock::now();offset=0; timer->start(100); } @@ -414,6 +426,9 @@ void qmpMainWindow::on_pbNext_clicked() player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange(); player->setWaitVoice(qmpSettingsWindow::getSettingsIntf()->value("Midi/WaitVoice",1).toInt()); playerTh=new std::thread(&CMidiPlayer::playerThread,player); +#ifdef _WIN32 + SetThreadPriority(playerTh->native_handle(),THREAD_PRIORITY_TIME_CRITICAL); +#endif st=std::chrono::steady_clock::now();offset=0; timer->start(100); } @@ -439,6 +454,9 @@ void qmpMainWindow::selectionChanged() player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange(); player->setWaitVoice(qmpSettingsWindow::getSettingsIntf()->value("Midi/WaitVoice",1).toInt()); playerTh=new std::thread(&CMidiPlayer::playerThread,player); +#ifdef _WIN32 + SetThreadPriority(playerTh->native_handle(),THREAD_PRIORITY_TIME_CRITICAL); +#endif st=std::chrono::steady_clock::now();offset=0; timer->start(100); } diff --git a/qmpmidiplay.cpp b/qmpmidiplay.cpp index 8da2963..6f69e33 100644 --- a/qmpmidiplay.cpp +++ b/qmpmidiplay.cpp @@ -87,7 +87,7 @@ void CMidiPlayer::processEvent(const SEvent *e) case 0x01:case 0x02:case 0x03: case 0x04:case 0x05:case 0x06: case 0x07: - if(e->str)puts(e->str); + //if(e->str)puts(e->str); break; } } @@ -146,6 +146,7 @@ void CMidiPlayer::processEventStub(const SEvent *e) void w32usleep(uint64_t t) { uint64_t st=0,ct=0; + timeBeginPeriod(1); QueryPerformanceCounter((LARGE_INTEGER*)&st); do{ if(t>10000+(ct-st)*1000000/pf)Sleep((t-(ct-st)*1000000/pf)/2000); @@ -153,6 +154,7 @@ void w32usleep(uint64_t t) else std::this_thread::yield(); QueryPerformanceCounter((LARGE_INTEGER*)&ct); }while((ct-st)*1000000<t*pf); + timeEndPeriod(1); } #endif void CMidiPlayer::playEvents() @@ -165,7 +167,7 @@ void CMidiPlayer::playEvents() if(tcstop||!midiFile||tceptr>=midiFile->getEventCount())break; if(resumed)resumed=false; else -#ifdef _WIN32 +#if 0 w32usleep((midiFile->getEvent(tceptr)->time-ct)*(dpt/1000)); #else std::this_thread::sleep_for(std::chrono::nanoseconds(midiFile->getEvent(tceptr)->time-ct)*dpt); @@ -233,7 +235,10 @@ CMidiPlayer::CMidiPlayer(bool singleInst) QueryPerformanceFrequency((LARGE_INTEGER*)&pf); #endif } -CMidiPlayer::~CMidiPlayer(){if(singleInstance)fluidDeinitialize();} +CMidiPlayer::~CMidiPlayer() +{ + if(singleInstance)fluidDeinitialize(); +} void CMidiPlayer::playerPanic(bool reset) { if(reset)for(int i=0;i<16;++i) diff --git a/qmpmidiread.cpp b/qmpmidiread.cpp index 0bcf597..fd2e0d9 100644 --- a/qmpmidiread.cpp +++ b/qmpmidiread.cpp @@ -219,7 +219,6 @@ CMidiFile::CMidiFile(const char* fn) if(!(f=fopen(fn,"rb")))throw (fprintf(stderr,"E: file %s doesn't exist!\n",fn),2); chunkReader(1); for(uint32_t i=0;i<trk;i+=chunkReader(0)); - printf("%d note(s)\n",notes); fclose(f); std::sort(eventList,eventList+eventc,cmp); } |