diff options
| author | 2021-02-22 21:43:20 +0000 | |
|---|---|---|
| committer | 2021-02-22 21:43:20 +0000 | |
| commit | 95868547ef1e41d7ff1622b5800363d8f71874e4 (patch) | |
| tree | cf5ca95c3763b68908558b56688d0d04b7f08233 | |
| parent | d2191dbad69698f6e955172e842595ce12bba1b5 (diff) | |
| parent | 88205a34e840fdd3ed043eca64775366332c28c2 (diff) | |
Merge "MediaMetrics: Add LogSessionId" into sc-dev
| -rw-r--r-- | core/jni/android_media_AudioTrack.cpp | 14 | ||||
| -rw-r--r-- | media/java/android/media/AudioTrack.java | 23 |
2 files changed, 37 insertions, 0 deletions
diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp index ad9a547bc332..da60a75ba900 100644 --- a/core/jni/android_media_AudioTrack.cpp +++ b/core/jni/android_media_AudioTrack.cpp @@ -1419,6 +1419,18 @@ static jint android_media_AudioTrack_getDualMonoMode(JNIEnv *env, jobject thiz, return nativeToJavaStatus(status); } +static void android_media_AudioTrack_setLogSessionId(JNIEnv *env, jobject thiz, + jstring jlogSessionId) { + sp<AudioTrack> track = getAudioTrack(env, thiz); + if (track == nullptr) { + jniThrowException(env, "java/lang/IllegalStateException", + "Unable to retrieve AudioTrack pointer for setLogSessionId()"); + } + ScopedUtfChars logSessionId(env, jlogSessionId); + ALOGV("%s: logSessionId %s", __func__, logSessionId.c_str()); + track->setLogSessionId(logSessionId.c_str()); +} + static void android_media_AudioTrack_setPlayerIId(JNIEnv *env, jobject thiz, jint playerIId) { sp<AudioTrack> track = getAudioTrack(env, thiz); if (track == nullptr) { @@ -1506,6 +1518,8 @@ static const JNINativeMethod gMethods[] = { (void *)android_media_AudioTrack_getAudioDescriptionMixLeveldB}, {"native_set_dual_mono_mode", "(I)I", (void *)android_media_AudioTrack_setDualMonoMode}, {"native_get_dual_mono_mode", "([I)I", (void *)android_media_AudioTrack_getDualMonoMode}, + {"native_setLogSessionId", "(Ljava/lang/String;)V", + (void *)android_media_AudioTrack_setLogSessionId}, {"native_setPlayerIId", "(I)V", (void *)android_media_AudioTrack_setPlayerIId}, }; diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java index ae3c671108ed..6fcb75616f0d 100644 --- a/media/java/android/media/AudioTrack.java +++ b/media/java/android/media/AudioTrack.java @@ -565,6 +565,11 @@ public class AudioTrack extends PlayerBase */ private int mOffloadPaddingFrames = 0; + /** + * The log session id used for metrics. + */ + private String mLogSessionId; + //-------------------------------- // Used exclusively by native code //-------------------- @@ -3968,6 +3973,23 @@ public class AudioTrack extends PlayerBase } } + /** + * Sets a string handle to this AudioTrack for metrics collection. + * + * @param logSessionId a string which is used to identify this object + * to the metrics service. + * @throws IllegalStateException if AudioTrack not initialized. + * + * @hide + */ + public void setLogSessionId(@NonNull String logSessionId) { + if (mState == STATE_UNINITIALIZED) { + throw new IllegalStateException("track not initialized"); + } + native_setLogSessionId(logSessionId); + mLogSessionId = logSessionId; + } + //--------------------------------------------------------- // Inner classes //-------------------- @@ -4203,6 +4225,7 @@ public class AudioTrack extends PlayerBase private native int native_get_audio_description_mix_level_db(float[] level); private native int native_set_dual_mono_mode(int dualMonoMode); private native int native_get_dual_mono_mode(int[] dualMonoMode); + private native void native_setLogSessionId(@NonNull String logSessionId); /** * Sets the audio service Player Interface Id. |