DashPlayer:call unregisterHandler in DashPlayer, avoid memory leak
AHandler objects in mediaplayer registred with ALooper
but did not call unregister at shutdown.
Change-Id: If9140d30ace0423c8181a1a64707ddcdc448d525
CRs-Fixed: 461906
diff --git a/dashplayer/DashPlayer.cpp b/dashplayer/DashPlayer.cpp
index 1c065eb..17d2480 100644
--- a/dashplayer/DashPlayer.cpp
+++ b/dashplayer/DashPlayer.cpp
@@ -86,6 +86,18 @@
}
DashPlayer::~DashPlayer() {
+ if (mRenderer != NULL) {
+ looper()->unregisterHandler(mRenderer->id());
+ }
+ if (mAudioDecoder != NULL) {
+ looper()->unregisterHandler(mAudioDecoder->id());
+ }
+ if (mVideoDecoder != NULL) {
+ looper()->unregisterHandler(mVideoDecoder->id());
+ }
+ if (mTextDecoder != NULL) {
+ looper()->unregisterHandler(mTextDecoder->id());
+ }
if(mStats != NULL) {
mStats->logFpsSummary();
mStats = NULL;
@@ -502,12 +514,18 @@
ALOGV("%s shutdown completed", mTrackName);
if (track == kAudio) {
ALOGV("@@@@:: Dashplayer :: MESSAGE FROM DASHCODEC +++++++++++++++++++++++++++++++ kWhatShutdownCompleted:: audio");
+ if (mAudioDecoder != NULL) {
+ looper()->unregisterHandler(mAudioDecoder->id());
+ }
mAudioDecoder.clear();
CHECK_EQ((int)mFlushingAudio, (int)SHUTTING_DOWN_DECODER);
mFlushingAudio = SHUT_DOWN;
} else if (track == kVideo) {
ALOGV("@@@@:: Dashplayer :: MESSAGE FROM DASHCODEC +++++++++++++++++++++++++++++++ kWhatShutdownCompleted:: Video");
+ if (mVideoDecoder != NULL) {
+ looper()->unregisterHandler(mVideoDecoder->id());
+ }
mVideoDecoder.clear();
CHECK_EQ((int)mFlushingVideo, (int)SHUTTING_DOWN_DECODER);
@@ -1024,6 +1042,7 @@
mTextNotify->findMessage("codec-request", &codecRequest);
codecRequest = NULL;
mTextNotify = NULL;
+ looper()->unregisterHandler(mTextDecoder->id());
mTextDecoder.clear();
}
postScanSources();
@@ -1037,6 +1056,9 @@
++mScanSourcesGeneration;
mScanSourcesPending = false;
+ if (mRenderer != NULL) {
+ looper()->unregisterHandler(mRenderer->id());
+ }
if(mRenderer != NULL) {
mRenderer.clear();
}
@@ -1053,6 +1075,7 @@
mTextNotify->findMessage("codec-request", &codecRequest);
codecRequest = NULL;
mTextNotify = NULL;
+ looper()->unregisterHandler(mTextDecoder->id());
mTextDecoder.clear();
ALOGE("Text Dummy Decoder Deleted");
}
diff --git a/dashplayer/DashPlayerDecoder.cpp b/dashplayer/DashPlayerDecoder.cpp
index 180b355..1439560 100644
--- a/dashplayer/DashPlayerDecoder.cpp
+++ b/dashplayer/DashPlayerDecoder.cpp
@@ -41,6 +41,17 @@
}
DashPlayer::Decoder::~Decoder() {
+ ALooper::handler_id id = 0;
+ if (mCodec != NULL) {
+ id = mCodec->id();
+ }
+ if (id != 0) {
+ if (mCodecLooper != NULL) {
+ mCodecLooper->stop();
+ mCodecLooper->unregisterHandler(id);
+ }
+ looper()->unregisterHandler(id);
+ }
}
void DashPlayer::Decoder::configure(const sp<MetaData> &meta) {
diff --git a/dashplayer/DashPlayerDriver.cpp b/dashplayer/DashPlayerDriver.cpp
index bf4d898..f05631f 100755
--- a/dashplayer/DashPlayerDriver.cpp
+++ b/dashplayer/DashPlayerDriver.cpp
@@ -52,6 +52,7 @@
DashPlayerDriver::~DashPlayerDriver() {
mLooper->stop();
+ mLooper->unregisterHandler(mPlayer->id());
}
status_t DashPlayerDriver::initCheck() {