diff options
author | Lajos Molnar <lajos@google.com> | 2015-04-22 19:28:53 -0700 |
---|---|---|
committer | Lajos Molnar <lajos@google.com> | 2015-04-22 22:45:08 -0700 |
commit | c98f58efd147c574faa4a4f9956b5ab95e3027a5 (patch) | |
tree | fa26839226dea7268b05ba22b46be0a06e64d909 /media/jni/android_media_MediaPlayer.cpp | |
parent | c1d5487307aa5367bb321cafd9ac336beec39a7e (diff) | |
download | frameworks_base-c98f58efd147c574faa4a4f9956b5ab95e3027a5.zip frameworks_base-c98f58efd147c574faa4a4f9956b5ab95e3027a5.tar.gz frameworks_base-c98f58efd147c574faa4a4f9956b5ab95e3027a5.tar.bz2 |
media: add SyncSettings to MediaSync and MediaPlayer
Bug: 18249558
Change-Id: I76d7e20d0e0c2d1d24bf60ade6386986573476f0
Diffstat (limited to 'media/jni/android_media_MediaPlayer.cpp')
-rw-r--r-- | media/jni/android_media_MediaPlayer.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp index b79a6bb..2c61779 100644 --- a/media/jni/android_media_MediaPlayer.cpp +++ b/media/jni/android_media_MediaPlayer.cpp @@ -39,6 +39,7 @@ #include "utils/String8.h" #include "android_media_MediaDataSource.h" #include "android_media_PlaybackSettings.h" +#include "android_media_SyncSettings.h" #include "android_media_Utils.h" #include "android_os_Parcel.h" @@ -69,6 +70,7 @@ struct fields_t { static fields_t fields; static PlaybackSettings::fields_t gPlaybackSettingsFields; +static SyncSettings::fields_t gSyncSettingsFields; static Mutex sLock; @@ -476,6 +478,56 @@ android_media_MediaPlayer_getPlaybackSettings(JNIEnv *env, jobject thiz) } static void +android_media_MediaPlayer_setSyncSettings(JNIEnv *env, jobject thiz, jobject settings) +{ + sp<MediaPlayer> mp = getMediaPlayer(env, thiz); + if (mp == NULL) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return; + } + + SyncSettings scs; + scs.fillFromJobject(env, gSyncSettingsFields, settings); + ALOGV("setSyncSettings: %d:%d %d:%d %d:%f %d:%f", + scs.syncSourceSet, scs.syncSource, + scs.audioAdjustModeSet, scs.audioAdjustMode, + scs.toleranceSet, scs.tolerance, + scs.frameRateSet, scs.frameRate); + + // TODO: pass sync settings to mediaplayer when it supports it + // process_media_player_call(env, thiz, mp->setSyncSettings(scs), NULL, NULL); +} + +static jobject +android_media_MediaPlayer_getSyncSettings(JNIEnv *env, jobject thiz) +{ + sp<MediaPlayer> mp = getMediaPlayer(env, thiz); + if (mp == NULL) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return NULL; + } + + SyncSettings scs; + scs.syncSource = 0; // SYNC_SOURCE_DEFAULT + scs.audioAdjustMode = 0; // AUDIO_ADJUST_MODE_DEFAULT + scs.tolerance = 0.f; + scs.frameRate = 0.f; + + // TODO: get this from mediaplayer when it supports it + // process_media_player_call( + // env, thiz, mp->getSyncSettings(&scs), NULL, NULL); + ALOGV("getSyncSettings: %d %d %f %f", + scs.syncSource, scs.audioAdjustMode, scs.tolerance, scs.frameRate); + + scs.syncSourceSet = true; + scs.audioAdjustModeSet = true; + scs.toleranceSet = true; + scs.frameRateSet = false; + + return scs.asJobject(env, gSyncSettingsFields); +} + +static void android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, jint msec) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -760,6 +812,7 @@ android_media_MediaPlayer_native_init(JNIEnv *env) env->DeleteLocalRef(clazz); gPlaybackSettingsFields.init(env); + gSyncSettingsFields.init(env); } static void @@ -950,6 +1003,8 @@ static JNINativeMethod gMethods[] = { {"getVideoHeight", "()I", (void *)android_media_MediaPlayer_getVideoHeight}, {"setPlaybackSettings", "(Landroid/media/PlaybackSettings;)V", (void *)android_media_MediaPlayer_setPlaybackSettings}, {"getPlaybackSettings", "()Landroid/media/PlaybackSettings;", (void *)android_media_MediaPlayer_getPlaybackSettings}, + {"setSyncSettings", "(Landroid/media/SyncSettings;)V", (void *)android_media_MediaPlayer_setSyncSettings}, + {"getSyncSettings", "()Landroid/media/SyncSettings;", (void *)android_media_MediaPlayer_getSyncSettings}, {"seekTo", "(I)V", (void *)android_media_MediaPlayer_seekTo}, {"_pause", "()V", (void *)android_media_MediaPlayer_pause}, {"isPlaying", "()Z", (void *)android_media_MediaPlayer_isPlaying}, |