ENS_API_EXPORT OMX_ERRORTYPE NmfMpc_ProcessingComponent::freeBuffer(
		OMX_U32 nPortIndex,
        OMX_U32 nBufferIndex,
        OMX_BOOL bBufferAllocated,
        void *bufferAllocInfo,
        void *portPrivateInfo) 
{
    if (nPortIndex>=mENSComponent.getPortCount() || mENSComponent.getPort(nPortIndex)==0) {
        return OMX_ErrorBadPortIndex;
    }
    
    OMX_ERRORTYPE error;
    SharedBuffer *sharedBuf = static_cast<SharedBuffer *>(portPrivateInfo);

    if (bBufferAllocated) {
        error = doBufferDeAllocation(nPortIndex, nBufferIndex, bufferAllocInfo);
        if(error != OMX_ErrorNone) return error;
    } else if (useBufferNeedsMemcpy()){
        error = doBufferDeAllocation(nPortIndex, nBufferIndex, (void*)sharedBuf->getBufferAllocInfo());
        if(error != OMX_ErrorNone) return error;
    } else {
        ENS_Port *port = mENSComponent.getPort(nPortIndex);
		MMHwBuffer *sharedChunk = (MMHwBuffer *)port->getSharedChunk();
		if (sharedChunk && (nBufferIndex == 0)) {    // ER342234
			error = MMHwBuffer::Close(sharedChunk);
			DBC_ASSERT(error == OMX_ErrorNone);
            port->setSharedChunk(0);
		}
    }

    delete sharedBuf;

    return OMX_ErrorNone;
}
ENS_API_EXPORT OMX_ERRORTYPE NmfHostMpc_ProcessingComponent::freeBuffer(OMX_U32 nPortIndex,
									OMX_U32 nBufferIndex,
									OMX_BOOL bBufferAllocated,
									void *bufferAllocInfo,
									void *portPrivateInfo)
{
  OMX_ERRORTYPE error;
  SharedBuffer *sharedBuf = static_cast<SharedBuffer *>(portPrivateInfo);

  if (bBufferAllocated) {
    error = doBufferDeAllocation(nPortIndex, nBufferIndex, bufferAllocInfo);
    if(error != OMX_ErrorNone) return error;
  } else if (useBufferNeedsMemcpy()){
    error = doBufferDeAllocation(nPortIndex, nBufferIndex, (void*)sharedBuf->getBufferAllocInfo());
    if(error != OMX_ErrorNone) return error;
  }

  delete sharedBuf;

  return OMX_ErrorNone;
}