summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2013-09-04 22:29:19 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-04 22:29:19 +0000
commit04c58e9ec12c65c15738ba456f18a1f36416b0cc (patch)
tree5fb7dc84961333fc93327395c882bd78610c2e5e /core/jni
parentdbb0b824a7e1dc6909988ec06a46158c05d26a92 (diff)
parent948c2e6ff46d65942277f2e0e9ce0c038972b9d8 (diff)
downloadframeworks_base-04c58e9ec12c65c15738ba456f18a1f36416b0cc.zip
frameworks_base-04c58e9ec12c65c15738ba456f18a1f36416b0cc.tar.gz
frameworks_base-04c58e9ec12c65c15738ba456f18a1f36416b0cc.tar.bz2
Merge "Java API for AudioTrack timestamps" into klp-dev
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/android_media_AudioTrack.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp
index 51ba52a..225bf06 100644
--- a/core/jni/android_media_AudioTrack.cpp
+++ b/core/jni/android_media_AudioTrack.cpp
@@ -742,6 +742,30 @@ static jint android_media_AudioTrack_get_latency(JNIEnv *env, jobject thiz) {
// ----------------------------------------------------------------------------
+static jint android_media_AudioTrack_get_timestamp(JNIEnv *env, jobject thiz, jlongArray jTimestamp) {
+ sp<AudioTrack> lpTrack = getAudioTrack(env, thiz);
+
+ if (lpTrack == NULL) {
+ ALOGE("Unable to retrieve AudioTrack pointer for getTimestamp()");
+ return AUDIOTRACK_ERROR;
+ }
+ AudioTimestamp timestamp;
+ status_t status = lpTrack->getTimestamp(timestamp);
+ if (status == OK) {
+ jlong* nTimestamp = (jlong *) env->GetPrimitiveArrayCritical(jTimestamp, NULL);
+ if (nTimestamp == NULL) {
+ ALOGE("Unable to get array for getTimestamp()");
+ return AUDIOTRACK_ERROR;
+ }
+ nTimestamp[0] = (jlong) timestamp.mPosition;
+ nTimestamp[1] = (jlong) ((timestamp.mTime.tv_sec * 1000000000LL) + timestamp.mTime.tv_nsec);
+ env->ReleasePrimitiveArrayCritical(jTimestamp, nTimestamp, 0);
+ }
+ return (jint) android_media_translateErrorCode(status);
+}
+
+
+// ----------------------------------------------------------------------------
static jint android_media_AudioTrack_set_loop(JNIEnv *env, jobject thiz,
jint loopStart, jint loopEnd, jint loopCount) {
sp<AudioTrack> lpTrack = getAudioTrack(env, thiz);
@@ -869,6 +893,7 @@ static JNINativeMethod gMethods[] = {
{"native_set_position", "(I)I", (void *)android_media_AudioTrack_set_position},
{"native_get_position", "()I", (void *)android_media_AudioTrack_get_position},
{"native_get_latency", "()I", (void *)android_media_AudioTrack_get_latency},
+ {"native_get_timestamp", "([J)I", (void *)android_media_AudioTrack_get_timestamp},
{"native_set_loop", "(III)I", (void *)android_media_AudioTrack_set_loop},
{"native_reload_static", "()I", (void *)android_media_AudioTrack_reload},
{"native_get_output_sample_rate",