From 48f8a05bae260efd456bdc77eb34d71bfd9b0f4e Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 19 Dec 2013 14:50:50 -0500 Subject: [PATCH] Increase the default receive buffers for the RTP sockets to avoid dropping packets while the receive thread is suspended by the OS scheduler. Windows uses particularly small (8KB) receive buffers by default which this should work around. --- .../src/com/limelight/nvstream/av/audio/AudioStream.java | 3 +++ .../src/com/limelight/nvstream/av/video/VideoStream.java | 2 ++ 2 files changed, 5 insertions(+) diff --git a/moonlight-common/src/com/limelight/nvstream/av/audio/AudioStream.java b/moonlight-common/src/com/limelight/nvstream/av/audio/AudioStream.java index f216c8f7..ff635b2b 100644 --- a/moonlight-common/src/com/limelight/nvstream/av/audio/AudioStream.java +++ b/moonlight-common/src/com/limelight/nvstream/av/audio/AudioStream.java @@ -18,6 +18,8 @@ public class AudioStream { public static final int RTP_PORT = 48000; public static final int RTCP_PORT = 47999; + public static final int RTP_RECV_BUFFER = 64 * 1024; + private LinkedBlockingQueue packets = new LinkedBlockingQueue(100); private DatagramSocket rtp; @@ -87,6 +89,7 @@ public class AudioStream { { rtp = new DatagramSocket(null); rtp.setReuseAddress(true); + rtp.setReceiveBufferSize(RTP_RECV_BUFFER); rtp.bind(new InetSocketAddress(RTP_PORT)); } diff --git a/moonlight-common/src/com/limelight/nvstream/av/video/VideoStream.java b/moonlight-common/src/com/limelight/nvstream/av/video/VideoStream.java index f15e32ee..813c453c 100644 --- a/moonlight-common/src/com/limelight/nvstream/av/video/VideoStream.java +++ b/moonlight-common/src/com/limelight/nvstream/av/video/VideoStream.java @@ -24,6 +24,7 @@ public class VideoStream { public static final int FIRST_FRAME_PORT = 47996; public static final int FIRST_FRAME_TIMEOUT = 5000; + public static final int RTP_RECV_BUFFER = 128 * 1024; private LinkedBlockingQueue packets = new LinkedBlockingQueue(100); @@ -124,6 +125,7 @@ public class VideoStream { { rtp = new DatagramSocket(null); rtp.setReuseAddress(true); + rtp.setReceiveBufferSize(RTP_RECV_BUFFER); rtp.bind(new InetSocketAddress(RTP_PORT)); }