Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 906c6058 authored by Manish Dewangan's avatar Manish Dewangan Committed by Ricardo Cerqueira
Browse files

libstagefright: Fix for crash during playback of unsupported clip

-Crash in media server observed during playback of unsupported clip
-The OMX_EventError not handled properly in SF IL client leading
to crash as i/p buffers and o/p buffers are not freed.
-Shutting down the i/p and o/p ports when OMX_EventError is
received with state OMX_ErrorInvalidState. In error state,
free i/p and o/p buffers on receiving empty buffer done and
fill buffer done messages.

Change-Id: I6d2b7b659b5f424b9fc5d668e47f2a9d51b49314
CRs-Fixed: 331572

Conflicts:

	include/media/stagefright/OMXCodec.h
	media/libstagefright/OMXCodec.cpp
parent 640f4d5d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -236,6 +236,7 @@ private:
    bool mOnlySubmitOneBufferAtOneTime;
    bool mInterlaceFormatDetected;
    bool mSPSParsed;
    bool bInvalidState;
#endif

    // Used to record the decoding time for an output picture from
+26 −11
Original line number Diff line number Diff line
@@ -14,9 +14,6 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*--------------------------------------------------------------------------
Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
--------------------------------------------------------------------------*/

//#define LOG_NDEBUG 0
#define LOG_TAG "OMXCodec"
@@ -1902,18 +1899,15 @@ OMXCodec::OMXCodec(
      mLeftOverBuffer(NULL),
      mPaused(false),
#ifdef QCOM_HARDWARE
      bInvalidState(false),
      mInterlaceFormatDetected(false),
      mSPSParsed(false),
      mThumbnailMode(false),
#endif
      mNativeWindow(
              (!strncmp(componentName, "OMX.google.", 11)
              || !strcmp(componentName, "OMX.Nvidia.mpeg2v.decode"))
                        ? NULL : nativeWindow),
      mInterlaceFormatDetected(false),
      mSPSParsed(false),
      mThumbnailMode(false) {
#else
      mNativeWindow(!strncmp(componentName, "OMX.google.", 11)
                        ? NULL : nativeWindow),
                        ? NULL : nativeWindow) {
#endif
    mPortStatus[kPortIndexInput] = ENABLED;
    mPortStatus[kPortIndexOutput] = ENABLED;

@@ -2777,6 +2771,13 @@ void OMXCodec::on_message(const omx_message &msg) {

            BufferInfo* info = &buffers->editItemAt(i);
            info->mStatus = OWNED_BY_US;
#ifdef QCOM_HARDWARE
            if ((mState == ERROR)  && (bInvalidState == true)) {
              CODEC_LOGV("mState ERROR, freeing i/p buffer %p", buffer);
              status_t err = freeBuffer(kPortIndexInput, i);
              CHECK_EQ(err, (status_t)OK);
            }
#endif

            // Buffer could not be released until empty buffer done is called.
            if (info->mMediaBuffer != NULL) {
@@ -2836,6 +2837,13 @@ void OMXCodec::on_message(const omx_message &msg) {
            }

            info->mStatus = OWNED_BY_US;
#ifdef QCOM_HARDWARE
            if ((mState == ERROR) && (bInvalidState == true)) {
              CODEC_LOGV("mState ERROR, freeing o/p buffer %p", buffer);
              status_t err = freeBuffer(kPortIndexOutput, i);
              CHECK_EQ(err, (status_t)OK);
            }
#endif

            if (mPortStatus[kPortIndexOutput] == DISABLING) {
                CODEC_LOGV("Port is disabled, freeing buffer %p", buffer);
@@ -3050,6 +3058,13 @@ void OMXCodec::onEvent(OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) {
        case OMX_EventError:
        {
            CODEC_LOGE("ERROR(0x%08lx, %ld)", data1, data2);
#ifdef QCOM_HARDWARE
            if (data1 == OMX_ErrorInvalidState) {
                bInvalidState = true;
                mPortStatus[kPortIndexInput] = SHUTTING_DOWN;
                mPortStatus[kPortIndexOutput] = SHUTTING_DOWN;
            }
#endif

            setState(ERROR);
            break;