Skip to content

Commit a2e9c6d

Browse files
committed
bug fix if ONE_PARTICIPANT defined
if ONE_PARTICIPANT is defined, connection was not established
1 parent c83f866 commit a2e9c6d

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-23
lines changed

src/AppleMIDI.h

+7
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ class AppleMIDISession
5353
#ifdef KEEP_SESSION_NAME
5454
strncpy(this->localName, sessionName, DefaultSettings::MaxSessionNameLen);
5555
#endif
56+
57+
#ifdef ONE_PARTICIPANT
58+
participant.ssrc = 0;
59+
#endif
5660
};
5761

5862
virtual ~AppleMIDISession()
@@ -121,6 +125,9 @@ class AppleMIDISession
121125

122126
void end()
123127
{
128+
#ifdef ONE_PARTICIPANT
129+
participant.ssrc = 0;
130+
#endif
124131
controlPort.stop();
125132
dataPort.stop();
126133
}

src/AppleMIDI.hpp

+23-23
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,28 @@ void AppleMIDISession<UdpClass, Settings, Platform>::ReceivedInvitation(AppleMID
117117
template <class UdpClass, class Settings, class Platform>
118118
void AppleMIDISession<UdpClass, Settings, Platform>::ReceivedControlInvitation(AppleMIDI_Invitation_t &invitation)
119119
{
120+
// ignore invitation of a participant already in the participant list
121+
#ifndef ONE_PARTICIPANT
122+
if (nullptr != getParticipantBySSRC(invitation.ssrc))
123+
#else
124+
if (participant.ssrc == invitation.ssrc)
125+
#endif
126+
return;
127+
128+
#ifndef ONE_PARTICIPANT
129+
if (participants.full())
130+
#else
131+
if (participant.ssrc != 0)
132+
#endif
133+
{
134+
writeInvitation(controlPort, controlPort.remoteIP(), controlPort.remotePort(), invitation, amInvitationRejected);
135+
#ifdef USE_EXT_CALLBACKS
136+
if (nullptr != _exceptionCallback)
137+
_exceptionCallback(ssrc, TooManyParticipantsException, 0);
138+
#endif
139+
return;
140+
}
141+
120142
#ifndef ONE_PARTICIPANT
121143
Participant<Settings> participant;
122144
#endif
@@ -157,29 +179,7 @@ void AppleMIDISession<UdpClass, Settings, Platform>::ReceivedControlInvitation(A
157179
break;
158180
}
159181
#endif
160-
161-
// ignore invitation of a participant already in the participant list
162-
#ifndef ONE_PARTICIPANT
163-
if (nullptr != getParticipantBySSRC(invitation.ssrc))
164-
#else
165-
if (participant.ssrc == invitation.ssrc)
166-
#endif
167-
return;
168-
169-
#ifndef ONE_PARTICIPANT
170-
if (participants.full())
171-
#else
172-
if (participant.ssrc != 0)
173-
#endif
174-
{
175-
writeInvitation(controlPort, controlPort.remoteIP(), controlPort.remotePort(), invitation, amInvitationRejected);
176-
#ifdef USE_EXT_CALLBACKS
177-
if (nullptr != _exceptionCallback)
178-
_exceptionCallback(ssrc, TooManyParticipantsException, 0);
179-
#endif
180-
return;
181-
}
182-
182+
183183
#ifndef ONE_PARTICIPANT
184184
participants.push_back(participant);
185185
#endif

0 commit comments

Comments
 (0)