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

Commit 7342d093 authored by Hangyu Kuang's avatar Hangyu Kuang Committed by android-build-merger
Browse files

Merge "(DO NOT MERGE) media: Don't wait at MediaRecorder::stop() if we haven't...

Merge "(DO NOT MERGE) media: Don't wait at MediaRecorder::stop() if we haven't received any frames." into oc-dr1-dev
am: 0f96fc77

Change-Id: Ia0eee918b5094278d929f06005fb373219ebd37a
parents 7cb56192 0f96fc77
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -44,6 +44,9 @@ const int32_t kDefaultHwVideoEncoderFormat = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEF
const int32_t kDefaultVideoEncoderDataSpace = HAL_DATASPACE_V0_BT709;

const int kStopTimeoutUs = 300000; // allow 1 sec for shutting down encoder
// allow maximum 1 sec for stop time offset. This limits the the delay in the
// input source.
const int kMaxStopTimeOffsetUs = 1000000;

struct MediaCodecSource::Puller : public AHandler {
    explicit Puller(const sp<MediaSource> &source);
@@ -1017,7 +1020,15 @@ void MediaCodecSource::onMessageReceived(const sp<AMessage> &msg) {
            if (mEncoder->getInputFormat(&inputFormat) == OK &&
                    inputFormat->findInt64("android._stop-time-offset-us", &stopTimeOffsetUs) &&
                    stopTimeOffsetUs > 0) {
                if (stopTimeOffsetUs > kMaxStopTimeOffsetUs) {
                    ALOGW("Source stopTimeOffsetUs %lld too large, limit at %lld us",
                        (long long)stopTimeOffsetUs, (long long)kMaxStopTimeOffsetUs);
                    stopTimeOffsetUs = kMaxStopTimeOffsetUs;
                }
                timeoutUs += stopTimeOffsetUs;
            } else {
                // Use kMaxStopTimeOffsetUs if stop time offset is not provided by input source
                timeoutUs = kMaxStopTimeOffsetUs;
            }
        } else {
            mPuller->stop();
+2 −1
Original line number Diff line number Diff line
@@ -1229,7 +1229,8 @@ status_t GraphicBufferSource::getStopTimeOffsetUs(int64_t *stopTimeOffsetUs) {
        ALOGW("Fail to return stopTimeOffsetUs as stop time is not set");
        return INVALID_OPERATION;
    }
    *stopTimeOffsetUs = mStopTimeUs - mLastFrameTimestampUs;
    *stopTimeOffsetUs =
        mLastFrameTimestampUs == -1 ? 0 : mStopTimeUs - mLastFrameTimestampUs;
    return OK;
}