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

Commit dc1c7bf0 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 39e6e6a6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -62,4 +62,7 @@

    <!-- 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>
</resources>
+5 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import android.view.Surface;
import android.view.WindowManager;

import com.android.systemui.mediaprojection.MediaProjectionCaptureTarget;
import com.android.systemui.res.R;

import java.io.Closeable;
import java.io.File;
@@ -89,6 +90,7 @@ public class ScreenMediaRecorder extends MediaProjection.Callback {
    private ScreenRecordingAudioSource mAudioSource;
    private final MediaProjectionCaptureTarget mCaptureRegion;
    private final Handler mHandler;
    private int mMaxRefreshRate;

    private Context mContext;
    ScreenMediaRecorderListener mListener;
@@ -103,6 +105,8 @@ public class ScreenMediaRecorder extends MediaProjection.Callback {
        mCaptureRegion = captureRegion;
        mListener = listener;
        mAudioSource = audioSource;
        mMaxRefreshRate = mContext.getResources().getInteger(
                R.integer.config_screenRecorderMaxFramerate);
    }

    private void prepare() throws IOException, RemoteException, RuntimeException {
@@ -141,6 +145,7 @@ public class ScreenMediaRecorder extends MediaProjection.Callback {
        WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
        wm.getDefaultDisplay().getRealMetrics(metrics);
        int refreshRate = (int) wm.getDefaultDisplay().getRefreshRate();
        if (mMaxRefreshRate != 0 && refreshRate > mMaxRefreshRate) refreshRate = mMaxRefreshRate;
        int[] dimens = getSupportedSize(metrics.widthPixels, metrics.heightPixels, refreshRate);
        int width = dimens[0];
        int height = dimens[1];