summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2011-11-09 18:13:31 -0800
committerGlenn Kasten <gkasten@google.com>2011-11-10 15:04:42 -0800
commit42d2daefb2508a4f8f05ce8fe4c6b7da9f3d896d (patch)
tree2d951458b720a01f5ce55972b2cfe830176cdb36
parente07464884a4bcb4d1548e7408015364dc037bdc1 (diff)
downloadandroid_system_media-42d2daefb2508a4f8f05ce8fe4c6b7da9f3d896d.tar.gz
android_system_media-42d2daefb2508a4f8f05ce8fe4c6b7da9f3d896d.tar.bz2
android_system_media-42d2daefb2508a4f8f05ce8fe4c6b7da9f3d896d.zip
Bug 5201321 recover from mediaserver crash
Add a media player death notifier to recover from media server crashes. Downgrade some logs. Destructors should be protected. Change-Id: I7774733bcb12fc7fbfe237bdbeffca1adde46e78
-rw-r--r--wilhelm/src/android/AudioPlayer_to_android.cpp5
-rw-r--r--wilhelm/src/android/android_GenericMediaPlayer.cpp3
-rw-r--r--wilhelm/src/android/android_GenericMediaPlayer.h25
-rw-r--r--wilhelm/src/android/android_StreamPlayer.cpp3
4 files changed, 28 insertions, 8 deletions
diff --git a/wilhelm/src/android/AudioPlayer_to_android.cpp b/wilhelm/src/android/AudioPlayer_to_android.cpp
index 75084b70..8f60eada 100644
--- a/wilhelm/src/android/AudioPlayer_to_android.cpp
+++ b/wilhelm/src/android/AudioPlayer_to_android.cpp
@@ -839,7 +839,7 @@ static void sfplayer_handlePrefetchEvent(int event, int data1, int data2, void*
break;
case android::GenericPlayer::kEventErrorAfterPrepare: {
- SL_LOGI("kEventErrorAfterPrepare");
+ SL_LOGV("kEventErrorAfterPrepare");
// assume no callback
slPrefetchCallback callback = NULL;
@@ -847,12 +847,10 @@ static void sfplayer_handlePrefetchEvent(int event, int data1, int data2, void*
object_lock_exclusive(&ap->mObject);
if (IsInterfaceInitialized(&ap->mObject, MPH_PREFETCHSTATUS)) {
- SL_LOGI("inited");
ap->mPrefetchStatus.mLevel = 0;
ap->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_UNDERFLOW;
if (!(~ap->mPrefetchStatus.mCallbackEventsMask &
(SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE))) {
- SL_LOGI("enabled");
callback = ap->mPrefetchStatus.mCallback;
callbackPContext = ap->mPrefetchStatus.mContext;
}
@@ -863,7 +861,6 @@ static void sfplayer_handlePrefetchEvent(int event, int data1, int data2, void*
SL_LOGE("Error after prepare: %d", data1);
// callback with no lock held
- SL_LOGE("callback=%p context=%p", callback, callbackPContext);
if (NULL != callback) {
(*callback)(&ap->mPrefetchStatus.mItf, callbackPContext,
SL_PREFETCHEVENT_FILLLEVELCHANGE | SL_PREFETCHEVENT_STATUSCHANGE);
diff --git a/wilhelm/src/android/android_GenericMediaPlayer.cpp b/wilhelm/src/android/android_GenericMediaPlayer.cpp
index a56a230a..4abea4c0 100644
--- a/wilhelm/src/android/android_GenericMediaPlayer.cpp
+++ b/wilhelm/src/android/android_GenericMediaPlayer.cpp
@@ -179,7 +179,8 @@ GenericMediaPlayer::GenericMediaPlayer(const AudioPlayback_Parameters* params, b
mSeekTimeMsec(0),
mVideoSurfaceTexture(0),
mPlayer(0),
- mPlayerClient(new MediaPlayerNotificationClient(this))
+ mPlayerClient(new MediaPlayerNotificationClient(this)),
+ mPlayerDeathNotifier(new MediaPlayerDeathNotifier(mPlayerClient))
{
SL_LOGD("GenericMediaPlayer::GenericMediaPlayer()");
diff --git a/wilhelm/src/android/android_GenericMediaPlayer.h b/wilhelm/src/android/android_GenericMediaPlayer.h
index e095dab0..3e8fe81d 100644
--- a/wilhelm/src/android/android_GenericMediaPlayer.h
+++ b/wilhelm/src/android/android_GenericMediaPlayer.h
@@ -32,7 +32,6 @@ class MediaPlayerNotificationClient : public BnMediaPlayerClient
{
public:
MediaPlayerNotificationClient(GenericMediaPlayer* gmp);
- virtual ~MediaPlayerNotificationClient();
// IMediaPlayerClient implementation
virtual void notify(int msg, int ext1, int ext2, const Parcel *obj);
@@ -44,6 +43,9 @@ public:
// completed successfully, or false if it completed unsuccessfully
bool blockUntilPlayerPrepared();
+protected:
+ virtual ~MediaPlayerNotificationClient();
+
private:
const wp<GenericMediaPlayer> mGenericMediaPlayer;
Mutex mLock; // protects mPlayerPrepared
@@ -57,6 +59,24 @@ private:
};
+class MediaPlayerDeathNotifier : public IMediaDeathNotifier {
+public:
+ MediaPlayerDeathNotifier(const sp<MediaPlayerNotificationClient> playerClient) :
+ mPlayerClient(playerClient) {
+ }
+
+ void died() {
+ mPlayerClient->notify(MEDIA_ERROR, MEDIA_ERROR_SERVER_DIED, 0, NULL);
+ }
+
+protected:
+ virtual ~MediaPlayerDeathNotifier() { }
+
+private:
+ const sp<MediaPlayerNotificationClient> mPlayerClient;
+};
+
+
//--------------------------------------------------------------------------------------------------
class GenericMediaPlayer : public GenericPlayer
{
@@ -97,6 +117,9 @@ protected:
// Receives Android MediaPlayer events from mPlayer
const sp<MediaPlayerNotificationClient> mPlayerClient;
+ // Receives notifications about death of media.player service
+ const sp<MediaPlayerDeathNotifier> mPlayerDeathNotifier;
+
// Return a reference to the media player service, or LOGE and return NULL after retries fail
static const sp<IMediaPlayerService> getMediaPlayerService() {
return IMediaDeathNotifier::getMediaPlayerService();
diff --git a/wilhelm/src/android/android_StreamPlayer.cpp b/wilhelm/src/android/android_StreamPlayer.cpp
index 6e14897b..38475207 100644
--- a/wilhelm/src/android/android_StreamPlayer.cpp
+++ b/wilhelm/src/android/android_StreamPlayer.cpp
@@ -45,8 +45,7 @@ StreamSourceAppProxy::StreamSourceAppProxy(
}
StreamSourceAppProxy::~StreamSourceAppProxy() {
- // FIXME make this an SL_LOGV later; this just proves that the bug is fixed
- SL_LOGI("StreamSourceAppProxy::~StreamSourceAppProxy()");
+ SL_LOGV("StreamSourceAppProxy::~StreamSourceAppProxy()");
disconnect();
}