OSDN Git Service

mediacodec: Return an error on getOutputFormat if there is no output format yet
authorMartin Storsjo <martin@martin.st>
Fri, 13 Jul 2012 09:48:19 +0000 (12:48 +0300)
committerMartin Storsjo <martin@martin.st>
Fri, 13 Jul 2012 11:09:22 +0000 (14:09 +0300)
This avoids crashing if calling the public java method
MediaCodec.getOutputFormat immediately after MediaCodec.start
(as the documentation example shows that one should do!).

Change-Id: Icd3dd7ab9ae9e8f2a67cef171ff176735de95f58

media/libstagefright/MediaCodec.cpp

index ff71170..d28322f 100644 (file)
@@ -1118,7 +1118,8 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
             CHECK(msg->senderAwaitsResponse(&replyID));
 
             if ((mState != STARTED && mState != FLUSHING)
-                    || (mFlags & kFlagStickyError)) {
+                    || (mFlags & kFlagStickyError)
+                    || mOutputFormat == NULL) {
                 sp<AMessage> response = new AMessage;
                 response->setInt32("err", INVALID_OPERATION);