This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

openmax + ducati encoder issues on android



In my application I need to access camera and encode frames into h264. So far it seems that I'm having multiple issues with mComponentName:OMX.TI.DUCATI1.VIDEO.H264E

After making a few calls (video telephony calls) the app crashes when I try to start a new call:

camera->startPreview() resutls in:

dequeueBuffer failed: Out of memory (12)

The other big issue is that encoder->stop() doesn't seem to behave according to spec.

From MediaBuffer.h:

    // Any blocking read call returns immediately with a result of NO_INIT.
    // It is an error to call any methods other than start after this call
    // returns. Any buffers the object may be holding onto at the time of
    // the stop() call are released.
    // Also, it is imperative that any buffers output by this object and
    // held onto by callers be released before a call to stop() !!!
    virtual status_t stop() = 0;

However, I often get complete deadlock in this call. Sometimes I also got a deadlock in encoder->read(...) call. I use all this openmax related code from one thread only, that is, there is no threading issues on my side.

Here's how I do it (pseudo code):

	ProcessState::self()->startThreadPool();
	camera = Camera::connect(CamId);
	cameraSource = CameraSource::CreateFromCamera(camera->remote(), camera->getRecordingProxy(),  ...,ctx->surface, true);
	camera->startPreview();
	encoder = OMXCodec::Create(omx, encMeta, true, cameraSource, NULL, OMXCodec::kHardwareCodecsOnly | OMXCodec::kStoreMetaDataInVideoBuffers);
	encoder->start();
	while(!exitEncoderLoop)
	{
		//read frames...
		MediaBuffer* buf = NULL;
		encoder->read(&buf);
		/// copy data from buf
		buf->release();
	}
	//Existing encoder
	encoder->stop();
	camera->lock();
	camera->disconnect();
	camera->unlock();