From 7f587dc389eec8dd623ff8f1113cfaf6d9d58907 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 17 Oct 2014 17:03:58 -0700 Subject: [PATCH] Thread priority tweaks: Ensure renderer threads have higher priorities than the receive threads. Increase the priority of the resync thread to just below the video renderer so the control packet can be emitted ASAP. Lower the priority of the loss stats thread. Increase the priority of the input thread slightly above normal. --- .../src/com/limelight/nvstream/av/audio/AudioStream.java | 2 ++ .../src/com/limelight/nvstream/av/video/VideoStream.java | 2 +- .../src/com/limelight/nvstream/control/ControlStream.java | 2 ++ .../src/com/limelight/nvstream/input/ControllerStream.java | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) 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 f31af7fe..67bf9ed6 100644 --- a/moonlight-common/src/com/limelight/nvstream/av/audio/AudioStream.java +++ b/moonlight-common/src/com/limelight/nvstream/av/audio/AudioStream.java @@ -142,6 +142,7 @@ public class AudioStream { }; threads.add(t); t.setName("Audio - Player"); + t.setPriority(Thread.NORM_PRIORITY + 2); t.start(); } @@ -205,6 +206,7 @@ public class AudioStream { }; threads.add(t); t.setName("Audio - Receive"); + t.setPriority(Thread.NORM_PRIORITY + 1); t.start(); } 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 da0fd6d9..24157b1f 100644 --- a/moonlight-common/src/com/limelight/nvstream/av/video/VideoStream.java +++ b/moonlight-common/src/com/limelight/nvstream/av/video/VideoStream.java @@ -252,7 +252,7 @@ public class VideoStream { }; threads.add(t); t.setName("Video - Receive"); - t.setPriority(Thread.MAX_PRIORITY); + t.setPriority(Thread.MAX_PRIORITY - 1); t.start(); } diff --git a/moonlight-common/src/com/limelight/nvstream/control/ControlStream.java b/moonlight-common/src/com/limelight/nvstream/control/ControlStream.java index 0255d073..d015d603 100644 --- a/moonlight-common/src/com/limelight/nvstream/control/ControlStream.java +++ b/moonlight-common/src/com/limelight/nvstream/control/ControlStream.java @@ -171,6 +171,7 @@ public class ControlStream implements ConnectionStatusListener { } } }; + lossStatsThread.setPriority(Thread.MIN_PRIORITY + 1); lossStatsThread.setName("Control - Loss Stats Thread"); lossStatsThread.start(); @@ -220,6 +221,7 @@ public class ControlStream implements ConnectionStatusListener { } }; resyncThread.setName("Control - Resync Thread"); + resyncThread.setPriority(Thread.MAX_PRIORITY - 1); resyncThread.start(); } diff --git a/moonlight-common/src/com/limelight/nvstream/input/ControllerStream.java b/moonlight-common/src/com/limelight/nvstream/input/ControllerStream.java index ad2222f3..93c3702f 100644 --- a/moonlight-common/src/com/limelight/nvstream/input/ControllerStream.java +++ b/moonlight-common/src/com/limelight/nvstream/input/ControllerStream.java @@ -186,6 +186,7 @@ public class ControllerStream { } }; inputThread.setName("Input - Queue"); + inputThread.setPriority(Thread.NORM_PRIORITY + 1); inputThread.start(); }