Fix UDP thread terminations

This commit is contained in:
Cameron Gutman
2016-02-15 18:46:14 -05:00
parent ceb9504ade
commit 5de8f4c98c
4 changed files with 34 additions and 29 deletions

View File

@@ -80,12 +80,16 @@ static void ReceiveThreadProc(void* context) {
}
}
err = (int)recv(rtpSocket, buffer, receiveSize, 0);
if (err <= 0) {
Limelog("Video Receive: recv() failed: %d\n", (int)LastSocketError());
err = recvUdpSocket(rtpSocket, buffer, receiveSize);
if (err < 0) {
Limelog("Video Receive: recvUdpSocket() failed: %d\n", (int)LastSocketError());
ListenerCallbacks.connectionTerminated(LastSocketError());
break;
}
else if (err == 0) {
// Receive timed out; try again
continue;
}
memcpy(&buffer[receiveSize], &err, sizeof(int));
@@ -161,9 +165,6 @@ void stopVideoStream(void) {
if (firstFrameSocket != INVALID_SOCKET) {
shutdownTcpSocket(firstFrameSocket);
}
if (rtpSocket != INVALID_SOCKET) {
shutdownUdpSocket(rtpSocket);
}
PltJoinThread(&udpPingThread);
PltJoinThread(&receiveThread);