From 97166e26b34557cb5e9d62f4bb715c74b49776b5 Mon Sep 17 00:00:00 2001 From: Bassam Helal Date: Sat, 27 Mar 2021 21:23:30 +0000 Subject: [PATCH] Surrounded all std::err calls regarding message queue limit reached with a #if defined(__RTMIDI_DEBUG__) in order to prevent console flooding when message queue limit is reached, this fixes the issue I filed here: https://github.com/thestk/rtmidi/issues/236 --- RtMidi.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/RtMidi.cpp b/RtMidi.cpp index 781d5b7c..dd27bbb7 100644 --- a/RtMidi.cpp +++ b/RtMidi.cpp @@ -829,8 +829,12 @@ static void midiInputCallback( const MIDIPacketList *list, void *procRef, void * } else { // As long as we haven't reached our queue size limit, push the message. - if ( !data->queue.push( message ) ) + if (!data->queue.push(message)) + { +#if defined(__RTMIDI_DEBUG__) std::cerr << "\nMidiInCore: message queue limit reached!!\n\n"; +#endif + } } message.bytes.clear(); } @@ -888,8 +892,12 @@ static void midiInputCallback( const MIDIPacketList *list, void *procRef, void * } else { // As long as we haven't reached our queue size limit, push the message. - if ( !data->queue.push( message ) ) + if (!data->queue.push(message)) + { +#if defined(__RTMIDI_DEBUG__) std::cerr << "\nMidiInCore: message queue limit reached!!\n\n"; +#endif + } } message.bytes.clear(); } @@ -1725,8 +1733,12 @@ static void *alsaMidiHandler( void *ptr ) } else { // As long as we haven't reached our queue size limit, push the message. - if ( !data->queue.push( message ) ) + if (!data->queue.push(message)) + { +#if defined(__RTMIDI_DEBUG__) std::cerr << "\nMidiInAlsa: message queue limit reached!!\n\n"; +#endif + } } } @@ -2529,8 +2541,12 @@ static void CALLBACK midiInputCallback( HMIDIIN /*hmin*/, } else { // As long as we haven't reached our queue size limit, push the message. - if ( !data->queue.push( apiData->message ) ) + if (!data->queue.push(apiData->message)) + { +#if defined(__RTMIDI_DEBUG__) std::cerr << "\nMidiInWinMM: message queue limit reached!!\n\n"; +#endif + } } // Clear the vector for the next input message. @@ -3070,8 +3086,12 @@ static int jackProcessIn( jack_nframes_t nframes, void *arg ) } else { // As long as we haven't reached our queue size limit, push the message. - if ( !rtData->queue.push( message ) ) + if (!rtData->queue.push(message)) + { +#if defined(__RTMIDI_DEBUG__) std::cerr << "\nMidiInJack: message queue limit reached!!\n\n"; +#endif + } } } }