aboutsummaryrefslogtreecommitdiff
path: root/core/qmpmidiplay.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2019-05-26 15:55:28 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2019-05-26 15:55:28 +0800
commit7b03fd544837fbe0bc5a5373b60dfd5de50892e1 (patch)
treea343c4efea96295d60b6e4b7944b8fa23d118db0 /core/qmpmidiplay.cpp
parent3f72121ac41741d53e4916f1275cbd4f93259c4d (diff)
downloadQMidiPlayer-7b03fd544837fbe0bc5a5373b60dfd5de50892e1.tar.xz
Major code refactor continued and (mostly) concluded.
Removed all references to ICallback in official plugins. New flag field in SEvent. Further type usage corrections.
Diffstat (limited to 'core/qmpmidiplay.cpp')
-rw-r--r--core/qmpmidiplay.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/core/qmpmidiplay.cpp b/core/qmpmidiplay.cpp
index 1e0cf8c..28ca9e7 100644
--- a/core/qmpmidiplay.cpp
+++ b/core/qmpmidiplay.cpp
@@ -13,8 +13,12 @@ uint64_t pf;
CMidiPlayer* CMidiPlayer::ref=nullptr;
bool CMidiPlayer::processEvent(const SEvent *e)
{
+ SEvent fe(*e);
+ fe.flags&=0xfe;
+ if(tceptr>=eorder.size()-1||getEvent(tceptr+1)->time>e->time)
+ fe.flags|=0x01;
for(int i=0;i<16;++i)if(eventHandlerCB[i])
- eventHandlerCB[i]->callBack((void*)e,eventHandlerCBuserdata[i]);
+ eventHandlerCB[i]->callBack((void*)&fe,eventHandlerCBuserdata[i]);
for(auto i=event_handlers.begin();i!=event_handlers.end();++i)
i->second.first((void*)e,i->second.second);
uint8_t ch=e->type&0x0F;
@@ -162,7 +166,7 @@ void w32usleep(uint64_t t)
timeEndPeriod(1);
}
#endif
-SEvent* CMidiPlayer::getEvent(int id)
+SEvent* CMidiPlayer::getEvent(uint32_t id)
{
size_t t=eorder[id].first,e=eorder[id].second;
return &midiFile->tracks[t].eventList[e];
@@ -570,7 +574,9 @@ void CMidiPlayer::unsetFileReadFinishedCB(int id)
{fileReadFinishCB[id]=nullptr;fileReadFinishCBuserdata[id]=nullptr;}
int CMidiPlayer::registerEventHandler(callback_t cb,void *userdata)
{
- event_handlers[event_handlers_id++]=std::make_pair(cb,userdata);
+ int ret;
+ event_handlers[ret=event_handlers_id++]=std::make_pair(cb,userdata);
+ return ret;
}
void CMidiPlayer::unregisterEventHandler(int id)
{
@@ -578,7 +584,9 @@ void CMidiPlayer::unregisterEventHandler(int id)
}
int CMidiPlayer::registerEventReadHandler(callback_t cb,void *userdata)
{
- event_read_handlers[event_read_handlers_id++]=std::make_pair(cb,userdata);
+ int ret;
+ event_read_handlers[ret=event_read_handlers_id++]=std::make_pair(cb,userdata);
+ return ret;
}
void CMidiPlayer::unregisterEventReadHandler(int id)
{
@@ -586,7 +594,9 @@ void CMidiPlayer::unregisterEventReadHandler(int id)
}
int CMidiPlayer::registerFileReadFinishHook(callback_t cb,void *userdata)
{
- file_read_finish_hooks[file_read_finish_hooks_id++]=std::make_pair(cb,userdata);
+ int ret;
+ file_read_finish_hooks[ret=file_read_finish_hooks_id++]=std::make_pair(cb,userdata);
+ return ret;
}
void CMidiPlayer::unregisterFileReadFinishHook(int id)
{