mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-25 22:13:04 +00:00
Reintroduce never drop frames option
This commit is contained in:
parent
5dac42646b
commit
362c466a16
@ -456,8 +456,8 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
|
|||||||
|
|
||||||
numFramesOut++;
|
numFramesOut++;
|
||||||
|
|
||||||
// Render the latest frame now if frame pacing is off
|
// Render the latest frame now if frame pacing isn't in balanced mode
|
||||||
if (prefs.framePacing == PreferenceConfiguration.FRAME_PACING_OFF) {
|
if (prefs.framePacing != PreferenceConfiguration.FRAME_PACING_BALANCED) {
|
||||||
// Get the last output buffer in the queue
|
// Get the last output buffer in the queue
|
||||||
while ((outIndex = videoDecoder.dequeueOutputBuffer(info, 0)) >= 0) {
|
while ((outIndex = videoDecoder.dequeueOutputBuffer(info, 0)) >= 0) {
|
||||||
videoDecoder.releaseOutputBuffer(lastIndex, false);
|
videoDecoder.releaseOutputBuffer(lastIndex, false);
|
||||||
@ -468,19 +468,31 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
|
|||||||
presentationTimeUs = info.presentationTimeUs;
|
presentationTimeUs = info.presentationTimeUs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (prefs.framePacing == PreferenceConfiguration.FRAME_PACING_MAX_SMOOTHNESS) {
|
||||||
// Use a PTS that will cause this frame to be dropped if another comes in within
|
// In max smoothness mode, we want to never drop frames
|
||||||
// the same V-sync period
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
videoDecoder.releaseOutputBuffer(lastIndex, System.nanoTime());
|
// Use a PTS that will cause this frame to never be dropped
|
||||||
|
videoDecoder.releaseOutputBuffer(lastIndex, 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
videoDecoder.releaseOutputBuffer(lastIndex, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
videoDecoder.releaseOutputBuffer(lastIndex, true);
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
// Use a PTS that will cause this frame to be dropped if another comes in within
|
||||||
|
// the same V-sync period
|
||||||
|
videoDecoder.releaseOutputBuffer(lastIndex, System.nanoTime());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
videoDecoder.releaseOutputBuffer(lastIndex, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activeWindowVideoStats.totalFramesRendered++;
|
activeWindowVideoStats.totalFramesRendered++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// For the frame pacing case, the Choreographer callback will handle rendering.
|
// For balanced frame pacing case, the Choreographer callback will handle rendering.
|
||||||
// We just put all frames into the output buffer queue and let it handle things.
|
// We just put all frames into the output buffer queue and let it handle things.
|
||||||
|
|
||||||
// Discard the oldest buffer if we've exceeded our limit.
|
// Discard the oldest buffer if we've exceeded our limit.
|
||||||
@ -570,9 +582,9 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
|
|||||||
public void start() {
|
public void start() {
|
||||||
startRendererThread();
|
startRendererThread();
|
||||||
|
|
||||||
// Start Choreographer callbacks for rendering with frame pacing enabled
|
// Start Choreographer callbacks for rendering with frame pacing in balanced mode
|
||||||
// NB: This must be done on a thread with a looper!
|
// NB: This must be done on a thread with a looper!
|
||||||
if (prefs.framePacing != PreferenceConfiguration.FRAME_PACING_OFF) {
|
if (prefs.framePacing == PreferenceConfiguration.FRAME_PACING_BALANCED) {
|
||||||
Handler h = new Handler(Looper.getMainLooper());
|
Handler h = new Handler(Looper.getMainLooper());
|
||||||
h.post(new Runnable() {
|
h.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -594,7 +606,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Halt further Choreographer callbacks
|
// Halt further Choreographer callbacks
|
||||||
if (prefs.framePacing != PreferenceConfiguration.FRAME_PACING_OFF) {
|
if (prefs.framePacing == PreferenceConfiguration.FRAME_PACING_BALANCED) {
|
||||||
Handler h = new Handler(Looper.getMainLooper());
|
Handler h = new Handler(Looper.getMainLooper());
|
||||||
h.post(new Runnable() {
|
h.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,8 +78,9 @@ public class PreferenceConfiguration {
|
|||||||
public static final int AUTOSELECT_H265 = 0;
|
public static final int AUTOSELECT_H265 = 0;
|
||||||
public static final int FORCE_H265_OFF = 1;
|
public static final int FORCE_H265_OFF = 1;
|
||||||
|
|
||||||
public static final int FRAME_PACING_OFF = 0;
|
public static final int FRAME_PACING_MIN_LATENCY = 0;
|
||||||
public static final int FRAME_PACING_ON = 1;
|
public static final int FRAME_PACING_BALANCED = 1;
|
||||||
|
public static final int FRAME_PACING_MAX_SMOOTHNESS = 2;
|
||||||
|
|
||||||
public static final String RES_360P = "640x360";
|
public static final String RES_360P = "640x360";
|
||||||
public static final String RES_480P = "854x480";
|
public static final String RES_480P = "854x480";
|
||||||
@ -276,16 +277,23 @@ public class PreferenceConfiguration {
|
|||||||
boolean legacyNeverDropFrames = prefs.getBoolean(LEGACY_DISABLE_FRAME_DROP_PREF_STRING, false);
|
boolean legacyNeverDropFrames = prefs.getBoolean(LEGACY_DISABLE_FRAME_DROP_PREF_STRING, false);
|
||||||
prefs.edit()
|
prefs.edit()
|
||||||
.remove(LEGACY_DISABLE_FRAME_DROP_PREF_STRING)
|
.remove(LEGACY_DISABLE_FRAME_DROP_PREF_STRING)
|
||||||
.putString(FRAME_PACING_PREF_STRING, legacyNeverDropFrames ? "smoothness" : "latency")
|
.putString(FRAME_PACING_PREF_STRING, legacyNeverDropFrames ? "balanced" : "latency")
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
String str = prefs.getString(FRAME_PACING_PREF_STRING, DEFAULT_FRAME_PACING);
|
String str = prefs.getString(FRAME_PACING_PREF_STRING, DEFAULT_FRAME_PACING);
|
||||||
if (str.equals("latency")) {
|
if (str.equals("latency")) {
|
||||||
return FRAME_PACING_OFF;
|
return FRAME_PACING_MIN_LATENCY;
|
||||||
|
}
|
||||||
|
else if (str.equals("balanced")) {
|
||||||
|
return FRAME_PACING_BALANCED;
|
||||||
|
}
|
||||||
|
else if (str.equals("smoothness")) {
|
||||||
|
return FRAME_PACING_MAX_SMOOTHNESS;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return FRAME_PACING_ON;
|
// Should never get here
|
||||||
|
return FRAME_PACING_MIN_LATENCY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,10 +97,12 @@
|
|||||||
|
|
||||||
<string-array name="video_frame_pacing_names">
|
<string-array name="video_frame_pacing_names">
|
||||||
<item>@string/pacing_latency</item>
|
<item>@string/pacing_latency</item>
|
||||||
|
<item>@string/pacing_balanced</item>
|
||||||
<item>@string/pacing_smoothness</item>
|
<item>@string/pacing_smoothness</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="video_frame_pacing_values" translatable="false">
|
<string-array name="video_frame_pacing_values" translatable="false">
|
||||||
<item>latency</item>
|
<item>latency</item>
|
||||||
|
<item>balanced</item>
|
||||||
<item>smoothness</item>
|
<item>smoothness</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -250,6 +250,7 @@
|
|||||||
|
|
||||||
<string name="title_frame_pacing">Video frame pacing</string>
|
<string name="title_frame_pacing">Video frame pacing</string>
|
||||||
<string name="summary_frame_pacing">Specify how to balance video latency and smoothness</string>
|
<string name="summary_frame_pacing">Specify how to balance video latency and smoothness</string>
|
||||||
<string name="pacing_latency">Prefer Lowest Latency</string>
|
<string name="pacing_latency">Prefer lowest latency</string>
|
||||||
<string name="pacing_smoothness">Prefer Smoothest Video</string>
|
<string name="pacing_balanced">Balanced</string>
|
||||||
|
<string name="pacing_smoothness">Prefer smoothest video (may significantly increase latency)</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user