@@ -117,6 +117,28 @@ void AppleMIDISession<UdpClass, Settings, Platform>::ReceivedInvitation(AppleMID
117117template <class UdpClass , class Settings , class Platform >
118118void 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