summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d
diff options
context:
space:
mode:
authorLeena Winterrowd <lenhardw@codeaurora.org>2014-07-25 10:05:12 -0700
committerLinux Build Service Account <lnxbuild@localhost>2014-11-04 08:23:15 -0700
commit2f74516bcc7eb0f89f65260e90175b07513aed95 (patch)
treea62825dfc51dd8bd4e756f4a13726c654a620dee /src/com/android/gallery3d
parentfe9714c433347c9cd18b8cee9a42d9423233dafb (diff)
downloadandroid_packages_apps_Gallery2-2f74516bcc7eb0f89f65260e90175b07513aed95.tar.gz
android_packages_apps_Gallery2-2f74516bcc7eb0f89f65260e90175b07513aed95.tar.bz2
android_packages_apps_Gallery2-2f74516bcc7eb0f89f65260e90175b07513aed95.zip
Handle exception thrown for invalid track formats
MediaMuxer's addTrack() function can throw IllegalArgumentException if the track added is invalid or not supported. Catch this exception to out nicely and avoid an app crash. Change-Id: Id837179c56878dd7fef96d3b798bf427d82d7175
Diffstat (limited to 'src/com/android/gallery3d')
-rw-r--r--src/com/android/gallery3d/app/VideoUtils.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/com/android/gallery3d/app/VideoUtils.java b/src/com/android/gallery3d/app/VideoUtils.java
index 359cf76f5..76d5d1e02 100644
--- a/src/com/android/gallery3d/app/VideoUtils.java
+++ b/src/com/android/gallery3d/app/VideoUtils.java
@@ -156,11 +156,16 @@ public class VideoUtils {
if (selectCurrentTrack) {
extractor.selectTrack(i);
- int dstIndex = muxer.addTrack(format);
- indexMap.put(i, dstIndex);
- if (format.containsKey(MediaFormat.KEY_MAX_INPUT_SIZE)) {
- int newSize = format.getInteger(MediaFormat.KEY_MAX_INPUT_SIZE);
- bufferSize = newSize > bufferSize ? newSize : bufferSize;
+ try {
+ int dstIndex = muxer.addTrack(format);
+ indexMap.put(i, dstIndex);
+ if (format.containsKey(MediaFormat.KEY_MAX_INPUT_SIZE)) {
+ int newSize = format.getInteger(MediaFormat.KEY_MAX_INPUT_SIZE);
+ bufferSize = newSize > bufferSize ? newSize : bufferSize;
+ }
+ } catch (IllegalArgumentException e) {
+ Log.e(LOGTAG, "Unsupported format '" + mime + "'");
+ throw new IOException("Muxer does not support " + mime);
}
}
}