summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorAndy McFadden <fadden@android.com>2013-08-13 09:56:19 -0700
committerAndy McFadden <fadden@android.com>2013-08-13 09:56:19 -0700
commit46052913f307b1561f1661bb776fa29c0775758c (patch)
tree198b0f96f080c9110688e19bd65d51182ed99b1e /cmds
parentfe9611bd65a8d968d6512f6a83078ac064ec8e6e (diff)
downloadframeworks_av-46052913f307b1561f1661bb776fa29c0775758c.zip
frameworks_av-46052913f307b1561f1661bb776fa29c0775758c.tar.gz
frameworks_av-46052913f307b1561f1661bb776fa29c0775758c.tar.bz2
Better error message
Attempt to create the output file before handing it to MediaMuxer, which doesn't report file-open failures in a useful way. Change-Id: Ie24ff577dd50e185b4eb72575684d23a46f38d3d
Diffstat (limited to 'cmds')
-rw-r--r--cmds/screenrecord/screenrecord.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/cmds/screenrecord/screenrecord.cpp b/cmds/screenrecord/screenrecord.cpp
index 28fc00f..923f781 100644
--- a/cmds/screenrecord/screenrecord.cpp
+++ b/cmds/screenrecord/screenrecord.cpp
@@ -36,6 +36,7 @@
#include <media/ICrypto.h>
#include <stdio.h>
+#include <fcntl.h>
#include <signal.h>
#include <getopt.h>
@@ -599,7 +600,19 @@ int main(int argc, char* const argv[]) {
return 2;
}
- status_t err = recordScreen(argv[optind]);
+ // MediaMuxer tries to create the file in the constructor, but we don't
+ // learn about the failure until muxer.start(), which returns a generic
+ // error code without logging anything. We attempt to create the file
+ // now for better diagnostics.
+ const char* fileName = argv[optind];
+ int fd = open(fileName, O_CREAT | O_RDWR, 0644);
+ if (fd < 0) {
+ fprintf(stderr, "Unable to open '%s': %s\n", fileName, strerror(errno));
+ return 1;
+ }
+ close(fd);
+
+ status_t err = recordScreen(fileName);
ALOGD(err == NO_ERROR ? "success" : "failed");
return (int) err;
}