Skip to content

Instantly share code, notes, and snippets.

@courville
Created December 10, 2019 17:27
Show Gist options
  • Save courville/48c992e4c0541caa44eeab3acf503f17 to your computer and use it in GitHub Desktop.
Save courville/48c992e4c0541caa44eeab3acf503f17 to your computer and use it in GitHub Desktop.
SurfaceController.java.diff
diff --git a/src/main/java/com/archos/mediacenter/video/player/SurfaceController.java b/src/main/java/com/archos/mediacenter/video/player/SurfaceController.java
index 089df18..4ebd723 100644
--- a/src/main/java/com/archos/mediacenter/video/player/SurfaceController.java
+++ b/src/main/java/com/archos/mediacenter/video/player/SurfaceController.java
@@ -20,6 +20,7 @@ import com.archos.medialib.IMediaPlayer;
import android.graphics.SurfaceTexture;
import android.opengl.GLSurfaceView;
+import android.os.Build;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@@ -27,6 +28,12 @@ import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import static com.archos.filecorelibrary.FileExtendedInfo.FileType.File;
+
public class SurfaceController {
private static String TAG = "SurfaceController";
private static boolean DBG = true;
@@ -232,6 +239,25 @@ public class SurfaceController {
mEffectType = type;
updateSurface();
}
+
+ public void setAmlogicMode(String mode) {
+ //#define SCREEN_MODE_NORMAL 0
+ //#define SCREEN_MODE_FULL_STRETCH 1
+ //#define SCREEN_MODE_4_3 2
+ //#define SCREEN_MODE_16_9 3
+ //#define SCREEN_MODE_NONLINEAR 4
+ //#define SCREEN_MODE_NORMAL_NOSCALEUP 5
+ //#define SCREEN_MODE_CROP_FULL 6
+ //#define SCREEN_MODE_CROP 7
+ if (Build.HARDWARE == "amlogic") {
+ try (FileWriter writer = new FileWriter("/sys/class/video/screen_mode");
+ BufferedWriter bw = new BufferedWriter(writer)) {
+ bw.write(mode);
+ } catch (IOException e) {
+ Log.w(TAG, "updateSurface: caught IOException: ", e);
+ }
+ }
+ }
synchronized private void updateSurface() {
if (DBG) Log.d(TAG, "updateSurface");
@@ -283,6 +309,7 @@ public class SurfaceController {
dw = (int) (dh * ar);
if (DBG) Log.d(TAG, "updateSurface: VideoFormat.ORIGINAL dar>=ar dw=" + dw);
}
+ if (Build.HARDWARE == "amlogic") setAmlogicMode("1");
break;
case VideoFormat.FULLSCREEN:
if (dar < ar) {
@@ -296,6 +323,7 @@ public class SurfaceController {
cropW = 1.0f;
if (DBG) Log.d(TAG, "updateSurface: VideoFormat.FULLSCREEN dar>=ar 16:9 movie on 4:3 screen dw=" + dw + ", dh=" + dh + ", cropW=" + cropW + ", cropH=" + cropH);
}
+ if (Build.HARDWARE == "amlogic") setAmlogicMode("6");
break;
case VideoFormat.AUTO: {
cropW = 1.0f;
@@ -310,6 +338,7 @@ public class SurfaceController {
cropW = (float)dw / (float)(dh * ar);
if (DBG) Log.d(TAG, "updateSurface: VideoFormat.AUTO dar<=ar dw=" + dw + ", dh=" + dh);
}
+ if (Build.HARDWARE == "amlogic") setAmlogicMode("1");
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment