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

Commit 1500df4a authored by Ray Essick's avatar Ray Essick Committed by Android (Google) Code Review
Browse files

Merge "Measure time flushing completed videos to storage"

parents 3263821d 0a98beca
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; }