mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-07-24 07:40:45 +00:00
Revert "Use connected datagram sockets for audio and video"
This causes problems on multi-homed GFE and Sunshine (prior to v0.21) hosts
because audio and video data can be sent back from an address different than
the one we used as our original destination address.
This reverts commit c13f4a323f.
This commit is contained in:
+9
-9
@@ -37,6 +37,12 @@ typedef struct _QUEUED_AUDIO_PACKET {
|
||||
|
||||
static void AudioPingThreadProc(void* context) {
|
||||
char legacyPingData[] = { 0x50, 0x49, 0x4E, 0x47 };
|
||||
LC_SOCKADDR saddr;
|
||||
|
||||
LC_ASSERT(AudioPortNumber != 0);
|
||||
|
||||
memcpy(&saddr, &RemoteAddr, sizeof(saddr));
|
||||
SET_PORT(&saddr, AudioPortNumber);
|
||||
|
||||
// We do not check for errors here. Socket errors will be handled
|
||||
// on the read-side in ReceiveThreadProc(). This avoids potential
|
||||
@@ -48,10 +54,10 @@ static void AudioPingThreadProc(void* context) {
|
||||
pingCount++;
|
||||
AudioPingPayload.sequenceNumber = BE32(pingCount);
|
||||
|
||||
send(rtpSocket, (char*)&AudioPingPayload, sizeof(AudioPingPayload), 0);
|
||||
sendto(rtpSocket, (char*)&AudioPingPayload, sizeof(AudioPingPayload), 0, (struct sockaddr*)&saddr, AddrLen);
|
||||
}
|
||||
else {
|
||||
send(rtpSocket, legacyPingData, sizeof(legacyPingData), 0);
|
||||
sendto(rtpSocket, legacyPingData, sizeof(legacyPingData), 0, (struct sockaddr*)&saddr, AddrLen);
|
||||
}
|
||||
|
||||
PltSleepMsInterruptible(&udpPingThread, 500);
|
||||
@@ -92,15 +98,9 @@ int notifyAudioPortNegotiationComplete(void) {
|
||||
return LastSocketFail();
|
||||
}
|
||||
|
||||
// Connect our audio socket to the target address and port
|
||||
int err = connectUdpSocket(rtpSocket, &RemoteAddr, AddrLen, AudioPortNumber);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
// We may receive audio before our threads are started, but that's okay. We'll
|
||||
// drop the first 1 second of audio packets to catch up with the backlog.
|
||||
err = PltCreateThread("AudioPing", AudioPingThreadProc, NULL, &udpPingThread);
|
||||
int err = PltCreateThread("AudioPing", AudioPingThreadProc, NULL, &udpPingThread);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user