0

I am trying to encode h264 using MediaCodec in nexus 7 device and after re running ( after closing ) my encoder process several times I get a failure when trying to create MediaCodec ( MediaCodec::CreateByType(looper, "video/avc", true) ). the log shows:

E/OMX-VENC-720p(  181):  Is component secure 0
E/OMX-VENC-720p(  181): ERROR: Omx_venc::Comp Init Returning failure
E/OMX-VENC-720p(  181):
E/OMX-VENC-720p(  181): ERROR: venc_open failed
E/OMX-VENC-720p(  181):
E/OMX-VENC-720p(  181):  Destroy C2D instance

after rebooting the device I can once again create the encoder. Is this a bug in the nexus hardware encoder or could this be a result of not releasing the encoder properly ?

jacob
  • 1,397
  • 1
  • 26
  • 53

1 Answers1

0

This is not expected.

If you grab the latest version of Grafika, you can find a "Codec open test" activity near the bottom. When you run this and click "START", it will try to open as many codecs as it can. If you click "Halt", it will halt the VM, and the app will be restarted.

With a Nexus 7 (2013) running 4.4.2, the first time I hit "start" I see four codecs created. If I hit it again, I get zero. If I cause a GC with DDMS or halt the process, it goes back to four. The only way it should get "stuck" is if the app is holding several open and is still running.

Whatever the case, make sure you release codecs when your app pauses. This is, of course, impossible if your app crashes, but in normal operation you don't want to hold on to hardware resources when your app isn't in the foreground actively using them. If there's a bug somewhere that prevents the system from cleaning up, it's even more important to release them promptly.

fadden
  • 51,356
  • 5
  • 116
  • 166