From c3c57aceb3d971e22fc5732bb3153f1202889f7f Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 20 Jul 2020 04:12:38 +0100 Subject: [PATCH] Cleanup Signed-off-by: falkTX --- source/native-plugins/midi-base.hpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/native-plugins/midi-base.hpp b/source/native-plugins/midi-base.hpp index 0497cee9a..2dd71a025 100644 --- a/source/native-plugins/midi-base.hpp +++ b/source/native-plugins/midi-base.hpp @@ -233,6 +233,8 @@ public: void play(long double timePosFrame, const double frames, const double offset = 0.0) { + long double ldtime; + if (! fMutex.tryLock()) return; @@ -244,14 +246,14 @@ public: const RawMidiEvent* const rawMidiEvent(it.getValue(nullptr)); CARLA_SAFE_ASSERT_CONTINUE(rawMidiEvent != nullptr); - if (rawMidiEvent->time < timePosFrame) + ldtime = static_cast(rawMidiEvent->time); + + if (ldtime < timePosFrame) continue; - if (static_cast(rawMidiEvent->time) > timePosFrame + frames) + if (ldtime > timePosFrame + frames) break; - kPlayer->writeMidiEvent(fMidiPort, - static_cast(rawMidiEvent->time) - timePosFrame + offset, - rawMidiEvent); + kPlayer->writeMidiEvent(fMidiPort, ldtime + offset - timePosFrame, rawMidiEvent); } fMutex.unlock();