diff options
author | Oliver Woodman <olly@google.com> | 2013-06-26 12:43:36 +0100 |
---|---|---|
committer | Oliver Woodman <olly@google.com> | 2013-07-01 22:30:18 +0100 |
commit | e64716ad01e52a9ce034369142c41d0333dd8dd4 (patch) | |
tree | 093ec11d7af4bfdfe245796d78baac0f8b3b4f71 /media | |
parent | e9df511e2018eb6a296408d09e355c6f2c77ae59 (diff) | |
download | frameworks_base-e64716ad01e52a9ce034369142c41d0333dd8dd4.zip frameworks_base-e64716ad01e52a9ce034369142c41d0333dd8dd4.tar.gz frameworks_base-e64716ad01e52a9ce034369142c41d0333dd8dd4.tar.bz2 |
Expose latency methods through AudioManager and AudioTrack.
There's a longer term plan to fix audio/video sync, but
this gets the Java level to parity with the native level,
and allows applications in Java to achieve sync in the
same way as the native media player. APIs are left as hidden
for now.
Bug: 9587132
Change-Id: Iaf70baac1ffb50ef48e03355163158568fbd0fe9
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/AudioManager.java | 11 | ||||
-rw-r--r-- | media/java/android/media/AudioSystem.java | 1 | ||||
-rw-r--r-- | media/java/android/media/AudioTrack.java | 14 |
3 files changed, 26 insertions, 0 deletions
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index 8295c5f..93ab401 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -2553,4 +2553,15 @@ public class AudioManager { } } + /** + * Returns the estimated latency for the given stream type in milliseconds. + * + * DO NOT UNHIDE. The existing approach for doing A/V sync has too many problems. We need + * a better solution. + * @hide + */ + public int getOutputLatency(int streamType) { + return AudioSystem.getOutputLatency(streamType); + } + } diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java index 4a33743..d42bfd4 100644 --- a/media/java/android/media/AudioSystem.java +++ b/media/java/android/media/AudioSystem.java @@ -401,5 +401,6 @@ public class AudioSystem // helpers for android.media.AudioManager.getProperty(), see description there for meaning public static native int getPrimaryOutputSamplingRate(); public static native int getPrimaryOutputFrameCount(); + public static native int getOutputLatency(int stream); } diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java index 399eb7b..9768a78 100644 --- a/media/java/android/media/AudioTrack.java +++ b/media/java/android/media/AudioTrack.java @@ -628,6 +628,18 @@ public class AudioTrack } /** + * Returns this track's estimated latency in milliseconds. This includes the latency due + * to AudioTrack buffer size, AudioMixer (if any) and audio hardware driver. + * + * DO NOT UNHIDE. The existing approach for doing A/V sync has too many problems. We need + * a better solution. + * @hide + */ + public int getLatency() { + return native_get_latency(); + } + + /** * Returns the hardware output sample rate */ static public int getNativeOutputSampleRate(int streamType) { @@ -1256,6 +1268,8 @@ public class AudioTrack private native final int native_set_position(int position); private native final int native_get_position(); + private native final int native_get_latency(); + private native final int native_set_loop(int start, int end, int loopCount); static private native final int native_get_output_sample_rate(int streamType); |