Skip to content

Commit d55bbdf

Browse files
committed
AppleMIDI dont log failure to send if no peer
Check if we think we have a peer before attempting to send
1 parent 7ad582f commit d55bbdf

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/udpmididevice.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ void CUDPMIDIDevice::OnAppleMIDIDataReceived(const u8* pData, size_t nSize)
111111

112112
void CUDPMIDIDevice::OnAppleMIDIConnect(const CIPAddress* pIPAddress, const char* pName)
113113
{
114+
m_bIsAppleMIDIConnected = true;
114115
LOGNOTE("RTP Device connected");
115116
}
116117

117118
void CUDPMIDIDevice::OnAppleMIDIDisconnect(const CIPAddress* pIPAddress, const char* pName)
118119
{
120+
m_bIsAppleMIDIConnected = false;
119121
LOGNOTE("RTP Device disconnected");
120122
}
121123

@@ -126,7 +128,7 @@ void CUDPMIDIDevice::OnUDPMIDIDataReceived(const u8* pData, size_t nSize)
126128

127129
void CUDPMIDIDevice::Send(const u8 *pMessage, size_t nLength, unsigned nCable)
128130
{
129-
if (m_pAppleMIDIParticipant) {
131+
if (m_pAppleMIDIParticipant && m_bIsAppleMIDIConnected) {
130132
bool res = m_pAppleMIDIParticipant->SendMIDIToHost(pMessage, nLength);
131133
if (!res) {
132134
LOGERR("Failed to send %u bytes to RTP-MIDI host", (unsigned long) nLength);

src/udpmididevice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class CUDPMIDIDevice : CAppleMIDIHandler, CUDPMIDIHandler, public CMIDIDevice
5151
CConfig *m_pConfig;
5252
CBcmRandomNumberGenerator m_Random;
5353
CAppleMIDIParticipant* m_pAppleMIDIParticipant; // AppleMIDI participant instance
54+
bool m_bIsAppleMIDIConnected = false;
5455
CUDPMIDIReceiver* m_pUDPMIDIReceiver;
5556
CSocket* m_pUDPSendSocket = nullptr;
5657
CIPAddress m_UDPDestAddress;

0 commit comments

Comments
 (0)