Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit a993c313 authored by Kuba Wojciechowski's avatar Kuba Wojciechowski Committed by Michael Bestas
Browse files

Screenrecord: Allow limiting the max framerate

Some devices seem to have problems when running the screen recorder at
native resolution @ max fps (I'm looking at you surya). The symptoms may
include severe lagging in the recording or stuff like crashes when
stopping in a landscape orientation. Allow limiting the recorder fps to
fix these issues.

Test: record screen on surya with config_screenRecorderMaxFramerate==90
while screen is running @ 120Hz, observe a smooth video. Stop the
recording while in full screen landscape youtube video, observe no crash

Change-Id: I361c7ae4bf74f2dd67b86e960f8d2d6ef63f5b8f
parent 1dfcdc09
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -66,6 +66,9 @@
    <!-- Whether usage of the proximity sensor during doze is supported -->
    <bool name="doze_proximity_sensor_supported">true</bool>

    <!-- If not zero, limits the internal screen recorder's framerate to the set value. -->
    <integer name="config_screenRecorderMaxFramerate">0</integer>

    <!-- Whether to play turbulence noise after clicking the play button -->
    <bool name="config_turbulenceNoise">true</bool>
</resources>
+4 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ public class ScreenMediaRecorder extends MediaProjection.Callback {
    private final MediaProjectionCaptureTarget mCaptureRegion;
    private final Handler mHandler;
    private final int mDisplayId;
    private int mMaxRefreshRate;

    private Context mContext;
    ScreenMediaRecorderListener mListener;
@@ -111,6 +112,8 @@ public class ScreenMediaRecorder extends MediaProjection.Callback {
        mListener = listener;
        mAudioSource = audioSource;
        mDisplayId = displayId;
        mMaxRefreshRate = mContext.getResources().getInteger(
                com.android.systemui.res.R.integer.config_screenRecorderMaxFramerate);
    }

    private void prepare() throws IOException, RemoteException, RuntimeException {
@@ -155,6 +158,7 @@ public class ScreenMediaRecorder extends MediaProjection.Callback {
        Display display = dm.getDisplay(mDisplayId);
        display.getRealMetrics(metrics);
        int refreshRate = (int) display.getRefreshRate();
        if (mMaxRefreshRate != 0 && refreshRate > mMaxRefreshRate) refreshRate = mMaxRefreshRate;
        int[] dimens = getSupportedSize(metrics.widthPixels, metrics.heightPixels, refreshRate);
        int width = dimens[0];
        int height = dimens[1];