diff options
author | Glenn Kasten <gkasten@google.com> | 2013-09-10 16:36:23 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-09-10 16:36:23 +0000 |
commit | d9f4e0cf2c2466d9e05f8562e55d342934f7ed0d (patch) | |
tree | 61d396071e36083323a00b779f66875855fe7892 | |
parent | 1d2daa7809b58c226410c0060d7837de0a29888a (diff) | |
parent | 596fb8e7969cafdf7f25dfdc97372be4c0950cc3 (diff) | |
download | frameworks_base-d9f4e0cf2c2466d9e05f8562e55d342934f7ed0d.zip frameworks_base-d9f4e0cf2c2466d9e05f8562e55d342934f7ed0d.tar.gz frameworks_base-d9f4e0cf2c2466d9e05f8562e55d342934f7ed0d.tar.bz2 |
Merge "AudioTrack.getTimestamp() return type is now boolean" into klp-dev
-rw-r--r-- | api/current.txt | 2 | ||||
-rw-r--r-- | media/java/android/media/AudioTrack.java | 27 |
2 files changed, 13 insertions, 16 deletions
diff --git a/api/current.txt b/api/current.txt index b8caad8..218b325 100644 --- a/api/current.txt +++ b/api/current.txt @@ -12172,7 +12172,7 @@ package android.media { method public int getSampleRate(); method public int getState(); method public int getStreamType(); - method public android.media.AudioTimestamp getTimestamp(android.media.AudioTimestamp); + method public boolean getTimestamp(android.media.AudioTimestamp); method public void pause() throws java.lang.IllegalStateException; method public void play() throws java.lang.IllegalStateException; method public void release(); diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java index 788257d..78a37c5 100644 --- a/media/java/android/media/AudioTrack.java +++ b/media/java/android/media/AudioTrack.java @@ -746,31 +746,28 @@ public class AudioTrack * If you need such features, consider implementing them at application level. * * @param timestamp a reference to a non-null AudioTimestamp instance allocated - * and owned by caller, or null. - * @return that same instance if timestamp parameter is non-null and a timestamp is available, - * or a reference to a new AudioTimestamp instance which is now owned by caller - * if timestamp parameter is null and a timestamp is available, - * or null if no timestamp is available. In either successful case, + * and owned by caller. + * @return true if a timestamp is available, or false if no timestamp is available. + * If a timestamp if available, * the AudioTimestamp instance is filled in with a position in frame units, together * with the estimated time when that frame was presented or is committed to * be presented. * In the case that no timestamp is available, any supplied instance is left unaltered. */ - public AudioTimestamp getTimestamp(AudioTimestamp timestamp) + public boolean getTimestamp(AudioTimestamp timestamp) { + if (timestamp == null) { + throw new IllegalArgumentException(); + } // It's unfortunate, but we have to either create garbage every time or use synchronized long[] longArray = new long[2]; int ret = native_get_timestamp(longArray); - if (ret == SUCCESS) { - if (timestamp == null) { - timestamp = new AudioTimestamp(); - } - timestamp.framePosition = longArray[0]; - timestamp.nanoTime = longArray[1]; - } else { - timestamp = null; + if (ret != SUCCESS) { + return false; } - return timestamp; + timestamp.framePosition = longArray[0]; + timestamp.nanoTime = longArray[1]; + return true; } |