diff options
author | YuanQY <yuanqingyun@gmail.com> | 2013-02-22 19:51:05 +0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2013-03-24 15:27:08 -0700 |
commit | 6e0d2a6e0ce70073f977844200f477b9c552a11e (patch) | |
tree | 7db31cec08ff439861e6b5e6fc263f0cb24cf87d | |
parent | 7d0a8e3019352e1a2f1147b23abc7989bf695243 (diff) | |
download | frameworks_base-6e0d2a6e0ce70073f977844200f477b9c552a11e.zip frameworks_base-6e0d2a6e0ce70073f977844200f477b9c552a11e.tar.gz frameworks_base-6e0d2a6e0ce70073f977844200f477b9c552a11e.tar.bz2 |
Fix resource leak: When call MediaMetadataRetriever.setDataSource or getFrameAtTime should ensure call release in finally to avoid resource leak
Patch set 2: Remove unnecessary white spaces
Change-Id: I49a7f2fb99dc8b9560e7c17421125356e45a87ac
-rwxr-xr-x | media/java/android/media/videoeditor/VideoEditorImpl.java | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/media/java/android/media/videoeditor/VideoEditorImpl.java b/media/java/android/media/videoeditor/VideoEditorImpl.java index 2446c2f..0953050 100755 --- a/media/java/android/media/videoeditor/VideoEditorImpl.java +++ b/media/java/android/media/videoeditor/VideoEditorImpl.java @@ -1834,10 +1834,20 @@ public class VideoEditorImpl implements VideoEditor { String filename = mI.getFilename(); if (mI instanceof MediaVideoItem) { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); - retriever.setDataSource(filename); - Bitmap bitmap = retriever.getFrameAtTime(); - retriever.release(); - retriever = null; + Bitmap bitmap = null; + try { + retriever.setDataSource(filename); + bitmap = retriever.getFrameAtTime(); + } catch (RuntimeException ex) { + // Ignore failures while cleaning up. + } finally { + try { + retriever.release(); + } catch (RuntimeException ex) { + // Ignore failures while cleaning up. + } + } + if (bitmap == null) { String msg = "Thumbnail extraction from " + filename + " failed"; |