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

Commit 76469cbe authored by Amy Zhang's avatar Amy Zhang Committed by Android (Google) Code Review
Browse files

Merge "Only allow RecordDVR to flush buffer when the DVR is stopped"

parents bfce445c 0317f6db
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ public class DvrRecorder implements AutoCloseable {
    private static int sInstantId = 0;
    private int mSegmentId = 0;
    private int mOverflow;
    private Boolean mIsStopped = null;

    private native int nativeAttachFilter(Filter filter);
    private native int nativeDetachFilter(Filter filter);
@@ -135,7 +136,13 @@ public class DvrRecorder implements AutoCloseable {
                .write(FrameworkStatsLog.TV_TUNER_DVR_STATUS, mUserId,
                    FrameworkStatsLog.TV_TUNER_DVR_STATUS__TYPE__RECORD,
                    FrameworkStatsLog.TV_TUNER_DVR_STATUS__STATE__STARTED, mSegmentId, 0);
        return nativeStartDvr();
        synchronized (mIsStopped) {
            int result = nativeStartDvr();
            if (result == Tuner.RESULT_SUCCESS) {
                mIsStopped = false;
            }
            return result;
        }
    }

    /**
@@ -152,7 +159,13 @@ public class DvrRecorder implements AutoCloseable {
                .write(FrameworkStatsLog.TV_TUNER_DVR_STATUS, mUserId,
                    FrameworkStatsLog.TV_TUNER_DVR_STATUS__TYPE__RECORD,
                    FrameworkStatsLog.TV_TUNER_DVR_STATUS__STATE__STOPPED, mSegmentId, mOverflow);
        return nativeStopDvr();
        synchronized (mIsStopped) {
            int result = nativeStopDvr();
            if (result == Tuner.RESULT_SUCCESS) {
                mIsStopped = true;
            }
            return result;
        }
    }

    /**
@@ -164,8 +177,14 @@ public class DvrRecorder implements AutoCloseable {
     */
    @Result
    public int flush() {
        synchronized (mIsStopped) {
            if (mIsStopped) {
                return nativeFlushDvr();
            }
            Log.w(TAG, "Cannot flush non-stopped Record DVR.");
            return Tuner.RESULT_INVALID_STATE;
        }
    }

    /**
     * Closes the DVR instance to release resources.