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

Commit d598a350 authored by Haynes Mathew George's avatar Haynes Mathew George Committed by Ricardo Cerqueira
Browse files

libstagefright: Checks before freeing buffers on a port

- OMXCodec calls dequeueBuffer on the NativeWindow in a loop
  and registers output buffers with the OMX component.
- If a dequeueBuffer fails, the buffers already registered
  with the OMX component were not getting freed laeding
  to a memory leak.
- On an error, check state of OMXCodec before freeing buffers on a port.

CRs-Fixed: 393352

(cherry picked from commit f2e982497c5d16db14812ee09cef5cbdf0d96331)

Change-Id: Ib4eb48c189197d253e4175708ce1778b9c92f315
parent c3cd45d7
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -2037,10 +2037,16 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
        cancelEnd = def.nBufferCountActual;
    }


    if (err != 0 &&
        ((mState == LOADED) || (mState == LOADED_TO_IDLE))) {
        freeBuffersOnPort(kPortIndexOutput);
    } else {
        for (OMX_U32 i = cancelStart; i < cancelEnd; i++) {
            BufferInfo *info = &mPortBuffers[kPortIndexOutput].editItemAt(i);
            cancelBufferToNativeWindow(info);
        }
    }

    return err;
}