diff options
author | Manikanta Sivapala <msivap@codeaurora.org> | 2015-09-01 14:37:14 +0530 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:28:49 -0600 |
commit | e829faf9eb2af7bac3813ff141ca54c456ea8b2a (patch) | |
tree | 6ffa2d0f1411d66f932bad4eb895d95cd201bfdf | |
parent | fe23cf231278b731d3e69daa9128897a886dd00b (diff) | |
download | frameworks_base-e829faf9eb2af7bac3813ff141ca54c456ea8b2a.zip frameworks_base-e829faf9eb2af7bac3813ff141ca54c456ea8b2a.tar.gz frameworks_base-e829faf9eb2af7bac3813ff141ca54c456ea8b2a.tar.bz2 |
frameworks/base : Handling usecases for ext mediaplayer
Handling usecases while creating ext mediaplayer like
extmediaplayer listner creation fails but QCMediaplayer
creation succeeds or vice versa.
Change-Id: Ic5242161bf30bd2688bd6aba6d6115ab0768e963
-rw-r--r-- | media/jni/android_media_MediaPlayer.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp index c39bb4e..7fe5f90 100644 --- a/media/jni/android_media_MediaPlayer.cpp +++ b/media/jni/android_media_MediaPlayer.cpp @@ -152,9 +152,7 @@ typedef MediaPlayer* (*CreateNativeQCMediaPlayerFn)(); class JNIMediaPlayerFactory { public: JNIMediaPlayerFactory() {}; - static sp<MediaPlayerListener> createExtMediaPlayerListener(JNIEnv *env, jobject thiz, jobject weak_this, sp<MediaPlayerListener> listener); - static void CreateNativeQCMediaPlayer(sp<MediaPlayer> &mp); - static bool checkExtMedia(JNIEnv *env, jobject thiz); + static bool CheckAndCreateExtMediaPlayer(JNIEnv *env, jobject thiz, jobject weak_this, sp<MediaPlayerListener> &listener, sp<MediaPlayer> &mp); private: static void *mLibHandle; static void loadLib(); @@ -167,6 +165,10 @@ class JNIMediaPlayerFactory { static CreateNativeQCMediaPlayerFn sNativeQCMediaPlayerFn; static CreateNativeQCMediaPlayerFn loadNativeQCMediaPlayer(); + + static sp<MediaPlayerListener> createExtMediaPlayerListener(JNIEnv *env, jobject thiz, jobject weak_this, sp<MediaPlayerListener> listener); + static bool checkExtMedia(JNIEnv *env, jobject thiz); + static void CreateNativeQCMediaPlayer(sp<MediaPlayer> &mp); }; void *JNIMediaPlayerFactory::mLibHandle = NULL; @@ -269,6 +271,19 @@ bool JNIMediaPlayerFactory::checkExtMedia(JNIEnv *env, jobject thiz) return bIsQCMediaPlayerPresent; } +bool JNIMediaPlayerFactory::CheckAndCreateExtMediaPlayer( + JNIEnv *env, jobject thiz, jobject weak_this, sp<MediaPlayerListener> &listener, sp<MediaPlayer> &mp) +{ + bool bOk = false; + listener = createExtMediaPlayerListener(env, thiz, weak_this, listener); + if (listener != NULL && checkExtMedia(env,thiz)) { + CreateNativeQCMediaPlayer(mp); + if (mp != NULL) { + bOk = true; + } + } + return bOk; +} // ---------------------------------------------------------------------------- @@ -1004,19 +1019,17 @@ android_media_MediaPlayer_native_setup(JNIEnv *env, jobject thiz, jobject weak_t sp<MediaPlayer> mp = NULL; + bool bOk = false; JNIMediaPlayerFactory *jniMediaPlayerFactory = new JNIMediaPlayerFactory(); sp<MediaPlayerListener> listener = new JNIMediaPlayerListener(env, thiz, weak_this); if (jniMediaPlayerFactory) { - listener = jniMediaPlayerFactory->createExtMediaPlayerListener(env, thiz, weak_this, listener); - if (jniMediaPlayerFactory->checkExtMedia(env,thiz)) { - jniMediaPlayerFactory->CreateNativeQCMediaPlayer(mp); - } + bOk = jniMediaPlayerFactory->CheckAndCreateExtMediaPlayer(env, thiz, weak_this, listener, mp); delete(jniMediaPlayerFactory); } - if (mp == NULL){ + if (!bOk){ mp = new MediaPlayer(); } if (mp == NULL) { |