From: Martin Storsjo Date: Fri, 13 Jul 2012 09:48:19 +0000 (+0300) Subject: mediacodec: Return an error on getOutputFormat if there is no output format yet X-Git-Tag: android-x86-4.4-r1~662^2~54^2~48^2^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5c63a648f943b0ec91c3262ced77d1598ff32093;p=android-x86%2Fframeworks-av.git mediacodec: Return an error on getOutputFormat if there is no output format yet 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 --- diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index ff71170b4f..d28322f4f1 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -1118,7 +1118,8 @@ void MediaCodec::onMessageReceived(const sp &msg) { CHECK(msg->senderAwaitsResponse(&replyID)); if ((mState != STARTED && mState != FLUSHING) - || (mFlags & kFlagStickyError)) { + || (mFlags & kFlagStickyError) + || mOutputFormat == NULL) { sp response = new AMessage; response->setInt32("err", INVALID_OPERATION);