From d1285ce7fc584198d8294722de736b79a42972bf Mon Sep 17 00:00:00 2001 From: newspacer Date: Wed, 20 Nov 2024 12:23:09 +0100 Subject: [PATCH] added helper function hasPendingMessages() Signed-off-by: newspacer --- modules/juce_audio_devices/midi_io/juce_MidiDevices.cpp | 5 +++++ modules/juce_audio_devices/midi_io/juce_MidiDevices.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/modules/juce_audio_devices/midi_io/juce_MidiDevices.cpp b/modules/juce_audio_devices/midi_io/juce_MidiDevices.cpp index 23b02c654167..0261793442f5 100644 --- a/modules/juce_audio_devices/midi_io/juce_MidiDevices.cpp +++ b/modules/juce_audio_devices/midi_io/juce_MidiDevices.cpp @@ -98,6 +98,11 @@ void MidiOutput::sendBlockOfMessages (const MidiBuffer& buffer, notify(); } +bool MidiOutput::hasPendingMessages() const +{ + return firstMessage != nullptr; +} + void MidiOutput::clearAllPendingMessages() { const ScopedLock sl (lock); diff --git a/modules/juce_audio_devices/midi_io/juce_MidiDevices.h b/modules/juce_audio_devices/midi_io/juce_MidiDevices.h index b22de5a8849a..436b02182b1f 100644 --- a/modules/juce_audio_devices/midi_io/juce_MidiDevices.h +++ b/modules/juce_audio_devices/midi_io/juce_MidiDevices.h @@ -420,6 +420,9 @@ class JUCE_API MidiOutput final : private Thread void sendBlockOfMessages (const MidiBuffer& buffer, double millisecondCounterToStartAt, double samplesPerSecondForBuffer); + + /** Returns true if there are pending midi messages */ + bool hasPendingMessages() const; /** Gets rid of any midi messages that had been added by sendBlockOfMessages(). */ void clearAllPendingMessages();