aboutsummaryrefslogtreecommitdiff
path: root/qmpmidiplay.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-03-19 11:53:26 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-03-19 11:53:26 +0800
commit6015dccd4a839d46749a3bf7c0e45263ac8870ca (patch)
treec15b1c06bb7464fe0c993fbda97f472d8fd7436e /qmpmidiplay.cpp
parent3270ec6072b333c548587621b141ee283beecc29 (diff)
downloadQMidiPlayer-6015dccd4a839d46749a3bf7c0e45263ac8870ca.tar.xz
Fairy Wars.
Diffstat (limited to 'qmpmidiplay.cpp')
-rw-r--r--qmpmidiplay.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/qmpmidiplay.cpp b/qmpmidiplay.cpp
index ebbf36e..8da2963 100644
--- a/qmpmidiplay.cpp
+++ b/qmpmidiplay.cpp
@@ -5,6 +5,7 @@
#include "qmpmidiplay.hpp"
#ifdef _WIN32
#include <windows.h>
+uint64_t pf;
#endif
void CMidiPlayer::fluidPreInitialize()
{
@@ -144,15 +145,14 @@ void CMidiPlayer::processEventStub(const SEvent *e)
#ifdef _WIN32
void w32usleep(uint64_t t)
{
- uint64_t st=0,ct=0,f=0;
- QueryPerformanceFrequency((LARGE_INTEGER*)&f);
+ uint64_t st=0,ct=0;
QueryPerformanceCounter((LARGE_INTEGER*)&st);
do{
- if(t>10000+(ct-st)*1000000/f)Sleep((t-(ct-st)*1000000/f)/2000);
- else if(t>5000+(ct-st)*1000000/f)Sleep(1);
+ if(t>10000+(ct-st)*1000000/pf)Sleep((t-(ct-st)*1000000/pf)/2000);
+ else if(t>5000+(ct-st)*1000000/pf)Sleep(1);
else std::this_thread::yield();
QueryPerformanceCounter((LARGE_INTEGER*)&ct);
- }while((ct-st)*1000000<t*f);
+ }while((ct-st)*1000000<t*pf);
}
#endif
void CMidiPlayer::playEvents()
@@ -229,6 +229,9 @@ CMidiPlayer::CMidiPlayer(bool singleInst)
{
midiFile=NULL;resumed=false;singleInstance=singleInst;
settings=NULL;synth=NULL;adriver=NULL;waitvoice=true;
+#ifdef _WIN32
+ QueryPerformanceFrequency((LARGE_INTEGER*)&pf);
+#endif
}
CMidiPlayer::~CMidiPlayer(){if(singleInstance)fluidDeinitialize();}
void CMidiPlayer::playerPanic(bool reset)