mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-26 06:22:45 +00:00
Correct some callers of time functions that expect monotonic clocks
This commit is contained in:
parent
766c9628b0
commit
e53a1f90b0
@ -8,6 +8,7 @@ import android.content.Context;
|
|||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -270,7 +271,7 @@ public class AnalogStick extends VirtualControllerElement {
|
|||||||
// We also release the deadzone if the user keeps the stick pressed for a bit to allow
|
// We also release the deadzone if the user keeps the stick pressed for a bit to allow
|
||||||
// them to make precise movements.
|
// them to make precise movements.
|
||||||
stick_state = (stick_state == STICK_STATE.MOVED_ACTIVE ||
|
stick_state = (stick_state == STICK_STATE.MOVED_ACTIVE ||
|
||||||
System.currentTimeMillis() - timeLastClick > timeoutDeadzone ||
|
SystemClock.uptimeMillis() - timeLastClick > timeoutDeadzone ||
|
||||||
movement_radius > radius_dead_zone) ?
|
movement_radius > radius_dead_zone) ?
|
||||||
STICK_STATE.MOVED_ACTIVE : STICK_STATE.MOVED_IN_DEAD_ZONE;
|
STICK_STATE.MOVED_ACTIVE : STICK_STATE.MOVED_IN_DEAD_ZONE;
|
||||||
|
|
||||||
@ -311,7 +312,7 @@ public class AnalogStick extends VirtualControllerElement {
|
|||||||
stick_state = STICK_STATE.MOVED_IN_DEAD_ZONE;
|
stick_state = STICK_STATE.MOVED_IN_DEAD_ZONE;
|
||||||
// check for double click
|
// check for double click
|
||||||
if (lastClickState == CLICK_STATE.SINGLE &&
|
if (lastClickState == CLICK_STATE.SINGLE &&
|
||||||
timeLastClick + timeoutDoubleClick > System.currentTimeMillis()) {
|
timeLastClick + timeoutDoubleClick > SystemClock.uptimeMillis()) {
|
||||||
click_state = CLICK_STATE.DOUBLE;
|
click_state = CLICK_STATE.DOUBLE;
|
||||||
notifyOnDoubleClick();
|
notifyOnDoubleClick();
|
||||||
} else {
|
} else {
|
||||||
@ -319,7 +320,7 @@ public class AnalogStick extends VirtualControllerElement {
|
|||||||
notifyOnClick();
|
notifyOnClick();
|
||||||
}
|
}
|
||||||
// reset last click timestamp
|
// reset last click timestamp
|
||||||
timeLastClick = System.currentTimeMillis();
|
timeLastClick = SystemClock.uptimeMillis();
|
||||||
// set item pressed and update
|
// set item pressed and update
|
||||||
setPressed(true);
|
setPressed(true);
|
||||||
break;
|
break;
|
||||||
|
@ -20,6 +20,7 @@ import android.media.MediaFormat;
|
|||||||
import android.media.MediaCodec.BufferInfo;
|
import android.media.MediaCodec.BufferInfo;
|
||||||
import android.media.MediaCodec.CodecException;
|
import android.media.MediaCodec.CodecException;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.util.Range;
|
import android.util.Range;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
|
|
||||||
@ -410,7 +411,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
//
|
//
|
||||||
if (initialException != null) {
|
if (initialException != null) {
|
||||||
// This isn't the first time we've had an exception processing video
|
// This isn't the first time we've had an exception processing video
|
||||||
if (System.currentTimeMillis() - initialExceptionTimestamp >= EXCEPTION_REPORT_DELAY_MS) {
|
if (SystemClock.uptimeMillis() - initialExceptionTimestamp >= EXCEPTION_REPORT_DELAY_MS) {
|
||||||
// It's been over 3 seconds and we're still getting exceptions. Throw the original now.
|
// It's been over 3 seconds and we're still getting exceptions. Throw the original now.
|
||||||
if (!reportedCrash) {
|
if (!reportedCrash) {
|
||||||
reportedCrash = true;
|
reportedCrash = true;
|
||||||
@ -427,7 +428,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
else {
|
else {
|
||||||
initialException = new RendererException(this, e);
|
initialException = new RendererException(this, e);
|
||||||
}
|
}
|
||||||
initialExceptionTimestamp = System.currentTimeMillis();
|
initialExceptionTimestamp = SystemClock.uptimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -637,7 +638,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lastFrameNumber == 0) {
|
if (lastFrameNumber == 0) {
|
||||||
activeWindowVideoStats.measurementStartTimestamp = System.currentTimeMillis();
|
activeWindowVideoStats.measurementStartTimestamp = SystemClock.uptimeMillis();
|
||||||
} else if (frameNumber != lastFrameNumber && frameNumber != lastFrameNumber + 1) {
|
} else if (frameNumber != lastFrameNumber && frameNumber != lastFrameNumber + 1) {
|
||||||
// We can receive the same "frame" multiple times if it's an IDR frame.
|
// We can receive the same "frame" multiple times if it's an IDR frame.
|
||||||
// In that case, each frame start NALU is submitted independently.
|
// In that case, each frame start NALU is submitted independently.
|
||||||
@ -649,7 +650,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
lastFrameNumber = frameNumber;
|
lastFrameNumber = frameNumber;
|
||||||
|
|
||||||
// Flip stats windows roughly every second
|
// Flip stats windows roughly every second
|
||||||
if (System.currentTimeMillis() >= activeWindowVideoStats.measurementStartTimestamp + 1000) {
|
if (SystemClock.uptimeMillis() >= activeWindowVideoStats.measurementStartTimestamp + 1000) {
|
||||||
if (prefs.enablePerfOverlay) {
|
if (prefs.enablePerfOverlay) {
|
||||||
VideoStats lastTwo = new VideoStats();
|
VideoStats lastTwo = new VideoStats();
|
||||||
lastTwo.add(lastWindowVideoStats);
|
lastTwo.add(lastWindowVideoStats);
|
||||||
@ -682,7 +683,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
|
|||||||
globalVideoStats.add(activeWindowVideoStats);
|
globalVideoStats.add(activeWindowVideoStats);
|
||||||
lastWindowVideoStats.copy(activeWindowVideoStats);
|
lastWindowVideoStats.copy(activeWindowVideoStats);
|
||||||
activeWindowVideoStats.clear();
|
activeWindowVideoStats.clear();
|
||||||
activeWindowVideoStats.measurementStartTimestamp = System.currentTimeMillis();
|
activeWindowVideoStats.measurementStartTimestamp = SystemClock.uptimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
activeWindowVideoStats.totalFramesReceived++;
|
activeWindowVideoStats.totalFramesReceived++;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.limelight.binding.video;
|
package com.limelight.binding.video;
|
||||||
|
|
||||||
|
import android.os.SystemClock;
|
||||||
|
|
||||||
class VideoStats {
|
class VideoStats {
|
||||||
|
|
||||||
long decoderTimeMs;
|
long decoderTimeMs;
|
||||||
@ -50,7 +52,7 @@ class VideoStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VideoStatsFps getFps() {
|
VideoStatsFps getFps() {
|
||||||
float elapsed = (System.currentTimeMillis() - this.measurementStartTimestamp) / (float) 1000;
|
float elapsed = (SystemClock.uptimeMillis() - this.measurementStartTimestamp) / (float) 1000;
|
||||||
|
|
||||||
VideoStatsFps fps = new VideoStatsFps();
|
VideoStatsFps fps = new VideoStatsFps();
|
||||||
if (elapsed > 0) {
|
if (elapsed > 0) {
|
||||||
|
@ -40,6 +40,7 @@ import android.net.NetworkCapabilities;
|
|||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
@ -176,7 +177,7 @@ public class ComputerManagerService extends Service {
|
|||||||
LimeLog.warning(tuple.computer.name + " is offline (try " + offlineCount + ")");
|
LimeLog.warning(tuple.computer.name + " is offline (try " + offlineCount + ")");
|
||||||
offlineCount++;
|
offlineCount++;
|
||||||
} else {
|
} else {
|
||||||
tuple.lastSuccessfulPollMs = System.currentTimeMillis();
|
tuple.lastSuccessfulPollMs = SystemClock.elapsedRealtime();
|
||||||
offlineCount = 0;
|
offlineCount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,7 +208,7 @@ public class ComputerManagerService extends Service {
|
|||||||
synchronized (pollingTuples) {
|
synchronized (pollingTuples) {
|
||||||
for (PollingTuple tuple : pollingTuples) {
|
for (PollingTuple tuple : pollingTuples) {
|
||||||
// Enforce the poll data TTL
|
// Enforce the poll data TTL
|
||||||
if (System.currentTimeMillis() - tuple.lastSuccessfulPollMs > POLL_DATA_TTL_MS) {
|
if (SystemClock.elapsedRealtime() - tuple.lastSuccessfulPollMs > POLL_DATA_TTL_MS) {
|
||||||
LimeLog.info("Timing out polled state for "+tuple.computer.name);
|
LimeLog.info("Timing out polled state for "+tuple.computer.name);
|
||||||
tuple.computer.state = ComputerDetails.State.UNKNOWN;
|
tuple.computer.state = ComputerDetails.State.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user