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

Commit 0a98beca authored by Ray Essick's avatar Ray Essick
Browse files

Measure time flushing completed videos to storage

Measure the fsync() time at the end of video recording for mpeg4 files.
This is intended to be a short term measurement.
Timing is logged to logcat.

Bug: 174770856
Test: Video Capture & read logcat
Change-Id: I786521ec705c13e315627e2cfe1f63448b62567f
parent cf6c0423
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -1137,11 +1137,24 @@ status_t MPEG4Writer::release() {
    if (!truncatePreAllocation()) {
        if (err == OK) { err = ERROR_IO; }
    }

    // TODO(b/174770856) remove this measurement (and perhaps the fsync)
    nsecs_t sync_started = systemTime(SYSTEM_TIME_REALTIME);
    if (fsync(mFd) != 0) {
        ALOGW("(ignored)fsync err:%s(%d)", std::strerror(errno), errno);
        // Don't bubble up fsync error, b/157291505.
        // if (err == OK) { err = ERROR_IO; }
    }
    nsecs_t sync_finished = systemTime(SYSTEM_TIME_REALTIME);
    nsecs_t sync_elapsed_ns = sync_finished - sync_started;
    int64_t filesize = -1;
    struct stat statbuf;
    if (fstat(mFd, &statbuf) == 0) {
        filesize = statbuf.st_size;
    }
    ALOGD("final fsync() takes %" PRId64 " ms, file size %" PRId64,
          sync_elapsed_ns / 1000000, (int64_t) filesize);

    if (close(mFd) != 0) {
        ALOGE("close err:%s(%d)", std::strerror(errno), errno);
        if (err == OK) { err = ERROR_IO; }