commit 41881a95ddbb9dfcdd9f01bb11196da8b3a8d883
parent 17e34687246b77e932bd1f55d85a1cd1324fb285
Author: Hans Petter Selasky <[email protected]>
Date: Sat, 19 Nov 2022 14:58:39 +0100
Let InMgr::flush() return a boolean indicating if all MIDI events have been processed or not.
Signed-off-by: Hans Petter Selasky <[email protected]>
Diffstat:
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/Nio/InMgr.cpp b/src/Nio/InMgr.cpp
@@ -91,12 +91,16 @@ void InMgr::putEvent(MidiEvent ev)
work.post();
}
-void InMgr::flush(unsigned frameStart, unsigned frameStop)
+bool InMgr::flush(unsigned frameStart, unsigned frameStop)
{
MidiEvent ev;
+ bool endReached = true;
+
while(!work.trywait()) {
queue.peak(ev);
if(ev.time < (int)frameStart || ev.time > (int)frameStop) {
+ //Check if end was reached
+ endReached = ev.time < (int)frameStart;
//Back out of transaction
work.post();
//printf("%d vs [%d..%d]\n",ev.time, frameStart, frameStop);
@@ -145,6 +149,7 @@ void InMgr::flush(unsigned frameStart, unsigned frameStop)
break;
}
}
+ return endReached;
}
bool InMgr::empty(void) const
diff --git a/src/Nio/InMgr.h b/src/Nio/InMgr.h
@@ -47,7 +47,7 @@ class InMgr
void putEvent(MidiEvent ev);
/**Flush the Midi Queue*/
- void flush(unsigned frameStart, unsigned frameStop);
+ bool flush(unsigned frameStart, unsigned frameStop);
bool empty() const;