Merge "Make sure the OMX component is synchronously shutdown before we try to instantiate another one. Also properly cleanup the software AVC decoder to avoid leaking memory."
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index d6db59f..85019aa 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -249,7 +249,16 @@
if (mVideoSource != NULL) {
mVideoSource->stop();
+
+ // The following hack is necessary to ensure that the OMX
+ // component is completely released by the time we may try
+ // to instantiate it again.
+ wp<MediaSource> tmp = mVideoSource;
mVideoSource.clear();
+ while (tmp.promote() != NULL) {
+ usleep(1000);
+ }
+ IPCThreadState::self()->flushCommands();
}
mAudioSource.clear();
diff --git a/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp b/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp
index d874224..36272ea 100644
--- a/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp
+++ b/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp
@@ -80,6 +80,8 @@
stop();
}
+ PVAVCCleanUpDecoder(mHandle);
+
delete mHandle;
mHandle = NULL;
}