FR: MidiOutput::hasPendingMessages()


I would like to request a very simple change, to allow querying of a MIDI output to determine whether or not it has messages which are waiting to be sent. When calling MidiOutput::sendBlockOfMessages(), it would be helpful to know when all messages in the passed MIDI buffer have been sent (or not), but currently there is no way to check this because MidiOutput::firstMessage is private. Therefore I suggest a small change; something like the following:

--- a/modules/juce_audio_devices/midi_io/juce_MidiDevices.cpp
+++ b/modules/juce_audio_devices/midi_io/juce_MidiDevices.cpp
@@ -73,6 +73,11 @@ void MidiOutput::sendBlockOfMessages (const MidiBuffer& buffer,
+bool MidiOutput::hasPendingMessages() const
+    return firstMessage != nullptr;
 void MidiOutput::clearAllPendingMessages()
     const ScopedLock sl (lock);
--- a/modules/juce_audio_devices/midi_io/juce_MidiDevices.h
+++ b/modules/juce_audio_devices/midi_io/juce_MidiDevices.h
@@ -333,6 +333,8 @@ public:
     /** Gets rid of any midi messages that had been added by sendBlockOfMessages(). */
     void clearAllPendingMessages();
+    bool hasPendingMessages() const;
     /** Starts up a background thread so that the device can send blocks of data.
         Call this to get the device ready, before using sendBlockOfMessages().