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
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp
index cadd691..de25291 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.cpp
+++ b/media/libmediaplayerservice/StagefrightRecorder.cpp
@@ -260,6 +260,9 @@
         return -EBADF;
     }
 
+    // start with a clean, empty file
+    ftruncate(fd, 0);
+
     if (mOutputFd >= 0) {
         ::close(mOutputFd);
     }