summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-04-20 19:37:26 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-04-20 19:37:26 +0000
commit7c33cc554d356cb28fd222c04090f70da2b27ae5 (patch)
tree6615c33618c92815c6b028ad278f94805fe97edf
parent28970f1138bc0c7e44fa7566aee18647c5f1f944 (diff)
parent2a747f8d533f12e54ca1edb72014beef1d00fbf0 (diff)
Merge "Make some minor improvements to MediaFormat" into rvc-dev
-rw-r--r--media/java/android/media/MediaFormat.java14
1 files changed, 5 insertions, 9 deletions
diff --git a/media/java/android/media/MediaFormat.java b/media/java/android/media/MediaFormat.java
index cbf2364b50a4..1bfa9991e5d2 100644
--- a/media/java/android/media/MediaFormat.java
+++ b/media/java/android/media/MediaFormat.java
@@ -1312,7 +1312,7 @@ public final class MediaFormat {
}
/**
- * Returns the value of an long key, or the default value if the key is missing.
+ * Returns the value of a long key, or the default value if the key is missing.
*
* @return defaultValue if the key does not exist or the stored value for the key is null
* @throws ClassCastException if the stored value for the key is int, float, ByteBuffer or
@@ -1340,19 +1340,15 @@ public final class MediaFormat {
}
/**
- * Returns the value of an float key, or the default value if the key is missing.
+ * Returns the value of a float key, or the default value if the key is missing.
*
* @return defaultValue if the key does not exist or the stored value for the key is null
* @throws ClassCastException if the stored value for the key is int, long, ByteBuffer or
* String
*/
public final float getFloat(@NonNull String name, float defaultValue) {
- try {
- return getFloat(name);
- } catch (NullPointerException e) {
- /* no such field or field is null */
- return defaultValue;
- }
+ Object value = mMap.get(name);
+ return value != null ? (float) value : defaultValue;
}
/**
@@ -1366,7 +1362,7 @@ public final class MediaFormat {
}
/**
- * Returns the value of an string key, or the default value if the key is missing.
+ * Returns the value of a string key, or the default value if the key is missing.
*
* @return defaultValue if the key does not exist or the stored value for the key is null
* @throws ClassCastException if the stored value for the key is int, long, float or ByteBuffer