diff options
author | Ashok Bhat <ashok.bhat@arm.com> | 2014-01-06 13:45:09 +0000 |
---|---|---|
committer | David Butcher <david.butcher@arm.com> | 2014-01-15 13:09:27 +0000 |
commit | 075e9a19ce645752f8282bc19c91b25978a7dc52 (patch) | |
tree | fce385509995923df2b7bb567081337fed25c6e5 /media/jni/android_media_MediaPlayer.cpp | |
parent | 337aa376c09bb97a48afe075b4018f030445534f (diff) | |
download | frameworks_base-075e9a19ce645752f8282bc19c91b25978a7dc52.zip frameworks_base-075e9a19ce645752f8282bc19c91b25978a7dc52.tar.gz frameworks_base-075e9a19ce645752f8282bc19c91b25978a7dc52.tar.bz2 |
AArch64: Use long for pointers in media classes
For storing pointers, long is used in media classes,
as native pointers can be 64-bit.
In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use
of jint instead of int in JNI function prototypes)
Change-Id: Idc4ca0124d03df7f9cef412488abafd020e5e774
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
Diffstat (limited to 'media/jni/android_media_MediaPlayer.cpp')
-rw-r--r-- | media/jni/android_media_MediaPlayer.cpp | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp index 5e3fb1a..9d0d5a6 100644 --- a/media/jni/android_media_MediaPlayer.cpp +++ b/media/jni/android_media_MediaPlayer.cpp @@ -133,21 +133,21 @@ void JNIMediaPlayerListener::notify(int msg, int ext1, int ext2, const Parcel *o static sp<MediaPlayer> getMediaPlayer(JNIEnv* env, jobject thiz) { Mutex::Autolock l(sLock); - MediaPlayer* const p = (MediaPlayer*)env->GetIntField(thiz, fields.context); + MediaPlayer* const p = (MediaPlayer*)env->GetLongField(thiz, fields.context); return sp<MediaPlayer>(p); } static sp<MediaPlayer> setMediaPlayer(JNIEnv* env, jobject thiz, const sp<MediaPlayer>& player) { Mutex::Autolock l(sLock); - sp<MediaPlayer> old = (MediaPlayer*)env->GetIntField(thiz, fields.context); + sp<MediaPlayer> old = (MediaPlayer*)env->GetLongField(thiz, fields.context); if (player.get()) { player->incStrong((void*)setMediaPlayer); } if (old != 0) { old->decStrong((void*)setMediaPlayer); } - env->SetIntField(thiz, fields.context, (int)player.get()); + env->SetLongField(thiz, fields.context, (jlong)player.get()); return old; } @@ -244,7 +244,7 @@ android_media_MediaPlayer_setDataSourceFD(JNIEnv *env, jobject thiz, jobject fil static sp<IGraphicBufferProducer> getVideoSurfaceTexture(JNIEnv* env, jobject thiz) { - IGraphicBufferProducer * const p = (IGraphicBufferProducer*)env->GetIntField(thiz, fields.surface_texture); + IGraphicBufferProducer * const p = (IGraphicBufferProducer*)env->GetLongField(thiz, fields.surface_texture); return sp<IGraphicBufferProducer>(p); } @@ -293,7 +293,7 @@ setVideoSurface(JNIEnv *env, jobject thiz, jobject jsurface, jboolean mediaPlaye } } - env->SetIntField(thiz, fields.surface_texture, (int)new_st.get()); + env->SetLongField(thiz, fields.surface_texture, (jlong)new_st.get()); // This will fail if the media player has not been initialized yet. This // can be the case if setDisplay() on MediaPlayer.java has been called @@ -384,7 +384,7 @@ android_media_MediaPlayer_isPlaying(JNIEnv *env, jobject thiz) sp<MediaPlayer> mp = getMediaPlayer(env, thiz); if (mp == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return false; + return JNI_FALSE; } const jboolean is_playing = mp->isPlaying(); @@ -393,7 +393,7 @@ android_media_MediaPlayer_isPlaying(JNIEnv *env, jobject thiz) } static void -android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, int msec) +android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, jint msec) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); if (mp == NULL ) { @@ -404,7 +404,7 @@ android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, int msec) process_media_player_call( env, thiz, mp->seekTo(msec), NULL, NULL ); } -static int +static jint android_media_MediaPlayer_getVideoWidth(JNIEnv *env, jobject thiz) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -418,10 +418,10 @@ android_media_MediaPlayer_getVideoWidth(JNIEnv *env, jobject thiz) w = 0; } ALOGV("getVideoWidth: %d", w); - return w; + return (jint) w; } -static int +static jint android_media_MediaPlayer_getVideoHeight(JNIEnv *env, jobject thiz) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -435,11 +435,11 @@ android_media_MediaPlayer_getVideoHeight(JNIEnv *env, jobject thiz) h = 0; } ALOGV("getVideoHeight: %d", h); - return h; + return (jint) h; } -static int +static jint android_media_MediaPlayer_getCurrentPosition(JNIEnv *env, jobject thiz) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -450,10 +450,10 @@ android_media_MediaPlayer_getCurrentPosition(JNIEnv *env, jobject thiz) int msec; process_media_player_call( env, thiz, mp->getCurrentPosition(&msec), NULL, NULL ); ALOGV("getCurrentPosition: %d (msec)", msec); - return msec; + return (jint) msec; } -static int +static jint android_media_MediaPlayer_getDuration(JNIEnv *env, jobject thiz) { sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -464,7 +464,7 @@ android_media_MediaPlayer_getDuration(JNIEnv *env, jobject thiz) int msec; process_media_player_call( env, thiz, mp->getDuration(&msec), NULL, NULL ); ALOGV("getDuration: %d (msec)", msec); - return msec; + return (jint) msec; } static void @@ -480,7 +480,7 @@ android_media_MediaPlayer_reset(JNIEnv *env, jobject thiz) } static void -android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, int streamtype) +android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, jint streamtype) { ALOGV("setAudioStreamType: %d", streamtype); sp<MediaPlayer> mp = getMediaPlayer(env, thiz); @@ -510,21 +510,21 @@ android_media_MediaPlayer_isLooping(JNIEnv *env, jobject thiz) sp<MediaPlayer> mp = getMediaPlayer(env, thiz); if (mp == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return false; + return JNI_FALSE; } - return mp->isLooping(); + return mp->isLooping() ? JNI_TRUE : JNI_FALSE; } static void -android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, float leftVolume, float rightVolume) +android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, jfloat leftVolume, jfloat rightVolume) { - ALOGV("setVolume: left %f right %f", leftVolume, rightVolume); + ALOGV("setVolume: left %f right %f", (float) leftVolume, (float) rightVolume); sp<MediaPlayer> mp = getMediaPlayer(env, thiz); if (mp == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); return; } - process_media_player_call( env, thiz, mp->setVolume(leftVolume, rightVolume), NULL, NULL ); + process_media_player_call( env, thiz, mp->setVolume((float) leftVolume, (float) rightVolume), NULL, NULL ); } // Sends the request and reply parcels to the media player via the @@ -544,7 +544,7 @@ android_media_MediaPlayer_invoke(JNIEnv *env, jobject thiz, // Don't use process_media_player_call which use the async loop to // report errors, instead returns the status. - return media_player->invoke(*request, reply); + return (jint) media_player->invoke(*request, reply); } // Sends the new filter to the client. @@ -564,7 +564,7 @@ android_media_MediaPlayer_setMetadataFilter(JNIEnv *env, jobject thiz, jobject r return UNKNOWN_ERROR; } - return media_player->setMetadataFilter(*filter); + return (jint) media_player->setMetadataFilter(*filter); } static jboolean @@ -574,14 +574,14 @@ android_media_MediaPlayer_getMetadata(JNIEnv *env, jobject thiz, jboolean update sp<MediaPlayer> media_player = getMediaPlayer(env, thiz); if (media_player == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return false; + return JNI_FALSE; } Parcel *metadata = parcelForJavaObject(env, reply); if (metadata == NULL ) { jniThrowException(env, "java/lang/RuntimeException", "Reply parcel is null"); - return false; + return JNI_FALSE; } metadata->freeData(); @@ -589,7 +589,11 @@ android_media_MediaPlayer_getMetadata(JNIEnv *env, jobject thiz, jboolean update // metadata. Note however that the parcel actually starts with the // return code so you should not rewind the parcel using // setDataPosition(0). - return media_player->getMetadata(update_only, apply_filter, metadata) == OK; + if (media_player->getMetadata(update_only, apply_filter, metadata) == OK) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } } // This function gets some field IDs, which in turn causes class initialization. @@ -605,7 +609,7 @@ android_media_MediaPlayer_native_init(JNIEnv *env) return; } - fields.context = env->GetFieldID(clazz, "mNativeContext", "I"); + fields.context = env->GetFieldID(clazz, "mNativeContext", "J"); if (fields.context == NULL) { return; } @@ -616,7 +620,7 @@ android_media_MediaPlayer_native_init(JNIEnv *env) return; } - fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "I"); + fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "J"); if (fields.surface_texture == NULL) { return; } @@ -696,7 +700,7 @@ static jint android_media_MediaPlayer_get_audio_session_id(JNIEnv *env, jobject return 0; } - return mp->getAudioSessionId(); + return (jint) mp->getAudioSessionId(); } static void @@ -733,7 +737,7 @@ android_media_MediaPlayer_pullBatteryData(JNIEnv *env, jobject thiz, jobject jav Parcel *reply = parcelForJavaObject(env, java_reply); - return service->pullBatteryData(reply); + return (jint) service->pullBatteryData(reply); } static jint @@ -772,7 +776,7 @@ android_media_MediaPlayer_setRetransmitEndpoint(JNIEnv *env, jobject thiz, jniThrowException(env, "java/lang/IllegalStateException", NULL); } - return ret; + return (jint) ret; } static void |