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

Commit 69113e8c authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Truncate file before recording into it.

Recording into an existing file of non-zero length could leave old
data in the file after the recording ends. Best case that wastes
space, worst case it results in a file that's considered corrupt
on playback.

Change-Id: I2c77a107603b2b36790958360ff0856c2b28d677
parent f888020c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -260,6 +260,9 @@ status_t StagefrightRecorder::setOutputFile(int fd, int64_t offset, int64_t leng
        return -EBADF;
    }

    // start with a clean, empty file
    ftruncate(fd, 0);

    if (mOutputFd >= 0) {
        ::close(mOutputFd);
    }