mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-06-17 22:31:35 +00:00
Fix frame pacing issues on Snapdragon. Improve latency on Tegra (not perfect still).
This commit is contained in:
@@ -354,6 +354,7 @@ public class NvVideoStream {
|
|||||||
|
|
||||||
private void outputDisplayLoop(Thread t)
|
private void outputDisplayLoop(Thread t)
|
||||||
{
|
{
|
||||||
|
long nextFrameTimeUs = 0;
|
||||||
while (!t.isInterrupted())
|
while (!t.isInterrupted())
|
||||||
{
|
{
|
||||||
BufferInfo info = new BufferInfo();
|
BufferInfo info = new BufferInfo();
|
||||||
@@ -370,8 +371,23 @@ public class NvVideoStream {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (outIndex >= 0) {
|
if (outIndex >= 0) {
|
||||||
videoDecoder.releaseOutputBuffer(outIndex, true);
|
boolean render = false;
|
||||||
|
|
||||||
|
if (currentTimeUs() >= nextFrameTimeUs) {
|
||||||
|
render = true;
|
||||||
|
nextFrameTimeUs = computePresentationTime(60);
|
||||||
|
}
|
||||||
|
|
||||||
|
videoDecoder.releaseOutputBuffer(outIndex, render);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static long currentTimeUs() {
|
||||||
|
return System.nanoTime() / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long computePresentationTime(int frameRate) {
|
||||||
|
return currentTimeUs() + (1000000 / frameRate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user