Skip to content

Commit 31fc929

Browse files
committed
corrected session name in Data invitation
session name was incorrect: it contained the remote session name, not the local session name. It did not cause an issue as the session name of the control invitation is used (most of the time)
1 parent 17a1b7b commit 31fc929

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

src/AppleMIDI.hpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,20 @@ 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+
#ifndef ONE_PARTICIPANT
121+
Participant<Settings> participant;
122+
#endif
123+
participant.kind = Listener;
124+
participant.ssrc = invitation.ssrc;
125+
participant.remoteIP = controlPort.remoteIP();
126+
participant.remotePort = controlPort.remotePort();
127+
participant.lastSyncExchangeTime = now;
120128
#ifdef KEEP_SESSION_NAME
129+
strncpy(participant.sessionName, invitation.sessionName, DefaultSettings::MaxSessionNameLen);
130+
#endif
131+
132+
#ifdef KEEP_SESSION_NAME
133+
// Re-use the invitation for acceptance. Overwrite sessionName with ours
121134
strncpy(invitation.sessionName, localName, DefaultSettings::MaxSessionNameLen);
122135
invitation.sessionName[DefaultSettings::MaxSessionNameLen] = '\0';
123136
#endif
@@ -166,19 +179,7 @@ void AppleMIDISession<UdpClass, Settings, Platform>::ReceivedControlInvitation(A
166179
#endif
167180
return;
168181
}
169-
170-
#ifndef ONE_PARTICIPANT
171-
Participant<Settings> participant;
172-
#endif
173-
participant.kind = Listener;
174-
participant.ssrc = invitation.ssrc;
175-
participant.remoteIP = controlPort.remoteIP();
176-
participant.remotePort = controlPort.remotePort();
177-
participant.lastSyncExchangeTime = now;
178-
#ifdef KEEP_SESSION_NAME
179-
strncpy(participant.sessionName, invitation.sessionName, DefaultSettings::MaxSessionNameLen);
180-
#endif
181-
182+
182183
#ifndef ONE_PARTICIPANT
183184
participants.push_back(participant);
184185
#endif
@@ -205,6 +206,12 @@ void AppleMIDISession<UdpClass, Settings, Platform>::ReceivedDataInvitation(Appl
205206
return;
206207
}
207208

209+
#ifdef KEEP_SESSION_NAME
210+
// Re-use the invitation for acceptance. Overwrite sessionName with ours
211+
strncpy(invitation.sessionName, localName, DefaultSettings::MaxSessionNameLen);
212+
invitation.sessionName[DefaultSettings::MaxSessionNameLen] = '\0';
213+
#endif
214+
208215
// writeInvitation will alter the values of the invitation,
209216
// in order to safe memory and computing cycles its easier to make a copy
210217
// of the ssrc here.
@@ -217,7 +224,7 @@ void AppleMIDISession<UdpClass, Settings, Platform>::ReceivedDataInvitation(Appl
217224
// Inform that we have an established connection
218225
if (nullptr != _connectedCallback)
219226
#ifdef KEEP_SESSION_NAME
220-
_connectedCallback(ssrc_, invitation.sessionName);
227+
_connectedCallback(ssrc_, pParticipant->sessionName);
221228
#else
222229
_connectedCallback(ssrc_, nullptr);
223230
#endif

0 commit comments

Comments
 (0)