From c02ca4ca1e7597891bcf92f9294c83d928118cf9 Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Wed, 10 Sep 2014 10:43:41 -0700 Subject: fix failure in MediaCodecTest#testException reset codec after failed configure() Bug: 17418876 Change-Id: I21ff8a0751dae6a164678015142e11d481403bed --- media/libstagefright/MediaCodec.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index fc2dd30..0bfc6e4 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -270,7 +270,20 @@ status_t MediaCodec::configure( } sp response; - return PostAndAwaitResponse(msg, &response); + status_t err = PostAndAwaitResponse(msg, &response); + + if (err != OK && err != INVALID_OPERATION) { + // MediaCodec now set state to UNINITIALIZED upon any fatal error. + // To maintain backward-compatibility, do a reset() to put codec + // back into INITIALIZED state. + // But don't reset if the err is INVALID_OPERATION, which means + // the configure failure is due to wrong state. + + ALOGE("configure failed with err 0x%08x, resetting...", err); + reset(); + } + + return err; } status_t MediaCodec::createInputSurface( -- cgit v1.1