mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 03:23:07 +00:00
Switch from ArrayBlockingQueues to LinkedBlockingQueues for increased throughput. Set thread priorities for the decoder and ping threads.
This commit is contained in:
parent
d9527a3810
commit
dd82573d08
@ -7,7 +7,7 @@ import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import com.limelight.nvstream.av.AvByteBufferDescriptor;
|
||||
import com.limelight.nvstream.av.AvRtpPacket;
|
||||
@ -23,7 +23,7 @@ public class NvAudioStream {
|
||||
public static final int RTP_PORT = 48000;
|
||||
public static final int RTCP_PORT = 47999;
|
||||
|
||||
private ArrayBlockingQueue<AvRtpPacket> packets = new ArrayBlockingQueue<AvRtpPacket>(100);
|
||||
private LinkedBlockingQueue<AvRtpPacket> packets = new LinkedBlockingQueue<AvRtpPacket>(100);
|
||||
|
||||
private AudioTrack track;
|
||||
|
||||
@ -171,9 +171,9 @@ public class NvAudioStream {
|
||||
return;
|
||||
}
|
||||
|
||||
track.write(samples.data, samples.offset, samples.length);
|
||||
track.write(samples.data, samples.offset, samples.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
threads.add(t);
|
||||
t.setName("Audio - Player");
|
||||
@ -243,6 +243,7 @@ public class NvAudioStream {
|
||||
}
|
||||
};
|
||||
threads.add(t);
|
||||
t.setPriority(Thread.MIN_PRIORITY);
|
||||
t.setName("Audio - Ping");
|
||||
t.start();
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import com.limelight.nvstream.av.AvByteBufferDescriptor;
|
||||
import com.limelight.nvstream.av.AvDecodeUnit;
|
||||
@ -31,7 +31,7 @@ public class NvVideoStream {
|
||||
|
||||
public static final int FIRST_FRAME_TIMEOUT = 5000;
|
||||
|
||||
private ArrayBlockingQueue<AvRtpPacket> packets = new ArrayBlockingQueue<AvRtpPacket>(100);
|
||||
private LinkedBlockingQueue<AvRtpPacket> packets = new LinkedBlockingQueue<AvRtpPacket>(100);
|
||||
|
||||
private InetAddress host;
|
||||
private DatagramSocket rtp;
|
||||
@ -207,6 +207,7 @@ public class NvVideoStream {
|
||||
};
|
||||
threads.add(t);
|
||||
t.setName("Video - Decoder");
|
||||
t.setPriority(Thread.MAX_PRIORITY);
|
||||
t.start();
|
||||
}
|
||||
|
||||
@ -302,6 +303,7 @@ public class NvVideoStream {
|
||||
};
|
||||
threads.add(t);
|
||||
t.setName("Video - Ping");
|
||||
t.setPriority(Thread.MIN_PRIORITY);
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,16 @@
|
||||
package com.limelight.nvstream.av.audio;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import com.limelight.nvstream.av.AvByteBufferDescriptor;
|
||||
import com.limelight.nvstream.av.AvRtpPacket;
|
||||
import com.limelight.nvstream.av.AvShortBufferDescriptor;
|
||||
|
||||
public class AvAudioDepacketizer {
|
||||
private ArrayBlockingQueue<AvShortBufferDescriptor> decodedUnits =
|
||||
new ArrayBlockingQueue<AvShortBufferDescriptor>(15);
|
||||
|
||||
private static final int DU_LIMIT = 15;
|
||||
private LinkedBlockingQueue<AvShortBufferDescriptor> decodedUnits =
|
||||
new LinkedBlockingQueue<AvShortBufferDescriptor>(DU_LIMIT);
|
||||
|
||||
// Sequencing state
|
||||
private short lastSequenceNumber;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.limelight.nvstream.av.video;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import com.limelight.nvstream.av.AvByteBufferDescriptor;
|
||||
import com.limelight.nvstream.av.AvDecodeUnit;
|
||||
@ -26,8 +26,8 @@ public class AvVideoDepacketizer {
|
||||
|
||||
private ConnectionStatusListener controlListener;
|
||||
|
||||
private static final int DU_LIMIT = 30;
|
||||
private ArrayBlockingQueue<AvDecodeUnit> decodedUnits = new ArrayBlockingQueue<AvDecodeUnit>(DU_LIMIT);
|
||||
private static final int DU_LIMIT = 15;
|
||||
private LinkedBlockingQueue<AvDecodeUnit> decodedUnits = new LinkedBlockingQueue<AvDecodeUnit>(DU_LIMIT);
|
||||
|
||||
public AvVideoDepacketizer(ConnectionStatusListener controlListener)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user