summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/OMXCodec.cpp
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2012-08-24 10:53:31 -0700
committerJames Dong <jdong@google.com>2012-08-24 13:10:16 -0700
commitaa8879d381918335c9d829fc279b76d53a15a550 (patch)
tree0ec909da8db12815112ba15ba266d1093ff91de8 /media/libstagefright/OMXCodec.cpp
parent9a150640a28d3fa5507a590125a6c004681bb221 (diff)
downloadframeworks_av-aa8879d381918335c9d829fc279b76d53a15a550.zip
frameworks_av-aa8879d381918335c9d829fc279b76d53a15a550.tar.gz
frameworks_av-aa8879d381918335c9d829fc279b76d53a15a550.tar.bz2
Fixed a native crash due to unexpected state at destroy time when encoder component's source fails to start
o Encoder component initializes to be in the state of EXECUTING before its source gets started, because we wanted to be able to configure the source to use the advertised number of input buffers. However, if the source fails to start, then the encoder ends up in the state of EXECUTING when OMXCodec object gets destroyed. As a result, the assertion on the expected state in OMXCodec's constructor fails. The fix is to stop the video encoder component right way when its source fails to start so to bring the state of the encoder component back to the expected state. o related-to-bug: 7045494 Change-Id: I6d4a221eb809d7137f53e58098a04816998f7a25
Diffstat (limited to 'media/libstagefright/OMXCodec.cpp')
-rwxr-xr-xmedia/libstagefright/OMXCodec.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 5615d0f..d0e306c 100755
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -3621,7 +3621,11 @@ status_t OMXCodec::start(MetaData *meta) {
}
params->setInt32(kKeyNumBuffers, mPortBuffers[kPortIndexInput].size());
- return mSource->start(params.get());
+ err = mSource->start(params.get());
+ if (err != OK) {
+ stopOmxComponent_l();
+ }
+ return err;
}
// Decoder case
@@ -3633,8 +3637,16 @@ status_t OMXCodec::start(MetaData *meta) {
status_t OMXCodec::stop() {
CODEC_LOGV("stop mState=%d", mState);
-
Mutex::Autolock autoLock(mLock);
+ status_t err = stopOmxComponent_l();
+ mSource->stop();
+
+ CODEC_LOGV("stopped in state %d", mState);
+ return err;
+}
+
+status_t OMXCodec::stopOmxComponent_l() {
+ CODEC_LOGV("stopOmxComponent_l mState=%d", mState);
while (isIntermediateState(mState)) {
mAsyncCompletion.wait(mLock);
@@ -3732,10 +3744,6 @@ status_t OMXCodec::stop() {
mLeftOverBuffer = NULL;
}
- mSource->stop();
-
- CODEC_LOGV("stopped in state %d", mState);
-
return OK;
}